@mintlify/msft-sdk 1.1.17 → 1.1.19
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/ApiPlayground/ApiPlaygroundContext.js +11 -0
- package/dist/api-playground/ApiPlayground/ApiPlaygroundContext.js.map +1 -0
- package/dist/api-playground-2/ApiExamples.js +3 -3
- package/dist/api-playground-2/components/Example/GeneratedRequestExample.js +97 -92
- package/dist/api-playground-2/components/Example/GeneratedRequestExample.js.map +1 -1
- package/dist/api-playground-2/components/Example/GeneratedResponseExample.js +2 -2
- 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/api-playground-2/constants/index.js +20 -0
- package/dist/api-playground-2/constants/index.js.map +1 -0
- package/dist/api-playground-2/generators/createBodyData.js +67 -0
- package/dist/api-playground-2/generators/createBodyData.js.map +1 -0
- package/dist/api-playground-2/generators/createHeaders.js +45 -0
- package/dist/api-playground-2/generators/createHeaders.js.map +1 -0
- package/dist/api-playground-2/generators/generateInteractiveCodeSample.js +50 -0
- package/dist/api-playground-2/generators/generateInteractiveCodeSample.js.map +1 -0
- package/dist/api-playground-2/generators/generateRequest.js +65 -0
- package/dist/api-playground-2/generators/generateRequest.js.map +1 -0
- package/dist/api-playground-2/generators/generateResponseExampleMap.js +36 -0
- package/dist/api-playground-2/generators/generateResponseExampleMap.js.map +1 -0
- package/dist/api-playground-2/generators/generateSnippet.js +42 -0
- package/dist/api-playground-2/generators/generateSnippet.js.map +1 -0
- package/dist/api-playground-2/generators/generateSnippetMap.js +68 -0
- package/dist/api-playground-2/generators/generateSnippetMap.js.map +1 -0
- package/dist/api-playground-2/generators/getFileProperties.js +24 -0
- package/dist/api-playground-2/generators/getFileProperties.js.map +1 -0
- package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js +22 -0
- package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getAllRequiredProperties.js +10 -0
- package/dist/api-playground-2/schemaGraph/getAllRequiredProperties.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/processExamples.js +13 -0
- package/dist/api-playground-2/schemaGraph/processExamples.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/utils.js +76 -0
- package/dist/api-playground-2/schemaGraph/utils.js.map +1 -0
- package/dist/components/Api/dropdown-menu.js +4 -3
- package/dist/components/Api/dropdown-menu.js.map +1 -1
- package/dist/components/content-components/CodeGroupSelect/index.js +3 -3
- 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/dist/constants/initialRequest.js +14 -0
- package/dist/constants/initialRequest.js.map +1 -0
- package/dist/constants/snippetPresets.js +47 -13
- package/dist/constants/snippetPresets.js.map +1 -1
- package/dist/contexts/CodeExampleLabelContext.js +14 -0
- package/dist/contexts/CodeExampleLabelContext.js.map +1 -0
- package/dist/contexts/ConfigContext.js +1 -2
- package/dist/contexts/ConfigContext.js.map +1 -1
- package/dist/env.js +3 -0
- package/dist/env.js.map +1 -0
- package/dist/hooks/useSendPlaygroundRequest.js +18 -0
- package/dist/hooks/useSendPlaygroundRequest.js.map +1 -0
- package/dist/utils/locales/en.js +111 -0
- package/dist/utils/locales/en.js.map +1 -0
- package/dist/utils/locales/index.js +6 -0
- package/dist/utils/locales/index.js.map +1 -0
- package/dist/utils/uuid.js +7 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +2 -7
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import "@mintlify/validation";
|
|
2
|
+
import { apiPlaygroundInputKeys as y } from "../constants/index.js";
|
|
3
|
+
const p = (e) => typeof e == "object" && e !== null && !Array.isArray(e), h = (e) => p(e) ? "type" in e || "properties" in e || "oneOf" in e || "anyOf" in e || "allOf" in e || "items" in e || "additionalProperties" in e || "enum" in e || "const" in e || "format" in e || "pattern" in e || "minimum" in e || "maximum" in e || "minLength" in e || "maxLength" in e || "minItems" in e || "maxItems" in e || "minProperties" in e || "maxProperties" in e || "required" in e || "nullable" in e || "description" in e : !1, O = (e) => {
|
|
4
|
+
var o;
|
|
5
|
+
const t = {};
|
|
6
|
+
return Object.entries(((o = e.operation) == null ? void 0 : o.responses) ?? {}).forEach(([i, s]) => {
|
|
7
|
+
var n, c;
|
|
8
|
+
const r = (c = (n = e.dependencies) == null ? void 0 : n.responses) == null ? void 0 : c[s];
|
|
9
|
+
r && r.content && (t[i] = r.content);
|
|
10
|
+
}), t;
|
|
11
|
+
}, g = (e) => {
|
|
12
|
+
const t = {
|
|
13
|
+
server: {},
|
|
14
|
+
header: {},
|
|
15
|
+
path: {},
|
|
16
|
+
query: {},
|
|
17
|
+
cookie: {},
|
|
18
|
+
body: void 0
|
|
19
|
+
};
|
|
20
|
+
return Object.entries(e).forEach(([o, i]) => {
|
|
21
|
+
if (i == null)
|
|
22
|
+
return;
|
|
23
|
+
const s = o.split(new RegExp("(?<!\\\\)\\.")).map((m) => m.replace(/\\\./g, "."));
|
|
24
|
+
if (s.length < 2) {
|
|
25
|
+
o === "body" && (t.body = i);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const [r, ...n] = s, c = Object.values(y);
|
|
29
|
+
!r || !c.includes(r) || (r !== y.body ? d(
|
|
30
|
+
t[r],
|
|
31
|
+
[...n],
|
|
32
|
+
i
|
|
33
|
+
) : [...n].length === 0 ? t.body = i : ((t.body === void 0 || typeof t.body != "object") && (t.body = {}), d(t.body, n, i)));
|
|
34
|
+
}), f(t);
|
|
35
|
+
}, a = (e) => {
|
|
36
|
+
if (!p(e))
|
|
37
|
+
return !1;
|
|
38
|
+
const t = Object.keys(e);
|
|
39
|
+
return t.length === 0 ? !1 : t.every((o) => /^\d+$/.test(o));
|
|
40
|
+
}, f = (e) => {
|
|
41
|
+
if (e == null)
|
|
42
|
+
return e;
|
|
43
|
+
if (Array.isArray(e))
|
|
44
|
+
return e.map(f);
|
|
45
|
+
if (p(e)) {
|
|
46
|
+
if (a(e))
|
|
47
|
+
return Object.keys(e).sort((s, r) => Number(s) - Number(r)).map((s) => e[s]).map(f);
|
|
48
|
+
const t = {};
|
|
49
|
+
for (const [o, i] of Object.entries(e))
|
|
50
|
+
t[o] = f(i);
|
|
51
|
+
return t;
|
|
52
|
+
}
|
|
53
|
+
return e;
|
|
54
|
+
}, d = (e, t, o) => {
|
|
55
|
+
const i = [];
|
|
56
|
+
for (let r = 0; r < t.length; r++) {
|
|
57
|
+
const n = t[r];
|
|
58
|
+
if (n === "oneOf") {
|
|
59
|
+
r++;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
n === "additionalProperties" || n === "items" || n && i.push(n);
|
|
63
|
+
}
|
|
64
|
+
let s = e;
|
|
65
|
+
for (let r = 0; r < i.length; r++) {
|
|
66
|
+
const n = i[r];
|
|
67
|
+
r === i.length - 1 ? n && (s[n] = o) : (n && (!s[n] || typeof s[n] != "object") && (s[n] = {}), n && (s = s[n]));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
p as isPlainRecord,
|
|
72
|
+
h as isSchemaObject,
|
|
73
|
+
O as mapResponseExamples,
|
|
74
|
+
g as unflattenInputs
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/api-playground-2/schemaGraph/utils.ts"],"sourcesContent":["import { openApiToSchemaGraph } from '@mintlify/validation';\nimport type {\n ApiPlaygroundInputs,\n ArraySchemaObject,\n MediaObject,\n ParameterObject,\n GraphNode,\n SchemaObject,\n DataSchema,\n} from '@mintlify/validation';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport {\n CIRCULAR_REF_KEY,\n combinationKeys,\n initialApiPlaygroundInputs,\n MAX_SCHEMA_COMBINATION_SIZE,\n stringFileFormats,\n apiPlaygroundInputKeys,\n} from '@/api-playground-2/constants';\nimport type {\n ApiReferenceDataV2,\n CircularRefObject,\n DifferentiatedType,\n ResolvedSchemaObject,\n ReducedSchema,\n} from '@/api-playground-2/types';\n\nimport { PlaygroundInputValue } from '../hooks/usePlaygroundInputsStore';\nimport { cn } from '@/utils/cn';\n\nexport { cn };\n\nexport function isCircularRef(value: unknown): value is CircularRefObject {\n return (\n typeof value === 'object' &&\n value !== null &&\n CIRCULAR_REF_KEY in value &&\n typeof value[CIRCULAR_REF_KEY] === 'string'\n );\n}\n\nexport const isResolvedSchemaObject = (obj: unknown): obj is ResolvedSchemaObject => {\n return isSchemaObject(obj) && ('isCircular' in obj || 'isRequired' in obj);\n};\n\nexport const createEmptyReducedSchema = (): ReducedSchema => ({ oneOf: [] });\nexport const createUnknownReducedSchema = (): ReducedSchema => ({ oneOf: [{}] });\n\nexport const isPlainRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport const isReducedSchema = (schema: unknown): schema is ReducedSchema =>\n isSchemaObject(schema) && Array.isArray(schema.oneOf);\n\n/**\n * Given an OpenAPI 3.1 schema, this function will attempt to determine the schema type\n * based on the properties present in the schema. This is useful for assigning types to\n * schemas that are missing a type.\n *\n * For example, if a schema has no type but has `schema.properties`, we can infer the\n * intended type is `object`.\n *\n * Used in the Conversion step.\n *\n * @param schema\n * @returns if exactly one type can be inferred, the string corresponding to that type; otherwise `undefined`\n */\nexport const inferType = (\n schema: Omit<SchemaObject, 'type'>\n): OpenAPIV3_1.ArraySchemaObjectType | OpenAPIV3_1.NonArraySchemaObjectType | undefined => {\n let type: OpenAPIV3_1.ArraySchemaObjectType | OpenAPIV3_1.NonArraySchemaObjectType | undefined;\n if (\n schema.format !== undefined ||\n schema.pattern !== undefined ||\n schema.minLength !== undefined ||\n schema.maxLength !== undefined ||\n schema.enum?.every((option) => typeof option === 'string')\n ) {\n type = 'string';\n }\n if (\n schema.multipleOf !== undefined ||\n schema.minimum !== undefined ||\n schema.maximum !== undefined ||\n schema.exclusiveMinimum !== undefined ||\n schema.exclusiveMaximum !== undefined ||\n schema.enum?.every((option) => typeof option === 'number')\n ) {\n if (type !== undefined) {\n return undefined;\n }\n type = 'number';\n }\n if (\n ('items' in schema && schema.items !== undefined) ||\n schema.minItems !== undefined ||\n schema.maxItems !== undefined ||\n schema.uniqueItems !== undefined\n ) {\n if (type !== undefined) {\n return undefined;\n }\n type = 'array';\n }\n if (\n schema.additionalProperties !== undefined ||\n schema.properties !== undefined ||\n schema.minProperties !== undefined ||\n schema.maxProperties !== undefined\n ) {\n if (type !== undefined) {\n return undefined;\n }\n type = 'object';\n }\n\n return type;\n};\n\nexport const isSchemaObject = (obj: unknown): obj is SchemaObject => {\n if (!isPlainRecord(obj)) {\n return false;\n }\n\n return (\n 'type' in obj ||\n 'properties' in obj ||\n 'oneOf' in obj ||\n 'anyOf' in obj ||\n 'allOf' in obj ||\n 'items' in obj ||\n 'additionalProperties' in obj ||\n 'enum' in obj ||\n 'const' in obj ||\n 'format' in obj ||\n 'pattern' in obj ||\n 'minimum' in obj ||\n 'maximum' in obj ||\n 'minLength' in obj ||\n 'maxLength' in obj ||\n 'minItems' in obj ||\n 'maxItems' in obj ||\n 'minProperties' in obj ||\n 'maxProperties' in obj ||\n 'required' in obj ||\n 'nullable' in obj ||\n 'description' in obj\n );\n};\n\nexport const isArrayObject = (obj: unknown): obj is ArraySchemaObject => {\n return isSchemaObject(obj) && obj.type === 'array';\n};\n\nexport function hasCombinationKey(obj: Record<string, unknown>): boolean {\n return combinationKeys.some((key) => key in obj);\n}\n\nexport function shouldTruncateForSize(schema: OpenAPIV3_1.SchemaObject): boolean {\n const oneOfSize = Array.isArray(schema.oneOf) ? schema.oneOf.length : 1;\n const anyOfSize = Array.isArray(schema.anyOf) ? schema.anyOf.length : 1;\n const allOfSize = Array.isArray(schema.allOf) ? schema.allOf.length : 1;\n\n const combinations: number[] = [oneOfSize, anyOfSize, allOfSize];\n\n // go three levels deep to estimate if combinations may explode\n combinationKeys.forEach((key) => {\n if (schema[key as keyof OpenAPIV3_1.SchemaObject]) {\n const subSchema = schema[key as keyof OpenAPIV3_1.SchemaObject];\n combinations.push(Object.keys(subSchema).length);\n combinationKeys.forEach((subSchemaKey) => {\n if (subSchema[subSchemaKey as keyof OpenAPIV3_1.SchemaObject]) {\n const subSubSchema = subSchema[subSchemaKey as keyof OpenAPIV3_1.SchemaObject];\n combinations.push(Object.keys(subSubSchema).length);\n combinationKeys.forEach((subSubSchemaKey) => {\n if (subSubSchema[subSubSchemaKey as keyof OpenAPIV3_1.SchemaObject]) {\n const subSubSubSchema =\n subSubSchema[subSubSchemaKey as keyof OpenAPIV3_1.SchemaObject];\n combinations.push(Object.keys(subSubSubSchema).length);\n }\n });\n }\n });\n }\n });\n\n const totalCombinations = combinations.reduce((acc, curr) => acc * curr, 1);\n\n return totalCombinations > MAX_SCHEMA_COMBINATION_SIZE;\n}\n\n// similar to RecursiveParamField/renderTruncatedNextProperties\nexport function createTruncatedNextProperties(\n schema: OpenAPIV3_1.SchemaObject\n): OpenAPIV3_1.SchemaObject {\n const truncatedSchema = { ...schema };\n\n // Remove all composition properties to prevent further recursion\n delete truncatedSchema.oneOf;\n delete truncatedSchema.anyOf;\n delete truncatedSchema.allOf;\n\n if (truncatedSchema.type === 'array') {\n truncatedSchema.items = {};\n } else if (truncatedSchema.type === 'object') {\n truncatedSchema.properties = {};\n if (\n truncatedSchema.additionalProperties &&\n typeof truncatedSchema.additionalProperties === 'object'\n ) {\n truncatedSchema.additionalProperties = {};\n }\n }\n\n return truncatedSchema;\n}\n\nexport function createTruncatedReducedSchema(schema: OpenAPIV3_1.SchemaObject): ReducedSchema {\n const truncatedSchema = createTruncatedNextProperties(schema);\n // For reduction, we need to wrap in oneOf\n return { oneOf: [truncatedSchema] };\n}\n\nexport function collectCombinationSizes(\n value: unknown,\n remainingDepth: number,\n combinations: number[]\n): void {\n if (remainingDepth === 0 || value === undefined || value === null) {\n return;\n }\n\n if (Array.isArray(value)) {\n combinations.push(value.length);\n if (remainingDepth > 1) {\n value.forEach((item) => collectCombinationSizes(item, remainingDepth - 1, combinations));\n }\n return;\n }\n\n if (isPlainRecord(value)) {\n combinations.push(Object.keys(value).length);\n if (remainingDepth > 1) {\n Object.values(value).forEach((item) =>\n collectCombinationSizes(item, remainingDepth - 1, combinations)\n );\n }\n }\n}\n\nexport const addKeyIfDefined = <D, K extends keyof D>(\n key: K,\n value: D[K] | undefined,\n destination: D\n) => {\n if (value !== undefined) {\n destination[key] = value;\n }\n};\n\nexport const copyKeyIfDefined = <D, K extends keyof D>(\n key: K,\n source: Pick<D, K>,\n destination: D\n) => {\n if (source[key] !== undefined) {\n destination[key] = source[key];\n }\n};\n\nexport const takeLast = <T extends keyof OpenAPIV3_1.SchemaObject>(\n schema1: OpenAPIV3_1.SchemaObject,\n schema2: OpenAPIV3_1.SchemaObject,\n key: T\n): OpenAPIV3_1.SchemaObject[T] => {\n return schema2[key] ?? schema1[key];\n};\n\nexport const combine = <T extends keyof OpenAPIV3_1.SchemaObject>(\n schema1: OpenAPIV3_1.SchemaObject,\n schema2: OpenAPIV3_1.SchemaObject,\n key: T,\n transform: (\n a: NonNullable<OpenAPIV3_1.SchemaObject[T]>,\n b: NonNullable<OpenAPIV3_1.SchemaObject[T]>\n ) => OpenAPIV3_1.SchemaObject[T]\n): OpenAPIV3_1.SchemaObject[T] => {\n return schema1[key] !== undefined && schema2[key] !== undefined\n ? transform(schema1[key], schema2[key])\n : schema1[key] ?? schema2[key];\n};\n\nexport const copyExampleIfDefined = (\n source: Pick<OpenAPIV3_1.SchemaObject, 'example' | 'examples'>,\n destination: Pick<DataSchema, 'example'>\n) => {\n const example = source.example !== undefined ? source.example : source.examples?.[0];\n if (example !== undefined) {\n destination.example = example;\n }\n};\n\n// Testing utility for quick and dirty schema graph conversion\nexport const convertSchemaToGraph = (\n schema: OpenAPIV3_1.SchemaObject,\n skipClone: boolean = false\n) => {\n let spec: OpenAPIV3_1.Document;\n if ('openapi' in schema) {\n spec = schema as OpenAPIV3_1.Document;\n } else {\n spec = {\n openapi: '3.1.0',\n info: { title: 'Test', version: '1.0.0' },\n paths: {},\n components: {\n schemas: {\n TestSchema: schema,\n },\n },\n };\n }\n if (!skipClone) {\n const clonedSpec = JSON.parse(JSON.stringify(spec));\n return openApiToSchemaGraph({\n spec: clonedSpec,\n filename: 'test.json',\n originalFileLocation: 'test.json',\n });\n }\n return openApiToSchemaGraph({\n spec,\n filename: 'test.json',\n originalFileLocation: 'test.json',\n });\n};\n\nexport const flattenSingleOneOf = <T extends GraphNode & { oneOf?: SchemaObject[] }>(\n node: T\n): T => {\n if (node.oneOf && node.oneOf.length === 1) {\n return node.oneOf[0] as T;\n }\n return node;\n};\n\nexport const flattenSchemaOneOfs = (schema: SchemaObject): SchemaObject => {\n let result = { ...schema } as SchemaObject;\n\n // recursively flatten into each combinator\n if (result.properties && typeof result.properties === 'object') {\n const flattened: Record<string, SchemaObject> = {};\n for (const [key, value] of Object.entries(result.properties)) {\n if (isSchemaObject(value)) {\n flattened[key] = flattenSchemaOneOfs(value);\n } else {\n flattened[key] = value as SchemaObject;\n }\n }\n result.properties = flattened;\n }\n\n if ('items' in result && result.items && typeof result.items === 'object') {\n if (isSchemaObject(result.items)) {\n result.items = flattenSchemaOneOfs(result.items);\n }\n }\n\n if (\n result.additionalProperties &&\n typeof result.additionalProperties === 'object' &&\n isSchemaObject(result.additionalProperties)\n ) {\n result.additionalProperties = flattenSchemaOneOfs(result.additionalProperties);\n }\n if (result.oneOf && Array.isArray(result.oneOf) && result.oneOf.length > 1) {\n const oneOfArray = result.oneOf;\n const mappedOneOf = (oneOfArray as unknown[]).map((item: unknown) => {\n if (isSchemaObject(item)) {\n return flattenSchemaOneOfs(item);\n }\n return item as SchemaObject;\n });\n result.oneOf = mappedOneOf as SchemaObject[];\n }\n\n if (\n 'oneOf' in result &&\n result.oneOf &&\n Array.isArray(result.oneOf) &&\n result.oneOf.length === 1\n ) {\n const singleItem = result.oneOf[0];\n if (isSchemaObject(singleItem)) {\n result = { ...result, ...singleItem } as SchemaObject;\n delete (result as { oneOf?: unknown[] }).oneOf;\n return flattenSchemaOneOfs(result);\n }\n }\n\n return result;\n};\n\nexport const calculateMaxDepth = (obj: unknown, currentDepth = 0): number => {\n if (obj === null || typeof obj !== 'object') {\n return currentDepth;\n }\n\n if (Array.isArray(obj)) {\n if (obj.length === 0) return currentDepth;\n return Math.max(...obj.map((item) => calculateMaxDepth(item, currentDepth)));\n }\n\n const depths = Object.entries(obj).map(([key, value]) => {\n if (key === 'type' || key === 'title') {\n return currentDepth;\n }\n return calculateMaxDepth(value, currentDepth + 1);\n });\n\n return depths.length > 0 ? Math.max(...depths) : currentDepth;\n};\n\n// converts standard schema types to differentiated types that were used in v1 and oneOf type\nexport const getDifferentiatedType = (schema: ResolvedSchemaObject): DifferentiatedType => {\n if (schema.oneOf) {\n return 'oneOf';\n }\n if (schema.enum) {\n switch (schema.type) {\n case 'string':\n return 'enum<string>';\n case 'number':\n return 'enum<number>';\n case 'integer':\n return 'enum<integer>';\n default:\n return schema.type;\n }\n }\n if (schema.format && stringFileFormats.includes(schema.format)) {\n return 'file';\n }\n return schema.type;\n};\n\nexport const isEnum = (schema: SchemaObject): boolean => {\n return 'enum' in schema && schema.enum !== undefined;\n};\n\nexport const getSchemaPlaceholder = (schema: SchemaObject): string | undefined => {\n return 'placeholder' in schema && typeof schema.placeholder === 'string'\n ? schema.placeholder\n : undefined;\n};\n\nexport const isStringSchema = (schema: SchemaObject): boolean => {\n return schema.type === 'string';\n};\n\nexport const isNumberSchema = (schema: SchemaObject): boolean => {\n return schema.type === 'number' || schema.type === 'integer';\n};\n\nexport const mapResponseExamples = (apiReferenceData: ApiReferenceDataV2) => {\n const responseCodeMediaObjectMap: Record<string, MediaObject> = {};\n Object.entries(apiReferenceData.operation?.responses ?? {}).forEach(([responseCode, UUID]) => {\n const response = apiReferenceData.dependencies?.responses?.[UUID];\n if (response && response.content) {\n responseCodeMediaObjectMap[responseCode] = response.content;\n }\n });\n return responseCodeMediaObjectMap;\n};\n\nexport const generatePrefillRequestData = (\n apiReferenceData: ApiReferenceDataV2\n): ApiPlaygroundInputs[] => {\n const requestBodyContent = apiReferenceData.dependencies?.requestBody?.content;\n if (requestBodyContent === undefined) {\n return [initialApiPlaygroundInputs];\n }\n const requestBodyContentTypes = Object.keys(requestBodyContent);\n const contentType = requestBodyContentTypes[0];\n if (!contentType) {\n return [initialApiPlaygroundInputs];\n }\n const requestBodyContentExamples = Object.values(requestBodyContent[contentType]?.examples ?? {});\n const examples: ApiPlaygroundInputs[] = [];\n for (const example of requestBodyContentExamples) {\n if ('value' in example) {\n examples.push({\n ...initialApiPlaygroundInputs,\n body: example.value,\n });\n }\n }\n\n return examples;\n};\n\nexport const getParametersPerSection = (\n apiReferenceData: ApiReferenceDataV2\n): {\n header: ParameterObject[];\n path: ParameterObject[];\n query: ParameterObject[];\n cookie: ParameterObject[];\n} => {\n const parameters = apiReferenceData.dependencies?.parameters;\n if (parameters) {\n const parameterObjects = Object.values(parameters);\n const headerParameters = parameterObjects.filter(\n (parameter) => !('in' in parameter) || parameter.in === 'header'\n );\n const cookieParameters = parameterObjects.filter((parameter) => parameter.in === 'cookie');\n const pathParameters = parameterObjects.filter((parameter) => parameter.in === 'path');\n const queryParameters = parameterObjects.filter((parameter) => parameter.in === 'query');\n return {\n header: headerParameters,\n path: pathParameters,\n query: queryParameters,\n cookie: cookieParameters,\n };\n }\n return { header: [], path: [], query: [], cookie: [] };\n};\n\nexport const getSchemaDefault = (schema: object | undefined): unknown | undefined => {\n let defaultValue = undefined;\n if (!schema) {\n return undefined;\n }\n if (typeof schema === 'object' && 'default' in schema) {\n defaultValue = schema.default;\n }\n if (typeof schema === 'object' && 'x-default' in schema) {\n defaultValue = schema['x-default'];\n }\n return defaultValue;\n};\n\nexport const getUniqueInputKey = (\n inputKeyPrefix: string,\n schema: ResolvedSchemaObject,\n arrayIndex?: number,\n key?: string\n) => {\n if (!schema.uniqueKey) {\n return inputKeyPrefix;\n } else {\n const arrayIndexOrKey = arrayIndex || key;\n return `${inputKeyPrefix ? inputKeyPrefix + '.' : ''}${schema.uniqueKey}${arrayIndexOrKey ? '.' + arrayIndexOrKey : ''}`;\n }\n};\n\nexport const convertAnySchemaToOneOfs = (): SchemaObject => {\n return {\n oneOf: [\n {\n type: 'string',\n },\n {\n type: 'number',\n },\n {\n type: 'boolean',\n },\n {\n type: 'object',\n properties: {},\n },\n {\n type: 'array',\n items: {\n oneOf: [\n { type: 'string' },\n { type: 'number' },\n { type: 'boolean' },\n { type: 'object', properties: {} },\n { type: 'array', items: {} },\n { type: 'null' },\n ],\n },\n },\n {\n type: 'null',\n },\n ],\n };\n};\n\nexport const getRequestBodyContentType = (\n apiReferenceData: ApiReferenceDataV2,\n contentTypeIndex: number\n): string | undefined => {\n const requestBodyContent = apiReferenceData.dependencies?.requestBody?.content;\n if (requestBodyContent === undefined) {\n return undefined;\n }\n const requestBodyContentTypes = Object.keys(requestBodyContent);\n return requestBodyContentTypes[contentTypeIndex];\n};\n\nexport const escapeDots = (key: string): string => {\n return key.replace(/\\./g, '\\\\.');\n};\n\nexport const mapParamInToPlaygroundInputKey = (parameterIn: string): string => {\n switch (parameterIn) {\n case 'header':\n return apiPlaygroundInputKeys.header;\n case 'path':\n return apiPlaygroundInputKeys.path;\n case 'query':\n return apiPlaygroundInputKeys.query;\n case 'cookie':\n return apiPlaygroundInputKeys.cookie;\n default:\n return apiPlaygroundInputKeys.header;\n }\n};\n\n// CLANKED AS HELL. TODO: Refactor.\nexport const unflattenInputs = (\n inputs: Record<string, PlaygroundInputValue>\n): ApiPlaygroundInputs => {\n const result: ApiPlaygroundInputs = {\n server: {},\n header: {},\n path: {},\n query: {},\n cookie: {},\n body: undefined,\n };\n\n Object.entries(inputs).forEach(([key, value]) => {\n // skip undefined/null values\n if (value === undefined || value === null) {\n return;\n }\n // split on . but not on \\. (escaped dots), then unescape the parts\n const parts = key.split(/(?<!\\\\)\\./).map((part) => part.replace(/\\\\\\./g, '.'));\n if (parts.length < 2) {\n if (key === 'body') {\n result.body = value;\n }\n return;\n }\n\n const [section, ...keyPath] = parts;\n\n const validKeys = Object.values(apiPlaygroundInputKeys);\n if (!section || !validKeys.includes(section)) {\n return;\n }\n\n if (section !== apiPlaygroundInputKeys.body) {\n setNestedValue(\n result[section as keyof ApiPlaygroundInputs] as Record<string, unknown>,\n [...keyPath],\n value\n );\n } else {\n if ([...keyPath].length === 0) {\n result.body = value;\n } else {\n // Initialize body as object if it's undefined\n if (result.body === undefined || typeof result.body !== 'object') {\n result.body = {};\n }\n setNestedValue(result.body as Record<string, unknown>, keyPath, value);\n }\n }\n });\n\n // Convert array-like objects (objects with only numeric keys) to actual arrays\n return convertArrayLikeToArray(result) as ApiPlaygroundInputs;\n};\n\n// Check if an object should be converted to an array (all keys are numeric strings)\nconst isArrayLike = (obj: unknown): obj is Record<string, unknown> => {\n if (!isPlainRecord(obj)) {\n return false;\n }\n const keys = Object.keys(obj);\n if (keys.length === 0) {\n return false;\n }\n // Check if all keys are numeric strings\n return keys.every((k) => /^\\d+$/.test(k));\n};\n\n// Recursively convert array-like objects to arrays\nconst convertArrayLikeToArray = (value: unknown): unknown => {\n if (value === null || value === undefined) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map(convertArrayLikeToArray);\n }\n\n if (isPlainRecord(value)) {\n if (isArrayLike(value)) {\n // Convert object with numeric keys to array\n // Sort keys numerically and map to values\n const keys = Object.keys(value).sort((a, b) => Number(a) - Number(b));\n const arr = keys.map((k) => value[k]);\n // Recursively convert nested values\n return arr.map(convertArrayLikeToArray);\n }\n\n // Recursively process regular objects\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n result[key] = convertArrayLikeToArray(val);\n }\n return result;\n }\n\n return value;\n};\n\n// recursively set a value in a nested object\nconst setNestedValue = (obj: Record<string, unknown>, keyPath: string[], value: unknown) => {\n // First pass: filter out keys we want to skip\n const filteredKeys: string[] = [];\n for (let i = 0; i < keyPath.length; i++) {\n const key = keyPath[i];\n if (key === 'oneOf') {\n // Skip this key and the next one (the oneOf index)\n i++;\n continue;\n }\n if (key === 'additionalProperties' || key === 'items') {\n // Skip these keys\n continue;\n }\n if (key) {\n filteredKeys.push(key);\n }\n }\n\n // Second pass: navigate through/create nested structure and set value\n let current = obj;\n for (let i = 0; i < filteredKeys.length; i++) {\n const key = filteredKeys[i];\n if (i === filteredKeys.length - 1) {\n // Last key - set the value\n if (key) {\n current[key] = value;\n }\n } else {\n // Not the last key - ensure nested object exists\n if (key && (!current[key] || typeof current[key] !== 'object')) {\n current[key] = {};\n }\n if (key) {\n current = current[key] as Record<string, unknown>;\n }\n }\n }\n};\n// CLANK ENDS HERE\n\nexport const filterSchemasWithConsts = (\n schemas: ResolvedSchemaObject[]\n): ResolvedSchemaObject[] => {\n const filteredSchemas = schemas.filter((schema) => {\n if ('enum' in schema && schema.enum && 'const' in schema) {\n return schema.enum.includes(schema.const);\n }\n return true;\n });\n return filteredSchemas;\n};\n\nexport const getBodyDefaultsFromSchema = (schema: SchemaObject): Record<string, unknown> => {\n const bodyDefaults: Record<string, unknown> = {};\n\n if ('uniqueKey' in schema && schema.uniqueKey !== undefined) {\n const defaultValue = getSchemaDefault(schema);\n if (defaultValue !== undefined) {\n const inputKey = `${apiPlaygroundInputKeys.body}.${schema.uniqueKey}`;\n bodyDefaults[inputKey] = defaultValue;\n }\n }\n\n if ('oneOf' in schema && Array.isArray(schema.oneOf)) {\n schema.oneOf.forEach((subSchema) => {\n if (isSchemaObject(subSchema)) {\n const subDefaults = getBodyDefaultsFromSchema(subSchema);\n Object.assign(bodyDefaults, subDefaults);\n }\n });\n }\n\n if (schema.type === 'object' && schema.properties) {\n Object.values(schema.properties).forEach((propSchema) => {\n if (isSchemaObject(propSchema)) {\n const propDefaults = getBodyDefaultsFromSchema(propSchema);\n Object.assign(bodyDefaults, propDefaults);\n }\n });\n }\n\n if (\n schema.additionalProperties &&\n typeof schema.additionalProperties === 'object' &&\n isSchemaObject(schema.additionalProperties)\n ) {\n const addPropsDefaults = getBodyDefaultsFromSchema(schema.additionalProperties);\n Object.assign(bodyDefaults, addPropsDefaults);\n }\n\n if (schema.type === 'array' && 'items' in schema && isSchemaObject(schema.items)) {\n const itemsDefaults = getBodyDefaultsFromSchema(schema.items);\n Object.assign(bodyDefaults, itemsDefaults);\n }\n\n return bodyDefaults;\n};"],"names":["isPlainRecord","value","isSchemaObject","obj","mapResponseExamples","apiReferenceData","responseCodeMediaObjectMap","_a","responseCode","UUID","response","_b","unflattenInputs","inputs","result","key","parts","part","section","keyPath","validKeys","apiPlaygroundInputKeys","setNestedValue","convertArrayLikeToArray","isArrayLike","keys","k","a","b","val","filteredKeys","i","current"],"mappings":";;AAiDO,MAAMA,IAAgB,CAACC,MAC5B,OAAOA,KAAU,YAAYA,MAAU,QAAQ,CAAC,MAAM,QAAQA,CAAK,GAsExDC,IAAiB,CAACC,MACxBH,EAAcG,CAAG,IAKpB,UAAUA,KACV,gBAAgBA,KAChB,WAAWA,KACX,WAAWA,KACX,WAAWA,KACX,WAAWA,KACX,0BAA0BA,KAC1B,UAAUA,KACV,WAAWA,KACX,YAAYA,KACZ,aAAaA,KACb,aAAaA,KACb,aAAaA,KACb,eAAeA,KACf,eAAeA,KACf,cAAcA,KACd,cAAcA,KACd,mBAAmBA,KACnB,mBAAmBA,KACnB,cAAcA,KACd,cAAcA,KACd,iBAAiBA,IAzBV,IAuVEC,IAAsB,CAACC,MAAyC;;AAC3E,QAAMC,IAA0D,CAAA;AAChE,gBAAO,UAAQC,IAAAF,EAAiB,cAAjB,gBAAAE,EAA4B,cAAa,EAAE,EAAE,QAAQ,CAAC,CAACC,GAAcC,CAAI,MAAM;;AAC5F,UAAMC,KAAWC,KAAAJ,IAAAF,EAAiB,iBAAjB,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,CAAG;AAAA,EAG3B;AACF;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as m, jsxs as r } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import "@mintlify/validation";
|
|
3
|
+
import { cn as d } from "../../utils/cn.js";
|
|
3
4
|
import * as t from "@radix-ui/react-dropdown-menu";
|
|
4
5
|
import { ChevronRightFilled as l, CheckmarkCircleRegular as c, CircleRegular as p } from "@fluentui/react-icons";
|
|
5
6
|
import * as o from "react";
|
|
6
7
|
const f = o.forwardRef((n, e) => /* @__PURE__ */ m(t.Root, { modal: !1, ...n }));
|
|
7
8
|
f.displayName = t.Root.displayName;
|
|
8
|
-
const
|
|
9
|
+
const I = t.Trigger, u = o.forwardRef(({ className: n, inset: e, children: i, ...a }, s) => /* @__PURE__ */ r(
|
|
9
10
|
t.SubTrigger,
|
|
10
11
|
{
|
|
11
12
|
ref: s,
|
|
@@ -122,6 +123,6 @@ export {
|
|
|
122
123
|
x as DropdownMenuSeparator,
|
|
123
124
|
b as DropdownMenuSubContent,
|
|
124
125
|
u as DropdownMenuSubTrigger,
|
|
125
|
-
|
|
126
|
+
I as DropdownMenuTrigger
|
|
126
127
|
};
|
|
127
128
|
//# sourceMappingURL=dropdown-menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-menu.js","sources":["../../../src/components/Api/dropdown-menu.tsx"],"sourcesContent":["import { cn } from '@/api-playground-2/schemaGraph/utils';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { CheckmarkCircleRegular, ChevronRightFilled, CircleRegular } from '@fluentui/react-icons';\nimport * as React from 'react';\n\nconst DropdownMenu = React.forwardRef<\n typeof DropdownMenuPrimitive.Root,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root>\n>((props, _ref) => <DropdownMenuPrimitive.Root modal={false} {...props} />);\nDropdownMenu.displayName = DropdownMenuPrimitive.Root.displayName;\n\nconst DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\n\nconst DropdownMenuGroup = DropdownMenuPrimitive.Group;\n\nconst DropdownMenuPortal = DropdownMenuPrimitive.Portal;\n\nconst DropdownMenuSub = DropdownMenuPrimitive.Sub;\n\nconst DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nconst DropdownMenuSubTrigger = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(({ className, inset, children, ...props }, ref) => (\n <DropdownMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n 'mint:flex mint:cursor-default mint:select-none mint:items-center mint:rounded-md mint:px-2 mint:py-1.5 mint:text-sm mint:outline-none mint:focus:bg-accent mint:data-[state=open]:bg-accent',\n inset && 'mint:pl-8',\n className\n )}\n {...props}\n >\n {children}\n <ChevronRightFilled className=\"mint:size-4 mint:ml-auto\" />\n </DropdownMenuPrimitive.SubTrigger>\n));\nDropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;\n\nconst DropdownMenuSubContent = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'mint:z-50 mint:min-w-[8rem] mint:overflow-hidden mint:rounded-xl mint:border mint:bg-popover mint:p-1 mint:shadow-md mint:data-[state=open]:animate-in mint:data-[state=closed]:animate-out mint:data-[state=closed]:fade-out-0 mint:data-[state=open]:fade-in-0 mint:data-[state=closed]:zoom-out-95 mint:data-[state=open]:zoom-in-95 mint:data-[side=bottom]:slide-in-from-top-2 mint:data-[side=left]:slide-in-from-right-2 mint:data-[side=right]:slide-in-from-left-2 mint:data-[side=top]:slide-in-from-bottom-2',\n className\n )}\n {...props}\n />\n));\nDropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;\n\nconst DropdownMenuContent = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n>(({ className, sideOffset = 8, ...props }, ref) => (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n 'mint:bg-white mint:dark:bg-zinc-950 mint:z-50 mint:min-w-[8rem] mint:overflow-hidden mint:rounded-xl mint:border mint:p-3 mint:text-secondary mint:data-[state=open]:animate-in mint:data-[state=closed]:animate-out mint:data-[state=closed]:fade-out-0 mint:data-[state=open]:fade-in-0 mint:data-[state=closed]:zoom-out-95 mint:data-[state=open]:zoom-in-95 mint:data-[side=bottom]:slide-in-from-top-2 mint:data-[side=left]:slide-in-from-right-2 mint:data-[side=right]:slide-in-from-left-2 mint:data-[side=top]:slide-in-from-bottom-2 mint:shadow-xl mint:shadow-zinc-400/10 mint:dark:border-white/10 mint:dark:shadow-none',\n className\n )}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n));\nDropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;\n\ntype DropdownMenuItemProps = React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n isSelected?: boolean;\n};\n\nconst DropdownMenuItem = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Item>,\n DropdownMenuItemProps\n>(({ className, inset, isSelected, ...props }, ref) => (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n 'mint:relative mint:flex mint:cursor-pointer mint:select-none mint:items-center mint:rounded-lg mint:px-2 mint:py-1.5 mint:text-sm mint:outline-none mint:focus:bg-accent mint:focus:text-accent-foreground mint:data-[disabled]:pointer-events-none mint:data-[disabled]:opacity-50 mint:hover:bg-zinc-950/5 mint:dark:hover:bg-white/5',\n inset && 'mint:pl-8',\n isSelected && 'mint:bg-zinc-950/5 mint:dark:bg-white/5 mint:font-medium',\n className\n )}\n {...props}\n />\n));\nDropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;\n\nconst DropdownMenuCheckboxItem = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(({ className, children, checked, ...props }, ref) => (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(\n 'mint:relative mint:flex mint:cursor-default mint:select-none mint:items-center mint:rounded-sm mint:py-1.5 mint:pl-8 mint:pr-2 mint:text-sm mint:outline-none mint:transition-colors mint:focus:bg-accent mint:focus:text-accent-foreground mint:data-[disabled]:pointer-events-none mint:data-[disabled]:opacity-50',\n className\n )}\n checked={checked}\n {...props}\n >\n <span className=\"mint:absolute mint:left-2 mint:flex mint:size-3.5 mint:items-center mint:justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CheckmarkCircleRegular className=\"mint:size-4\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n));\nDropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;\n\nconst DropdownMenuRadioItem = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>\n>(({ className, children, ...props }, ref) => (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(\n 'mint:relative mint:flex mint:cursor-default mint:select-none mint:items-center mint:rounded-md mint:py-1.5 mint:pl-8 mint:pr-2 mint:text-sm mint:outline-none mint:transition-colors mint:focus:bg-accent mint:focus:text-accent-foreground mint:data-[disabled]:pointer-events-none mint:data-[disabled]:opacity-50',\n className\n )}\n {...props}\n >\n <span className=\"mint:absolute mint:left-2 mint:flex mint:size-3.5 mint:items-center mint:justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CircleRegular className=\"mint:size-2 mint:fill-current\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n));\nDropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;\n\nconst DropdownMenuLabel = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(({ className, inset, ...props }, ref) => (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn('mint:px-2 mint:py-1.5 mint:text-sm mint:font-semibold', inset && 'mint:pl-8', className)}\n {...props}\n />\n));\nDropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;\n\nconst DropdownMenuSeparator = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('mint:-mx-1 mint:my-1 mint:h-px mint:bg-zinc-950/10 mint:dark:bg-white/10', className)}\n {...props}\n />\n));\nDropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;\n\nconst DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span className={cn('mint:ml-auto mint:text-xs mint:tracking-widest mint:opacity-60', className)} {...props} />\n );\n};\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\nexport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuPortal,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n};\n"],"names":["DropdownMenu","React","props","_ref","jsx","DropdownMenuPrimitive","DropdownMenuTrigger","DropdownMenuSubTrigger","className","inset","children","ref","jsxs","cn","ChevronRightFilled","DropdownMenuSubContent","DropdownMenuContent","sideOffset","DropdownMenuItem","isSelected","DropdownMenuCheckboxItem","checked","CheckmarkCircleRegular","DropdownMenuRadioItem","CircleRegular","DropdownMenuLabel","DropdownMenuSeparator"],"mappings":";;;;;AAKA,MAAMA,IAAeC,EAAM,WAGzB,CAACC,GAAOC,MAAS,gBAAAC,EAACC,EAAsB,MAAtB,EAA2B,OAAO,IAAQ,GAAGH,GAAO,CAAE;AAC1EF,EAAa,cAAcK,EAAsB,KAAK;AAEtD,MAAMC,IAAsBD,EAAsB,SAU5CE,IAAyBN,EAAM,WAKnC,CAAC,EAAE,WAAAO,GAAW,OAAAC,GAAO,UAAAC,GAAU,GAAGR,KAASS,MAC3C,gBAAAC;AAAA,EAACP,EAAsB;AAAA,EAAtB;AAAA,IACC,KAAAM;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAJ,KAAS;AAAA,MACTD;AAAA,IAAA;AAAA,IAED,GAAGN;AAAA,IAEH,UAAA;AAAA,MAAAQ;AAAA,MACD,gBAAAN,EAACU,GAAA,EAAmB,WAAU,2BAAA,CAA2B;AAAA,IAAA;AAAA,EAAA;AAC3D,CACD;AACDP,EAAuB,cAAcF,EAAsB,WAAW;AAEtE,MAAMU,IAAyBd,EAAM,WAGnC,CAAC,EAAE,WAAAO,GAAW,GAAGN,EAAA,GAASS,MAC1B,gBAAAP;AAAA,EAACC,EAAsB;AAAA,EAAtB;AAAA,IACC,KAAAM;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAL;AAAA,IAAA;AAAA,IAED,GAAGN;AAAA,EAAA;AACN,CACD;AACDa,EAAuB,cAAcV,EAAsB,WAAW;AAEtE,MAAMW,IAAsBf,EAAM,WAGhC,CAAC,EAAE,WAAAO,GAAW,YAAAS,IAAa,GAAG,GAAGf,KAASS,MAC1C,gBAAAP,EAACC,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A,IACC,KAAAM;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAL;AAAA,IAAA;AAAA,IAED,GAAGN;AAAA,IAEJ,UAAA;AAAA,MAAA,gBAAAE,EAAC,QAAA,EAAK,WAAU,2FACd,UAAA,gBAAAA,EAACC,EAAsB,eAAtB,EACC,UAAA,gBAAAD,EAACoB,GAAA,EAAc,WAAU,gCAAA,CAAgC,EAAA,CAC3D,GACF;AAAA,MACCd;AAAA,IAAA;AAAA,EAAA;AACH,CACD;AACDa,EAAsB,cAAclB,EAAsB,UAAU;AAEpE,MAAMoB,IAAoBxB,EAAM,WAK9B,CAAC,EAAE,WAAAO,GAAW,OAAAC,GAAO,GAAGP,KAASS,MACjC,gBAAAP;AAAA,EAACC,EAAsB;AAAA,EAAtB;AAAA,IACC,KAAAM;AAAA,IACA,WAAWE,EAAG,yDAAyDJ,KAAS,aAAaD,CAAS;AAAA,IACrG,GAAGN;AAAA,EAAA;AACN,CACD;AACDuB,EAAkB,cAAcpB,EAAsB,MAAM;AAE5D,MAAMqB,IAAwBzB,EAAM,WAGlC,CAAC,EAAE,WAAAO,GAAW,GAAGN,EAAA,GAASS,MAC1B,gBAAAP;AAAA,EAACC,EAAsB;AAAA,EAAtB;AAAA,IACC,KAAAM;AAAA,IACA,WAAWE,EAAG,4EAA4EL,CAAS;AAAA,IAClG,GAAGN;AAAA,EAAA;AACN,CACD;AACDwB,EAAsB,cAAcrB,EAAsB,UAAU;"}
|
|
1
|
+
{"version":3,"file":"dropdown-menu.js","sources":["../../../src/components/Api/dropdown-menu.tsx"],"sourcesContent":["import { cn } from '@/api-playground-2/schemaGraph/utils';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { CheckmarkCircleRegular, ChevronRightFilled, CircleRegular } from '@fluentui/react-icons';\nimport * as React from 'react';\n\nconst DropdownMenu = React.forwardRef<\n typeof DropdownMenuPrimitive.Root,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root>\n>((props, _ref) => <DropdownMenuPrimitive.Root modal={false} {...props} />);\nDropdownMenu.displayName = DropdownMenuPrimitive.Root.displayName;\n\nconst DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\n\nconst DropdownMenuGroup = DropdownMenuPrimitive.Group;\n\nconst DropdownMenuPortal = DropdownMenuPrimitive.Portal;\n\nconst DropdownMenuSub = DropdownMenuPrimitive.Sub;\n\nconst DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nconst DropdownMenuSubTrigger = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(({ className, inset, children, ...props }, ref) => (\n <DropdownMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n 'mint:flex mint:cursor-default mint:select-none mint:items-center mint:rounded-md mint:px-2 mint:py-1.5 mint:text-sm mint:outline-none mint:focus:bg-accent mint:data-[state=open]:bg-accent',\n inset && 'mint:pl-8',\n className\n )}\n {...props}\n >\n {children}\n <ChevronRightFilled className=\"mint:size-4 mint:ml-auto\" />\n </DropdownMenuPrimitive.SubTrigger>\n));\nDropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;\n\nconst DropdownMenuSubContent = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'mint:z-50 mint:min-w-[8rem] mint:overflow-hidden mint:rounded-xl mint:border mint:bg-popover mint:p-1 mint:shadow-md mint:data-[state=open]:animate-in mint:data-[state=closed]:animate-out mint:data-[state=closed]:fade-out-0 mint:data-[state=open]:fade-in-0 mint:data-[state=closed]:zoom-out-95 mint:data-[state=open]:zoom-in-95 mint:data-[side=bottom]:slide-in-from-top-2 mint:data-[side=left]:slide-in-from-right-2 mint:data-[side=right]:slide-in-from-left-2 mint:data-[side=top]:slide-in-from-bottom-2',\n className\n )}\n {...props}\n />\n));\nDropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;\n\nconst DropdownMenuContent = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n>(({ className, sideOffset = 8, ...props }, ref) => (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n 'mint:bg-white mint:dark:bg-zinc-950 mint:z-50 mint:min-w-[8rem] mint:overflow-hidden mint:rounded-xl mint:border mint:p-3 mint:text-secondary mint:data-[state=open]:animate-in mint:data-[state=closed]:animate-out mint:data-[state=closed]:fade-out-0 mint:data-[state=open]:fade-in-0 mint:data-[state=closed]:zoom-out-95 mint:data-[state=open]:zoom-in-95 mint:data-[side=bottom]:slide-in-from-top-2 mint:data-[side=left]:slide-in-from-right-2 mint:data-[side=right]:slide-in-from-left-2 mint:data-[side=top]:slide-in-from-bottom-2 mint:shadow-xl mint:shadow-zinc-400/10 mint:dark:border-white/10 mint:dark:shadow-none',\n className\n )}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n));\nDropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;\n\ntype DropdownMenuItemProps = React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n isSelected?: boolean;\n};\n\nconst DropdownMenuItem = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Item>,\n DropdownMenuItemProps\n>(({ className, inset, isSelected, ...props }, ref) => (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n 'mint:relative mint:flex mint:cursor-pointer mint:select-none mint:items-center mint:rounded-lg mint:px-2 mint:py-1.5 mint:text-sm mint:outline-none mint:focus:bg-accent mint:focus:text-accent-foreground mint:data-[disabled]:pointer-events-none mint:data-[disabled]:opacity-50 mint:hover:bg-zinc-950/5 mint:dark:hover:bg-white/5',\n inset && 'mint:pl-8',\n isSelected && 'mint:bg-zinc-950/5 mint:dark:bg-white/5 mint:font-medium',\n className\n )}\n {...props}\n />\n));\nDropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;\n\nconst DropdownMenuCheckboxItem = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(({ className, children, checked, ...props }, ref) => (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(\n 'mint:relative mint:flex mint:cursor-default mint:select-none mint:items-center mint:rounded-sm mint:py-1.5 mint:pl-8 mint:pr-2 mint:text-sm mint:outline-none mint:transition-colors mint:focus:bg-accent mint:focus:text-accent-foreground mint:data-[disabled]:pointer-events-none mint:data-[disabled]:opacity-50',\n className\n )}\n checked={checked}\n {...props}\n >\n <span className=\"mint:absolute mint:left-2 mint:flex mint:size-3.5 mint:items-center mint:justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CheckmarkCircleRegular className=\"mint:size-4\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n));\nDropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;\n\nconst DropdownMenuRadioItem = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>\n>(({ className, children, ...props }, ref) => (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(\n 'mint:relative mint:flex mint:cursor-default mint:select-none mint:items-center mint:rounded-md mint:py-1.5 mint:pl-8 mint:pr-2 mint:text-sm mint:outline-none mint:transition-colors mint:focus:bg-accent mint:focus:text-accent-foreground mint:data-[disabled]:pointer-events-none mint:data-[disabled]:opacity-50',\n className\n )}\n {...props}\n >\n <span className=\"mint:absolute mint:left-2 mint:flex mint:size-3.5 mint:items-center mint:justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CircleRegular className=\"mint:size-2 mint:fill-current\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n));\nDropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;\n\nconst DropdownMenuLabel = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(({ className, inset, ...props }, ref) => (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn('mint:px-2 mint:py-1.5 mint:text-sm mint:font-semibold', inset && 'mint:pl-8', className)}\n {...props}\n />\n));\nDropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;\n\nconst DropdownMenuSeparator = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('mint:-mx-1 mint:my-1 mint:h-px mint:bg-zinc-950/10 mint:dark:bg-white/10', className)}\n {...props}\n />\n));\nDropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;\n\nconst DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span className={cn('mint:ml-auto mint:text-xs mint:tracking-widest mint:opacity-60', className)} {...props} />\n );\n};\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\nexport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuPortal,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n};\n"],"names":["DropdownMenu","React","props","_ref","jsx","DropdownMenuPrimitive","DropdownMenuTrigger","DropdownMenuSubTrigger","className","inset","children","ref","jsxs","cn","ChevronRightFilled","DropdownMenuSubContent","DropdownMenuContent","sideOffset","DropdownMenuItem","isSelected","DropdownMenuCheckboxItem","checked","CheckmarkCircleRegular","DropdownMenuRadioItem","CircleRegular","DropdownMenuLabel","DropdownMenuSeparator"],"mappings":";;;;;;AAKA,MAAMA,IAAeC,EAAM,WAGzB,CAACC,GAAOC,MAAS,gBAAAC,EAACC,EAAsB,MAAtB,EAA2B,OAAO,IAAQ,GAAGH,GAAO,CAAE;AAC1EF,EAAa,cAAcK,EAAsB,KAAK;AAEtD,MAAMC,IAAsBD,EAAsB,SAU5CE,IAAyBN,EAAM,WAKnC,CAAC,EAAE,WAAAO,GAAW,OAAAC,GAAO,UAAAC,GAAU,GAAGR,KAASS,MAC3C,gBAAAC;AAAA,EAACP,EAAsB;AAAA,EAAtB;AAAA,IACC,KAAAM;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAJ,KAAS;AAAA,MACTD;AAAA,IAAA;AAAA,IAED,GAAGN;AAAA,IAEH,UAAA;AAAA,MAAAQ;AAAA,MACD,gBAAAN,EAACU,GAAA,EAAmB,WAAU,2BAAA,CAA2B;AAAA,IAAA;AAAA,EAAA;AAC3D,CACD;AACDP,EAAuB,cAAcF,EAAsB,WAAW;AAEtE,MAAMU,IAAyBd,EAAM,WAGnC,CAAC,EAAE,WAAAO,GAAW,GAAGN,EAAA,GAASS,MAC1B,gBAAAP;AAAA,EAACC,EAAsB;AAAA,EAAtB;AAAA,IACC,KAAAM;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAL;AAAA,IAAA;AAAA,IAED,GAAGN;AAAA,EAAA;AACN,CACD;AACDa,EAAuB,cAAcV,EAAsB,WAAW;AAEtE,MAAMW,IAAsB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AAE,WAAAO,GAAW,UAAAE,GAAU,GAAGR,KAASS,MACpC,gBAAAC;AAAA,EAACP,EAAsB;AAAA,EAAtB;AAAA,IACC,KAAAM;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAL;AAAA,IAAA;AAAA,IAED,GAAGN;AAAA,IAEJ,UAAA;AAAA,MAAA,gBAAAE,EAAC,QAAA,EAAK,WAAU,2FACd,UAAA,gBAAAA,EAACC,EAAsB,eAAtB,EACC,UAAA,gBAAAD,EAACoB,GAAA,EAAc,WAAU,gCAAA,CAAgC,EAAA,CAC3D,GACF;AAAA,MACCd;AAAA,IAAA;AAAA,EAAA;AACH,CACD;AACDa,EAAsB,cAAclB,EAAsB,UAAU;AAEpE,MAAMoB,IAAoBxB,EAAM,WAK9B,CAAC,EAAE,WAAAO,GAAW,OAAAC,GAAO,GAAGP,KAASS,MACjC,gBAAAP;AAAA,EAACC,EAAsB;AAAA,EAAtB;AAAA,IACC,KAAAM;AAAA,IACA,WAAWE,EAAG,yDAAyDJ,KAAS,aAAaD,CAAS;AAAA,IACrG,GAAGN;AAAA,EAAA;AACN,CACD;AACDuB,EAAkB,cAAcpB,EAAsB,MAAM;AAE5D,MAAMqB,IAAwBzB,EAAM,WAGlC,CAAC,EAAE,WAAAO,GAAW,GAAGN,EAAA,GAASS,MAC1B,gBAAAP;AAAA,EAACC,EAAsB;AAAA,EAAtB;AAAA,IACC,KAAAM;AAAA,IACA,WAAWE,EAAG,4EAA4EL,CAAS;AAAA,IAClG,GAAGN;AAAA,EAAA;AACN,CACD;AACDwB,EAAsB,cAAcrB,EAAsB,UAAU;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as a, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { useContext as y, useState as f, useEffect as C } from "react";
|
|
3
|
-
import { ApiPlaygroundContext as k } from "
|
|
4
|
-
import { useCodeExampleLabel as j } from "
|
|
5
|
-
import { useSelectedLocale as G } from "
|
|
3
|
+
import { ApiPlaygroundContext as k } from "../../../api-playground/ApiPlayground/ApiPlaygroundContext.js";
|
|
4
|
+
import { useCodeExampleLabel as j } from "../../../contexts/CodeExampleLabelContext.js";
|
|
5
|
+
import { useSelectedLocale as G } from "../../../utils/locales/index.js";
|
|
6
6
|
import { CodeSnippet as L } from "../code-snippet.js";
|
|
7
7
|
import { CodeGroupCopyButton as N } from "./CodeGroupCopyButton.js";
|
|
8
8
|
import { CodeSelectDropdown as g } from "./CodeSelectDropdown.js";
|
|
@@ -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,E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QAAQ;AAAA,oBAChE,aAAa;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACf,EAAA,CACF;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAEF,gBAAAf,EAAC,SAAI,WAAU,8CACZ,YAAS,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,C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,EAAC,OAAA,EAAI,WAAU,gIAAA,CAAgI;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIvJ,CAAC;"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { CodeBlock 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;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialRequest.js","sources":["../../src/constants/initialRequest.ts"],"sourcesContent":["export const initialRequest = {\n headers: [],\n method: 'GET' as const,\n url: '',\n httpVersion: 'HTTP/1.1',\n queryString: [],\n headersSize: -1,\n cookies: [],\n bodySize: -1,\n};\n"],"names":["initialRequest"],"mappings":"AAAO,MAAMA,IAAiB;AAAA,EAC5B,SAAS,CAAA;AAAA,EACT,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,aAAa;AAAA,EACb,aAAa,CAAA;AAAA,EACb,aAAa;AAAA,EACb,SAAS,CAAA;AAAA,EACT,UAAU;AACZ;"}
|