UNPKG

@asyncapi/react-component

Version:

A React component for AsyncAPI specification.

44 lines 3.42 kB
import React from 'react'; import { Schema } from '../Schema'; import { SchemaHelpers } from '../../../helpers'; export var Conditions = function (_a) { var _b, _c, _d, _e, _f, _g; var schema = _a.schema, dependentSchemas = _a.dependentSchemas; return (React.createElement("div", { className: "space-y-2 bg-blue-100 border rounded rounded-tl-none p-4" }, ((_b = schema.oneOf()) === null || _b === void 0 ? void 0 : _b.length) && (React.createElement("div", { className: "" }, React.createElement("h5", { className: "text-sm font-semibold text-gray-700 mb-2" }, "Can be ", React.createElement("strong", null, "One Of"), " the following:"), (_c = schema.oneOf()) === null || _c === void 0 ? void 0 : _c.map(function (s, idx) { var _a; return (React.createElement(Schema, { key: idx, schema: s, schemaName: SchemaHelpers.applicatorSchemaName(idx, '', '', (_a = s.title()) !== null && _a !== void 0 ? _a : s.id()) })); }))), ((_d = schema.anyOf()) === null || _d === void 0 ? void 0 : _d.length) && (React.createElement("div", { className: "" }, React.createElement("h5", { className: "text-sm font-semibold text-gray-700 mb-2" }, "Can be ", React.createElement("strong", null, "Any Of"), " the following:"), (_e = schema.anyOf()) === null || _e === void 0 ? void 0 : _e.map(function (s, idx) { var _a; return (React.createElement(Schema, { key: idx, schema: s, schemaName: SchemaHelpers.applicatorSchemaName(idx, '', '', (_a = s.title()) !== null && _a !== void 0 ? _a : s.id()) })); }))), ((_f = schema.allOf()) === null || _f === void 0 ? void 0 : _f.length) && (React.createElement("div", { className: "" }, React.createElement("h5", { className: "text-sm font-semibold text-gray-700 mb-2" }, "Must consist ", React.createElement("strong", null, "All Of"), " the following:"), (_g = schema.allOf()) === null || _g === void 0 ? void 0 : _g.map(function (s, idx) { var _a; return (React.createElement(Schema, { key: idx, schema: s, schemaName: SchemaHelpers.applicatorSchemaName(idx, '', '', (_a = s.title()) !== null && _a !== void 0 ? _a : s.id()) })); }))), schema.not() && (React.createElement(Schema, { schema: schema.not(), schemaName: "Can NOT adhere to:" })), schema.propertyNames() && (React.createElement(Schema, { schema: schema.propertyNames(), schemaName: "Property names must adhere to:" })), schema.contains() && (React.createElement(Schema, { schema: schema.contains(), schemaName: "Array must contain at least one of:" })), schema.if() && (React.createElement("div", { className: "" }, React.createElement(Schema, { schema: schema.if(), schemaName: "If schema adheres to:" }), schema.then() && (React.createElement(Schema, { schema: schema.then(), schemaName: "Then must adhere to:" })), schema.else() && (React.createElement(Schema, { schema: schema.else(), schemaName: "Otherwise:" })))), dependentSchemas && (React.createElement(Schema, { schema: dependentSchemas, schemaName: "Dependent schemas:" })))); }; //# sourceMappingURL=Conditions.js.map