@clarify-labs/renderer 0.11.16 → 0.11.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/output/{OpenApiOperation-DxJl8ziP.cjs → OpenApiOperation-XH6b7ntf.cjs} +81 -45
- package/output/OpenApiOperation-XH6b7ntf.cjs.map +1 -0
- package/output/{OpenApiOperation-kL4Fxi0g.js → OpenApiOperation-hxX828Il.js} +81 -45
- package/output/OpenApiOperation-hxX828Il.js.map +1 -0
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/openapi/components/SchemaProperties.d.ts +1 -0
- package/output/openapi/lib/enum-options.d.ts +8 -0
- package/output/preview.cjs +1 -1
- package/output/preview.js +1 -1
- package/output/renderer.css +4 -0
- package/package.json +1 -1
- package/output/OpenApiOperation-DxJl8ziP.cjs.map +0 -1
- package/output/OpenApiOperation-kL4Fxi0g.js.map +0 -1
|
@@ -2900,16 +2900,41 @@ function OpenApiAuthDocumentation(props) {
|
|
|
2900
2900
|
});
|
|
2901
2901
|
}
|
|
2902
2902
|
//#endregion
|
|
2903
|
-
//#region source/openapi/
|
|
2904
|
-
function
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2903
|
+
//#region source/openapi/lib/enum-options.ts
|
|
2904
|
+
function enumValueKey(value) {
|
|
2905
|
+
return `${value === null ? "null" : typeof value}:${JSON.stringify(value)}`;
|
|
2906
|
+
}
|
|
2907
|
+
function enumMetadata(schema, keys, values) {
|
|
2908
|
+
const metadata = keys.map((key) => schema[key]).find((value) => Array.isArray(value) || isRecord$1(value));
|
|
2909
|
+
if (Array.isArray(metadata)) return values.map((_, index) => typeof metadata[index] === "string" ? metadata[index] : void 0);
|
|
2910
|
+
if (isRecord$1(metadata)) return values.map((value) => {
|
|
2911
|
+
const item = metadata[String(value)];
|
|
2912
|
+
return typeof item === "string" ? item : void 0;
|
|
2913
|
+
});
|
|
2914
|
+
return values.map(() => void 0);
|
|
2915
|
+
}
|
|
2916
|
+
function getEnumOptions(schema) {
|
|
2917
|
+
if (!isRecord$1(schema) || !Array.isArray(schema.enum)) return [];
|
|
2918
|
+
const values = schema.enum;
|
|
2919
|
+
const labels = enumMetadata(schema, [
|
|
2920
|
+
"x-enumLabels",
|
|
2921
|
+
"x-enumNames",
|
|
2922
|
+
"x-enum-varnames"
|
|
2923
|
+
], values);
|
|
2924
|
+
const descriptions = enumMetadata(schema, ["x-enumDescriptions"], values);
|
|
2925
|
+
return values.map((value, index) => {
|
|
2926
|
+
const valueText = String(value);
|
|
2927
|
+
return {
|
|
2928
|
+
key: enumValueKey(value),
|
|
2929
|
+
value,
|
|
2930
|
+
valueText,
|
|
2931
|
+
label: labels[index] ?? valueText,
|
|
2932
|
+
description: descriptions[index]
|
|
2933
|
+
};
|
|
2934
|
+
});
|
|
2912
2935
|
}
|
|
2936
|
+
//#endregion
|
|
2937
|
+
//#region source/openapi/components/SchemaProperties.tsx
|
|
2913
2938
|
function getSchemaDetails(schema) {
|
|
2914
2939
|
const details = [
|
|
2915
2940
|
typeof schema.const !== "undefined" ? `const: ${String(schema.const)}` : void 0,
|
|
@@ -2929,12 +2954,11 @@ function getSchemaNodeType(schema) {
|
|
|
2929
2954
|
}
|
|
2930
2955
|
function getEnumChildren(schema, path) {
|
|
2931
2956
|
if (!Array.isArray(schema.enum) || schema.enum.length === 0) return [];
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
name: String(value),
|
|
2957
|
+
return getEnumOptions(schema).map((option) => ({
|
|
2958
|
+
key: `${path || "root"}.enum.${option.key}`,
|
|
2959
|
+
name: option.valueText,
|
|
2936
2960
|
kind: "enum",
|
|
2937
|
-
description:
|
|
2961
|
+
description: option.description,
|
|
2938
2962
|
required: false,
|
|
2939
2963
|
children: []
|
|
2940
2964
|
}));
|
|
@@ -3095,6 +3119,9 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
3095
3119
|
})
|
|
3096
3120
|
};
|
|
3097
3121
|
}
|
|
3122
|
+
function shouldToggleSchemaRow(interactiveTarget, selectionInRow) {
|
|
3123
|
+
return !interactiveTarget && !selectionInRow;
|
|
3124
|
+
}
|
|
3098
3125
|
function EnumValueWithDescription(arg0) {
|
|
3099
3126
|
const { node } = arg0;
|
|
3100
3127
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
@@ -3153,8 +3180,8 @@ function SchemaNode(arg0) {
|
|
|
3153
3180
|
const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
|
|
3154
3181
|
const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
|
|
3155
3182
|
const rowClassName = "flex w-full min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left";
|
|
3156
|
-
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
3157
|
-
className: "min-w-0 flex-1",
|
|
3183
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3184
|
+
className: "min-w-0 flex-1 select-text",
|
|
3158
3185
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3159
3186
|
className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",
|
|
3160
3187
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -3174,20 +3201,25 @@ function SchemaNode(arg0) {
|
|
|
3174
3201
|
children: node.details
|
|
3175
3202
|
}) : null]
|
|
3176
3203
|
})]
|
|
3177
|
-
})
|
|
3178
|
-
className: "ml-2 flex h-5 w-5 flex-none items-center justify-center text-(--clarify-ui-text-faint)",
|
|
3179
|
-
"aria-hidden": "true",
|
|
3180
|
-
children: expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "h-4 w-4" })
|
|
3181
|
-
}) : null] });
|
|
3204
|
+
});
|
|
3182
3205
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
3183
3206
|
className: (0, clsx.default)("clarify-schema-node m-0 p-0", node.visible === false && "hidden"),
|
|
3184
|
-
children: [hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3207
|
+
children: [hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3208
|
+
onClick: (event) => {
|
|
3209
|
+
const target = event.target instanceof Element ? event.target : void 0;
|
|
3210
|
+
const interactiveTarget = Boolean(target?.closest("button, a, input, select, textarea, [role=\"button\"]"));
|
|
3211
|
+
const selection = window.getSelection();
|
|
3212
|
+
if (shouldToggleSchemaRow(interactiveTarget, Boolean(selection && !selection.isCollapsed && selection.containsNode(event.currentTarget, true)))) setLocallyExpanded((value) => !value);
|
|
3213
|
+
},
|
|
3214
|
+
className: (0, clsx.default)(rowClassName, "cursor-pointer transition hover:bg-(--clarify-ui-hover-background)"),
|
|
3215
|
+
children: [content, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3216
|
+
type: "button",
|
|
3217
|
+
"aria-label": `${expanded ? t("openapi.collapse") : t("openapi.expand")}: ${node.name}`,
|
|
3218
|
+
"aria-expanded": expanded,
|
|
3219
|
+
onClick: () => setLocallyExpanded((value) => !value),
|
|
3220
|
+
className: "ml-2 flex h-5 w-5 flex-none cursor-pointer items-center justify-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) outline-hidden transition hover:bg-(--clarify-ui-active-background) focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
3221
|
+
children: expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "h-4 w-4" })
|
|
3222
|
+
})]
|
|
3191
3223
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3192
3224
|
className: rowClassName,
|
|
3193
3225
|
children: content
|
|
@@ -3969,6 +4001,8 @@ function isFormMediaType(mediaType) {
|
|
|
3969
4001
|
}
|
|
3970
4002
|
function valueFromInput(schema, value) {
|
|
3971
4003
|
if (!isRecord$1(schema)) return value;
|
|
4004
|
+
const enumOption = getEnumOptions(schema).find((option) => option.valueText === value);
|
|
4005
|
+
if (enumOption) return enumOption.value;
|
|
3972
4006
|
if (schemaHasType(schema, "integer")) return value === "" ? "" : Number.parseInt(value, 10);
|
|
3973
4007
|
if (schemaHasType(schema, "number")) return value === "" ? "" : Number(value);
|
|
3974
4008
|
if (schemaHasType(schema, "boolean")) return value === "true";
|
|
@@ -3998,7 +4032,7 @@ function OpenApiRequestBodyEditor(arg0) {
|
|
|
3998
4032
|
const type = schemaToType(propertySchema) ?? "string";
|
|
3999
4033
|
const value = values[name];
|
|
4000
4034
|
const fieldId = `openapi-request-body-${name}`.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
4001
|
-
const options =
|
|
4035
|
+
const options = getEnumOptions(propertySchema);
|
|
4002
4036
|
const structured = schemaHasType(propertySchema, "array") || schemaHasType(propertySchema, "object");
|
|
4003
4037
|
const serializedValue = structured && typeof value !== "undefined" ? JSON.stringify(value, null, 2) : String(value ?? "");
|
|
4004
4038
|
let control;
|
|
@@ -4018,9 +4052,9 @@ function OpenApiRequestBodyEditor(arg0) {
|
|
|
4018
4052
|
onChange: (event) => updateProperty(name, propertySchema, event.target.value),
|
|
4019
4053
|
className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)",
|
|
4020
4054
|
children: [!required.has(name) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", { value: "" }) : null, options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
4021
|
-
value:
|
|
4022
|
-
children:
|
|
4023
|
-
},
|
|
4055
|
+
value: option.valueText,
|
|
4056
|
+
children: option.label
|
|
4057
|
+
}, option.key))]
|
|
4024
4058
|
});
|
|
4025
4059
|
else if (schemaHasType(propertySchema, "boolean")) control = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
4026
4060
|
id: fieldId,
|
|
@@ -4106,8 +4140,16 @@ function RequestField(arg0) {
|
|
|
4106
4140
|
const schema = resolveSchema(spec, parameter.schema);
|
|
4107
4141
|
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
4108
4142
|
const itemSchema = isRecord$1(schemaRecord?.items) ? schemaRecord.items : void 0;
|
|
4109
|
-
const options =
|
|
4110
|
-
|
|
4143
|
+
const options = getEnumOptions(schema).map(({ valueText, label, description }) => ({
|
|
4144
|
+
value: valueText,
|
|
4145
|
+
label,
|
|
4146
|
+
description
|
|
4147
|
+
}));
|
|
4148
|
+
const itemOptions = getEnumOptions(itemSchema).map(({ valueText, label, description }) => ({
|
|
4149
|
+
value: valueText,
|
|
4150
|
+
label,
|
|
4151
|
+
description
|
|
4152
|
+
}));
|
|
4111
4153
|
const type = schemaToType(schema) ?? "string";
|
|
4112
4154
|
const description = parameter.description ?? (typeof schemaRecord?.description === "string" ? schemaRecord.description : void 0);
|
|
4113
4155
|
const structured = type.includes("[]") || type.includes("object");
|
|
@@ -4187,10 +4229,7 @@ function RequestField(arg0) {
|
|
|
4187
4229
|
children: itemOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiInlineListbox, {
|
|
4188
4230
|
label: parameter.name ?? "",
|
|
4189
4231
|
value: arrayValue,
|
|
4190
|
-
options: itemOptions
|
|
4191
|
-
value: option,
|
|
4192
|
-
label: option
|
|
4193
|
-
})),
|
|
4232
|
+
options: itemOptions,
|
|
4194
4233
|
onChange: (next) => onChange(JSON.stringify(next)),
|
|
4195
4234
|
invalid: Boolean(issue),
|
|
4196
4235
|
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
@@ -4201,10 +4240,7 @@ function RequestField(arg0) {
|
|
|
4201
4240
|
options: [...parameter.required ? [] : [{
|
|
4202
4241
|
value: "",
|
|
4203
4242
|
label: t("openapi.none")
|
|
4204
|
-
}], ...options
|
|
4205
|
-
value: option,
|
|
4206
|
-
label: option
|
|
4207
|
-
}))],
|
|
4243
|
+
}], ...options],
|
|
4208
4244
|
onChange,
|
|
4209
4245
|
invalid: Boolean(issue),
|
|
4210
4246
|
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
@@ -4838,7 +4874,7 @@ function validateRequestParameter(spec, parameter, value) {
|
|
|
4838
4874
|
const schema = resolveSchema(spec, parameter.schema);
|
|
4839
4875
|
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
4840
4876
|
const type = schemaToType(schema) ?? "string";
|
|
4841
|
-
const options =
|
|
4877
|
+
const options = getEnumOptions(schema).map(({ valueText }) => valueText);
|
|
4842
4878
|
if (options.length > 0 && !options.includes(value)) return "invalidEnum";
|
|
4843
4879
|
return structuredIssue(value, type) ?? scalarIssue(value, type, schemaRecord?.format);
|
|
4844
4880
|
}
|
|
@@ -5363,7 +5399,7 @@ function EndpointPath(arg0) {
|
|
|
5363
5399
|
className: "min-w-0 flex-1 overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
|
|
5364
5400
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
5365
5401
|
className: "select-text font-mono text-(--clarify-theme-tokens-colors-foreground)",
|
|
5366
|
-
children: path
|
|
5402
|
+
children: path ? path.startsWith("/") ? path : `/${path}` : "/"
|
|
5367
5403
|
})
|
|
5368
5404
|
}), onCopy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
5369
5405
|
type: "button",
|
|
@@ -5937,4 +5973,4 @@ Object.defineProperty(exports, "primitives_exports", {
|
|
|
5937
5973
|
}
|
|
5938
5974
|
});
|
|
5939
5975
|
|
|
5940
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
5976
|
+
//# sourceMappingURL=OpenApiOperation-XH6b7ntf.cjs.map
|