@mintlify/msft-sdk 1.1.16 → 1.1.18
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/dist/api-playground-2/components/Example/GeneratedRequestExample.js +95 -90
- package/dist/api-playground-2/components/Example/GeneratedRequestExample.js.map +1 -1
- package/dist/api-playground-2/components/Example/RequestExample.js +40 -40
- package/dist/api-playground-2/components/Example/RequestExample.js.map +1 -1
- package/dist/api-playground-2/components/Example/ResponseExample.js +8 -8
- package/dist/api-playground-2/components/Example/ResponseExample.js.map +1 -1
- package/dist/components/content-components/code-group.js +40 -40
- package/dist/components/content-components/code-group.js.map +1 -1
- package/dist/components/content-components/code-snippets.js +11 -11
- package/dist/components/content-components/code-snippets.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,140 +1,145 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { useState as M, useEffect as B } from "react";
|
|
3
3
|
import { generateRequest as E } from "@/api-playground-2/generators/generateRequest";
|
|
4
4
|
import { generateSnippet as I } from "@/api-playground-2/generators/generateSnippet";
|
|
5
|
-
import { getFirstExampleValue as
|
|
6
|
-
import { CodeGroupSelect as
|
|
7
|
-
import { CodeSnippets as
|
|
8
|
-
import { langToPresetMap as
|
|
5
|
+
import { getFirstExampleValue as a } from "@/api-playground-2/schemaGraph/processExamples";
|
|
6
|
+
import { CodeGroupSelect as w } from "../../../components/content-components/CodeGroupSelect/index.js";
|
|
7
|
+
import { CodeSnippets as A } from "../../../components/content-components/code-snippets.js";
|
|
8
|
+
import { langToPresetMap as G } from "../../../constants/snippetPresets.js";
|
|
9
9
|
const Q = ({
|
|
10
|
-
baseUrl:
|
|
10
|
+
baseUrl: s,
|
|
11
11
|
apiReferenceData: t,
|
|
12
|
-
inputs:
|
|
13
|
-
requestExampleLanguages:
|
|
14
|
-
requiredOnly:
|
|
15
|
-
maxHeight:
|
|
12
|
+
inputs: n,
|
|
13
|
+
requestExampleLanguages: c,
|
|
14
|
+
requiredOnly: p,
|
|
15
|
+
maxHeight: o
|
|
16
16
|
}) => {
|
|
17
|
-
var f, S,
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
20
|
-
return /* @__PURE__ */
|
|
17
|
+
var f, S, r, x, d;
|
|
18
|
+
const m = (f = t.dependencies) == null ? void 0 : f.requestBody;
|
|
19
|
+
if (!m)
|
|
20
|
+
return /* @__PURE__ */ y(
|
|
21
21
|
C,
|
|
22
22
|
{
|
|
23
23
|
apiReferenceData: t,
|
|
24
|
-
baseUrl:
|
|
25
|
-
inputs:
|
|
26
|
-
requestExampleLanguages:
|
|
27
|
-
requiredOnly:
|
|
28
|
-
maxHeight:
|
|
24
|
+
baseUrl: s,
|
|
25
|
+
inputs: n,
|
|
26
|
+
requestExampleLanguages: c,
|
|
27
|
+
requiredOnly: p,
|
|
28
|
+
maxHeight: o
|
|
29
29
|
}
|
|
30
30
|
);
|
|
31
|
-
const i =
|
|
31
|
+
const i = a(m.content);
|
|
32
32
|
if (!i) return null;
|
|
33
|
-
const
|
|
34
|
-
([
|
|
35
|
-
contentType:
|
|
36
|
-
examples:
|
|
33
|
+
const l = Object.entries(m.content).map(
|
|
34
|
+
([e, T]) => ({
|
|
35
|
+
contentType: e,
|
|
36
|
+
examples: T.examples
|
|
37
37
|
})
|
|
38
|
-
),
|
|
39
|
-
return ((S =
|
|
40
|
-
|
|
38
|
+
), u = 0;
|
|
39
|
+
return ((S = l[u]) == null ? void 0 : S.examples.length) > 1 ? /* @__PURE__ */ y(
|
|
40
|
+
P,
|
|
41
41
|
{
|
|
42
42
|
apiReferenceData: t,
|
|
43
|
-
selectedBodyContentType: (
|
|
44
|
-
baseUrl:
|
|
45
|
-
inputs:
|
|
46
|
-
examples: (x =
|
|
47
|
-
requiredOnly:
|
|
48
|
-
maxHeight:
|
|
43
|
+
selectedBodyContentType: (r = l[u]) == null ? void 0 : r.contentType,
|
|
44
|
+
baseUrl: s,
|
|
45
|
+
inputs: n,
|
|
46
|
+
examples: (x = l[u]) == null ? void 0 : x.examples,
|
|
47
|
+
requiredOnly: p,
|
|
48
|
+
maxHeight: o
|
|
49
49
|
}
|
|
50
|
-
) : /* @__PURE__ */
|
|
50
|
+
) : /* @__PURE__ */ y(
|
|
51
51
|
C,
|
|
52
52
|
{
|
|
53
53
|
apiReferenceData: t,
|
|
54
|
-
selectedBodyContentType: (
|
|
55
|
-
baseUrl:
|
|
56
|
-
inputs:
|
|
54
|
+
selectedBodyContentType: (d = l[u]) == null ? void 0 : d.contentType,
|
|
55
|
+
baseUrl: s,
|
|
56
|
+
inputs: n,
|
|
57
57
|
exampleValue: i,
|
|
58
|
-
requestExampleLanguages:
|
|
59
|
-
requiredOnly:
|
|
60
|
-
maxHeight:
|
|
58
|
+
requestExampleLanguages: c,
|
|
59
|
+
requiredOnly: p,
|
|
60
|
+
maxHeight: o
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
}, C = ({
|
|
64
|
-
baseUrl:
|
|
64
|
+
baseUrl: s,
|
|
65
65
|
apiReferenceData: t,
|
|
66
|
-
inputs:
|
|
67
|
-
selectedBodyContentType:
|
|
68
|
-
exampleValue:
|
|
69
|
-
requestExampleLanguages:
|
|
70
|
-
requiredOnly:
|
|
66
|
+
inputs: n,
|
|
67
|
+
selectedBodyContentType: c,
|
|
68
|
+
exampleValue: p,
|
|
69
|
+
requestExampleLanguages: o,
|
|
70
|
+
requiredOnly: m,
|
|
71
71
|
maxHeight: i
|
|
72
72
|
}) => {
|
|
73
|
-
const [
|
|
73
|
+
const [l, u] = M(null), [f, S] = M(null);
|
|
74
74
|
return B(() => {
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
let r = !1;
|
|
76
|
+
const x = E({
|
|
77
|
+
baseUrl: s,
|
|
77
78
|
apiReferenceData: t,
|
|
78
|
-
inputs:
|
|
79
|
-
selectedBodyContentType:
|
|
80
|
-
exampleData:
|
|
81
|
-
requiredOnly:
|
|
82
|
-
}),
|
|
83
|
-
const
|
|
84
|
-
return
|
|
79
|
+
inputs: n,
|
|
80
|
+
selectedBodyContentType: c,
|
|
81
|
+
exampleData: p,
|
|
82
|
+
requiredOnly: m
|
|
83
|
+
}), d = o == null ? void 0 : o.reduce((e, T) => {
|
|
84
|
+
const h = G[T];
|
|
85
|
+
return h && e.push(h), e;
|
|
85
86
|
}, []);
|
|
86
|
-
I({
|
|
87
|
+
return I({
|
|
87
88
|
apiReferenceData: t,
|
|
88
|
-
pathInputs:
|
|
89
|
-
request:
|
|
90
|
-
snippetPresets:
|
|
91
|
-
}).then(
|
|
92
|
-
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
|
|
89
|
+
pathInputs: n.path,
|
|
90
|
+
request: x,
|
|
91
|
+
snippetPresets: d
|
|
92
|
+
}).then((e) => {
|
|
93
|
+
r || u(e);
|
|
94
|
+
}).catch((e) => {
|
|
95
|
+
r || (console.error(e), S(e));
|
|
96
|
+
}), () => {
|
|
97
|
+
r = !0;
|
|
98
|
+
};
|
|
99
|
+
}, [s, t, n, c, p, o, m]), f || !l ? null : /* @__PURE__ */ y(A, { snippets: l, dropdown: !0, maxHeight: i });
|
|
100
|
+
}, P = ({
|
|
101
|
+
baseUrl: s,
|
|
97
102
|
apiReferenceData: t,
|
|
98
|
-
inputs:
|
|
99
|
-
selectedBodyContentType:
|
|
100
|
-
examples:
|
|
101
|
-
requiredOnly:
|
|
102
|
-
maxHeight:
|
|
103
|
+
inputs: n,
|
|
104
|
+
selectedBodyContentType: c,
|
|
105
|
+
examples: p,
|
|
106
|
+
requiredOnly: o,
|
|
107
|
+
maxHeight: m
|
|
103
108
|
}) => {
|
|
104
|
-
const [i,
|
|
109
|
+
const [i, l] = M({}), [u, f] = M(null);
|
|
105
110
|
return B(() => {
|
|
106
|
-
const S =
|
|
111
|
+
const S = n.path, r = {};
|
|
107
112
|
(async () => {
|
|
108
|
-
for (const [
|
|
109
|
-
if (!
|
|
110
|
-
const
|
|
111
|
-
baseUrl:
|
|
113
|
+
for (const [d, { value: e }] of Object.entries(p)) {
|
|
114
|
+
if (!e) continue;
|
|
115
|
+
const T = E({
|
|
116
|
+
baseUrl: s,
|
|
112
117
|
apiReferenceData: t,
|
|
113
|
-
inputs:
|
|
114
|
-
selectedBodyContentType:
|
|
115
|
-
exampleData:
|
|
116
|
-
requiredOnly:
|
|
118
|
+
inputs: n,
|
|
119
|
+
selectedBodyContentType: c,
|
|
120
|
+
exampleData: e,
|
|
121
|
+
requiredOnly: o
|
|
117
122
|
});
|
|
118
123
|
try {
|
|
119
124
|
(await I({
|
|
120
125
|
apiReferenceData: t,
|
|
121
126
|
pathInputs: S,
|
|
122
|
-
request:
|
|
127
|
+
request: T,
|
|
123
128
|
isMultipleRequest: !0
|
|
124
129
|
})).forEach((j) => {
|
|
125
|
-
|
|
126
|
-
...
|
|
127
|
-
[
|
|
130
|
+
r[j.filename] = {
|
|
131
|
+
...r[j.filename],
|
|
132
|
+
[d]: j
|
|
128
133
|
};
|
|
129
134
|
});
|
|
130
|
-
} catch (
|
|
131
|
-
console.error(
|
|
135
|
+
} catch (h) {
|
|
136
|
+
console.error(h), f(h);
|
|
132
137
|
return;
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
|
-
|
|
140
|
+
l(r);
|
|
136
141
|
})();
|
|
137
|
-
}, [
|
|
142
|
+
}, [s, t, n, c, p, o]), u || Object.keys(i).length === 0 ? null : /* @__PURE__ */ y(w, { snippets: i, maxHeight: m });
|
|
138
143
|
};
|
|
139
144
|
export {
|
|
140
145
|
Q as GeneratedRequestExample
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratedRequestExample.js","sources":["../../../../src/api-playground-2/components/Example/GeneratedRequestExample.tsx"],"sourcesContent":["import { ApiPlaygroundInputs, ExampleSchema } from '@mintlify/validation';\nimport { JSX, useState, useEffect } from 'react';\n\nimport { generateRequest } from '@/api-playground-2/generators/generateRequest';\nimport { generateSnippet } from '@/api-playground-2/generators/generateSnippet';\nimport { getFirstExampleValue } from '@/api-playground-2/schemaGraph/processExamples';\nimport type { ApiReferenceDataV2 } from '@/api-playground-2/types';\nimport { CodeGroupSelect } from '../../../components/content-components/CodeGroupSelect';\nimport { CodeSnippets } from '../../../components/content-components/code-snippets';\nimport { langToPresetMap, SnippetPreset } from '../../../constants/snippetPresets';\nimport type { ExampleCodeSnippet } from '../../../types/exampleCodeSnippet';\n\nexport type GeneratedRequestExampleParams = {\n baseUrl: string;\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n requestExampleLanguages?: string[];\n requiredOnly?: boolean;\n maxHeight?: string;\n};\n\nexport const GeneratedRequestExample = ({\n baseUrl,\n apiReferenceData,\n inputs,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: GeneratedRequestExampleParams): JSX.Element | null => {\n const requestBody = apiReferenceData.dependencies?.requestBody;\n\n if (!requestBody) {\n return (\n <SingleRequest\n apiReferenceData={apiReferenceData}\n baseUrl={baseUrl}\n inputs={inputs}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n }\n\n const firstExampleValue = getFirstExampleValue(requestBody.content);\n\n if (!firstExampleValue) return null;\n\n const examplesByContentType = Object.entries(requestBody.content).map(\n ([contentType, content]) => {\n return {\n contentType,\n examples: content.examples,\n };\n }\n );\n const selectedContentTypeIndex = 0;\n\n return examplesByContentType[selectedContentTypeIndex]?.examples.length > 1 ? (\n <MultipleRequest\n apiReferenceData={apiReferenceData}\n selectedBodyContentType={examplesByContentType[selectedContentTypeIndex]?.contentType}\n baseUrl={baseUrl}\n inputs={inputs}\n examples={examplesByContentType[selectedContentTypeIndex]?.examples}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n ) : (\n <SingleRequest\n apiReferenceData={apiReferenceData}\n selectedBodyContentType={examplesByContentType[selectedContentTypeIndex]?.contentType}\n baseUrl={baseUrl}\n inputs={inputs}\n exampleValue={firstExampleValue}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n};\n\ntype SingleRequestParams = GeneratedRequestExampleParams & {\n selectedBodyContentType?: string;\n exampleValue?: unknown;\n};\n\nconst SingleRequest = ({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n exampleValue,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: SingleRequestParams) => {\n const [snippets, setSnippets] = useState<ExampleCodeSnippet[] | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const request = generateRequest({\n baseUrl,\n apiReferenceData,\n inputs: inputs,\n selectedBodyContentType,\n exampleData: exampleValue,\n requiredOnly,\n });\n\n const snippetPresets = requestExampleLanguages?.reduce<SnippetPreset[]>((acc, lang) => {\n const preset = langToPresetMap[lang];\n if (preset) acc.push(preset);\n return acc;\n }, []);\n\n generateSnippet({\n apiReferenceData,\n pathInputs: inputs.path,\n request,\n snippetPresets,\n })\n .then(setSnippets)\n .catch((err) => {\n console.error(err);\n setError(err);\n });\n }, [baseUrl, apiReferenceData, inputs, selectedBodyContentType, exampleValue, requestExampleLanguages, requiredOnly]);\n\n if (error) return null;\n if (!snippets) return null; // or a loading spinner\n\n return <CodeSnippets snippets={snippets} dropdown maxHeight={maxHeight} />;\n};\n\ntype MultipleRequestParams = GeneratedRequestExampleParams & {\n selectedBodyContentType?: string;\n examples: Record<string, ExampleSchema>;\n};\n\nconst MultipleRequest = ({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n examples,\n requiredOnly,\n maxHeight,\n}: MultipleRequestParams): JSX.Element | null => {\n const [nameToSnippetExamplesMap, setNameToSnippetExamplesMap] = useState<\n Record<string, Record<string, ExampleCodeSnippet>>\n >({});\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const pathInputs = inputs.path;\n const snippetMap: Record<string, Record<string, ExampleCodeSnippet>> = {};\n\n const generateAllSnippets = async () => {\n for (const [name, { value: exampleData }] of Object.entries(examples)) {\n if (!exampleData) continue;\n\n const request = generateRequest({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n exampleData,\n requiredOnly,\n });\n\n try {\n const snippets = await generateSnippet({\n apiReferenceData,\n pathInputs,\n request,\n isMultipleRequest: true,\n });\n\n snippets.forEach((snippet) => {\n snippetMap[snippet.filename] = {\n ...snippetMap[snippet.filename],\n [name]: snippet,\n };\n });\n } catch (err) {\n console.error(err);\n setError(err as Error);\n return;\n }\n }\n setNameToSnippetExamplesMap(snippetMap);\n };\n\n generateAllSnippets();\n }, [baseUrl, apiReferenceData, inputs, selectedBodyContentType, examples, requiredOnly]);\n\n if (error) return null;\n if (Object.keys(nameToSnippetExamplesMap).length === 0) return null;\n\n return <CodeGroupSelect snippets={nameToSnippetExamplesMap} maxHeight={maxHeight} />;\n};\n"],"names":["GeneratedRequestExample","baseUrl","apiReferenceData","inputs","requestExampleLanguages","requiredOnly","maxHeight","requestBody","_a","jsx","SingleRequest","firstExampleValue","getFirstExampleValue","examplesByContentType","contentType","content","selectedContentTypeIndex","_b","MultipleRequest","_c","_d","_e","selectedBodyContentType","exampleValue","snippets","setSnippets","useState","error","setError","useEffect","request","generateRequest","snippetPresets","acc","lang","preset","langToPresetMap","generateSnippet","err","CodeSnippets","examples","nameToSnippetExamplesMap","setNameToSnippetExamplesMap","pathInputs","snippetMap","name","exampleData","snippet","CodeGroupSelect"],"mappings":";;;;;;;;AAqBO,MAAMA,IAA0B,CAAC;AAAA,EACtC,SAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AACF,MAAyD;;AACvD,QAAMC,KAAcC,IAAAN,EAAiB,iBAAjB,gBAAAM,EAA+B;AAEnD,MAAI,CAACD;AACH,WACE,gBAAAE;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,kBAAAR;A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AM,EAAE,OAAOC,EAAA,CAAa,KAAK,OAAO,QAAQN,CAAQ,GAAG;AACrE,YAAI,CAACM,EAAa;AAElB,cAAMhB,IAAUC,EAAgB;AAAA,UAC9B,SAAA9B;AAAA,UACA,kBAAAC;AAAA,UACA,QAAAC;AAAA,UACA,yBAAAmB;AAAA,UACA,aAAAwB;AAAA,UACA,cAAAzC;AAAA,QAAA,CACD;AAED,YAAI;AAQF,WAPiB,MAAMgC,EAAgB;AAAA,YACrC,kBAAAnC;AAAA,YACA,YAAAyC;AAAA,YACA,SAAAb;AAAA,YACA,mBAAmB;AAAA,UAAA,CACpB,GAEQ,QAAQ,CAACiB,MAAY;AAC5B,YAAAH,EAAWG,EAAQ,QAAQ,IAAI;AAAA,cAC7B,GAAGH,EAAWG,EAAQ,QAAQ;AAAA,cAC9B,CAACF,CAAI,GAAGE;AAAA,YAAA;AAAA,UAEZ,CAAC;AAAA,QACH,SAAST,GAAK;AACZ,kBAAQ,MAAMA,CAAG,GACjBV,EAASU,CAAY;AACrB;AAAA,QACF;AAAA,MACF;AACA,MAAAI,EAA4BE,CAAU;AAAA,IACxC,GAEA;AAAA,EACF,GAAG,CAAC3C,GAASC,GAAkBC,GAAQmB,GAAyBkB,GAAUnC,CAAY,CAAC,GAEnFsB,KACA,OAAO,KAAKc,CAAwB,EAAE,WAAW,IAAU,OAExD,gBAAAhC,EAACuC,GAAA,EAAgB,UAAUP,GAA0B,WAAAnC,EAAA,CAAsB;AACpF;"}
|
|
1
|
+
{"version":3,"file":"GeneratedRequestExample.js","sources":["../../../../src/api-playground-2/components/Example/GeneratedRequestExample.tsx"],"sourcesContent":["import { ApiPlaygroundInputs, ExampleSchema } from '@mintlify/validation';\nimport { JSX, useState, useEffect } from 'react';\n\nimport { generateRequest } from '@/api-playground-2/generators/generateRequest';\nimport { generateSnippet } from '@/api-playground-2/generators/generateSnippet';\nimport { getFirstExampleValue } from '@/api-playground-2/schemaGraph/processExamples';\nimport type { ApiReferenceDataV2 } from '@/api-playground-2/types';\nimport { CodeGroupSelect } from '../../../components/content-components/CodeGroupSelect';\nimport { CodeSnippets } from '../../../components/content-components/code-snippets';\nimport { langToPresetMap, SnippetPreset } from '../../../constants/snippetPresets';\nimport type { ExampleCodeSnippet } from '../../../types/exampleCodeSnippet';\n\nexport type GeneratedRequestExampleParams = {\n baseUrl: string;\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n requestExampleLanguages?: string[];\n requiredOnly?: boolean;\n maxHeight?: string;\n};\n\nexport const GeneratedRequestExample = ({\n baseUrl,\n apiReferenceData,\n inputs,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: GeneratedRequestExampleParams): JSX.Element | null => {\n const requestBody = apiReferenceData.dependencies?.requestBody;\n\n if (!requestBody) {\n return (\n <SingleRequest\n apiReferenceData={apiReferenceData}\n baseUrl={baseUrl}\n inputs={inputs}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n }\n\n const firstExampleValue = getFirstExampleValue(requestBody.content);\n\n if (!firstExampleValue) return null;\n\n const examplesByContentType = Object.entries(requestBody.content).map(\n ([contentType, content]) => {\n return {\n contentType,\n examples: content.examples,\n };\n }\n );\n const selectedContentTypeIndex = 0;\n\n return examplesByContentType[selectedContentTypeIndex]?.examples.length > 1 ? (\n <MultipleRequest\n apiReferenceData={apiReferenceData}\n selectedBodyContentType={examplesByContentType[selectedContentTypeIndex]?.contentType}\n baseUrl={baseUrl}\n inputs={inputs}\n examples={examplesByContentType[selectedContentTypeIndex]?.examples}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n ) : (\n <SingleRequest\n apiReferenceData={apiReferenceData}\n selectedBodyContentType={examplesByContentType[selectedContentTypeIndex]?.contentType}\n baseUrl={baseUrl}\n inputs={inputs}\n exampleValue={firstExampleValue}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n};\n\ntype SingleRequestParams = GeneratedRequestExampleParams & {\n selectedBodyContentType?: string;\n exampleValue?: unknown;\n};\n\nconst SingleRequest = ({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n exampleValue,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: SingleRequestParams) => {\n const [snippets, setSnippets] = useState<ExampleCodeSnippet[] | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n \n const request = generateRequest({\n baseUrl,\n apiReferenceData,\n inputs: inputs,\n selectedBodyContentType,\n exampleData: exampleValue,\n requiredOnly,\n });\n\n const snippetPresets = requestExampleLanguages?.reduce<SnippetPreset[]>((acc, lang) => {\n const preset = langToPresetMap[lang];\n if (preset) acc.push(preset);\n return acc;\n }, []);\n\n generateSnippet({\n apiReferenceData,\n pathInputs: inputs.path,\n request,\n snippetPresets,\n })\n .then((result) => {\n if (!cancelled) {\n setSnippets(result);\n }\n })\n .catch((err) => {\n if (!cancelled) {\n console.error(err);\n setError(err);\n }\n });\n \n return () => {\n cancelled = true;\n };\n }, [baseUrl, apiReferenceData, inputs, selectedBodyContentType, exampleValue, requestExampleLanguages, requiredOnly]);\n\n if (error) return null;\n if (!snippets) return null;\n\n return <CodeSnippets snippets={snippets} dropdown maxHeight={maxHeight} />;\n};\n\ntype MultipleRequestParams = GeneratedRequestExampleParams & {\n selectedBodyContentType?: string;\n examples: Record<string, ExampleSchema>;\n};\n\nconst MultipleRequest = ({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n examples,\n requiredOnly,\n maxHeight,\n}: MultipleRequestParams): JSX.Element | null => {\n const [nameToSnippetExamplesMap, setNameToSnippetExamplesMap] = useState<\n Record<string, Record<string, ExampleCodeSnippet>>\n >({});\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const pathInputs = inputs.path;\n const snippetMap: Record<string, Record<string, ExampleCodeSnippet>> = {};\n\n const generateAllSnippets = async () => {\n for (const [name, { value: exampleData }] of Object.entries(examples)) {\n if (!exampleData) continue;\n\n const request = generateRequest({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n exampleData,\n requiredOnly,\n });\n\n try {\n const snippets = await generateSnippet({\n apiReferenceData,\n pathInputs,\n request,\n isMultipleRequest: true,\n });\n\n snippets.forEach((snippet) => {\n snippetMap[snippet.filename] = {\n ...snippetMap[snippet.filename],\n [name]: snippet,\n };\n });\n } catch (err) {\n console.error(err);\n setError(err as Error);\n return;\n }\n }\n setNameToSnippetExamplesMap(snippetMap);\n };\n\n generateAllSnippets();\n }, [baseUrl, apiReferenceData, inputs, selectedBodyContentType, examples, requiredOnly]);\n\n if (error) return null;\n if (Object.keys(nameToSnippetExamplesMap).length === 0) return null;\n\n return <CodeGroupSelect snippets={nameToSnippetExamplesMap} maxHeight={maxHeight} />;\n};\n"],"names":["GeneratedRequestExample","baseUrl","apiReferenceData","inputs","requestExampleLanguages","requiredOnly","maxHeight","requestBody","_a","jsx","SingleRequest","firstExampleValue","getFirstExampleValue","examplesByContentType","contentType","content","selectedContentTypeIndex","_b","MultipleRequest","_c","_d","_e","selectedBodyContentType","exampleValue","snippets","setSnippets","useState","error","setError","useEffect","cancelled","request","generateRequest","snippetPresets","acc","lang","preset","langToPresetMap","generateSnippet","result","err","CodeSnippets","examples","nameToSnippetExamplesMap","setNameToSnippetExamplesMap","pathInputs","snippetMap","name","exampleData","snippet","CodeGroupSelect"],"mappings":";;;;;;;;AAqBO,MAAMA,IAA0B,CAAC;AAAA,EACtC,SAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AACF,MAAyD;;AACvD,QAAMC,KAAcC,IAAAN,EAAiB,iBAAjB,gBAAAM,EAA+B;AAEnD,MAAI,CAACD;AACH,WACE,gBAAAE;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,kBAAAR;AAAA,QACA,SAAAD;AAAA,QACA,Q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EAAU,MAAM;AACd,UAAMgB,IAAa1C,EAAO,MACpB2C,IAAiE,CAAA;AAsCvE,KApC4B,YAAY;AACtC,iBAAW,CAACC,GAAM,EAAE,OAAOC,EAAA,CAAa,KAAK,OAAO,QAAQN,CAAQ,GAAG;AACrE,YAAI,CAACM,EAAa;AAElB,cAAMjB,IAAUC,EAAgB;AAAA,UAC9B,SAAA/B;AAAA,UACA,kBAAAC;AAAA,UACA,QAAAC;AAAA,UACA,yBAAAmB;AAAA,UACA,aAAA0B;AAAA,UACA,cAAA3C;AAAA,QAAA,CACD;AAED,YAAI;AAQF,WAPiB,MAAMiC,EAAgB;AAAA,YACrC,kBAAApC;AAAA,YACA,YAAA2C;AAAA,YACA,SAAAd;AAAA,YACA,mBAAmB;AAAA,UAAA,CACpB,GAEQ,QAAQ,CAACkB,MAAY;AAC5B,YAAAH,EAAWG,EAAQ,QAAQ,IAAI;AAAA,cAC7B,GAAGH,EAAWG,EAAQ,QAAQ;AAAA,cAC9B,CAACF,CAAI,GAAGE;AAAA,YAAA;AAAA,UAEZ,CAAC;AAAA,QACH,SAAST,GAAK;AACZ,kBAAQ,MAAMA,CAAG,GACjBZ,EAASY,CAAY;AACrB;AAAA,QACF;AAAA,MACF;AACA,MAAAI,EAA4BE,CAAU;AAAA,IACxC,GAEA;AAAA,EACF,GAAG,CAAC7C,GAASC,GAAkBC,GAAQmB,GAAyBoB,GAAUrC,CAAY,CAAC,GAEnFsB,KACA,OAAO,KAAKgB,CAAwB,EAAE,WAAW,IAAU,OAExD,gBAAAlC,EAACyC,GAAA,EAAgB,UAAUP,GAA0B,WAAArC,EAAA,CAAsB;AACpF;"}
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { initialApiPlaygroundInputs as
|
|
4
|
-
import { generateSnippetMap as
|
|
5
|
-
import { CodeGroupSelect as
|
|
6
|
-
import { CodeSnippets as
|
|
7
|
-
import { CodeBlock as
|
|
8
|
-
import { CodeGroup as
|
|
9
|
-
import { prismLangToDisplayLang as
|
|
10
|
-
import { useApiPlaygroundDisplay as
|
|
11
|
-
import { GeneratedRequestExample as
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as q, useEffect as y } from "react";
|
|
3
|
+
import { initialApiPlaygroundInputs as E } from "@/api-playground-2/constants";
|
|
4
|
+
import { generateSnippetMap as x } from "@/api-playground-2/generators/generateSnippetMap";
|
|
5
|
+
import { CodeGroupSelect as M } from "../../../components/content-components/CodeGroupSelect/index.js";
|
|
6
|
+
import { CodeSnippets as O } from "../../../components/content-components/code-snippets.js";
|
|
7
|
+
import { CodeBlock as T } from "../../../components/content-components/code-block.js";
|
|
8
|
+
import { CodeGroup as U } from "../../../components/content-components/code-group.js";
|
|
9
|
+
import { prismLangToDisplayLang as j } from "../../../constants/prism-languages.js";
|
|
10
|
+
import { useApiPlaygroundDisplay as w } from "../../../hooks/useApiPlaygroundDisplay.js";
|
|
11
|
+
import { GeneratedRequestExample as C } from "./GeneratedRequestExample.js";
|
|
12
12
|
const F = ({
|
|
13
13
|
apiReferenceData: o,
|
|
14
|
-
inputs: m =
|
|
15
|
-
maxHeight:
|
|
14
|
+
inputs: m = E,
|
|
15
|
+
maxHeight: p
|
|
16
16
|
}) => {
|
|
17
17
|
var r, s, c, e, g;
|
|
18
|
-
const
|
|
18
|
+
const u = (r = o.operation) == null ? void 0 : r.requestExamples, a = w(), i = (s = o.operation) == null ? void 0 : s.requestExampleLanguages, t = (c = o.operation) == null ? void 0 : c.requiredOnlyExamples, d = (e = o.operation) == null ? void 0 : e.requestExampleType;
|
|
19
19
|
switch (console.log("requestExampleType", d), (g = o.operation) == null ? void 0 : g.requestExampleType) {
|
|
20
20
|
case "mdx":
|
|
21
|
-
if (!
|
|
22
|
-
const f =
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
|
|
21
|
+
if (!u) return null;
|
|
22
|
+
const f = u.some((n) => n.dropdown ?? !1);
|
|
23
|
+
return /* @__PURE__ */ l(U, { isSmallText: !0, dropdown: f, noMargins: !0, className: p, children: u.map((n, b) => /* @__PURE__ */ l(
|
|
24
|
+
T,
|
|
25
25
|
{
|
|
26
|
-
language:
|
|
27
|
-
fileName:
|
|
28
|
-
children: /* @__PURE__ */
|
|
26
|
+
language: n.language,
|
|
27
|
+
fileName: n.filename,
|
|
28
|
+
children: /* @__PURE__ */ l("span", { children: n.code })
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
`${n.filename}-${n.language}-${b}`
|
|
31
31
|
)) });
|
|
32
32
|
case "codeSamples":
|
|
33
|
-
return o.operation.codeSamples ? /* @__PURE__ */
|
|
34
|
-
|
|
33
|
+
return o.operation.codeSamples ? /* @__PURE__ */ l(
|
|
34
|
+
L,
|
|
35
35
|
{
|
|
36
36
|
apiReferenceData: o,
|
|
37
37
|
inputs: m,
|
|
38
38
|
apiPlaygroundDisplay: a,
|
|
39
39
|
requestExampleLanguages: i,
|
|
40
40
|
requiredOnly: t,
|
|
41
|
-
maxHeight:
|
|
41
|
+
maxHeight: p
|
|
42
42
|
}
|
|
43
43
|
) : null;
|
|
44
44
|
case "generated":
|
|
45
45
|
const S = o.operation.baseUrl ?? o.operation.baseUrlOptions[0];
|
|
46
|
-
return S ? /* @__PURE__ */
|
|
47
|
-
|
|
46
|
+
return S ? /* @__PURE__ */ l(
|
|
47
|
+
C,
|
|
48
48
|
{
|
|
49
49
|
apiReferenceData: o,
|
|
50
50
|
baseUrl: S,
|
|
51
51
|
inputs: m,
|
|
52
52
|
requestExampleLanguages: i,
|
|
53
53
|
requiredOnly: t,
|
|
54
|
-
maxHeight:
|
|
54
|
+
maxHeight: p
|
|
55
55
|
}
|
|
56
56
|
) : null;
|
|
57
57
|
}
|
|
58
|
-
},
|
|
58
|
+
}, L = ({
|
|
59
59
|
apiReferenceData: o,
|
|
60
60
|
inputs: m,
|
|
61
|
-
apiPlaygroundDisplay:
|
|
62
|
-
requestExampleLanguages:
|
|
61
|
+
apiPlaygroundDisplay: p,
|
|
62
|
+
requestExampleLanguages: u,
|
|
63
63
|
requiredOnly: a,
|
|
64
64
|
maxHeight: i
|
|
65
65
|
}) => {
|
|
66
|
-
const [t, d] =
|
|
67
|
-
if (
|
|
66
|
+
const [t, d] = q(null);
|
|
67
|
+
if (y(() => {
|
|
68
68
|
var r;
|
|
69
|
-
(r = o.operation) != null && r.codeSamples &&
|
|
69
|
+
(r = o.operation) != null && r.codeSamples && x({
|
|
70
70
|
apiReferenceData: o,
|
|
71
71
|
codeSamples: o.operation.codeSamples,
|
|
72
72
|
baseUrl: o.operation.baseUrl ?? o.operation.baseUrlOptions[0],
|
|
73
|
-
apiPlaygroundMode:
|
|
74
|
-
requestExampleLanguages:
|
|
73
|
+
apiPlaygroundMode: p,
|
|
74
|
+
requestExampleLanguages: u,
|
|
75
75
|
requiredOnly: a,
|
|
76
76
|
inputs: m
|
|
77
77
|
}).then(d);
|
|
78
|
-
}, [o, m,
|
|
78
|
+
}, [o, m, p, u, a]), !t) return null;
|
|
79
79
|
if (Object.values(t).every((r) => Object.keys(r).length <= 1)) {
|
|
80
80
|
let s = Object.values(t).flatMap((e) => Object.values(e));
|
|
81
81
|
return new Set(s.map((e) => e.filename)).size !== s.length && (s = s.map((e) => ({
|
|
82
82
|
...e,
|
|
83
|
-
filename:
|
|
84
|
-
}))), /* @__PURE__ */
|
|
83
|
+
filename: j[e.language] ?? e.language
|
|
84
|
+
}))), /* @__PURE__ */ l(O, { snippets: s, dropdown: !0, maxHeight: i });
|
|
85
85
|
}
|
|
86
|
-
return /* @__PURE__ */
|
|
86
|
+
return /* @__PURE__ */ l(M, { snippets: t, maxHeight: i });
|
|
87
87
|
};
|
|
88
88
|
export {
|
|
89
89
|
F as RequestExample
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestExample.js","sources":["../../../../src/api-playground-2/components/Example/RequestExample.tsx"],"sourcesContent":["import { ApiPlaygroundInputs } from '@mintlify/validation';\nimport { useState, useEffect } from 'react';\n\nimport { initialApiPlaygroundInputs } from '@/api-playground-2/constants';\nimport { generateSnippetMap } from '@/api-playground-2/generators/generateSnippetMap';\nimport type { ApiReferenceDataV2, CodeExample } from '@/api-playground-2/types';\nimport { CodeGroupSelect } from '../../../components/content-components/CodeGroupSelect';\nimport { CodeSnippet } from '../../../components/content-components/code-snippet';\nimport { CodeSnippets } from '../../../components/content-components/code-snippets';\nimport { CodeBlock } from '../../../components/content-components/code-block';\nimport { CodeGroup } from '../../../components/content-components/code-group';\nimport { prismLangToDisplayLang } from '../../../constants/prism-languages';\nimport { useApiPlaygroundDisplay } from '../../../hooks/useApiPlaygroundDisplay';\nimport type { ExampleCodeSnippet } from '../../../types/exampleCodeSnippet';\n\nimport { GeneratedRequestExample } from './GeneratedRequestExample';\n\nexport const RequestExample = ({\n apiReferenceData,\n inputs = initialApiPlaygroundInputs,\n maxHeight,\n}: {\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n maxHeight?: string;\n}) => {\n const requestExamples = apiReferenceData.operation?.requestExamples;\n const apiPlaygroundDisplay = useApiPlaygroundDisplay();\n const requestExampleLanguages = apiReferenceData.operation?.requestExampleLanguages;\n const requiredOnly = apiReferenceData.operation?.requiredOnlyExamples;\n\n const requestExampleType = apiReferenceData.operation?.requestExampleType;\n\n console.log('requestExampleType', requestExampleType);\n\n switch (apiReferenceData.operation?.requestExampleType) {\n case 'mdx':\n if (!requestExamples) return null;\n const dropdown = requestExamples.some((example: CodeExample) => example.dropdown ?? false);\n return (\n <CodeGroup isSmallText dropdown={dropdown} noMargins className={maxHeight}>\n {requestExamples.map((example: CodeExample) => (\n <CodeBlock\n language={example.language}\n fileName={example.filename}\n key={example.filename}\n >\n <span>{example.code}</span>\n </CodeBlock>\n ))}\n </CodeGroup>\n );\n case 'codeSamples':\n if (!apiReferenceData.operation.codeSamples) return null;\n return (\n <CodeSamplesExample\n apiReferenceData={apiReferenceData}\n inputs={inputs}\n apiPlaygroundDisplay={apiPlaygroundDisplay}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n case 'generated':\n const baseUrl =\n apiReferenceData.operation.baseUrl ?? apiReferenceData.operation.baseUrlOptions[0];\n if (!baseUrl) return null;\n return (\n <GeneratedRequestExample\n apiReferenceData={apiReferenceData}\n baseUrl={baseUrl}\n inputs={inputs}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n }\n};\n\nconst CodeSamplesExample = ({\n apiReferenceData,\n inputs,\n apiPlaygroundDisplay,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: {\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n apiPlaygroundDisplay: 'none' | 'simple' | 'interactive';\n requestExampleLanguages?: string[];\n requiredOnly?: boolean;\n maxHeight?: string;\n}) => {\n const [snippetMap, setSnippetMap] = useState<Record<string, Record<string, ExampleCodeSnippet>> | null>(null);\n\n useEffect(() => {\n if (!apiReferenceData.operation?.codeSamples) return;\n\n generateSnippetMap({\n apiReferenceData,\n codeSamples: apiReferenceData.operation.codeSamples,\n baseUrl: apiReferenceData.operation.baseUrl ?? apiReferenceData.operation.baseUrlOptions[0],\n apiPlaygroundMode: apiPlaygroundDisplay,\n requestExampleLanguages,\n requiredOnly,\n inputs,\n }).then(setSnippetMap);\n }, [apiReferenceData, inputs, apiPlaygroundDisplay, requestExampleLanguages, requiredOnly]);\n\n if (!snippetMap) return null;\n\n if (Object.values(snippetMap).every((value) => Object.keys(value).length <= 1)) {\n const codeSnippetMap = Object.values(snippetMap);\n let snippets = codeSnippetMap.flatMap((record) => Object.values(record));\n const uniqueLabels = new Set(snippets.map((snippet) => snippet.filename));\n if (uniqueLabels.size !== snippets.length) {\n snippets = snippets.map((snippet) => ({\n ...snippet,\n filename: prismLangToDisplayLang[snippet.language] ?? snippet.language,\n }));\n }\n return <CodeSnippets snippets={snippets} dropdown maxHeight={maxHeight} />;\n }\n\n return <CodeGroupSelect snippets={snippetMap} maxHeight={maxHeight} />;\n};\n"],"names":["RequestExample","apiReferenceData","inputs","initialApiPlaygroundInputs","maxHeight","requestExamples","_a","apiPlaygroundDisplay","useApiPlaygroundDisplay","requestExampleLanguages","_b","requiredOnly","_c","requestExampleType","_d","_e","dropdown","example","jsx","CodeGroup","CodeBlock","CodeSamplesExample","baseUrl","GeneratedRequestExample","snippetMap","setSnippetMap","useState","useEffect","generateSnippetMap","value","snippets","record","snippet","prismLangToDisplayLang","CodeSnippets","CodeGroupSelect"],"mappings":";;;;;;;;;;;AAiBO,MAAMA,IAAiB,CAAC;AAAA,EAC7B,kBAAAC;AAAA,EACA,QAAAC,IAASC;AAAA,EACT,WAAAC;AACF,MAIM;;AACJ,QAAMC,KAAkBC,IAAAL,EAAiB,cAAjB,gBAAAK,EAA4B,iBAC9CC,IAAuBC,EAAA,GACvBC,KAA0BC,IAAAT,EAAiB,cAAjB,gBAAAS,EAA4B,yBACtDC,KAAeC,IAAAX,EAAiB,cAAjB,gBAAAW,EAA4B,sBAE3CC,KAAqBC,IAAAb,EAAiB,cAAjB,gBAAAa,EAA4B;AAIvD,UAFA,QAAQ,IAAI,sBAAsBD,CAAkB,IAE5CE,IAAAd,EAAiB,cAAjB,gBAAAc,EAA4B,oBAAA;AAAA,IAClC,KAAK;AACH,UAAI,CAACV,EAAiB,QAAO;AAC7B,YAAMW,IAAWX,EAAgB,KAAK,CAACY,MAAyBA,EAAQ,YAAY,EAAK;AACzF,aACE,gBAAAC,EAACC,GAAA,EAAU,aAAW,IAAC,UAAAH,GAAoB,WAAS,IAAC,WAAWZ,GAC7D,UAAAC,EAAgB,IAAI,CAACY,
|
|
1
|
+
{"version":3,"file":"RequestExample.js","sources":["../../../../src/api-playground-2/components/Example/RequestExample.tsx"],"sourcesContent":["import { ApiPlaygroundInputs } from '@mintlify/validation';\nimport { useState, useEffect } from 'react';\n\nimport { initialApiPlaygroundInputs } from '@/api-playground-2/constants';\nimport { generateSnippetMap } from '@/api-playground-2/generators/generateSnippetMap';\nimport type { ApiReferenceDataV2, CodeExample } from '@/api-playground-2/types';\nimport { CodeGroupSelect } from '../../../components/content-components/CodeGroupSelect';\nimport { CodeSnippet } from '../../../components/content-components/code-snippet';\nimport { CodeSnippets } from '../../../components/content-components/code-snippets';\nimport { CodeBlock } from '../../../components/content-components/code-block';\nimport { CodeGroup } from '../../../components/content-components/code-group';\nimport { prismLangToDisplayLang } from '../../../constants/prism-languages';\nimport { useApiPlaygroundDisplay } from '../../../hooks/useApiPlaygroundDisplay';\nimport type { ExampleCodeSnippet } from '../../../types/exampleCodeSnippet';\n\nimport { GeneratedRequestExample } from './GeneratedRequestExample';\n\nexport const RequestExample = ({\n apiReferenceData,\n inputs = initialApiPlaygroundInputs,\n maxHeight,\n}: {\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n maxHeight?: string;\n}) => {\n const requestExamples = apiReferenceData.operation?.requestExamples;\n const apiPlaygroundDisplay = useApiPlaygroundDisplay();\n const requestExampleLanguages = apiReferenceData.operation?.requestExampleLanguages;\n const requiredOnly = apiReferenceData.operation?.requiredOnlyExamples;\n\n const requestExampleType = apiReferenceData.operation?.requestExampleType;\n\n console.log('requestExampleType', requestExampleType);\n\n switch (apiReferenceData.operation?.requestExampleType) {\n case 'mdx':\n if (!requestExamples) return null;\n const dropdown = requestExamples.some((example: CodeExample) => example.dropdown ?? false);\n return (\n <CodeGroup isSmallText dropdown={dropdown} noMargins className={maxHeight}>\n {requestExamples.map((example: CodeExample, index) => (\n <CodeBlock\n language={example.language}\n fileName={example.filename}\n key={`${example.filename}-${example.language}-${index}`}\n >\n <span>{example.code}</span>\n </CodeBlock>\n ))}\n </CodeGroup>\n );\n case 'codeSamples':\n if (!apiReferenceData.operation.codeSamples) return null;\n return (\n <CodeSamplesExample\n apiReferenceData={apiReferenceData}\n inputs={inputs}\n apiPlaygroundDisplay={apiPlaygroundDisplay}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n case 'generated':\n const baseUrl =\n apiReferenceData.operation.baseUrl ?? apiReferenceData.operation.baseUrlOptions[0];\n if (!baseUrl) return null;\n return (\n <GeneratedRequestExample\n apiReferenceData={apiReferenceData}\n baseUrl={baseUrl}\n inputs={inputs}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n }\n};\n\nconst CodeSamplesExample = ({\n apiReferenceData,\n inputs,\n apiPlaygroundDisplay,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: {\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n apiPlaygroundDisplay: 'none' | 'simple' | 'interactive';\n requestExampleLanguages?: string[];\n requiredOnly?: boolean;\n maxHeight?: string;\n}) => {\n const [snippetMap, setSnippetMap] = useState<Record<string, Record<string, ExampleCodeSnippet>> | null>(null);\n\n useEffect(() => {\n if (!apiReferenceData.operation?.codeSamples) return;\n\n generateSnippetMap({\n apiReferenceData,\n codeSamples: apiReferenceData.operation.codeSamples,\n baseUrl: apiReferenceData.operation.baseUrl ?? apiReferenceData.operation.baseUrlOptions[0],\n apiPlaygroundMode: apiPlaygroundDisplay,\n requestExampleLanguages,\n requiredOnly,\n inputs,\n }).then(setSnippetMap);\n }, [apiReferenceData, inputs, apiPlaygroundDisplay, requestExampleLanguages, requiredOnly]);\n\n if (!snippetMap) return null;\n\n if (Object.values(snippetMap).every((value) => Object.keys(value).length <= 1)) {\n const codeSnippetMap = Object.values(snippetMap);\n let snippets = codeSnippetMap.flatMap((record) => Object.values(record));\n const uniqueLabels = new Set(snippets.map((snippet) => snippet.filename));\n if (uniqueLabels.size !== snippets.length) {\n snippets = snippets.map((snippet) => ({\n ...snippet,\n filename: prismLangToDisplayLang[snippet.language] ?? snippet.language,\n }));\n }\n return <CodeSnippets snippets={snippets} dropdown maxHeight={maxHeight} />;\n }\n\n return <CodeGroupSelect snippets={snippetMap} maxHeight={maxHeight} />;\n};\n"],"names":["RequestExample","apiReferenceData","inputs","initialApiPlaygroundInputs","maxHeight","requestExamples","_a","apiPlaygroundDisplay","useApiPlaygroundDisplay","requestExampleLanguages","_b","requiredOnly","_c","requestExampleType","_d","_e","dropdown","example","jsx","CodeGroup","index","CodeBlock","CodeSamplesExample","baseUrl","GeneratedRequestExample","snippetMap","setSnippetMap","useState","useEffect","generateSnippetMap","value","snippets","record","snippet","prismLangToDisplayLang","CodeSnippets","CodeGroupSelect"],"mappings":";;;;;;;;;;;AAiBO,MAAMA,IAAiB,CAAC;AAAA,EAC7B,kBAAAC;AAAA,EACA,QAAAC,IAASC;AAAA,EACT,WAAAC;AACF,MAIM;;AACJ,QAAMC,KAAkBC,IAAAL,EAAiB,cAAjB,gBAAAK,EAA4B,iBAC9CC,IAAuBC,EAAA,GACvBC,KAA0BC,IAAAT,EAAiB,cAAjB,gBAAAS,EAA4B,yBACtDC,KAAeC,IAAAX,EAAiB,cAAjB,gBAAAW,EAA4B,sBAE3CC,KAAqBC,IAAAb,EAAiB,cAAjB,gBAAAa,EAA4B;AAIvD,UAFA,QAAQ,IAAI,sBAAsBD,CAAkB,IAE5CE,IAAAd,EAAiB,cAAjB,gBAAAc,EAA4B,oBAAA;AAAA,IAClC,KAAK;AACH,UAAI,CAACV,EAAiB,QAAO;AAC7B,YAAMW,IAAWX,EAAgB,KAAK,CAACY,MAAyBA,EAAQ,YAAY,EAAK;AACzF,aACE,gBAAAC,EAACC,GAAA,EAAU,aAAW,IAAC,UAAAH,GAAoB,WAAS,IAAC,WAAWZ,GAC7D,UAAAC,EAAgB,IAAI,CAACY,GAAsBG,MAC1C,gBAAAF;AAAA,QAACG;AAAA,QAAA;AAAA,UACC,UAAUJ,EAAQ;AAAA,UAClB,UAAUA,EAAQ;AAAA,UAGlB,UAAA,gBAAAC,EAAC,QAAA,EAAM,UAAAD,EAAQ,KAAA,CAAK;AAAA,QAA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EAAY,QAAO;AAExB,MAAI,OAAO,OAAOA,CAAU,EAAE,MAAM,CAACK,MAAU,OAAO,KAAKA,CAAK,EAAE,UAAU,CAAC,GAAG;AAE9E,QAAIC,IADmB,OAAO,OAAON,CAAU,EACjB,QAAQ,CAACO,MAAW,OAAO,OAAOA,CAAM,CAAC;AAEvE,WADqB,IAAI,IAAID,EAAS,IAAI,CAACE,MAAYA,EAAQ,QAAQ,CAAC,EACvD,SAASF,EAAS,WACjCA,IAAWA,EAAS,IAAI,CAACE,OAAa;AAAA,MACpC,GAAGA;AAAA,MACH,UAAUC,EAAuBD,EAAQ,QAAQ,KAAKA,EAAQ;AAAA,IAAA,EAC9D,IAEG,gBAAAf,EAACiB,GAAA,EAAa,UAAAJ,GAAoB,UAAQ,IAAC,WAAA3B,GAAsB;AAAA,EAC1E;AAEA,SAAO,gBAAAc,EAACkB,GAAA,EAAgB,UAAUX,GAAY,WAAArB,EAAA,CAAsB;AACtE;"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { CodeBlock as
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { CodeBlock as a } from "../../../components/content-components/code-block.js";
|
|
3
3
|
import { CodeGroup as i } from "../../../components/content-components/code-group.js";
|
|
4
|
-
import { GeneratedResponseExample as
|
|
5
|
-
const
|
|
4
|
+
import { GeneratedResponseExample as d } from "./GeneratedResponseExample.js";
|
|
5
|
+
const E = ({ apiReferenceData: r, maxHeight: s }) => {
|
|
6
6
|
var l, p;
|
|
7
7
|
const n = (l = r.operation) == null ? void 0 : l.responseExamples;
|
|
8
8
|
if (((p = r.operation) == null ? void 0 : p.responseExampleType) === "mdx") {
|
|
9
9
|
if (!n) return null;
|
|
10
|
-
const m = n.some((
|
|
11
|
-
return /* @__PURE__ */
|
|
10
|
+
const m = n.some((o) => o.dropdown ?? !1);
|
|
11
|
+
return /* @__PURE__ */ e(i, { isSmallText: !0, dropdown: m, noMargins: !0, className: s, children: n.map((o, t) => /* @__PURE__ */ e(a, { language: o.language, fileName: o.filename, children: /* @__PURE__ */ e("span", { children: o.code }) }, `${o.filename}-${o.language}-${t}`)) });
|
|
12
12
|
} else
|
|
13
|
-
return /* @__PURE__ */
|
|
13
|
+
return /* @__PURE__ */ e(d, { apiReferenceData: r, maxHeight: s });
|
|
14
14
|
};
|
|
15
15
|
export {
|
|
16
|
-
|
|
16
|
+
E as ResponseExample
|
|
17
17
|
};
|
|
18
18
|
//# sourceMappingURL=ResponseExample.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseExample.js","sources":["../../../../src/api-playground-2/components/Example/ResponseExample.tsx"],"sourcesContent":["'use client';\n\nimport type { ApiReferenceDataV2, CodeExample } from '@/api-playground-2/types';\nimport { CodeBlock } from '../../../components/content-components/code-block';\nimport { CodeGroup } from '../../../components/content-components/code-group';\n\nimport { GeneratedResponseExample } from './GeneratedResponseExample';\n\nexport const ResponseExample = ({ apiReferenceData, maxHeight }: { apiReferenceData: ApiReferenceDataV2; maxHeight?: string }) => {\n const responseExamples = apiReferenceData.operation?.responseExamples;\n\n if (apiReferenceData.operation?.responseExampleType === 'mdx') {\n if (!responseExamples) return null;\n const dropdown = responseExamples.some((example: CodeExample) => example.dropdown ?? false);\n return (\n <CodeGroup isSmallText dropdown={dropdown} noMargins className={maxHeight}>\n {responseExamples.map((example: CodeExample) => (\n <CodeBlock language={example.language} fileName={example.filename} key={example.filename}>\n <span>{example.code}</span>\n </CodeBlock>\n ))}\n </CodeGroup>\n );\n } else {\n return <GeneratedResponseExample apiReferenceData={apiReferenceData} maxHeight={maxHeight} />;\n }\n};\n"],"names":["ResponseExample","apiReferenceData","maxHeight","responseExamples","_a","_b","dropdown","example","
|
|
1
|
+
{"version":3,"file":"ResponseExample.js","sources":["../../../../src/api-playground-2/components/Example/ResponseExample.tsx"],"sourcesContent":["'use client';\n\nimport type { ApiReferenceDataV2, CodeExample } from '@/api-playground-2/types';\nimport { CodeBlock } from '../../../components/content-components/code-block';\nimport { CodeGroup } from '../../../components/content-components/code-group';\n\nimport { GeneratedResponseExample } from './GeneratedResponseExample';\n\nexport const ResponseExample = ({ apiReferenceData, maxHeight }: { apiReferenceData: ApiReferenceDataV2; maxHeight?: string }) => {\n const responseExamples = apiReferenceData.operation?.responseExamples;\n\n if (apiReferenceData.operation?.responseExampleType === 'mdx') {\n if (!responseExamples) return null;\n const dropdown = responseExamples.some((example: CodeExample) => example.dropdown ?? false);\n return (\n <CodeGroup isSmallText dropdown={dropdown} noMargins className={maxHeight}>\n {responseExamples.map((example: CodeExample, index) => (\n <CodeBlock language={example.language} fileName={example.filename} key={`${example.filename}-${example.language}-${index}`}>\n <span>{example.code}</span>\n </CodeBlock>\n ))}\n </CodeGroup>\n );\n } else {\n return <GeneratedResponseExample apiReferenceData={apiReferenceData} maxHeight={maxHeight} />;\n }\n};\n"],"names":["ResponseExample","apiReferenceData","maxHeight","responseExamples","_a","_b","dropdown","example","CodeGroup","index","jsx","CodeBlock","GeneratedResponseExample"],"mappings":";;;;AAQO,MAAMA,IAAkB,CAAC,EAAE,kBAAAC,GAAkB,WAAAC,QAA8E;;AAChI,QAAMC,KAAmBC,IAAAH,EAAiB,cAAjB,gBAAAG,EAA4B;AAErD,QAAIC,IAAAJ,EAAiB,cAAjB,gBAAAI,EAA4B,yBAAwB,OAAO;AAC7D,QAAI,CAACF,EAAkB,QAAO;AAC9B,UAAMG,IAAWH,EAAiB,KAAK,CAACI,MAAyBA,EAAQ,YAAY,EAAK;AAC1F,6BACGC,GAAA,EAAU,aAAW,IAAC,UAAAF,GAAoB,WAAS,IAAC,WAAWJ,GAC7D,UAAAC,EAAiB,IAAI,CAACI,GAAsBE,MAC3C,gBAAAC,EAACC,KAAU,UAAUJ,EAAQ,UAAU,UAAUA,EAAQ,UACvD,UAAA,gBAAAG,EAAC,QAAA,EAAM,UAAAH,EAAQ,MAAK,EAAA,GADkD,GAAGA,EAAQ,QAAQ,IAAIA,EAAQ,QAAQ,IAAIE,CAAK,EAExH,CACD,GACH;AAAA,EAEJ;AACE,WAAO,gBAAAC,EAACE,GAAA,EAAyB,kBAAAX,GAAoC,WAAAC,EAAA,CAAsB;AAE/F;"}
|
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
import { jsxs as u, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import { ChevronDownFilled as
|
|
2
|
+
import * as d from "@radix-ui/react-tabs";
|
|
3
|
+
import j, { forwardRef as k, useRef as F, useState as L, useCallback as V } from "react";
|
|
4
|
+
import { ChevronDownFilled as G } from "@fluentui/react-icons";
|
|
5
5
|
import { cn as g } from "../../utils/cn.js";
|
|
6
|
-
import { CopyToClipboardButton as
|
|
7
|
-
import { getNodeText as
|
|
8
|
-
import { capitalize as
|
|
9
|
-
const
|
|
6
|
+
import { CopyToClipboardButton as z } from "./code-block.js";
|
|
7
|
+
import { getNodeText as B } from "../../utils/get-node-text.js";
|
|
8
|
+
import { capitalize as D } from "../../utils/string.js";
|
|
9
|
+
const K = k(function({ children: r, onChange: a, className: o, dropdown: l, noMargins: x, ...T }, C) {
|
|
10
10
|
var N, w;
|
|
11
|
-
const { defaultValue:
|
|
11
|
+
const { defaultValue: f, ...S } = T, b = F(/* @__PURE__ */ new Map()), i = Array.isArray(r) ? r : j.Children.toArray(r), [h, A] = L(0), v = V(
|
|
12
12
|
(n) => {
|
|
13
13
|
var s;
|
|
14
|
-
const t = Number(n),
|
|
15
|
-
A(t),
|
|
16
|
-
const
|
|
17
|
-
|
|
14
|
+
const t = Number(n), m = ((s = document.activeElement) == null ? void 0 : s.getAttribute("role")) === "tab";
|
|
15
|
+
A(t), a == null || a(t), m && requestAnimationFrame(() => {
|
|
16
|
+
const p = b.current.get(t);
|
|
17
|
+
p && p.focus();
|
|
18
18
|
});
|
|
19
19
|
},
|
|
20
|
-
[
|
|
20
|
+
[a]
|
|
21
21
|
);
|
|
22
|
-
if (!
|
|
22
|
+
if (!r)
|
|
23
23
|
return null;
|
|
24
24
|
if (i.length === 0)
|
|
25
25
|
return console.warn("CodeGroup has no children, expected at least one CodeBlock child."), null;
|
|
26
|
-
const
|
|
26
|
+
const c = Number(h), I = () => {
|
|
27
27
|
var n;
|
|
28
|
-
return /* @__PURE__ */ e("div", { className: "mint:flex mint:items-center mint:gap-1.5 mint:text-xs mint:font-medium mint:min-w-0", children: /* @__PURE__ */ e("span", { className: "mint:truncate mint:text-[#171717] mint:dark:text-[#fafafa]", children: (n = i[
|
|
29
|
-
},
|
|
30
|
-
|
|
28
|
+
return /* @__PURE__ */ e("div", { className: "mint:flex mint:items-center mint:gap-1.5 mint:text-xs mint:font-medium mint:min-w-0", children: /* @__PURE__ */ e("span", { className: "mint:truncate mint:text-[#171717] mint:dark:text-[#fafafa]", children: (n = i[c]) == null ? void 0 : n.props.fileName }) });
|
|
29
|
+
}, $ = () => /* @__PURE__ */ e(d.List, { className: "mint:flex-1 mint:min-w-0 mint:text-xs mint:leading-6 mint:rounded-tl-xl mint:gap-1 mint:flex mint:overflow-x-auto mint:overflow-y-hidden", children: i.map((n, t) => /* @__PURE__ */ e(
|
|
30
|
+
_,
|
|
31
31
|
{
|
|
32
32
|
value: String(t),
|
|
33
|
-
isSelected:
|
|
33
|
+
isSelected: c === t,
|
|
34
34
|
tabsLength: i.length,
|
|
35
|
-
ref: (
|
|
36
|
-
|
|
35
|
+
ref: (m) => {
|
|
36
|
+
m && b.current.set(t, m);
|
|
37
37
|
},
|
|
38
38
|
children: n.props.fileName
|
|
39
39
|
},
|
|
40
40
|
n.props.fileName + "TabItem" + t
|
|
41
|
-
)) }),
|
|
41
|
+
)) }), R = () => {
|
|
42
42
|
var n;
|
|
43
43
|
return /* @__PURE__ */ u("div", { className: "mint:relative", children: [
|
|
44
44
|
/* @__PURE__ */ e(
|
|
45
45
|
"select",
|
|
46
46
|
{
|
|
47
|
-
value: ((n = i[
|
|
47
|
+
value: ((n = i[c]) == null ? void 0 : n.props.language) || "",
|
|
48
48
|
onChange: (t) => {
|
|
49
|
-
const
|
|
49
|
+
const m = t.target.value, s = i.findIndex((p) => p.props.language === m);
|
|
50
50
|
s !== -1 && v(String(s));
|
|
51
51
|
},
|
|
52
52
|
className: "mint:appearance-none mint:bg-transparent mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:rounded-lg mint:px-2.5 mint:pr-7 mint:py-1 mint:text-xs mint:font-medium mint:text-[#171717] mint:dark:text-[#fafafa] mint:cursor-pointer mint:focus:outline-0",
|
|
53
|
-
children: i.map((t) => /* @__PURE__ */ e("option", { value: t.props.language, children:
|
|
53
|
+
children: i.map((t, m) => /* @__PURE__ */ e("option", { value: t.props.language, children: D(t.props.language || "") }, `${t.props.language}-${t.props.fileName}-${m}`))
|
|
54
54
|
}
|
|
55
55
|
),
|
|
56
|
-
/* @__PURE__ */ e(
|
|
56
|
+
/* @__PURE__ */ e(G, { className: "mint:absolute mint:right-2 mint:top-1/2 mint:-translate-y-1/2 mint:w-3.5 mint:h-3.5 mint:pointer-events-none mint:text-[#737373] mint:dark:text-[#a3a3a3]" })
|
|
57
57
|
] });
|
|
58
58
|
};
|
|
59
59
|
return /* @__PURE__ */ u(
|
|
60
|
-
|
|
60
|
+
d.Root,
|
|
61
61
|
{
|
|
62
|
-
defaultValue:
|
|
62
|
+
defaultValue: f == null ? void 0 : typeof f == "string" ? f : String(f),
|
|
63
63
|
ref: C,
|
|
64
|
-
value: String(
|
|
64
|
+
value: String(h),
|
|
65
65
|
onValueChange: v,
|
|
66
66
|
className: g(
|
|
67
67
|
!x && "mint:mt-4 mint:mb-4",
|
|
@@ -79,13 +79,13 @@ const Q = k(function({ children: m, onChange: r, className: o, dropdown: l, noMa
|
|
|
79
79
|
""
|
|
80
80
|
),
|
|
81
81
|
children: [
|
|
82
|
-
l ? /* @__PURE__ */ e(I, {}) : /* @__PURE__ */ e(
|
|
82
|
+
l ? /* @__PURE__ */ e(I, {}) : /* @__PURE__ */ e($, {}),
|
|
83
83
|
/* @__PURE__ */ u("div", { className: "mint:flex mint:items-center mint:justify-end mint:shrink-0 mint:gap-1.5", children: [
|
|
84
|
-
l && /* @__PURE__ */ e(
|
|
84
|
+
l && /* @__PURE__ */ e(R, {}),
|
|
85
85
|
/* @__PURE__ */ e(
|
|
86
|
-
|
|
86
|
+
z,
|
|
87
87
|
{
|
|
88
|
-
textToCopy:
|
|
88
|
+
textToCopy: B((w = (N = i[c]) == null ? void 0 : N.props) == null ? void 0 : w.children),
|
|
89
89
|
showTooltip: !0
|
|
90
90
|
}
|
|
91
91
|
)
|
|
@@ -94,24 +94,24 @@ const Q = k(function({ children: m, onChange: r, className: o, dropdown: l, noMa
|
|
|
94
94
|
}
|
|
95
95
|
),
|
|
96
96
|
/* @__PURE__ */ e("div", { className: "mint:flex mint:flex-1 mint:overflow-hidden", children: i.map((n, t) => /* @__PURE__ */ e(
|
|
97
|
-
|
|
97
|
+
d.Content,
|
|
98
98
|
{
|
|
99
99
|
value: String(t),
|
|
100
100
|
className: "mint:w-full mint:min-w-full mint:max-w-full mint:h-full mint:max-h-full",
|
|
101
101
|
tabIndex: -1,
|
|
102
102
|
children: /* @__PURE__ */ e("div", { className: "mint:overflow-auto mint:max-h-[calc(40vh-3rem)]", children: n })
|
|
103
103
|
},
|
|
104
|
-
n.props.fileName
|
|
104
|
+
`${n.props.fileName}-${n.props.language}-${t}`
|
|
105
105
|
)) })
|
|
106
106
|
]
|
|
107
107
|
}
|
|
108
108
|
);
|
|
109
|
-
}),
|
|
109
|
+
}), _ = k(function({ children: r, value: a, isSelected: o, tabsLength: l }, x) {
|
|
110
110
|
return /* @__PURE__ */ u(
|
|
111
|
-
|
|
111
|
+
d.Trigger,
|
|
112
112
|
{
|
|
113
113
|
ref: x,
|
|
114
|
-
value:
|
|
114
|
+
value: a,
|
|
115
115
|
className: g(
|
|
116
116
|
"mint:group mint:flex mint:items-center mint:relative mint:gap-1.5 mint:my-1 mint:mb-1.5 mint:outline-0 mint:whitespace-nowrap mint:font-medium mint:ml-0! mint:first:ml-2.5! mint:focus:outline-2",
|
|
117
117
|
o && "mint:text-[#9263f1] mint:dark:text-[#c9aaf9]",
|
|
@@ -125,7 +125,7 @@ const Q = k(function({ children: m, onChange: r, className: o, dropdown: l, noMa
|
|
|
125
125
|
"mint:flex mint:items-center mint:gap-1.5 mint:px-1.5 mint:rounded-lg mint:z-10",
|
|
126
126
|
l > 1 && "mint:group-hover:bg-[#f5f5f5] mint:group-hover:dark:bg-[#1a1a1a] mint:group-hover:text-[#9263f1] mint:group-hover:dark:text-[#c9aaf9]"
|
|
127
127
|
),
|
|
128
|
-
children:
|
|
128
|
+
children: r
|
|
129
129
|
}
|
|
130
130
|
),
|
|
131
131
|
o && /* @__PURE__ */ e("div", { className: "mint:absolute mint:-bottom-1.5 mint:left-0 mint:right-0 mint:h-0.5 mint:rounded-full mint:bg-[#9263f1] mint:dark:bg-[#c9aaf9]" })
|
|
@@ -134,6 +134,6 @@ const Q = k(function({ children: m, onChange: r, className: o, dropdown: l, noMa
|
|
|
134
134
|
);
|
|
135
135
|
});
|
|
136
136
|
export {
|
|
137
|
-
|
|
137
|
+
K as CodeGroup
|
|
138
138
|
};
|
|
139
139
|
//# sourceMappingURL=code-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-group.js","sources":["../../../src/components/content-components/code-group.tsx"],"sourcesContent":["'use client';\n\nimport * as TabsPrimitive from '@radix-ui/react-tabs';\nimport React, {\n ComponentPropsWithoutRef,\n ReactElement,\n ReactNode,\n forwardRef,\n useCallback,\n useState,\n useRef,\n} from 'react';\nimport { ChevronDownFilled } from '@fluentui/react-icons';\n\nimport { cn } from '../../utils/cn';\nimport { CodeBlock } from './code-block';\nimport { CopyToClipboardButton } from './code-block';\nimport { getNodeText } from '../../utils/get-node-text';\nimport { capitalize } from '../../utils/string';\n\ntype CodeBlockProps = ComponentPropsWithoutRef<typeof CodeBlock>;\n\nexport type CodeGroupPropsBase = {\n dropdown?: boolean;\n isSmallText?: boolean;\n noMargins?: boolean;\n children?: ReactElement<CodeBlockProps>[] | ReactElement<CodeBlockProps>;\n onChange?: (index: number) => void;\n};\n\nexport type CodeGroupProps = CodeGroupPropsBase &\n Omit<ComponentPropsWithoutRef<'div'>, keyof CodeGroupPropsBase | 'dir'>;\n\ntype CodeBlockChild = Exclude<React.ReactElement<CodeBlockProps>, boolean | null | undefined>;\n\nexport const CodeGroup = forwardRef<HTMLDivElement, CodeGroupProps>(function CodeGroup(\n { children, onChange, className, dropdown, noMargins, ...restProps },\n ref\n) {\n // Filter out props that are incompatible with TabsPrimitive.Root\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { defaultValue, ...props } = restProps as any;\n const triggerRefs = useRef<Map<number, HTMLButtonElement>>(new Map());\n const childArr = Array.isArray(children)\n ? children\n : (React.Children.toArray(children) as Array<CodeBlockChild>);\n\n const [selectedTab, setSelectedTab] = useState(0);\n\n const handleValueChange = useCallback(\n (value: string) => {\n const index = Number(value);\n const wasFocusOnTab = document.activeElement?.getAttribute('role') === 'tab';\n\n setSelectedTab(index);\n onChange?.(index);\n\n if (wasFocusOnTab) {\n requestAnimationFrame(() => {\n const trigger = triggerRefs.current.get(index);\n if (trigger) {\n trigger.focus();\n }\n });\n }\n },\n [onChange]\n );\n\n if (!children) {\n return null;\n }\n\n if (childArr.length === 0) {\n console.warn('CodeGroup has no children, expected at least one CodeBlock child.');\n return null;\n }\n\n const selectedIndex = Number(selectedTab);\n\n const SelectedFilename = () => {\n return (\n <div className=\"mint:flex mint:items-center mint:gap-1.5 mint:text-xs mint:font-medium mint:min-w-0\">\n <span className=\"mint:truncate mint:text-[#171717] mint:dark:text-[#fafafa]\">\n {childArr[selectedIndex]?.props.fileName}\n </span>\n </div>\n );\n };\n\n const TabList = () => {\n return (\n <TabsPrimitive.List className=\"mint:flex-1 mint:min-w-0 mint:text-xs mint:leading-6 mint:rounded-tl-xl mint:gap-1 mint:flex mint:overflow-x-auto mint:overflow-y-hidden\">\n {childArr.map((child, index) => (\n <TabItem\n key={child.props.fileName + 'TabItem' + index}\n value={String(index)}\n isSelected={selectedIndex === index}\n tabsLength={childArr.length}\n ref={(el) => {\n if (el) {\n triggerRefs.current.set(index, el);\n }\n }}\n >\n {child.props.fileName}\n </TabItem>\n ))}\n </TabsPrimitive.List>\n );\n };\n\n const LanguageDropdown = () => {\n return (\n <div className=\"mint:relative\">\n <select\n value={childArr[selectedIndex]?.props.language || ''}\n onChange={(e) => {\n const language = e.target.value;\n const index = childArr.findIndex((child) => child.props.language === language);\n if (index !== -1) {\n handleValueChange(String(index));\n }\n }}\n className=\"mint:appearance-none mint:bg-transparent mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:rounded-lg mint:px-2.5 mint:pr-7 mint:py-1 mint:text-xs mint:font-medium mint:text-[#171717] mint:dark:text-[#fafafa] mint:cursor-pointer mint:focus:outline-0\"\n >\n {childArr.map((child) => (\n <option key={child.props.language} value={child.props.language}>\n {capitalize(child.props.language || '')}\n </option>\n ))}\n </select>\n <ChevronDownFilled className=\"mint:absolute mint:right-2 mint:top-1/2 mint:-translate-y-1/2 mint:w-3.5 mint:h-3.5 mint:pointer-events-none mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n </div>\n );\n };\n\n return (\n <TabsPrimitive.Root\n defaultValue={defaultValue == undefined ? undefined : (typeof defaultValue === 'string' ? defaultValue : String(defaultValue))}\n ref={ref}\n value={String(selectedTab)}\n onValueChange={handleValueChange}\n className={cn(\n !noMargins && 'mint:mt-4 mint:mb-4',\n 'mint:flex mint:flex-col not-prose mint:relative mint:overflow-hidden mint:rounded-2xl mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:bg-white mint:dark:bg-[#0a0a0a]',\n className\n )}\n asChild={false}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(props as any)}\n >\n <div\n className={cn(\n 'mint:flex mint:items-center mint:justify-between mint:gap-2 mint:relative mint:px-2.5 mint:py-2',\n dropdown ? '' : ''\n )}\n >\n {dropdown ? <SelectedFilename /> : <TabList />}\n <div className=\"mint:flex mint:items-center mint:justify-end mint:shrink-0 mint:gap-1.5\">\n {dropdown && <LanguageDropdown />}\n <CopyToClipboardButton\n textToCopy={getNodeText(childArr[selectedIndex]?.props?.children)}\n showTooltip={true}\n />\n </div>\n </div>\n <div className=\"mint:flex mint:flex-1 mint:overflow-hidden\">\n {childArr.map((child, index) => {\n return (\n <TabsPrimitive.Content\n key={child.props.fileName}\n value={String(index)}\n className=\"mint:w-full mint:min-w-full mint:max-w-full mint:h-full mint:max-h-full\"\n tabIndex={-1}\n >\n <div className=\"mint:overflow-auto mint:max-h-[calc(40vh-3rem)]\">\n {child}\n </div>\n </TabsPrimitive.Content>\n );\n })}\n </div>\n </TabsPrimitive.Root>\n );\n});\n\nconst TabItem = forwardRef<\n React.ElementRef<typeof TabsPrimitive.Trigger>,\n {\n children: ReactNode;\n value: string;\n isSelected: boolean;\n tabsLength: number;\n }\n>(function TabItem({ children, value, isSelected, tabsLength }, ref) {\n return (\n <TabsPrimitive.Trigger\n ref={ref}\n value={value}\n className={cn(\n 'mint:group mint:flex mint:items-center mint:relative mint:gap-1.5 mint:my-1 mint:mb-1.5 mint:outline-0 mint:whitespace-nowrap mint:font-medium mint:ml-0! mint:first:ml-2.5! mint:focus:outline-2',\n isSelected && 'mint:text-[#9263f1] mint:dark:text-[#c9aaf9]',\n !isSelected && 'mint:text-[#737373] mint:dark:text-[#a3a3a3]'\n )}\n >\n <div\n className={cn(\n 'mint:flex mint:items-center mint:gap-1.5 mint:px-1.5 mint:rounded-lg mint:z-10',\n tabsLength > 1 &&\n 'mint:group-hover:bg-[#f5f5f5] mint:group-hover:dark:bg-[#1a1a1a] mint:group-hover:text-[#9263f1] mint:group-hover:dark:text-[#c9aaf9]'\n )}\n >\n {children}\n </div>\n\n {isSelected && (\n <div className=\"mint:absolute mint:-bottom-1.5 mint:left-0 mint:right-0 mint:h-0.5 mint:rounded-full mint:bg-[#9263f1] mint:dark:bg-[#c9aaf9]\" />\n )}\n </TabsPrimitive.Trigger>\n );\n});\n\nexport function CodeBlockTooltip({ text }: { text: string }) {\n return (\n <div\n aria-hidden\n className=\"mint:absolute mint:top-11 mint:left-1/2 mint:transform mint:whitespace-nowrap mint:-translate-x-1/2 mint:-translate-y-1/2 mint:peer-hover:opacity-100 mint:opacity-0 mint:text-white mint:rounded-lg mint:px-1.5 mint:py-0.5 mint:text-xs mint:bg-primary-dark\"\n >\n {text}\n </div>\n );\n}\n"],"names":["CodeGroup","forwardRef","children","onChange","className","dropdown","noMargins","restProps","ref","defaultValue","props","triggerRefs","useRef","childArr","React","selectedTab","setSelectedTab","useState","handleValueChange","useCallback","value","index","wasFocusOnTab","_a","trigger","selectedIndex","SelectedFilename","jsx","TabList","TabsPrimitive","child","TabItem","el","LanguageDropdown","jsxs","e","language","capitalize","ChevronDownFilled","cn","CopyToClipboardButton","getNodeText","_b","isSelected","tabsLength"],"mappings":";;;;;;;;AAmCO,MAAMA,IAAYC,EAA2C,SAClE,EAAE,UAAAC,GAAU,UAAAC,GAAU,WAAAC,GAAW,UAAAC,GAAU,WAAAC,GAAW,GAAGC,EAAA,GACzDC,GACA;;AAGA,QAAM,EAAE,cAAAC,GAAc,GAAGC,EAAA,IAAUH,GAC7BI,IAAcC,EAAuC,oBAAI,KAAK,GAC9DC,IAAW,MAAM,QAAQX,CAAQ,IACnCA,IACCY,EAAM,SAAS,QAAQZ,CAAQ,GAE9B,CAACa,GAAaC,CAAc,IAAIC,EAAS,CAAC,GAE1CC,IAAoBC;AAAA,IACxB,CAACC,MAAkB;;AACjB,YAAMC,IAAQ,OAAOD,CAAK,GACpBE,MAAgBC,IAAA,SAAS,kBAAT,gBAAAA,EAAwB,aAAa,aAAY;AAEvE,MAAAP,EAAeK,CAAK,GACpBlB,KAAA,QAAAA,EAAWkB,IAEPC,KACF,sBAAsB,MAAM;AAC1B,cAAME,IAAUb,EAAY,QAAQ,IAAIU,CAAK;AAC7C,QAA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S,IAAI,CAACG,GAAOT,MAElB,gBAAAM;AAAA,UAACE,EAAc;AAAA,UAAd;AAAA,YAEC,OAAO,OAAOR,CAAK;AAAA,YACnB,WAAU;AAAA,YACV,UAAU;AAAA,YAEV,UAAA,gBAAAM,EAAC,OAAA,EAAI,WAAU,mDACZ,UAAAG,EAAA,CACH;AAAA,UAAA;AAAA,UAPKA,EAAM,MAAM;AAAA,QAAA,CAUtB,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC,GAEKC,IAAU9B,EAQd,SAAiB,EAAE,UAAAC,GAAU,OAAAkB,GAAO,YAAAuB,GAAY,YAAAC,EAAA,GAAcpC,GAAK;AACnE,SACE,gBAAA0B;AAAA,IAACL,EAAc;AAAA,IAAd;AAAA,MACC,KAAArB;AAAA,MACA,OAAAY;AAAA,MACA,WAAWmB;AAAA,QACT;AAAA,QACAI,KAAc;AAAA,QACd,CAACA,KAAc;AAAA,MAAA;AAAA,MAGjB,UAAA;AAAA,QAAA,gBAAAhB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWY;AAAA,cACT;AAAA,cACAK,IAAa,KACX;AAAA,YAAA;AAAA,YAGH,UAAA1C;AAAA,UAAA;AAAA,QAAA;AAAA,QAGFyC,KACC,gBAAAhB,EAAC,OAAA,EAAI,WAAU,gIAAA,CAAgI;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIvJ,CAAC;"}
|
|
1
|
+
{"version":3,"file":"code-group.js","sources":["../../../src/components/content-components/code-group.tsx"],"sourcesContent":["'use client';\n\nimport * as TabsPrimitive from '@radix-ui/react-tabs';\nimport React, {\n ComponentPropsWithoutRef,\n ReactElement,\n ReactNode,\n forwardRef,\n useCallback,\n useState,\n useRef,\n} from 'react';\nimport { ChevronDownFilled } from '@fluentui/react-icons';\n\nimport { cn } from '../../utils/cn';\nimport { CodeBlock } from './code-block';\nimport { CopyToClipboardButton } from './code-block';\nimport { getNodeText } from '../../utils/get-node-text';\nimport { capitalize } from '../../utils/string';\n\ntype CodeBlockProps = ComponentPropsWithoutRef<typeof CodeBlock>;\n\nexport type CodeGroupPropsBase = {\n dropdown?: boolean;\n isSmallText?: boolean;\n noMargins?: boolean;\n children?: ReactElement<CodeBlockProps>[] | ReactElement<CodeBlockProps>;\n onChange?: (index: number) => void;\n};\n\nexport type CodeGroupProps = CodeGroupPropsBase &\n Omit<ComponentPropsWithoutRef<'div'>, keyof CodeGroupPropsBase | 'dir'>;\n\ntype CodeBlockChild = Exclude<React.ReactElement<CodeBlockProps>, boolean | null | undefined>;\n\nexport const CodeGroup = forwardRef<HTMLDivElement, CodeGroupProps>(function CodeGroup(\n { children, onChange, className, dropdown, noMargins, ...restProps },\n ref\n) {\n // Filter out props that are incompatible with TabsPrimitive.Root\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { defaultValue, ...props } = restProps as any;\n const triggerRefs = useRef<Map<number, HTMLButtonElement>>(new Map());\n const childArr = Array.isArray(children)\n ? children\n : (React.Children.toArray(children) as Array<CodeBlockChild>);\n\n const [selectedTab, setSelectedTab] = useState(0);\n\n const handleValueChange = useCallback(\n (value: string) => {\n const index = Number(value);\n const wasFocusOnTab = document.activeElement?.getAttribute('role') === 'tab';\n\n setSelectedTab(index);\n onChange?.(index);\n\n if (wasFocusOnTab) {\n requestAnimationFrame(() => {\n const trigger = triggerRefs.current.get(index);\n if (trigger) {\n trigger.focus();\n }\n });\n }\n },\n [onChange]\n );\n\n if (!children) {\n return null;\n }\n\n if (childArr.length === 0) {\n console.warn('CodeGroup has no children, expected at least one CodeBlock child.');\n return null;\n }\n\n const selectedIndex = Number(selectedTab);\n\n const SelectedFilename = () => {\n return (\n <div className=\"mint:flex mint:items-center mint:gap-1.5 mint:text-xs mint:font-medium mint:min-w-0\">\n <span className=\"mint:truncate mint:text-[#171717] mint:dark:text-[#fafafa]\">\n {childArr[selectedIndex]?.props.fileName}\n </span>\n </div>\n );\n };\n\n const TabList = () => {\n return (\n <TabsPrimitive.List className=\"mint:flex-1 mint:min-w-0 mint:text-xs mint:leading-6 mint:rounded-tl-xl mint:gap-1 mint:flex mint:overflow-x-auto mint:overflow-y-hidden\">\n {childArr.map((child, index) => (\n <TabItem\n key={child.props.fileName + 'TabItem' + index}\n value={String(index)}\n isSelected={selectedIndex === index}\n tabsLength={childArr.length}\n ref={(el) => {\n if (el) {\n triggerRefs.current.set(index, el);\n }\n }}\n >\n {child.props.fileName}\n </TabItem>\n ))}\n </TabsPrimitive.List>\n );\n };\n\n const LanguageDropdown = () => {\n return (\n <div className=\"mint:relative\">\n <select\n value={childArr[selectedIndex]?.props.language || ''}\n onChange={(e) => {\n const language = e.target.value;\n const index = childArr.findIndex((child) => child.props.language === language);\n if (index !== -1) {\n handleValueChange(String(index));\n }\n }}\n className=\"mint:appearance-none mint:bg-transparent mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:rounded-lg mint:px-2.5 mint:pr-7 mint:py-1 mint:text-xs mint:font-medium mint:text-[#171717] mint:dark:text-[#fafafa] mint:cursor-pointer mint:focus:outline-0\"\n >\n {childArr.map((child, index) => (\n <option key={`${child.props.language}-${child.props.fileName}-${index}`} value={child.props.language}>\n {capitalize(child.props.language || '')}\n </option>\n ))}\n </select>\n <ChevronDownFilled className=\"mint:absolute mint:right-2 mint:top-1/2 mint:-translate-y-1/2 mint:w-3.5 mint:h-3.5 mint:pointer-events-none mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n </div>\n );\n };\n\n return (\n <TabsPrimitive.Root\n defaultValue={defaultValue == undefined ? undefined : (typeof defaultValue === 'string' ? defaultValue : String(defaultValue))}\n ref={ref}\n value={String(selectedTab)}\n onValueChange={handleValueChange}\n className={cn(\n !noMargins && 'mint:mt-4 mint:mb-4',\n 'mint:flex mint:flex-col not-prose mint:relative mint:overflow-hidden mint:rounded-2xl mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:bg-white mint:dark:bg-[#0a0a0a]',\n className\n )}\n asChild={false}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(props as any)}\n >\n <div\n className={cn(\n 'mint:flex mint:items-center mint:justify-between mint:gap-2 mint:relative mint:px-2.5 mint:py-2',\n dropdown ? '' : ''\n )}\n >\n {dropdown ? <SelectedFilename /> : <TabList />}\n <div className=\"mint:flex mint:items-center mint:justify-end mint:shrink-0 mint:gap-1.5\">\n {dropdown && <LanguageDropdown />}\n <CopyToClipboardButton\n textToCopy={getNodeText(childArr[selectedIndex]?.props?.children)}\n showTooltip={true}\n />\n </div>\n </div>\n <div className=\"mint:flex mint:flex-1 mint:overflow-hidden\">\n {childArr.map((child, index) => {\n return (\n <TabsPrimitive.Content\n key={`${child.props.fileName}-${child.props.language}-${index}`}\n value={String(index)}\n className=\"mint:w-full mint:min-w-full mint:max-w-full mint:h-full mint:max-h-full\"\n tabIndex={-1}\n >\n <div className=\"mint:overflow-auto mint:max-h-[calc(40vh-3rem)]\">\n {child}\n </div>\n </TabsPrimitive.Content>\n );\n })}\n </div>\n </TabsPrimitive.Root>\n );\n});\n\nconst TabItem = forwardRef<\n React.ElementRef<typeof TabsPrimitive.Trigger>,\n {\n children: ReactNode;\n value: string;\n isSelected: boolean;\n tabsLength: number;\n }\n>(function TabItem({ children, value, isSelected, tabsLength }, ref) {\n return (\n <TabsPrimitive.Trigger\n ref={ref}\n value={value}\n className={cn(\n 'mint:group mint:flex mint:items-center mint:relative mint:gap-1.5 mint:my-1 mint:mb-1.5 mint:outline-0 mint:whitespace-nowrap mint:font-medium mint:ml-0! mint:first:ml-2.5! mint:focus:outline-2',\n isSelected && 'mint:text-[#9263f1] mint:dark:text-[#c9aaf9]',\n !isSelected && 'mint:text-[#737373] mint:dark:text-[#a3a3a3]'\n )}\n >\n <div\n className={cn(\n 'mint:flex mint:items-center mint:gap-1.5 mint:px-1.5 mint:rounded-lg mint:z-10',\n tabsLength > 1 &&\n 'mint:group-hover:bg-[#f5f5f5] mint:group-hover:dark:bg-[#1a1a1a] mint:group-hover:text-[#9263f1] mint:group-hover:dark:text-[#c9aaf9]'\n )}\n >\n {children}\n </div>\n\n {isSelected && (\n <div className=\"mint:absolute mint:-bottom-1.5 mint:left-0 mint:right-0 mint:h-0.5 mint:rounded-full mint:bg-[#9263f1] mint:dark:bg-[#c9aaf9]\" />\n )}\n </TabsPrimitive.Trigger>\n );\n});\n\nexport function CodeBlockTooltip({ text }: { text: string }) {\n return (\n <div\n aria-hidden\n className=\"mint:absolute mint:top-11 mint:left-1/2 mint:transform mint:whitespace-nowrap mint:-translate-x-1/2 mint:-translate-y-1/2 mint:peer-hover:opacity-100 mint:opacity-0 mint:text-white mint:rounded-lg mint:px-1.5 mint:py-0.5 mint:text-xs mint:bg-primary-dark\"\n >\n {text}\n </div>\n );\n}\n"],"names":["CodeGroup","forwardRef","children","onChange","className","dropdown","noMargins","restProps","ref","defaultValue","props","triggerRefs","useRef","childArr","React","selectedTab","setSelectedTab","useState","handleValueChange","useCallback","value","index","wasFocusOnTab","_a","trigger","selectedIndex","SelectedFilename","jsx","TabList","TabsPrimitive","child","TabItem","el","LanguageDropdown","jsxs","e","language","capitalize","ChevronDownFilled","cn","CopyToClipboardButton","getNodeText","_b","isSelected","tabsLength"],"mappings":";;;;;;;;AAmCO,MAAMA,IAAYC,EAA2C,SAClE,EAAE,UAAAC,GAAU,UAAAC,GAAU,WAAAC,GAAW,UAAAC,GAAU,WAAAC,GAAW,GAAGC,EAAA,GACzDC,GACA;;AAGA,QAAM,EAAE,cAAAC,GAAc,GAAGC,EAAA,IAAUH,GAC7BI,IAAcC,EAAuC,oBAAI,KAAK,GAC9DC,IAAW,MAAM,QAAQX,CAAQ,IACnCA,IACCY,EAAM,SAAS,QAAQZ,CAAQ,GAE9B,CAACa,GAAaC,CAAc,IAAIC,EAAS,CAAC,GAE1CC,IAAoBC;AAAA,IACxB,CAACC,MAAkB;;AACjB,YAAMC,IAAQ,OAAOD,CAAK,GACpBE,MAAgBC,IAAA,SAAS,kBAAT,gBAAAA,EAAwB,aAAa,aA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lock as
|
|
3
|
-
import { CodeGroup as
|
|
4
|
-
import { CodeSnippet as
|
|
5
|
-
const
|
|
6
|
-
snippets:
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { CodeBlock as i } from "./code-block.js";
|
|
3
|
+
import { CodeGroup as u } from "./code-group.js";
|
|
4
|
+
import { CodeSnippet as d } from "./code-snippet.js";
|
|
5
|
+
const h = ({
|
|
6
|
+
snippets: o,
|
|
7
7
|
dropdown: r,
|
|
8
8
|
maxHeight: l,
|
|
9
9
|
...m
|
|
10
|
-
}) => /* @__PURE__ */
|
|
11
|
-
|
|
10
|
+
}) => /* @__PURE__ */ a(u, { isSmallText: !0, ...m, dropdown: r, noMargins: !0, className: l, children: o.map(({ code: g, ...e }, n) => /* @__PURE__ */ a(
|
|
11
|
+
i,
|
|
12
12
|
{
|
|
13
13
|
language: e.language,
|
|
14
14
|
fileName: e.filename,
|
|
15
|
-
children: /* @__PURE__ */
|
|
15
|
+
children: /* @__PURE__ */ a(d, { language: e.language, children: g })
|
|
16
16
|
},
|
|
17
|
-
e.filename
|
|
17
|
+
`${e.filename}-${e.language}-${n}`
|
|
18
18
|
)) });
|
|
19
19
|
export {
|
|
20
|
-
|
|
20
|
+
h as CodeSnippets
|
|
21
21
|
};
|
|
22
22
|
//# sourceMappingURL=code-snippets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-snippets.js","sources":["../../../src/components/content-components/code-snippets.tsx"],"sourcesContent":["'use client';\n\nimport { ComponentPropsWithoutRef } from 'react';\n\nimport { CodeBlock } from './code-block';\nimport { CodeGroup } from './code-group';\nimport { ExampleCodeSnippet } from '../../constants/snippetPresets';\n\nimport { CodeSnippet } from './code-snippet';\n\nexport interface CodeSnippetsProps {\n dropdown?: boolean;\n snippets: ExampleCodeSnippet[];\n maxHeight?: string;\n}\n\nexport const CodeSnippets = ({\n snippets,\n dropdown,\n maxHeight,\n ...props\n}: CodeSnippetsProps & ComponentPropsWithoutRef<typeof CodeGroup>) => (\n <CodeGroup isSmallText {...props} dropdown={dropdown} noMargins className={maxHeight}>\n {snippets.map(({ code, ...snippet }: ExampleCodeSnippet) => (\n <CodeBlock\n language={snippet.language}\n fileName={snippet.filename}\n key={snippet.filename}\n >\n <CodeSnippet language={snippet.language}>{code}</CodeSnippet>\n </CodeBlock>\n ))}\n </CodeGroup>\n);\n"],"names":["CodeSnippets","snippets","dropdown","maxHeight","props","CodeGroup","code","snippet","jsx","CodeBlock","CodeSnippet"],"mappings":";;;;AAgBO,MAAMA,IAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,wBACGC,GAAA,EAAU,aAAW,IAAE,GAAGD,GAAO,UAAAF,GAAoB,WAAS,IAAC,WAAWC,GACxE,
|
|
1
|
+
{"version":3,"file":"code-snippets.js","sources":["../../../src/components/content-components/code-snippets.tsx"],"sourcesContent":["'use client';\n\nimport { ComponentPropsWithoutRef } from 'react';\n\nimport { CodeBlock } from './code-block';\nimport { CodeGroup } from './code-group';\nimport { ExampleCodeSnippet } from '../../constants/snippetPresets';\n\nimport { CodeSnippet } from './code-snippet';\n\nexport interface CodeSnippetsProps {\n dropdown?: boolean;\n snippets: ExampleCodeSnippet[];\n maxHeight?: string;\n}\n\nexport const CodeSnippets = ({\n snippets,\n dropdown,\n maxHeight,\n ...props\n}: CodeSnippetsProps & ComponentPropsWithoutRef<typeof CodeGroup>) => (\n <CodeGroup isSmallText {...props} dropdown={dropdown} noMargins className={maxHeight}>\n {snippets.map(({ code, ...snippet }: ExampleCodeSnippet, index) => (\n <CodeBlock\n language={snippet.language}\n fileName={snippet.filename}\n key={`${snippet.filename}-${snippet.language}-${index}`}\n >\n <CodeSnippet language={snippet.language}>{code}</CodeSnippet>\n </CodeBlock>\n ))}\n </CodeGroup>\n);\n"],"names":["CodeSnippets","snippets","dropdown","maxHeight","props","CodeGroup","code","snippet","index","jsx","CodeBlock","CodeSnippet"],"mappings":";;;;AAgBO,MAAMA,IAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,wBACGC,GAAA,EAAU,aAAW,IAAE,GAAGD,GAAO,UAAAF,GAAoB,WAAS,IAAC,WAAWC,GACxE,UAAAF,EAAS,IAAI,CAAC,EAAE,MAAAK,GAAM,GAAGC,KAA+BC,MACvD,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,UAAUH,EAAQ;AAAA,IAClB,UAAUA,EAAQ;AAAA,IAGlB,UAAA,gBAAAE,EAACE,GAAA,EAAY,UAAUJ,EAAQ,UAAW,UAAAD,EAAA,CAAK;AAAA,EAAA;AAAA,EAF1C,GAAGC,EAAQ,QAAQ,IAAIA,EAAQ,QAAQ,IAAIC,CAAK;AAGvD,CACD,EAAA,CACH;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/msft-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Lightweight SDK for Microsoft documentation with MDX rendering",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"hast-util-to-mdast": "^10.1.2",
|
|
68
68
|
"hast-util-to-string": "^3.0.1",
|
|
69
69
|
"html-react-parser": "^5.2.8",
|
|
70
|
-
"httpsnippet
|
|
70
|
+
"@readme/httpsnippet": "^11.0.0",
|
|
71
71
|
"lodash": "^4.17.21",
|
|
72
72
|
"lucide-react": "^0.552.0",
|
|
73
73
|
"mdast-util-mdx-jsx": "^3.2.0",
|