UNPKG

@asyncapi/react-component

Version:

A React component for AsyncAPI specification.

30 lines 2.45 kB
import React from 'react'; import { SchemaHelpers } from '../../../helpers'; export var Rules = function (_a) { var _b; var schema = _a.schema, constraints = _a.constraints; return (React.createElement("div", { className: "flex flex-col space-y-2 bg-blue-100 p-4 rounded rounded-tl-none border" }, schema.format() && (React.createElement("span", { className: "no-underline rounded lowercase p-1 text-sm" }, "format:", ' ', React.createElement("span", { className: "rounded font-bold p-1 text-sm" }, schema.format()))), schema.pattern() && (React.createElement("span", { className: "no-underline rounded lowercase p-1 text-sm" }, "must match:", ' ', React.createElement("span", { className: "rounded font-bold p-1 text-sm" }, schema.pattern()))), schema.contentEncoding() !== undefined && (React.createElement("span", { className: "no-underline rounded lowercase p-1 text-sm" }, "encoding:", ' ', React.createElement("span", { className: "rounded font-bold p-1 text-sm" }, schema.contentEncoding()))), constraints.map(function (constraint) { return (React.createElement("strong", { key: constraint, className: "text-purple-700 p-1 rounded-md text-sm" }, constraint)); }), schema.default() !== undefined && (React.createElement("div", { className: "text-sm" }, React.createElement("span", { className: "" }, "Default value:"), React.createElement("span", { className: "bg-orange-50 text-orange-700 font-bold px-2 py-1 rounded" }, SchemaHelpers.prettifyValue(schema.default())))), schema.const() !== undefined && (React.createElement("div", { className: "text-sm" }, React.createElement("span", { className: "" }, "Constant value: "), React.createElement("span", { className: "bg-orange-50 text-orange-700 font-bold px-2 py-1 rounded" }, SchemaHelpers.prettifyValue(schema.const())))), schema.enum() && (React.createElement("div", { className: "text-sm" }, React.createElement("span", { className: "" }, "Allowed values: "), (_b = schema.enum()) === null || _b === void 0 ? void 0 : _b.map(function (e, idx) { return (React.createElement("span", { key: idx, className: "bg-orange-50 text-orange-700 font-bold px-2 py-1 rounded" }, SchemaHelpers.prettifyValue(e))); }))))); }; //# sourceMappingURL=Rules.js.map