@asyncapi/react-component 1.0.0-next.39 → 1.0.0-next.41
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/README.md +5 -4
- package/browser/index.js +3 -3
- package/browser/standalone/index.js +3 -3
- package/browser/standalone/without-parser.js +2 -2
- package/browser/without-parser.js +3 -3
- package/lib/cjs/components/CollapseButton.js +5 -6
- package/lib/cjs/components/CollapseButton.js.map +1 -1
- package/lib/cjs/components/Schema.js +19 -10
- package/lib/cjs/components/Schema.js.map +1 -1
- package/lib/cjs/config/config.js.map +1 -1
- package/lib/cjs/config/default.js +3 -0
- package/lib/cjs/config/default.js.map +1 -1
- package/lib/cjs/constants.js +4 -2
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/containers/Messages/MessageExample.js +5 -5
- package/lib/cjs/containers/Messages/MessageExample.js.map +1 -1
- package/lib/cjs/containers/Operations/Operation.js +4 -1
- package/lib/cjs/containers/Operations/Operation.js.map +1 -1
- package/lib/cjs/containers/Sidebar/Sidebar.js +5 -2
- package/lib/cjs/containers/Sidebar/Sidebar.js.map +1 -1
- package/lib/esm/components/CollapseButton.js +5 -6
- package/lib/esm/components/CollapseButton.js.map +1 -1
- package/lib/esm/components/Schema.js +20 -11
- package/lib/esm/components/Schema.js.map +1 -1
- package/lib/esm/config/config.js.map +1 -1
- package/lib/esm/config/default.js +3 -0
- package/lib/esm/config/default.js.map +1 -1
- package/lib/esm/constants.js +2 -0
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/containers/Messages/MessageExample.js +5 -5
- package/lib/esm/containers/Messages/MessageExample.js.map +1 -1
- package/lib/esm/containers/Operations/Operation.js +5 -2
- package/lib/esm/containers/Operations/Operation.js.map +1 -1
- package/lib/esm/containers/Sidebar/Sidebar.js +6 -3
- package/lib/esm/containers/Sidebar/Sidebar.js.map +1 -1
- package/lib/types/components/CollapseButton.d.ts +1 -0
- package/lib/types/components/CollapseButton.d.ts.map +1 -1
- package/lib/types/components/Schema.d.ts.map +1 -1
- package/lib/types/config/config.d.ts +2 -0
- package/lib/types/config/config.d.ts.map +1 -1
- package/lib/types/config/default.d.ts.map +1 -1
- package/lib/types/constants.d.ts +2 -0
- package/lib/types/constants.d.ts.map +1 -1
- package/lib/types/containers/Messages/MessageExample.d.ts.map +1 -1
- package/lib/types/containers/Operations/Operation.d.ts.map +1 -1
- package/lib/types/containers/Sidebar/Sidebar.d.ts.map +1 -1
- package/package.json +2 -1
- package/styles/default.css +25 -0
- package/styles/default.min.css +1 -1
|
@@ -27,13 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.CollapseButton = void 0;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
|
+
var hi_1 = require("react-icons/hi");
|
|
30
31
|
var CollapseButton = function (_a) {
|
|
31
|
-
var chevronProps = _a.chevronProps, children = _a.children, rest = __rest(_a, ["chevronProps", "children"]);
|
|
32
|
-
return (react_1.default.createElement("button", __assign({}, rest, { className: "focus:outline-none ".concat(rest.className) }),
|
|
33
|
-
children,
|
|
34
|
-
react_1.default.createElement(
|
|
35
|
-
'') }),
|
|
36
|
-
react_1.default.createElement("polygon", { points: "17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 " }))));
|
|
32
|
+
var chevronProps = _a.chevronProps, _b = _a.expanded, expanded = _b === void 0 ? false : _b, children = _a.children, rest = __rest(_a, ["chevronProps", "expanded", "children"]);
|
|
33
|
+
return (react_1.default.createElement("button", __assign({}, rest, { className: "focus:outline-none ".concat(rest.className), type: "button" }),
|
|
34
|
+
react_1.default.createElement("div", { className: "inline-block" }, children),
|
|
35
|
+
react_1.default.createElement(hi_1.HiChevronRight, __assign({}, chevronProps, { className: "inline-block align-baseline cursor-pointer ml-0.5 -mb-1 w-5 h-5 transform transition-transform duration-150 ease-linear ".concat(expanded ? '-rotate-90' : '', " ").concat((chevronProps === null || chevronProps === void 0 ? void 0 : chevronProps.className) || '') }))));
|
|
37
36
|
};
|
|
38
37
|
exports.CollapseButton = CollapseButton;
|
|
39
38
|
//# sourceMappingURL=CollapseButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollapseButton.js","sourceRoot":"","sources":["../../../src/components/CollapseButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAmE;
|
|
1
|
+
{"version":3,"file":"CollapseButton.js","sourceRoot":"","sources":["../../../src/components/CollapseButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAmE;AACnE,qCAAgD;AAOzC,IAAM,cAAc,GAAmC,UAAC,EAK9D;IAJC,IAAA,YAAY,kBAAA,EACZ,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,QAAQ,cAAA,EACL,IAAI,cAJsD,wCAK9D,CADQ;IACH,OAAA,CACJ,qDACM,IAAI,IACR,SAAS,EAAE,6BAAsB,IAAI,CAAC,SAAS,CAAE,EACjD,IAAI,EAAC,QAAQ;QAEb,uCAAK,SAAS,EAAC,cAAc,IAAE,QAAQ,CAAO;QAC9C,8BAAC,mBAAc,eACT,YAAY,IAChB,SAAS,EAAE,kIACT,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,cAC1B,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,KAAI,EAAE,CAAE,IACnC,CACK,CACV,CAAA;CAAA,CAAC;AAnBW,QAAA,cAAc,kBAmBzB","sourcesContent":["import React, { ButtonHTMLAttributes, SVGAttributes } from 'react';\nimport { HiChevronRight } from 'react-icons/hi';\n\ninterface Props extends ButtonHTMLAttributes<HTMLButtonElement> {\n chevronProps?: SVGAttributes<SVGElement>;\n expanded?: boolean;\n}\n\nexport const CollapseButton: React.FunctionComponent<Props> = ({\n chevronProps,\n expanded = false,\n children,\n ...rest\n}) => (\n <button\n {...rest}\n className={`focus:outline-none ${rest.className}`}\n type=\"button\"\n >\n <div className=\"inline-block\">{children}</div>\n <HiChevronRight\n {...chevronProps}\n className={`inline-block align-baseline cursor-pointer ml-0.5 -mb-1 w-5 h-5 transform transition-transform duration-150 ease-linear ${\n expanded ? '-rotate-90' : ''\n } ${chevronProps?.className || ''}`}\n />\n </button>\n);\n"]}
|
|
@@ -27,11 +27,21 @@ exports.Schema = void 0;
|
|
|
27
27
|
var react_1 = __importStar(require("react"));
|
|
28
28
|
var index_1 = require("./index");
|
|
29
29
|
var helpers_1 = require("../helpers");
|
|
30
|
-
var SchemaContext = react_1.default.createContext({
|
|
30
|
+
var SchemaContext = react_1.default.createContext({
|
|
31
|
+
reverse: false,
|
|
32
|
+
deepExpanded: false,
|
|
33
|
+
});
|
|
31
34
|
var Schema = function (_a) {
|
|
32
|
-
var schemaName = _a.schemaName, schema = _a.schema, _b = _a.required, required = _b === void 0 ? false : _b, _c = _a.isPatternProperty, isPatternProperty = _c === void 0 ? false : _c, _d = _a.isProperty, isProperty = _d === void 0 ? false : _d, _e = _a.isCircular, isCircular = _e === void 0 ? false : _e, dependentRequired = _a.dependentRequired, _f = _a.expanded,
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
+
var schemaName = _a.schemaName, schema = _a.schema, _b = _a.required, required = _b === void 0 ? false : _b, _c = _a.isPatternProperty, isPatternProperty = _c === void 0 ? false : _c, _d = _a.isProperty, isProperty = _d === void 0 ? false : _d, _e = _a.isCircular, isCircular = _e === void 0 ? false : _e, dependentRequired = _a.dependentRequired, _f = _a.expanded, propExpanded = _f === void 0 ? false : _f, _g = _a.onlyTitle, onlyTitle = _g === void 0 ? false : _g;
|
|
36
|
+
var _h = (0, react_1.useContext)(SchemaContext), reverse = _h.reverse, deepExpanded = _h.deepExpanded;
|
|
37
|
+
var _j = (0, react_1.useState)(propExpanded), expanded = _j[0], setExpanded = _j[1];
|
|
38
|
+
var _k = (0, react_1.useState)(false), deepExpand = _k[0], setDeepExpand = _k[1];
|
|
39
|
+
(0, react_1.useEffect)(function () {
|
|
40
|
+
setDeepExpand(deepExpanded);
|
|
41
|
+
}, [deepExpanded, setDeepExpand]);
|
|
42
|
+
(0, react_1.useEffect)(function () {
|
|
43
|
+
setExpanded(deepExpand);
|
|
44
|
+
}, [deepExpand, setExpanded]);
|
|
35
45
|
if (!schema ||
|
|
36
46
|
(typeof schemaName === 'string' &&
|
|
37
47
|
((schemaName === null || schemaName === void 0 ? void 0 : schemaName.startsWith('x-parser-')) ||
|
|
@@ -59,7 +69,6 @@ var Schema = function (_a) {
|
|
|
59
69
|
schemaItems.isCircular() ||
|
|
60
70
|
schemaItems.ext('x-parser-circular') ||
|
|
61
71
|
false;
|
|
62
|
-
uid = schemaItems.uid();
|
|
63
72
|
if (isCircular &&
|
|
64
73
|
typeof schemaItems.circularSchema === 'function') {
|
|
65
74
|
schemaType = helpers_1.SchemaHelpers.toSchemaType(schemaItems.circularSchema());
|
|
@@ -71,13 +80,13 @@ var Schema = function (_a) {
|
|
|
71
80
|
}
|
|
72
81
|
var styledSchemaName = isProperty ? 'italic' : '';
|
|
73
82
|
var renderedSchemaName = typeof schemaName === 'string' ? (react_1.default.createElement("span", { className: "break-words text-sm ".concat(styledSchemaName) }, schemaName)) : (schemaName);
|
|
74
|
-
return (react_1.default.createElement(SchemaContext.Provider, { value: { reverse: !reverse } },
|
|
83
|
+
return (react_1.default.createElement(SchemaContext.Provider, { value: { reverse: !reverse, deepExpanded: deepExpand } },
|
|
75
84
|
react_1.default.createElement("div", null,
|
|
76
85
|
react_1.default.createElement("div", { className: "flex py-2" },
|
|
77
86
|
react_1.default.createElement("div", { className: "".concat(onlyTitle ? '' : 'min-w-1/4', " mr-2") },
|
|
78
|
-
isExpandable && !isCircular ? (react_1.default.createElement(
|
|
79
|
-
|
|
80
|
-
} },
|
|
87
|
+
isExpandable && !isCircular ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
88
|
+
react_1.default.createElement(index_1.CollapseButton, { onClick: function () { return setExpanded(function (prev) { return !prev; }); }, expanded: expanded }, renderedSchemaName),
|
|
89
|
+
react_1.default.createElement("button", { type: "button", onClick: function () { return setDeepExpand(function (prev) { return !prev; }); }, className: "ml-1 text-sm text-gray-500" }, deepExpand ? 'Collapse all' : 'Expand all'))) : (react_1.default.createElement("span", { className: "break-words text-sm ".concat(isProperty ? 'italic' : '') }, schemaName)),
|
|
81
90
|
isPatternProperty && (react_1.default.createElement("div", { className: "text-gray-500 text-xs italic" }, "(pattern property)")),
|
|
82
91
|
required && react_1.default.createElement("div", { className: "text-red-600 text-xs" }, "required"),
|
|
83
92
|
dependentRequired && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
@@ -132,7 +141,7 @@ var Schema = function (_a) {
|
|
|
132
141
|
' ',
|
|
133
142
|
schema.examples().map(function (e, idx) { return (react_1.default.createElement("li", { key: idx, className: "border inline-block text-orange-600 rounded ml-1 py-0 px-2 break-all" },
|
|
134
143
|
react_1.default.createElement("span", null, helpers_1.SchemaHelpers.prettifyValue(e)))); }))))))),
|
|
135
|
-
isCircular || !isExpandable ? null : (react_1.default.createElement("div", { className: "rounded p-4 py-2 border bg-gray-100 ".concat(reverse ? 'bg-gray-200' : '', " ").concat(
|
|
144
|
+
isCircular || !isExpandable ? null : (react_1.default.createElement("div", { className: "rounded p-4 py-2 border bg-gray-100 ".concat(reverse ? 'bg-gray-200' : '', " ").concat(expanded ? 'block' : 'hidden') },
|
|
136
145
|
react_1.default.createElement(SchemaProperties, { schema: schema }),
|
|
137
146
|
react_1.default.createElement(SchemaItems, { schema: schema }),
|
|
138
147
|
schema.oneOf() &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../../src/components/Schema.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAoD;AAGpD,iCAAqE;AACrE,sCAA2C;AAc3C,IAAM,aAAa,GA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AAC;KACb;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE;QAClC,OAAO,IAAI,CAAC;KACb;IAED,IAAM,eAAe,GAAG,MAAM,CAAC,eAAe,EAAS,CAAC;IACxD,IAAI,eAAe,KAAK,IAAI,IAAI,eAAe,KAAK,SAAS,EAAE;QAC7D,OAAO,CACL,qCAAG,SAAS,EAAC,4BAA4B,oCAErC,CACL,CAAC;KACH;IACD,IAAI,eAAe,KAAK,KAAK,EAAE;QAC7B,OAAO,CACL,qCAAG,SAAS,EAAC,4BAA4B;;YAClB,oDAAoB;wBACvC,CACL,CAAC;KACH;IACD,OAAO,8BAAC,cAAM,IAAC,UAAU,EAAC,mBAAmB,EAAC,MAAM,EAAE,eAAe,GAAI,CAAC;AAC5E,CAAC,CAAC","sourcesContent":["import React, { useState, useContext } from 'react';\nimport { Schema as SchemaType } from '@asyncapi/parser';\n\nimport { Href, CollapseButton, Markdown, Extensions } from './index';\nimport { SchemaHelpers } from '../helpers';\n\ninterface Props {\n schemaName?: React.ReactNode;\n schema?: SchemaType;\n required?: boolean;\n isPatternProperty?: boolean;\n isProperty?: boolean;\n isCircular?: boolean;\n dependentRequired?: string[];\n expanded?: boolean;\n onlyTitle?: boolean;\n}\n\nconst SchemaContext = React.createContext({ reverse: false });\n\nexport const Schema: React.FunctionComponent<Props> = ({\n schemaName,\n schema,\n required = false,\n isPatternProperty = false,\n isProperty = false,\n isCircular = false,\n dependentRequired,\n expanded = false,\n onlyTitle = false,\n}) => {\n const { reverse } = useContext(SchemaContext);\n const [expand, setExpand] = useState(expanded);\n\n if (\n !schema ||\n (typeof schemaName === 'string' &&\n (schemaName?.startsWith('x-parser-') ||\n schemaName?.startsWith('x-schema-private-')))\n ) {\n return null;\n }\n\n const dependentSchemas = SchemaHelpers.getDependentSchemas(schema);\n\n const constraints = SchemaHelpers.humanizeConstraints(schema);\n const externalDocs = schema.externalDocs();\n\n const renderType = schema.ext(SchemaHelpers.extRenderType) !== false;\n const rawValue = schema.ext(SchemaHelpers.extRawValue) === true;\n const parameterLocation = schema.ext(SchemaHelpers.extParameterLocation);\n const isExpandable = SchemaHelpers.isExpandable(schema) || dependentSchemas;\n\n let schemaType = SchemaHelpers.toSchemaType(schema);\n isCircular =\n isCircular ||\n schema.isCircular() ||\n schema.ext('x-parser-circular') ||\n false;\n let uid = schema.uid();\n\n const schemaItems = schema.items();\n if (schemaItems && !Array.isArray(schemaItems)) {\n /**\n * fallback for older logic for circular references:\n *\n * checking uid for circular items\n * `x-parser-circular` extension is added to every schema which has circular `items` field,\n * so we must check that `items` is schema (not array of schemas) and infer UID of schema to display which schema is circular (by the name of schema)\n */\n isCircular =\n isCircular ||\n schemaItems.isCircular() ||\n schemaItems.ext('x-parser-circular') ||\n false;\n uid = schemaItems.uid();\n if (\n isCircular &&\n typeof (schemaItems as any).circularSchema === 'function'\n ) {\n schemaType = SchemaHelpers.toSchemaType(\n (schemaItems as any).circularSchema(),\n );\n }\n } else if (\n isCircular &&\n typeof (schema as any).circularSchema === 'function'\n ) {\n schemaType = SchemaHelpers.toSchemaType((schema as any).circularSchema());\n }\n\n const styledSchemaName = isProperty ? 'italic' : '';\n const renderedSchemaName =\n typeof schemaName === 'string' ? (\n <span className={`break-words text-sm ${styledSchemaName}`}>\n {schemaName}\n </span>\n ) : (\n schemaName\n );\n\n return (\n <SchemaContext.Provider value={{ reverse: !reverse }}>\n <div>\n <div className=\"flex py-2\">\n <div className={`${onlyTitle ? '' : 'min-w-1/4'} mr-2`}>\n {isExpandable && !isCircular ? (\n <CollapseButton\n onClick={() => setExpand(prev => !prev)}\n chevronProps={{\n className: expand ? '-rotate-180' : '-rotate-90',\n }}\n >\n {renderedSchemaName}\n </CollapseButton>\n ) : (\n <span\n className={`break-words text-sm ${isProperty ? 'italic' : ''}`}\n >\n {schemaName}\n </span>\n )}\n {isPatternProperty && (\n <div className=\"text-gray-500 text-xs italic\">\n (pattern property)\n </div>\n )}\n {required && <div className=\"text-red-600 text-xs\">required</div>}\n {dependentRequired && (\n <>\n <div className=\"text-gray-500 text-xs\">\n required when defined:\n </div>\n <div className=\"text-red-600 text-xs\">\n {dependentRequired.join(', ')}\n </div>\n </>\n )}\n {schema.deprecated() && (\n <div className=\"text-red-600 text-xs\">deprecated</div>\n )}\n {schema.writeOnly() && (\n <div className=\"text-gray-500 text-xs\">write-only</div>\n )}\n {schema.readOnly() && (\n <div className=\"text-gray-500 text-xs\">read-only</div>\n )}\n </div>\n {rawValue ? (\n <div>\n <div className=\"text-sm\">{schema.const()}</div>\n </div>\n ) : (\n <div>\n <div>\n {renderType && (\n <div className=\"capitalize text-sm text-teal-500 font-bold inline-block mr-2\">\n {isCircular ? `${schemaType} [CIRCULAR]` : schemaType}\n </div>\n )}\n <div className=\"inline-block\">\n {schema.format() && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n format: {schema.format()}\n </span>\n )}\n\n {/* related to string */}\n {schema.pattern() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded mr-2 p-1 text-xs\">\n must match: {schema.pattern()}\n </span>\n )}\n {schema.contentMediaType() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n media type: {schema.contentMediaType()}\n </span>\n )}\n {schema.contentEncoding() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n encoding: {schema.contentEncoding()}\n </span>\n )}\n\n {/* constraints */}\n {!!constraints.length &&\n constraints.map(c => (\n <span\n className=\"bg-purple-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\"\n key={c}\n >\n {c}\n </span>\n ))}\n\n {uid && !uid.startsWith('<anonymous-') && (\n <span className=\"border text-orange-600 rounded mr-2 p-1 text-xs\">\n uid: {uid}\n </span>\n )}\n </div>\n\n {schema.hasDescription() && (\n <div>\n <Markdown>{schema.description()}</Markdown>\n </div>\n )}\n\n {schema.default() !== undefined && (\n <div className=\"text-xs\">\n Default value:\n <span className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\">\n {SchemaHelpers.prettifyValue(schema.default())}\n </span>\n </div>\n )}\n {schema.const() !== undefined && (\n <div className=\"text-xs\">\n Const:\n <span className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\">\n {SchemaHelpers.prettifyValue(schema.const())}\n </span>\n </div>\n )}\n {schema.enum() && (\n <ul className=\"text-xs\">\n Allowed values:{' '}\n {schema.enum().map((e, idx) => (\n <li\n key={idx}\n className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\"\n >\n <span>{SchemaHelpers.prettifyValue(e)}</span>\n </li>\n ))}\n </ul>\n )}\n {parameterLocation && (\n <div className=\"text-xs\">\n Parameter location:{' '}\n <span className=\"border text-orange-600 rounded mr-2 p-1 text-xs\">\n {parameterLocation}\n </span>\n </div>\n )}\n {externalDocs && (\n <span className=\"border border-solid border-orange-300 hover:bg-orange-300 hover:text-orange-600 text-orange-500 font-bold no-underline text-xs uppercase rounded px-2 py-0\">\n <Href\n href={externalDocs.url()}\n title={externalDocs.description() || ''}\n >\n Documentation\n </Href>\n </span>\n )}\n {schema.examples() && (\n <ul className=\"text-xs\">\n Examples values:{' '}\n {schema.examples().map((e, idx) => (\n <li\n key={idx}\n className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2 break-all\"\n >\n <span>{SchemaHelpers.prettifyValue(e)}</span>\n </li>\n ))}\n </ul>\n )}\n </div>\n </div>\n )}\n </div>\n\n {isCircular || !isExpandable ? null : (\n <div\n className={`rounded p-4 py-2 border bg-gray-100 ${\n reverse ? 'bg-gray-200' : ''\n } ${expand ? 'block' : 'hidden'}`}\n >\n <SchemaProperties schema={schema} />\n <SchemaItems schema={schema} />\n\n {schema.oneOf() &&\n schema\n .oneOf()\n .map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Adheres to:' : 'Or to:'}\n />\n ))}\n {schema.anyOf() &&\n schema\n .anyOf()\n .map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Can adhere to:' : 'Or to:'}\n />\n ))}\n {schema.allOf() &&\n schema\n .allOf()\n .map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Consists of:' : 'And with:'}\n />\n ))}\n {schema.not() && (\n <Schema schema={schema.not()} schemaName=\"Cannot adhere to:\" />\n )}\n\n {schema.propertyNames() && (\n <Schema\n schema={schema.propertyNames()}\n schemaName=\"Property names must adhere to:\"\n />\n )}\n {schema.contains() && (\n <Schema\n schema={schema.contains()}\n schemaName=\"Array must contain at least one of:\"\n />\n )}\n\n {schema.if() && (\n <Schema schema={schema.if()} schemaName=\"If schema adheres to:\" />\n )}\n {schema.then() && (\n <Schema\n schema={schema.then()}\n schemaName=\"Then must adhere to:\"\n />\n )}\n {schema.else() && (\n <Schema schema={schema.else()} schemaName=\"Otherwise:\" />\n )}\n\n {dependentSchemas && (\n <Schema\n schema={dependentSchemas}\n schemaName=\"Dependent schemas:\"\n />\n )}\n\n <Extensions item={schema} />\n\n <AdditionalProperties schema={schema} />\n <AdditionalItems schema={schema} />\n </div>\n )}\n </div>\n </SchemaContext.Provider>\n );\n};\n\ninterface SchemaPropertiesProps {\n schema: SchemaType;\n}\n\nconst SchemaProperties: React.FunctionComponent<SchemaPropertiesProps> = ({\n schema,\n}) => {\n const properties = schema.properties() || {};\n if (!Object.keys(properties)) {\n return null;\n }\n\n const required = schema.required() || [];\n const patternProperties = schema.patternProperties();\n const circularProps = schema.ext('x-parser-circular-props') || [];\n\n return (\n <>\n {Object.entries(properties).map(([propertyName, property]) => (\n <Schema\n schema={property}\n schemaName={propertyName}\n required={required.includes(propertyName)}\n isProperty={true}\n isCircular={circularProps.includes(propertyName)}\n dependentRequired={SchemaHelpers.getDependentRequired(\n propertyName,\n schema,\n )}\n key={propertyName}\n />\n ))}\n {Object.entries(patternProperties).map(([propertyName, property]) => (\n <Schema\n schema={property}\n schemaName={propertyName}\n isPatternProperty={true}\n isProperty={true}\n isCircular={circularProps.includes(propertyName)}\n key={propertyName}\n />\n ))}\n </>\n );\n};\n\ninterface AdditionalPropertiesProps {\n schema: SchemaType;\n}\n\nconst AdditionalProperties: React.FunctionComponent<AdditionalPropertiesProps> = ({\n schema,\n}) => {\n if (schema.ext(SchemaHelpers.extRenderAdditionalInfo) === false) {\n return null;\n }\n\n let type = schema.type();\n type = Array.isArray(type) ? type : [type];\n if (!type.includes('object')) {\n return null;\n }\n\n const additionalProperties = schema.additionalProperties();\n if (additionalProperties === true || additionalProperties === undefined) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional properties are allowed.\n </p>\n );\n }\n if (additionalProperties === false) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional properties are <strong>NOT</strong> allowed.\n </p>\n );\n }\n return (\n <Schema schemaName=\"Additional properties:\" schema={additionalProperties} />\n );\n};\n\ninterface SchemaItemsProps {\n schema: SchemaType;\n}\n\nconst SchemaItems: React.FunctionComponent<SchemaItemsProps> = ({ schema }) => {\n let type = schema.type();\n type = Array.isArray(type) ? type : [type];\n if (!type.includes('array')) {\n return null;\n }\n const items = schema.items();\n\n // object in items\n if (\n items &&\n !Array.isArray(items) &&\n Object.keys(items.properties() || {}).length\n ) {\n return <SchemaProperties schema={items} />;\n } else if (Array.isArray(items)) {\n return (\n <>\n {items.map((item, idx) => (\n <Schema schema={item} schemaName={`${idx + 1} item:`} key={idx} />\n ))}\n </>\n );\n }\n return <Schema schema={items} schemaName=\"Items:\" />;\n};\n\ninterface AdditionalItemsProps {\n schema: SchemaType;\n}\n\nconst AdditionalItems: React.FunctionComponent<AdditionalItemsProps> = ({\n schema,\n}) => {\n if (schema.ext(SchemaHelpers.extRenderAdditionalInfo) === false) {\n return null;\n }\n\n let type = schema.type();\n type = Array.isArray(type) ? type : [type];\n if (!type.includes('array')) {\n return null;\n }\n if (!Array.isArray(schema.items())) {\n return null;\n }\n\n const additionalItems = schema.additionalItems() as any;\n if (additionalItems === true || additionalItems === undefined) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional items are allowed.\n </p>\n );\n }\n if (additionalItems === false) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional items are <strong>NOT</strong> allowed.\n </p>\n );\n }\n return <Schema schemaName=\"Additional items:\" schema={additionalItems} />;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../../src/components/Schema.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+D;AAG/D,iCAAqE;AACrE,sCAA2C;AAc3C,IAAM,aAAa,GAAG,eAAK,CAAC,aAAa,CAAC;IACxC,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,KAAK;CACpB,CAAC,CAAC;AAEI,IAAM,MAAM,GAAmC,UAAC,EAUtD;QATC,UAAU,gBAAA,EACV,MAAM,YAAA,EACN,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,yBAAyB,EAAzB,iBAAiB,mBAAG,KAAK,KAAA,EACzB,kBAAkB,EAAlB,UAAU,mBAAG,KAAK,KAAA,EAClB,kBAAkB,EAAlB,UAAU,mBAAG,KAAK,KAAA,EAClB,iBAAiB,uBAAA,EACjB,gBAA8B,EAApB,YAAY,mBAAG,KAAK,KAAA,EAC9B,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA;IAEX,IAAA,KAA4B,IAAA,kBAAU,EAAC,aAAa,CAAC,EAAnD,OAAO,aAAA,EAAE,YAAY,kBAA8B,CAAC;IACtD,IAAA,KAA0B,IAAA,gBAAQ,EAAC,YAAY,CAAC,EAA/C,QAAQ,QAAA,EAAE,WAAW,QAA0B,CAAC;IACjD,IAAA,KAA8B,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAA5C,UAAU,QAAA,EAAE,aAAa,QAAmB,CAAC;IAEpD,IAAA,iBAAS,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O,CACL,qCAAG,SAAS,EAAC,4BAA4B,oCAErC,CACL,CAAC;KACH;IACD,IAAI,eAAe,KAAK,KAAK,EAAE;QAC7B,OAAO,CACL,qCAAG,SAAS,EAAC,4BAA4B;;YAClB,oDAAoB;wBACvC,CACL,CAAC;KACH;IACD,OAAO,8BAAC,cAAM,IAAC,UAAU,EAAC,mBAAmB,EAAC,MAAM,EAAE,eAAe,GAAI,CAAC;AAC5E,CAAC,CAAC","sourcesContent":["import React, { useState, useEffect, useContext } from 'react';\nimport { Schema as SchemaType } from '@asyncapi/parser';\n\nimport { Href, CollapseButton, Markdown, Extensions } from './index';\nimport { SchemaHelpers } from '../helpers';\n\ninterface Props {\n schemaName?: React.ReactNode;\n schema?: SchemaType;\n required?: boolean;\n isPatternProperty?: boolean;\n isProperty?: boolean;\n isCircular?: boolean;\n dependentRequired?: string[];\n expanded?: boolean;\n onlyTitle?: boolean;\n}\n\nconst SchemaContext = React.createContext({\n reverse: false,\n deepExpanded: false,\n});\n\nexport const Schema: React.FunctionComponent<Props> = ({\n schemaName,\n schema,\n required = false,\n isPatternProperty = false,\n isProperty = false,\n isCircular = false,\n dependentRequired,\n expanded: propExpanded = false,\n onlyTitle = false,\n}) => {\n const { reverse, deepExpanded } = useContext(SchemaContext);\n const [expanded, setExpanded] = useState(propExpanded);\n const [deepExpand, setDeepExpand] = useState(false);\n\n useEffect(() => {\n setDeepExpand(deepExpanded);\n }, [deepExpanded, setDeepExpand]);\n\n useEffect(() => {\n setExpanded(deepExpand);\n }, [deepExpand, setExpanded]);\n\n if (\n !schema ||\n (typeof schemaName === 'string' &&\n (schemaName?.startsWith('x-parser-') ||\n schemaName?.startsWith('x-schema-private-')))\n ) {\n return null;\n }\n\n const dependentSchemas = SchemaHelpers.getDependentSchemas(schema);\n\n const constraints = SchemaHelpers.humanizeConstraints(schema);\n const externalDocs = schema.externalDocs();\n\n const renderType = schema.ext(SchemaHelpers.extRenderType) !== false;\n const rawValue = schema.ext(SchemaHelpers.extRawValue) === true;\n const parameterLocation = schema.ext(SchemaHelpers.extParameterLocation);\n const isExpandable = SchemaHelpers.isExpandable(schema) || dependentSchemas;\n\n let schemaType = SchemaHelpers.toSchemaType(schema);\n isCircular =\n isCircular ||\n schema.isCircular() ||\n schema.ext('x-parser-circular') ||\n false;\n const uid = schema.uid();\n\n const schemaItems = schema.items();\n if (schemaItems && !Array.isArray(schemaItems)) {\n /**\n * fallback for older logic for circular references:\n *\n * checking uid for circular items\n * `x-parser-circular` extension is added to every schema which has circular `items` field,\n * so we must check that `items` is schema (not array of schemas) and infer UID of schema to display which schema is circular (by the name of schema)\n */\n isCircular =\n isCircular ||\n schemaItems.isCircular() ||\n schemaItems.ext('x-parser-circular') ||\n false;\n if (\n isCircular &&\n typeof (schemaItems as any).circularSchema === 'function'\n ) {\n schemaType = SchemaHelpers.toSchemaType(\n (schemaItems as any).circularSchema(),\n );\n }\n } else if (\n isCircular &&\n typeof (schema as any).circularSchema === 'function'\n ) {\n schemaType = SchemaHelpers.toSchemaType((schema as any).circularSchema());\n }\n\n const styledSchemaName = isProperty ? 'italic' : '';\n const renderedSchemaName =\n typeof schemaName === 'string' ? (\n <span className={`break-words text-sm ${styledSchemaName}`}>\n {schemaName}\n </span>\n ) : (\n schemaName\n );\n\n return (\n <SchemaContext.Provider\n value={{ reverse: !reverse, deepExpanded: deepExpand }}\n >\n <div>\n <div className=\"flex py-2\">\n <div className={`${onlyTitle ? '' : 'min-w-1/4'} mr-2`}>\n {isExpandable && !isCircular ? (\n <>\n <CollapseButton\n onClick={() => setExpanded(prev => !prev)}\n expanded={expanded}\n >\n {renderedSchemaName}\n </CollapseButton>\n <button\n type=\"button\"\n onClick={() => setDeepExpand(prev => !prev)}\n className=\"ml-1 text-sm text-gray-500\"\n >\n {deepExpand ? 'Collapse all' : 'Expand all'}\n </button>\n </>\n ) : (\n <span\n className={`break-words text-sm ${isProperty ? 'italic' : ''}`}\n >\n {schemaName}\n </span>\n )}\n {isPatternProperty && (\n <div className=\"text-gray-500 text-xs italic\">\n (pattern property)\n </div>\n )}\n {required && <div className=\"text-red-600 text-xs\">required</div>}\n {dependentRequired && (\n <>\n <div className=\"text-gray-500 text-xs\">\n required when defined:\n </div>\n <div className=\"text-red-600 text-xs\">\n {dependentRequired.join(', ')}\n </div>\n </>\n )}\n {schema.deprecated() && (\n <div className=\"text-red-600 text-xs\">deprecated</div>\n )}\n {schema.writeOnly() && (\n <div className=\"text-gray-500 text-xs\">write-only</div>\n )}\n {schema.readOnly() && (\n <div className=\"text-gray-500 text-xs\">read-only</div>\n )}\n </div>\n {rawValue ? (\n <div>\n <div className=\"text-sm\">{schema.const()}</div>\n </div>\n ) : (\n <div>\n <div>\n {renderType && (\n <div className=\"capitalize text-sm text-teal-500 font-bold inline-block mr-2\">\n {isCircular ? `${schemaType} [CIRCULAR]` : schemaType}\n </div>\n )}\n <div className=\"inline-block\">\n {schema.format() && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n format: {schema.format()}\n </span>\n )}\n\n {/* related to string */}\n {schema.pattern() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded mr-2 p-1 text-xs\">\n must match: {schema.pattern()}\n </span>\n )}\n {schema.contentMediaType() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n media type: {schema.contentMediaType()}\n </span>\n )}\n {schema.contentEncoding() !== undefined && (\n <span className=\"bg-yellow-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\">\n encoding: {schema.contentEncoding()}\n </span>\n )}\n\n {/* constraints */}\n {!!constraints.length &&\n constraints.map(c => (\n <span\n className=\"bg-purple-600 font-bold no-underline text-white rounded lowercase mr-2 p-1 text-xs\"\n key={c}\n >\n {c}\n </span>\n ))}\n\n {uid && !uid.startsWith('<anonymous-') && (\n <span className=\"border text-orange-600 rounded mr-2 p-1 text-xs\">\n uid: {uid}\n </span>\n )}\n </div>\n\n {schema.hasDescription() && (\n <div>\n <Markdown>{schema.description()}</Markdown>\n </div>\n )}\n\n {schema.default() !== undefined && (\n <div className=\"text-xs\">\n Default value:\n <span className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\">\n {SchemaHelpers.prettifyValue(schema.default())}\n </span>\n </div>\n )}\n {schema.const() !== undefined && (\n <div className=\"text-xs\">\n Const:\n <span className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\">\n {SchemaHelpers.prettifyValue(schema.const())}\n </span>\n </div>\n )}\n {schema.enum() && (\n <ul className=\"text-xs\">\n Allowed values:{' '}\n {schema.enum().map((e, idx) => (\n <li\n key={idx}\n className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2\"\n >\n <span>{SchemaHelpers.prettifyValue(e)}</span>\n </li>\n ))}\n </ul>\n )}\n {parameterLocation && (\n <div className=\"text-xs\">\n Parameter location:{' '}\n <span className=\"border text-orange-600 rounded mr-2 p-1 text-xs\">\n {parameterLocation}\n </span>\n </div>\n )}\n {externalDocs && (\n <span className=\"border border-solid border-orange-300 hover:bg-orange-300 hover:text-orange-600 text-orange-500 font-bold no-underline text-xs uppercase rounded px-2 py-0\">\n <Href\n href={externalDocs.url()}\n title={externalDocs.description() || ''}\n >\n Documentation\n </Href>\n </span>\n )}\n {schema.examples() && (\n <ul className=\"text-xs\">\n Examples values:{' '}\n {schema.examples().map((e, idx) => (\n <li\n key={idx}\n className=\"border inline-block text-orange-600 rounded ml-1 py-0 px-2 break-all\"\n >\n <span>{SchemaHelpers.prettifyValue(e)}</span>\n </li>\n ))}\n </ul>\n )}\n </div>\n </div>\n )}\n </div>\n\n {isCircular || !isExpandable ? null : (\n <div\n className={`rounded p-4 py-2 border bg-gray-100 ${\n reverse ? 'bg-gray-200' : ''\n } ${expanded ? 'block' : 'hidden'}`}\n >\n <SchemaProperties schema={schema} />\n <SchemaItems schema={schema} />\n\n {schema.oneOf() &&\n schema\n .oneOf()\n .map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Adheres to:' : 'Or to:'}\n />\n ))}\n {schema.anyOf() &&\n schema\n .anyOf()\n .map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Can adhere to:' : 'Or to:'}\n />\n ))}\n {schema.allOf() &&\n schema\n .allOf()\n .map((s, idx) => (\n <Schema\n key={idx}\n schema={s}\n schemaName={idx === 0 ? 'Consists of:' : 'And with:'}\n />\n ))}\n {schema.not() && (\n <Schema schema={schema.not()} schemaName=\"Cannot adhere to:\" />\n )}\n\n {schema.propertyNames() && (\n <Schema\n schema={schema.propertyNames()}\n schemaName=\"Property names must adhere to:\"\n />\n )}\n {schema.contains() && (\n <Schema\n schema={schema.contains()}\n schemaName=\"Array must contain at least one of:\"\n />\n )}\n\n {schema.if() && (\n <Schema schema={schema.if()} schemaName=\"If schema adheres to:\" />\n )}\n {schema.then() && (\n <Schema\n schema={schema.then()}\n schemaName=\"Then must adhere to:\"\n />\n )}\n {schema.else() && (\n <Schema schema={schema.else()} schemaName=\"Otherwise:\" />\n )}\n\n {dependentSchemas && (\n <Schema\n schema={dependentSchemas}\n schemaName=\"Dependent schemas:\"\n />\n )}\n\n <Extensions item={schema} />\n\n <AdditionalProperties schema={schema} />\n <AdditionalItems schema={schema} />\n </div>\n )}\n </div>\n </SchemaContext.Provider>\n );\n};\n\ninterface SchemaPropertiesProps {\n schema: SchemaType;\n}\n\nconst SchemaProperties: React.FunctionComponent<SchemaPropertiesProps> = ({\n schema,\n}) => {\n const properties = schema.properties() || {};\n if (!Object.keys(properties)) {\n return null;\n }\n\n const required = schema.required() || [];\n const patternProperties = schema.patternProperties();\n const circularProps = schema.ext('x-parser-circular-props') || [];\n\n return (\n <>\n {Object.entries(properties).map(([propertyName, property]) => (\n <Schema\n schema={property}\n schemaName={propertyName}\n required={required.includes(propertyName)}\n isProperty={true}\n isCircular={circularProps.includes(propertyName)}\n dependentRequired={SchemaHelpers.getDependentRequired(\n propertyName,\n schema,\n )}\n key={propertyName}\n />\n ))}\n {Object.entries(patternProperties).map(([propertyName, property]) => (\n <Schema\n schema={property}\n schemaName={propertyName}\n isPatternProperty={true}\n isProperty={true}\n isCircular={circularProps.includes(propertyName)}\n key={propertyName}\n />\n ))}\n </>\n );\n};\n\ninterface AdditionalPropertiesProps {\n schema: SchemaType;\n}\n\nconst AdditionalProperties: React.FunctionComponent<AdditionalPropertiesProps> = ({\n schema,\n}) => {\n if (schema.ext(SchemaHelpers.extRenderAdditionalInfo) === false) {\n return null;\n }\n\n let type = schema.type();\n type = Array.isArray(type) ? type : [type];\n if (!type.includes('object')) {\n return null;\n }\n\n const additionalProperties = schema.additionalProperties();\n if (additionalProperties === true || additionalProperties === undefined) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional properties are allowed.\n </p>\n );\n }\n if (additionalProperties === false) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional properties are <strong>NOT</strong> allowed.\n </p>\n );\n }\n return (\n <Schema schemaName=\"Additional properties:\" schema={additionalProperties} />\n );\n};\n\ninterface SchemaItemsProps {\n schema: SchemaType;\n}\n\nconst SchemaItems: React.FunctionComponent<SchemaItemsProps> = ({ schema }) => {\n let type = schema.type();\n type = Array.isArray(type) ? type : [type];\n if (!type.includes('array')) {\n return null;\n }\n const items = schema.items();\n\n // object in items\n if (\n items &&\n !Array.isArray(items) &&\n Object.keys(items.properties() || {}).length\n ) {\n return <SchemaProperties schema={items} />;\n } else if (Array.isArray(items)) {\n return (\n <>\n {items.map((item, idx) => (\n <Schema schema={item} schemaName={`${idx + 1} item:`} key={idx} />\n ))}\n </>\n );\n }\n return <Schema schema={items} schemaName=\"Items:\" />;\n};\n\ninterface AdditionalItemsProps {\n schema: SchemaType;\n}\n\nconst AdditionalItems: React.FunctionComponent<AdditionalItemsProps> = ({\n schema,\n}) => {\n if (schema.ext(SchemaHelpers.extRenderAdditionalInfo) === false) {\n return null;\n }\n\n let type = schema.type();\n type = Array.isArray(type) ? type : [type];\n if (!type.includes('array')) {\n return null;\n }\n if (!Array.isArray(schema.items())) {\n return null;\n }\n\n const additionalItems = schema.additionalItems() as any;\n if (additionalItems === true || additionalItems === undefined) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional items are allowed.\n </p>\n );\n }\n if (additionalItems === false) {\n return (\n <p className=\"mt-2 text-xs text-gray-700\">\n Additional items are <strong>NOT</strong> allowed.\n </p>\n );\n }\n return <Schema schemaName=\"Additional items:\" schema={additionalItems} />;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConfigInterface {\n schemaID?: string;\n show?: ShowConfig;\n sidebar?: SideBarConfig;\n parserOptions?: any;\n}\n\nexport interface ShowConfig {\n sidebar?: boolean;\n info?: boolean;\n servers?: boolean;\n operations?: boolean;\n messages?: boolean;\n schemas?: boolean;\n errors?: boolean;\n}\n\nexport interface SideBarConfig {\n showOperations?: 'byDefault' | 'bySpecTags' | 'byOperationsTags';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConfigInterface {\n schemaID?: string;\n show?: ShowConfig;\n sidebar?: SideBarConfig;\n parserOptions?: any;\n publishLabel?: string;\n subscribeLabel?: string;\n}\n\nexport interface ShowConfig {\n sidebar?: boolean;\n info?: boolean;\n servers?: boolean;\n operations?: boolean;\n messages?: boolean;\n schemas?: boolean;\n errors?: boolean;\n}\n\nexport interface SideBarConfig {\n showOperations?: 'byDefault' | 'bySpecTags' | 'byOperationsTags';\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultConfig = void 0;
|
|
4
|
+
var constants_1 = require("../constants");
|
|
4
5
|
exports.defaultConfig = {
|
|
5
6
|
schemaID: '',
|
|
6
7
|
show: {
|
|
@@ -15,5 +16,7 @@ exports.defaultConfig = {
|
|
|
15
16
|
sidebar: {
|
|
16
17
|
showOperations: 'byOperationsTags',
|
|
17
18
|
},
|
|
19
|
+
publishLabel: constants_1.PUBLISH_LABEL_DEFAULT_TEXT,
|
|
20
|
+
subscribeLabel: constants_1.SUBSCRIBE_LABEL_DEFAULT_TEXT,
|
|
18
21
|
};
|
|
19
22
|
//# sourceMappingURL=default.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/config/default.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/config/default.ts"],"names":[],"mappings":";;;AACA,0CAGsB;AAET,QAAA,aAAa,GAAoB;IAC5C,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE;QACJ,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,IAAI;KACb;IACD,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;KACnC;IACD,YAAY,EAAE,sCAA0B;IACxC,cAAc,EAAE,wCAA4B;CAC7C,CAAC","sourcesContent":["import { ConfigInterface } from './config';\nimport {\n PUBLISH_LABEL_DEFAULT_TEXT,\n SUBSCRIBE_LABEL_DEFAULT_TEXT,\n} from '../constants';\n\nexport const defaultConfig: ConfigInterface = {\n schemaID: '',\n show: {\n sidebar: false,\n info: true,\n servers: true,\n operations: true,\n messages: true,\n schemas: true,\n errors: true,\n },\n sidebar: {\n showOperations: 'byOperationsTags',\n },\n publishLabel: PUBLISH_LABEL_DEFAULT_TEXT,\n subscribeLabel: SUBSCRIBE_LABEL_DEFAULT_TEXT,\n};\n"]}
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.URL_VARIABLES_TEXT = void 0;
|
|
3
|
+
exports.EXPAND_ERROR_BUTTON_TEXT = exports.ERROR_TEXT = exports.ANY_TEXT = exports.NONE_TEXT = exports.SCHEMA_EXAMPLE_TEXT = exports.PAYLOAD_EXAMPLE_TEXT = exports.MESSAGE_PAYLOAD_TEXT = exports.PAYLOAD_TEXT = exports.TAGS_TEXT = exports.HEADERS_EXAMPLE_TEXT = exports.MESSAGE_HEADERS_TEXT = exports.HEADERS_TEXT = exports.PARAMETERS_TEXT = exports.CHANNELS_TEXT = exports.SCHEMAS_TEXT = exports.MESSAGES_TEXT = exports.OPERATIONS_TEXT = exports.SERVERS_TEXT = exports.GENERATED_TEXT = exports.REQUIRED_TEXT = exports.SUBSCRIBE_LABEL_DEFAULT_TEXT = exports.SUBSCRIBE_TEXT = exports.PUBLISH_LABEL_DEFAULT_TEXT = exports.PUBLISH_TEXT = exports.DEPRECATED_TEXT = exports.SPECIFICATION_TEXT = exports.TYPE_TEXT = exports.LOCATION_TEXT = exports.EXTERAL_DOCUMENTATION_TEXT = exports.EMAIL_SUPPORT_TEXT = exports.URL_SUPPORT_TEXT = exports.TERMS_OF_SERVICE_TEXT = exports.LICENSE_TEXT = exports.EMAIL_TEXT = exports.URL_TEXT = exports.NAM_TEXTE = exports.CONTACT_TEXT = exports.ONE_OF_FOLLOWING_MESSAGES_SUBSCRIBE_SINGLE_TEXT = exports.ONE_OF_FOLLOWING_MESSAGES_SUBSCRIBE_TEXT = exports.ONE_OF_FOLLOWING_MESSAGES_PUBLISH_SINGLE_TEXT = exports.ONE_OF_FOLLOWING_MESSAGES_PUBLISH_TEXT = exports.GENERATED_BADGE_TEXT = exports.ANY_OF_PAYLOADS_TEXT = exports.ONE_OF_PAYLOADS_TEXT = exports.SERVERS = exports.VALIDATION_ERRORS_TYPE = exports.EXPAND_ALL_TEXT = exports.COLLAPSE_ALL_TEXT = exports.CONTENT_TYPES_SITE = exports.CSS_PREFIX = void 0;
|
|
4
|
+
exports.URL_VARIABLES_TEXT = exports.SECURITY_TEXT = exports.COLLAPSE_ERROR_BUTTON_TEXT = void 0;
|
|
5
5
|
exports.CSS_PREFIX = 'asyncapi';
|
|
6
6
|
exports.CONTENT_TYPES_SITE = 'https://www.iana.org/assignments/media-types';
|
|
7
7
|
exports.COLLAPSE_ALL_TEXT = 'Collapse All';
|
|
@@ -29,7 +29,9 @@ exports.TYPE_TEXT = 'Type';
|
|
|
29
29
|
exports.SPECIFICATION_TEXT = 'Specification';
|
|
30
30
|
exports.DEPRECATED_TEXT = 'Deprecated';
|
|
31
31
|
exports.PUBLISH_TEXT = 'Publish';
|
|
32
|
+
exports.PUBLISH_LABEL_DEFAULT_TEXT = 'PUB';
|
|
32
33
|
exports.SUBSCRIBE_TEXT = 'Subscribe';
|
|
34
|
+
exports.SUBSCRIBE_LABEL_DEFAULT_TEXT = 'SUB';
|
|
33
35
|
exports.REQUIRED_TEXT = 'Required';
|
|
34
36
|
exports.GENERATED_TEXT = 'Generated';
|
|
35
37
|
exports.SERVERS_TEXT = 'Servers';
|
package/lib/cjs/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;;AAAa,QAAA,UAAU,GAAG,UAAU,CAAC;AACxB,QAAA,kBAAkB,GAC7B,8CAA8C,CAAC;AACpC,QAAA,iBAAiB,GAAG,cAAc,CAAC;AACnC,QAAA,eAAe,GAAG,YAAY,CAAC;AAE/B,QAAA,sBAAsB,GACjC,yDAAyD,CAAC;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC;AAEpB,QAAA,oBAAoB,GAAG,wBAAwB,CAAC;AAChD,QAAA,oBAAoB,GAAG,wBAAwB,CAAC;AAChD,QAAA,oBAAoB,GAAG,WAAW,CAAC;AACnC,QAAA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AAG,iBAAiB,CAAC;AACzC,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAC5C,QAAA,mBAAmB,GAAG,SAAS,CAAC;AAEhC,QAAA,SAAS,GAAG,MAAM,CAAC;AACnB,QAAA,QAAQ,GAAG,KAAK,CAAC;AACjB,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,wBAAwB,GAAG,QAAQ,CAAC;AACpC,QAAA,0BAA0B,GAAG,UAAU,CAAC;AAExC,QAAA,aAAa,GAAG,UAAU,CAAC;AAE3B,QAAA,kBAAkB,GAAG,eAAe,CAAC","sourcesContent":["export const CSS_PREFIX = 'asyncapi';\nexport const CONTENT_TYPES_SITE =\n 'https://www.iana.org/assignments/media-types';\nexport const COLLAPSE_ALL_TEXT = 'Collapse All';\nexport const EXPAND_ALL_TEXT = 'Expand All';\n\nexport const VALIDATION_ERRORS_TYPE =\n 'https://github.com/asyncapi/parser-js/validation-errors';\nexport const SERVERS = 'Servers';\n\nexport const ONE_OF_PAYLOADS_TEXT = 'One of those payloads:';\nexport const ANY_OF_PAYLOADS_TEXT = 'Any of those payloads:';\nexport const GENERATED_BADGE_TEXT = 'generated';\nexport const ONE_OF_FOLLOWING_MESSAGES_PUBLISH_TEXT =\n 'You can send one of the following messages:';\nexport const ONE_OF_FOLLOWING_MESSAGES_PUBLISH_SINGLE_TEXT =\n 'You can send the following message:';\nexport const ONE_OF_FOLLOWING_MESSAGES_SUBSCRIBE_TEXT =\n 'You can subscribe to one of the following messages:';\nexport const ONE_OF_FOLLOWING_MESSAGES_SUBSCRIBE_SINGLE_TEXT =\n 'You can subscribe to the following message:';\n\nexport const CONTACT_TEXT = 'Contact';\nexport const NAM_TEXTE = 'Name';\nexport const URL_TEXT = 'Url';\nexport const EMAIL_TEXT = 'Email';\nexport const LICENSE_TEXT = 'License';\nexport const TERMS_OF_SERVICE_TEXT = 'Terms of service';\nexport const URL_SUPPORT_TEXT = 'Support';\nexport const EMAIL_SUPPORT_TEXT = 'Email support';\nexport const EXTERAL_DOCUMENTATION_TEXT = 'External Docs';\nexport const LOCATION_TEXT = 'Location';\nexport const TYPE_TEXT = 'Type';\nexport const SPECIFICATION_TEXT = 'Specification';\n\nexport const DEPRECATED_TEXT = 'Deprecated';\nexport const PUBLISH_TEXT = 'Publish';\nexport const SUBSCRIBE_TEXT = 'Subscribe';\nexport const REQUIRED_TEXT = 'Required';\nexport const GENERATED_TEXT = 'Generated';\n\nexport const SERVERS_TEXT = 'Servers';\nexport const OPERATIONS_TEXT = 'Operations';\nexport const MESSAGES_TEXT = 'Messages';\nexport const SCHEMAS_TEXT = 'Schemas';\n\nexport const CHANNELS_TEXT = 'Channels';\nexport const PARAMETERS_TEXT = 'Parameters';\nexport const HEADERS_TEXT = 'Headers';\nexport const MESSAGE_HEADERS_TEXT = 'Message Headers';\nexport const HEADERS_EXAMPLE_TEXT = 'Example of headers';\nexport const TAGS_TEXT = 'Tags';\nexport const PAYLOAD_TEXT = 'Payload';\nexport const MESSAGE_PAYLOAD_TEXT = 'Message Payload';\nexport const PAYLOAD_EXAMPLE_TEXT = 'Example of payload';\nexport const SCHEMA_EXAMPLE_TEXT = 'Example';\n\nexport const NONE_TEXT = 'None';\nexport const ANY_TEXT = 'Any';\nexport const ERROR_TEXT = 'Error';\nexport const EXPAND_ERROR_BUTTON_TEXT = 'Expand';\nexport const COLLAPSE_ERROR_BUTTON_TEXT = 'Collapse';\n\nexport const SECURITY_TEXT = 'Security';\n\nexport const URL_VARIABLES_TEXT = 'URL Variables';\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;;AAAa,QAAA,UAAU,GAAG,UAAU,CAAC;AACxB,QAAA,kBAAkB,GAC7B,8CAA8C,CAAC;AACpC,QAAA,iBAAiB,GAAG,cAAc,CAAC;AACnC,QAAA,eAAe,GAAG,YAAY,CAAC;AAE/B,QAAA,sBAAsB,GACjC,yDAAyD,CAAC;AAC/C,QAAA,OAAO,GA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AAY,CAAC;AAC/B,QAAA,YAAY,GAAG,SAAS,CAAC;AACzB,QAAA,oBAAoB,GAAG,iBAAiB,CAAC;AACzC,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAC5C,QAAA,SAAS,GAAG,MAAM,CAAC;AACnB,QAAA,YAAY,GAAG,SAAS,CAAC;AACzB,QAAA,oBAAoB,GAAG,iBAAiB,CAAC;AACzC,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAC5C,QAAA,mBAAmB,GAAG,SAAS,CAAC;AAEhC,QAAA,SAAS,GAAG,MAAM,CAAC;AACnB,QAAA,QAAQ,GAAG,KAAK,CAAC;AACjB,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,wBAAwB,GAAG,QAAQ,CAAC;AACpC,QAAA,0BAA0B,GAAG,UAAU,CAAC;AAExC,QAAA,aAAa,GAAG,UAAU,CAAC;AAE3B,QAAA,kBAAkB,GAAG,eAAe,CAAC","sourcesContent":["export const CSS_PREFIX = 'asyncapi';\nexport const CONTENT_TYPES_SITE =\n 'https://www.iana.org/assignments/media-types';\nexport const COLLAPSE_ALL_TEXT = 'Collapse All';\nexport const EXPAND_ALL_TEXT = 'Expand All';\n\nexport const VALIDATION_ERRORS_TYPE =\n 'https://github.com/asyncapi/parser-js/validation-errors';\nexport const SERVERS = 'Servers';\n\nexport const ONE_OF_PAYLOADS_TEXT = 'One of those payloads:';\nexport const ANY_OF_PAYLOADS_TEXT = 'Any of those payloads:';\nexport const GENERATED_BADGE_TEXT = 'generated';\nexport const ONE_OF_FOLLOWING_MESSAGES_PUBLISH_TEXT =\n 'You can send one of the following messages:';\nexport const ONE_OF_FOLLOWING_MESSAGES_PUBLISH_SINGLE_TEXT =\n 'You can send the following message:';\nexport const ONE_OF_FOLLOWING_MESSAGES_SUBSCRIBE_TEXT =\n 'You can subscribe to one of the following messages:';\nexport const ONE_OF_FOLLOWING_MESSAGES_SUBSCRIBE_SINGLE_TEXT =\n 'You can subscribe to the following message:';\n\nexport const CONTACT_TEXT = 'Contact';\nexport const NAM_TEXTE = 'Name';\nexport const URL_TEXT = 'Url';\nexport const EMAIL_TEXT = 'Email';\nexport const LICENSE_TEXT = 'License';\nexport const TERMS_OF_SERVICE_TEXT = 'Terms of service';\nexport const URL_SUPPORT_TEXT = 'Support';\nexport const EMAIL_SUPPORT_TEXT = 'Email support';\nexport const EXTERAL_DOCUMENTATION_TEXT = 'External Docs';\nexport const LOCATION_TEXT = 'Location';\nexport const TYPE_TEXT = 'Type';\nexport const SPECIFICATION_TEXT = 'Specification';\n\nexport const DEPRECATED_TEXT = 'Deprecated';\nexport const PUBLISH_TEXT = 'Publish';\nexport const PUBLISH_LABEL_DEFAULT_TEXT = 'PUB';\nexport const SUBSCRIBE_TEXT = 'Subscribe';\nexport const SUBSCRIBE_LABEL_DEFAULT_TEXT = 'SUB';\nexport const REQUIRED_TEXT = 'Required';\nexport const GENERATED_TEXT = 'Generated';\n\nexport const SERVERS_TEXT = 'Servers';\nexport const OPERATIONS_TEXT = 'Operations';\nexport const MESSAGES_TEXT = 'Messages';\nexport const SCHEMAS_TEXT = 'Schemas';\n\nexport const CHANNELS_TEXT = 'Channels';\nexport const PARAMETERS_TEXT = 'Parameters';\nexport const HEADERS_TEXT = 'Headers';\nexport const MESSAGE_HEADERS_TEXT = 'Message Headers';\nexport const HEADERS_EXAMPLE_TEXT = 'Example of headers';\nexport const TAGS_TEXT = 'Tags';\nexport const PAYLOAD_TEXT = 'Payload';\nexport const MESSAGE_PAYLOAD_TEXT = 'Message Payload';\nexport const PAYLOAD_EXAMPLE_TEXT = 'Example of payload';\nexport const SCHEMA_EXAMPLE_TEXT = 'Example';\n\nexport const NONE_TEXT = 'None';\nexport const ANY_TEXT = 'Any';\nexport const ERROR_TEXT = 'Error';\nexport const EXPAND_ERROR_BUTTON_TEXT = 'Expand';\nexport const COLLAPSE_ERROR_BUTTON_TEXT = 'Collapse';\n\nexport const SECURITY_TEXT = 'Security';\n\nexport const URL_VARIABLES_TEXT = 'URL Variables';\n"]}
|
|
@@ -42,14 +42,14 @@ var MessageExample = function (_a) {
|
|
|
42
42
|
exports.MessageExample = MessageExample;
|
|
43
43
|
var Example = function (_a) {
|
|
44
44
|
var _b = _a.type, type = _b === void 0 ? 'Payload' : _b, schema = _a.schema, _c = _a.examples, examples = _c === void 0 ? [] : _c;
|
|
45
|
-
var _d = (0, react_1.useState)(false),
|
|
45
|
+
var _d = (0, react_1.useState)(false), expanded = _d[0], setExpanded = _d[1];
|
|
46
46
|
return (react_1.default.createElement("div", { className: "mt-4" },
|
|
47
47
|
react_1.default.createElement("div", null,
|
|
48
|
-
react_1.default.createElement(components_1.CollapseButton, { onClick: function () { return
|
|
49
|
-
className:
|
|
48
|
+
react_1.default.createElement(components_1.CollapseButton, { onClick: function () { return setExpanded(function (prev) { return !prev; }); }, expanded: expanded, chevronProps: {
|
|
49
|
+
className: 'fill-current text-gray-200',
|
|
50
50
|
} },
|
|
51
|
-
react_1.default.createElement("span", { className: "
|
|
52
|
-
react_1.default.createElement("div", { className:
|
|
51
|
+
react_1.default.createElement("span", { className: "inline-block w-20 py-0.5 mr-1 text-gray-200 text-sm border text-center rounded focus:outline-none" }, type))),
|
|
52
|
+
react_1.default.createElement("div", { className: expanded ? 'block' : 'hidden' }, examples && examples.length > 0 ? (react_1.default.createElement("ul", null, examples.map(function (example, idx) { return (react_1.default.createElement("li", { className: "mt-4", key: idx },
|
|
53
53
|
react_1.default.createElement("h5", { className: "text-xs font-bold text-gray-500" }, example.name
|
|
54
54
|
? "#".concat(idx + 1, " Example - ").concat(example.name)
|
|
55
55
|
: "#".concat(idx + 1, " Example")),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageExample.js","sourceRoot":"","sources":["../../../../src/containers/Messages/MessageExample.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AAGxC,+CAA+D;AAC/D,iDAAuD;AAOhD,IAAM,cAAc,GAAmC,UAAC,EAAW;QAAT,OAAO,aAAA;IACtE,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,IAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAClC,IAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAElC,OAAO,CACL,uCAAK,SAAS,EAAC,yEAAyE;QACtF,sCAAI,SAAS,EAAC,oBAAoB,eAAc;QAC/C,OAAO,IAAI,CACV,8BAAC,eAAO,IACN,IAAI,EAAC,SAAS,EACd,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,wBAAc,CAAC,kBAAkB,CAAC,OAAO,CAAC,GACpD,CACH;QACA,OAAO,IAAI,CACV,8BAAC,eAAO,IACN,IAAI,EAAC,SAAS,EACd,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,wBAAc,CAAC,kBAAkB,CAAC,OAAO,CAAC,GACpD,CACH,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,cAAc,kBA2BzB;AAQK,IAAM,OAAO,GAA0C,UAAC,EAI9D;QAHC,YAAgB,EAAhB,IAAI,mBAAG,SAAS,KAAA,EAChB,MAAM,YAAA,EACN,gBAAa,EAAb,QAAQ,mBAAG,EAAE,KAAA;IAEP,IAAA,
|
|
1
|
+
{"version":3,"file":"MessageExample.js","sourceRoot":"","sources":["../../../../src/containers/Messages/MessageExample.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AAGxC,+CAA+D;AAC/D,iDAAuD;AAOhD,IAAM,cAAc,GAAmC,UAAC,EAAW;QAAT,OAAO,aAAA;IACtE,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,IAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAClC,IAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAElC,OAAO,CACL,uCAAK,SAAS,EAAC,yEAAyE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AG,EAAE,GAAG;YAC3B,sCAAI,SAAS,EAAC,iCAAiC,IAC5C,OAAO,CAAC,IAAI;gBACX,CAAC,CAAC,WAAI,GAAG,GAAG,CAAC,wBAAc,OAAO,CAAC,IAAI,CAAE;gBACzC,CAAC,CAAC,WAAI,GAAG,GAAG,CAAC,aAAU,CACtB;YACJ,OAAO,CAAC,OAAO,IAAI,CAClB,qCAAG,SAAS,EAAC,iCAAiC,IAC3C,OAAO,CAAC,OAAO,CACd,CACL;YACD,uCAAK,SAAS,EAAC,MAAM;gBACnB,8BAAC,wBAAW,IACV,OAAO,EAAE,wBAAc,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,GACxD,CACE,CACH,CACN,EAlB+B,CAkB/B,CAAC,CACC,CACN,CAAC,CAAC,CAAC,CACF,uCAAK,SAAS,EAAC,MAAM;YACnB,8BAAC,wBAAW,IACV,OAAO,EAAE,wBAAc,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,GACtD;YACF,sCAAI,SAAS,EAAC,6CAA6C,qDAEtD,CACD,CACP,CACG,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AA1DW,QAAA,OAAO,WA0DlB","sourcesContent":["import React, { useState } from 'react';\nimport { Message, Schema } from '@asyncapi/parser';\n\nimport { CollapseButton, JSONSnippet } from '../../components';\nimport { MessageHelpers } from '../../helpers/message';\nimport { MessageExample as MessageExampleType } from '../../types';\n\ninterface Props {\n message: Message;\n}\n\nexport const MessageExample: React.FunctionComponent<Props> = ({ message }) => {\n if (!message) {\n return null;\n }\n\n const payload = message.payload();\n const headers = message.headers();\n\n return (\n <div className=\"bg-gray-800 px-8 py-4 mt-4 -mx-8 2xl:mx-0 2xl:px-4 2xl:rounded examples\">\n <h4 className=\"text-white text-lg\">Examples</h4>\n {payload && (\n <Example\n type=\"Payload\"\n schema={payload}\n examples={MessageHelpers.getPayloadExamples(message)}\n />\n )}\n {headers && (\n <Example\n type=\"Headers\"\n schema={headers}\n examples={MessageHelpers.getHeadersExamples(message)}\n />\n )}\n </div>\n );\n};\n\ninterface ExampleProps {\n type: 'Payload' | 'Headers';\n schema: Schema;\n examples?: MessageExampleType[];\n}\n\nexport const Example: React.FunctionComponent<ExampleProps> = ({\n type = 'Payload',\n schema,\n examples = [],\n}) => {\n const [expanded, setExpanded] = useState(false);\n\n return (\n <div className=\"mt-4\">\n <div>\n <CollapseButton\n onClick={() => setExpanded(prev => !prev)}\n expanded={expanded}\n chevronProps={{\n className: 'fill-current text-gray-200',\n }}\n >\n <span className=\"inline-block w-20 py-0.5 mr-1 text-gray-200 text-sm border text-center rounded focus:outline-none\">\n {type}\n </span>\n </CollapseButton>\n </div>\n <div className={expanded ? 'block' : 'hidden'}>\n {examples && examples.length > 0 ? (\n <ul>\n {examples.map((example, idx) => (\n <li className=\"mt-4\" key={idx}>\n <h5 className=\"text-xs font-bold text-gray-500\">\n {example.name\n ? `#${idx + 1} Example - ${example.name}`\n : `#${idx + 1} Example`}\n </h5>\n {example.summary && (\n <p className=\"text-xs font-bold text-gray-500\">\n {example.summary}\n </p>\n )}\n <div className=\"mt-1\">\n <JSONSnippet\n snippet={MessageHelpers.sanitizeExample(example.example)}\n />\n </div>\n </li>\n ))}\n </ul>\n ) : (\n <div className=\"mt-4\">\n <JSONSnippet\n snippet={MessageHelpers.generateExample(schema.json())}\n />\n <h6 className=\"text-xs font-bold text-gray-600 italic mt-2\">\n This example has been generated automatically.\n </h6>\n </div>\n )}\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -66,6 +66,7 @@ var Operation = function (props) {
|
|
|
66
66
|
exports.Operation = Operation;
|
|
67
67
|
var OperationInfo = function (_a) {
|
|
68
68
|
var _b = _a.type, type = _b === void 0 ? types_1.PayloadType.PUBLISH : _b, operation = _a.operation, channelName = _a.channelName, channel = _a.channel;
|
|
69
|
+
var config = (0, contexts_1.useConfig)();
|
|
69
70
|
var operationSummary = operation.summary();
|
|
70
71
|
var externalDocs = operation.externalDocs();
|
|
71
72
|
var operationId = operation.id();
|
|
@@ -74,7 +75,9 @@ var OperationInfo = function (_a) {
|
|
|
74
75
|
react_1.default.createElement("h3", null,
|
|
75
76
|
react_1.default.createElement("span", { className: "font-mono border uppercase p-1 rounded mr-2 ".concat(type === types_1.PayloadType.PUBLISH
|
|
76
77
|
? 'border-blue-600 text-blue-500'
|
|
77
|
-
: 'border-green-600 text-green-600'), title: type }, type === types_1.PayloadType.PUBLISH
|
|
78
|
+
: 'border-green-600 text-green-600'), title: type }, type === types_1.PayloadType.PUBLISH
|
|
79
|
+
? config.publishLabel || constants_1.PUBLISH_LABEL_DEFAULT_TEXT
|
|
80
|
+
: config.subscribeLabel || constants_1.SUBSCRIBE_LABEL_DEFAULT_TEXT),
|
|
78
81
|
' ',
|
|
79
82
|
react_1.default.createElement("span", { className: "font-mono text-base" }, channelName))),
|
|
80
83
|
channel.hasDescription() && (react_1.default.createElement("div", { className: "mt-2" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operation.js","sourceRoot":"","sources":["../../../../src/containers/Operations/Operation.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAG1B,+CAA8C;AAC9C,gDAA+C;AAC/C,+CAO0B;AAE1B,2CAA2C;AAC3C,yCAA6D;AAC7D,6CAA6D;AAC7D,qCAA0C;AASnC,IAAM,SAAS,GAAmC,UAAA,KAAK;IAC5D,IAAM,MAAM,GAAG,IAAA,oBAAS,GAAE,CAAC;IACnB,IAAA,KAAgE,KAAK,KAA3C,EAA1B,IAAI,mBAAG,mBAAW,CAAC,OAAO,KAAA,EAAE,SAAS,GAA2B,KAAK,UAAhC,EAAE,WAAW,GAAc,KAAK,YAAnB,EAAE,OAAO,GAAK,KAAK,QAAV,CAAW;IAE9E,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAGD,IAAM,OAAO,GAAG,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,IAA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EAAC,4BAA4B,IAAE,gBAAgB,CAAK,CACjE;QACA,SAAS,CAAC,cAAc,EAAE,IAAI,CAC7B,uCAAK,SAAS,EAAC,MAAM;YACnB,8BAAC,qBAAQ,QAAE,SAAS,CAAC,WAAW,EAAE,CAAY,CAC1C,CACP;QAEA,YAAY,IAAI,CACf,sCAAI,SAAS,EAAC,8CAA8C,IACzD,YAAY,IAAI,CACf,sCAAI,SAAS,EAAC,cAAc;YAC1B,8BAAC,iBAAI,IACH,SAAS,EAAC,4JAA4J,EACtK,IAAI,EAAE,YAAY,CAAC,GAAG,EAAE;gBAExB,4CAAO,sCAA0B,CAAQ,CACpC,CACJ,CACN,CACE,CACN;QAEA,WAAW,IAAI,CACd,uCAAK,SAAS,EAAC,2CAA2C;YACxD,uCAAK,SAAS,EAAC,uBAAuB;;gBAEpC,wCAAM,SAAS,EAAC,uDAAuD,IACpE,WAAW,CACP,CACH,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AArEW,QAAA,aAAa,iBAqExB","sourcesContent":["import React from 'react';\nimport { Channel, Operation as OperationType } from '@asyncapi/parser';\n\nimport { Message } from '../Messages/Message';\nimport { Security } from '../Servers/Security';\nimport {\n Href,\n Markdown,\n Schema,\n Bindings,\n Tags,\n Extensions,\n} from '../../components';\n\nimport { useConfig } from '../../contexts';\nimport { CommonHelpers, SchemaHelpers } from '../../helpers';\nimport { EXTERAL_DOCUMENTATION_TEXT } from '../../constants';\nimport { PayloadType } from '../../types';\n\ninterface Props {\n type: PayloadType;\n operation: OperationType;\n channelName: string;\n channel: Channel;\n}\n\nexport const Operation: React.FunctionComponent<Props> = props => {\n const config = useConfig();\n const { type = PayloadType.PUBLISH, operation, channelName, channel } = props;\n\n if (!operation || !channel) {\n return null;\n }\n\n // check typeof as fallback for older version than `2.2.0`\n const servers = typeof channel.servers === 'function' && channel.servers();\n // check typeof as fallback for older version than `2.4.0`\n const security =\n typeof operation.security === 'function' && operation.security();\n const parameters = SchemaHelpers.parametersToSchema(channel.parameters());\n\n return (\n <div>\n <div className=\"panel-item--center px-8\">\n <OperationInfo {...props} />\n\n {servers && servers.length > 0 ? (\n <div className=\"mt-2 text-sm\">\n <p>Available only on servers:</p>\n <ul className=\"flex flex-wrap leading-normal\">\n {servers.map(server => (\n <li className=\"inline-block mt-2 mr-2\" key={server as string}>\n <a\n href={`#${CommonHelpers.getIdentifier(\n 'server-' + server,\n config,\n )}`}\n className=\"border border-solid border-blue-300 hover:bg-blue-300 hover:text-blue-600 text-blue-500 font-bold no-underline text-xs rounded px-3 py-1 cursor-pointer\"\n >\n <span className=\"underline\">{server}</span>\n </a>\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n {parameters && (\n <div\n className=\"mt-2\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-parameters`,\n config,\n )}\n >\n <Schema\n schemaName=\"Parameters\"\n schema={parameters}\n expanded={true}\n />\n </div>\n )}\n\n {security && (\n <div\n className=\"mt-2\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-security`,\n config,\n )}\n >\n <Security\n security={security}\n header=\"Additional security requirements\"\n />\n </div>\n )}\n\n {channel.hasBindings() && (\n <div className=\"mt-2\">\n <Bindings\n name=\"Channel specific information\"\n bindings={channel.bindings()}\n />\n </div>\n )}\n\n <Extensions name=\"Channel Extensions\" item={channel} />\n\n {operation.hasBindings() && (\n <div className=\"mt-2\">\n <Bindings\n name=\"Operation specific information\"\n bindings={operation.bindings()}\n />\n </div>\n )}\n\n <Extensions name=\"Operation Extensions\" item={operation} />\n\n {operation.hasTags() && (\n <div className=\"mt-2\">\n <Tags tags={operation.tags()} />\n </div>\n )}\n </div>\n\n <div\n className=\"w-full mt-4\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-message`,\n config,\n )}\n >\n {operation.hasMultipleMessages() ? (\n <div className=\"mt-2\">\n <p className=\"px-8\">\n Accepts <strong>one of</strong> the following messages:\n </p>\n <ul>\n {operation.messages().map((msg, idx) => (\n <li className=\"mt-4\" key={idx}>\n <Message message={msg} index={idx} showExamples={true} />\n </li>\n ))}\n </ul>\n </div>\n ) : (\n <div className=\"mt-2\">\n <p className=\"px-8\">Accepts the following message:</p>\n <div className=\"mt-2\">\n <Message\n message={(operation.message as (index: number) => any)(0)}\n showExamples={true}\n />\n </div>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport const OperationInfo: React.FunctionComponent<Props> = ({\n type = PayloadType.PUBLISH,\n operation,\n channelName,\n channel,\n}) => {\n const operationSummary = operation.summary();\n const externalDocs = operation.externalDocs();\n const operationId = operation.id();\n\n return (\n <>\n <div className=\"mb-4\">\n <h3>\n <span\n className={`font-mono border uppercase p-1 rounded mr-2 ${\n type === PayloadType.PUBLISH\n ? 'border-blue-600 text-blue-500'\n : 'border-green-600 text-green-600'\n }`}\n title={type}\n >\n {type === PayloadType.PUBLISH ? 'PUB' : 'SUB'}\n </span>{' '}\n <span className=\"font-mono text-base\">{channelName}</span>\n </h3>\n </div>\n\n {channel.hasDescription() && (\n <div className=\"mt-2\">\n <Markdown>{channel.description()}</Markdown>\n </div>\n )}\n {operationSummary && (\n <p className=\"text-gray-600 text-sm mt-2\">{operationSummary}</p>\n )}\n {operation.hasDescription() && (\n <div className=\"mt-2\">\n <Markdown>{operation.description()}</Markdown>\n </div>\n )}\n\n {externalDocs && (\n <ul className=\"leading-normal mt-2 mb-4 space-x-2 space-y-2\">\n {externalDocs && (\n <li className=\"inline-block\">\n <Href\n className=\"border border-solid border-orange-300 hover:bg-orange-300 hover:text-orange-600 text-orange-500 font-bold no-underline text-xs uppercase rounded px-3 py-1\"\n href={externalDocs.url()}\n >\n <span>{EXTERAL_DOCUMENTATION_TEXT}</span>\n </Href>\n </li>\n )}\n </ul>\n )}\n\n {operationId && (\n <div className=\"border bg-gray-100 rounded px-4 py-2 mt-2\">\n <div className=\"text-sm text-gray-700\">\n Operation ID\n <span className=\"border text-orange-600 rounded text-xs ml-2 py-0 px-2\">\n {operationId}\n </span>\n </div>\n </div>\n )}\n </>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Operation.js","sourceRoot":"","sources":["../../../../src/containers/Operations/Operation.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAG1B,+CAA8C;AAC9C,gDAA+C;AAC/C,+CAO0B;AAE1B,2CAA2C;AAC3C,yCAA6D;AAC7D,6CAIyB;AACzB,qCAA0C;AASnC,IAAM,SAAS,GAAmC,UAAA,KAAK;IAC5D,IAAM,MAAM,GAAG,IAAA,oBAAS,GAAE,CAAC;IACnB,IAAA,KAAgE,KAAK,KAA3C,EAA1B,IAAI,mBAAG,mBAAW,CAAC,OAAO,KAAA,EAAE,SAAS,GAA2B,KAAK,UAAhC,EAAE,WAAW,GAAc,KAAK,YAAnB,EAAE,OAAO,GAAK,KAAK,QAAV,CAAW;IAE9E,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAGD,IAAM,OAAO,GAAG,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAE3E,IAAM,QAAQ,GACZ,OAAO,SAAS,CAAC,QAAQ,KAAK,UAAU,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnE,IAAM,UAAU,GAAG,uBAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAE1E,OAAO,CACL;QACE,uCAAK,SAAS,EAAC,yBAAyB;YACtC,8BAAC,qBAAa,eAAK,KAAK,EAAI;YAE3B,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/B,uCAAK,SAAS,EAAC,cAAc;gBAC3B,sEAAiC;gBACjC,sCAAI,SAAS,EAAC,+BAA+B,IAC1C,OAAO,CAAC,GAAG,CAAC,UAAA,MAAM,IAAI,OAAA,CACrB,sCAAI,SAAS,EAAC,wBAAwB,EAAC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AK,SAAS,EAAC,2CAA2C;YACxD,uCAAK,SAAS,EAAC,uBAAuB;;gBAEpC,wCAAM,SAAS,EAAC,uDAAuD,IACpE,WAAW,CACP,CACH,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAxEW,QAAA,aAAa,iBAwExB","sourcesContent":["import React from 'react';\nimport { Channel, Operation as OperationType } from '@asyncapi/parser';\n\nimport { Message } from '../Messages/Message';\nimport { Security } from '../Servers/Security';\nimport {\n Href,\n Markdown,\n Schema,\n Bindings,\n Tags,\n Extensions,\n} from '../../components';\n\nimport { useConfig } from '../../contexts';\nimport { CommonHelpers, SchemaHelpers } from '../../helpers';\nimport {\n EXTERAL_DOCUMENTATION_TEXT,\n PUBLISH_LABEL_DEFAULT_TEXT,\n SUBSCRIBE_LABEL_DEFAULT_TEXT,\n} from '../../constants';\nimport { PayloadType } from '../../types';\n\ninterface Props {\n type: PayloadType;\n operation: OperationType;\n channelName: string;\n channel: Channel;\n}\n\nexport const Operation: React.FunctionComponent<Props> = props => {\n const config = useConfig();\n const { type = PayloadType.PUBLISH, operation, channelName, channel } = props;\n\n if (!operation || !channel) {\n return null;\n }\n\n // check typeof as fallback for older version than `2.2.0`\n const servers = typeof channel.servers === 'function' && channel.servers();\n // check typeof as fallback for older version than `2.4.0`\n const security =\n typeof operation.security === 'function' && operation.security();\n const parameters = SchemaHelpers.parametersToSchema(channel.parameters());\n\n return (\n <div>\n <div className=\"panel-item--center px-8\">\n <OperationInfo {...props} />\n\n {servers && servers.length > 0 ? (\n <div className=\"mt-2 text-sm\">\n <p>Available only on servers:</p>\n <ul className=\"flex flex-wrap leading-normal\">\n {servers.map(server => (\n <li className=\"inline-block mt-2 mr-2\" key={server as string}>\n <a\n href={`#${CommonHelpers.getIdentifier(\n 'server-' + server,\n config,\n )}`}\n className=\"border border-solid border-blue-300 hover:bg-blue-300 hover:text-blue-600 text-blue-500 font-bold no-underline text-xs rounded px-3 py-1 cursor-pointer\"\n >\n <span className=\"underline\">{server}</span>\n </a>\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n {parameters && (\n <div\n className=\"mt-2\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-parameters`,\n config,\n )}\n >\n <Schema\n schemaName=\"Parameters\"\n schema={parameters}\n expanded={true}\n />\n </div>\n )}\n\n {security && (\n <div\n className=\"mt-2\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-security`,\n config,\n )}\n >\n <Security\n security={security}\n header=\"Additional security requirements\"\n />\n </div>\n )}\n\n {channel.hasBindings() && (\n <div className=\"mt-2\">\n <Bindings\n name=\"Channel specific information\"\n bindings={channel.bindings()}\n />\n </div>\n )}\n\n <Extensions name=\"Channel Extensions\" item={channel} />\n\n {operation.hasBindings() && (\n <div className=\"mt-2\">\n <Bindings\n name=\"Operation specific information\"\n bindings={operation.bindings()}\n />\n </div>\n )}\n\n <Extensions name=\"Operation Extensions\" item={operation} />\n\n {operation.hasTags() && (\n <div className=\"mt-2\">\n <Tags tags={operation.tags()} />\n </div>\n )}\n </div>\n\n <div\n className=\"w-full mt-4\"\n id={CommonHelpers.getIdentifier(\n `operation-${type}-${channelName}-message`,\n config,\n )}\n >\n {operation.hasMultipleMessages() ? (\n <div className=\"mt-2\">\n <p className=\"px-8\">\n Accepts <strong>one of</strong> the following messages:\n </p>\n <ul>\n {operation.messages().map((msg, idx) => (\n <li className=\"mt-4\" key={idx}>\n <Message message={msg} index={idx} showExamples={true} />\n </li>\n ))}\n </ul>\n </div>\n ) : (\n <div className=\"mt-2\">\n <p className=\"px-8\">Accepts the following message:</p>\n <div className=\"mt-2\">\n <Message\n message={(operation.message as (index: number) => any)(0)}\n showExamples={true}\n />\n </div>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport const OperationInfo: React.FunctionComponent<Props> = ({\n type = PayloadType.PUBLISH,\n operation,\n channelName,\n channel,\n}) => {\n const config = useConfig();\n const operationSummary = operation.summary();\n const externalDocs = operation.externalDocs();\n const operationId = operation.id();\n\n return (\n <>\n <div className=\"mb-4\">\n <h3>\n <span\n className={`font-mono border uppercase p-1 rounded mr-2 ${\n type === PayloadType.PUBLISH\n ? 'border-blue-600 text-blue-500'\n : 'border-green-600 text-green-600'\n }`}\n title={type}\n >\n {type === PayloadType.PUBLISH\n ? config.publishLabel || PUBLISH_LABEL_DEFAULT_TEXT\n : config.subscribeLabel || SUBSCRIBE_LABEL_DEFAULT_TEXT}\n </span>{' '}\n <span className=\"font-mono text-base\">{channelName}</span>\n </h3>\n </div>\n\n {channel.hasDescription() && (\n <div className=\"mt-2\">\n <Markdown>{channel.description()}</Markdown>\n </div>\n )}\n {operationSummary && (\n <p className=\"text-gray-600 text-sm mt-2\">{operationSummary}</p>\n )}\n {operation.hasDescription() && (\n <div className=\"mt-2\">\n <Markdown>{operation.description()}</Markdown>\n </div>\n )}\n\n {externalDocs && (\n <ul className=\"leading-normal mt-2 mb-4 space-x-2 space-y-2\">\n {externalDocs && (\n <li className=\"inline-block\">\n <Href\n className=\"border border-solid border-orange-300 hover:bg-orange-300 hover:text-orange-600 text-orange-500 font-bold no-underline text-xs uppercase rounded px-3 py-1\"\n href={externalDocs.url()}\n >\n <span>{EXTERAL_DOCUMENTATION_TEXT}</span>\n </Href>\n </li>\n )}\n </ul>\n )}\n\n {operationId && (\n <div className=\"border bg-gray-100 rounded px-4 py-2 mt-2\">\n <div className=\"text-sm text-gray-700\">\n Operation ID\n <span className=\"border text-orange-600 rounded text-xs ml-2 py-0 px-2\">\n {operationId}\n </span>\n </div>\n </div>\n )}\n </>\n );\n};\n"]}
|
|
@@ -28,6 +28,7 @@ var react_1 = __importStar(require("react"));
|
|
|
28
28
|
var components_1 = require("../../components");
|
|
29
29
|
var contexts_1 = require("../../contexts");
|
|
30
30
|
var helpers_1 = require("../../helpers");
|
|
31
|
+
var constants_1 = require("../../constants");
|
|
31
32
|
var SidebarContext = react_1.default.createContext({
|
|
32
33
|
setShowSidebar: function (value) { return value; },
|
|
33
34
|
});
|
|
@@ -205,18 +206,20 @@ var OperationsByTagItem = function (_a) {
|
|
|
205
206
|
};
|
|
206
207
|
var OperationsPubItem = function (_a) {
|
|
207
208
|
var channelName = _a.channelName;
|
|
209
|
+
var config = (0, contexts_1.useConfig)();
|
|
208
210
|
var setShowSidebar = (0, react_1.useContext)(SidebarContext).setShowSidebar;
|
|
209
211
|
return (react_1.default.createElement("li", null,
|
|
210
212
|
react_1.default.createElement("a", { className: "flex no-underline text-gray-700 mb-2 hover:text-gray-900", href: "#operation-publish-".concat(channelName), onClick: function () { return setShowSidebar(false); } },
|
|
211
|
-
react_1.default.createElement("span", { className: "bg-blue-600 font-bold h-6 no-underline text-white uppercase p-1 mr-2 rounded text-xs", title: "Publish" },
|
|
213
|
+
react_1.default.createElement("span", { className: "bg-blue-600 font-bold h-6 no-underline text-white uppercase p-1 mr-2 rounded text-xs", title: "Publish" }, config.publishLabel || constants_1.PUBLISH_LABEL_DEFAULT_TEXT),
|
|
212
214
|
react_1.default.createElement("span", { className: "break-all inline-block" }, channelName))));
|
|
213
215
|
};
|
|
214
216
|
var OperationsSubItem = function (_a) {
|
|
215
217
|
var channelName = _a.channelName;
|
|
218
|
+
var config = (0, contexts_1.useConfig)();
|
|
216
219
|
var setShowSidebar = (0, react_1.useContext)(SidebarContext).setShowSidebar;
|
|
217
220
|
return (react_1.default.createElement("li", null,
|
|
218
221
|
react_1.default.createElement("a", { className: "flex no-underline text-gray-700 mb-2 hover:text-gray-900", href: "#operation-subscribe-".concat(channelName), onClick: function () { return setShowSidebar(false); } },
|
|
219
|
-
react_1.default.createElement("span", { className: "bg-green-600 font-bold h-6 no-underline text-white uppercase p-1 mr-2 rounded text-xs", title: "Subscribe" },
|
|
222
|
+
react_1.default.createElement("span", { className: "bg-green-600 font-bold h-6 no-underline text-white uppercase p-1 mr-2 rounded text-xs", title: "Subscribe" }, config.subscribeLabel || constants_1.SUBSCRIBE_LABEL_DEFAULT_TEXT),
|
|
220
223
|
react_1.default.createElement("span", { className: "break-all inline-block" }, channelName))));
|
|
221
224
|
};
|
|
222
225
|
//# sourceMappingURL=Sidebar.js.map
|