@asyncapi/react-component 1.0.0-next.43 → 1.0.0-next.44

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.
@@ -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 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
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConfigInterface {\n schemaID?: string;\n show?: ShowConfig;\n expand?: ExpandConfig;\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 ExpandConfig {\n messageExamples?: boolean;\n}\n\nexport interface SideBarConfig {\n showOperations?: 'byDefault' | 'bySpecTags' | 'byOperationsTags';\n}\n"]}
@@ -13,6 +13,9 @@ exports.defaultConfig = {
13
13
  schemas: true,
14
14
  errors: true,
15
15
  },
16
+ expand: {
17
+ messageExamples: false,
18
+ },
16
19
  sidebar: {
17
20
  showOperations: 'byOperationsTags',
18
21
  },
@@ -1 +1 @@
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"]}
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,MAAM,EAAE;QACN,eAAe,EAAE,KAAK;KACvB;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 expand: {\n messageExamples: false,\n },\n sidebar: {\n showOperations: 'byOperationsTags',\n },\n publishLabel: PUBLISH_LABEL_DEFAULT_TEXT,\n subscribeLabel: SUBSCRIBE_LABEL_DEFAULT_TEXT,\n};\n"]}
@@ -135,7 +135,7 @@ var AsyncApiComponent = (function (_super) {
135
135
  var _b = this.props, config = _b.config, propError = _b.error;
136
136
  var _c = this.state, asyncapi = _c.asyncapi, stateError = _c.error;
137
137
  var error = propError || stateError;
138
- var concatenatedConfig = __assign(__assign(__assign({}, config_1.defaultConfig), config), { show: __assign(__assign({}, config_1.defaultConfig.show), (!!config && config.show)), sidebar: __assign(__assign({}, config_1.defaultConfig.sidebar), (!!config && config.sidebar)) });
138
+ var concatenatedConfig = __assign(__assign(__assign({}, config_1.defaultConfig), config), { show: __assign(__assign({}, config_1.defaultConfig.show), (!!config && config.show)), expand: __assign(__assign({}, config_1.defaultConfig.expand), (!!config && config.expand)), sidebar: __assign(__assign({}, config_1.defaultConfig.sidebar), (!!config && config.sidebar)) });
139
139
  if (!asyncapi) {
140
140
  if (!error) {
141
141
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"Standalone.js","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/Standalone.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AAGzC,yCAAqD;AAErD,uCAA8D;AAE9D,oDAAsC;AACtC,wCAAuC;AAavC;IAAgC,qCAAuC;IAMrE,2BAAY,KAAoB;QAAhC,YACE,kBAAM,KAAK,CAAC,SAOb;QAbD,WAAK,GAAkB;YACrB,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,SAAS;SACjB,CAAC;QAKA,IAAM,UAAU,G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AAK,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC;SACnE;QAED,OAAO,CACL,8BAAC,gBAAc,IACb,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;IACJ,CAAC;IAEO,uCAAW,GAAnB,UAAoB,MAAmB;QACrC,IAAM,UAAU,GAAG,8BAAoB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACnE,IAAI,CAAC,UAAU,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;YACvC,OAAO;SACR;QACD,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;IACH,wBAAC;AAAD,CAAC,AAzED,CAAgC,iBAAS,GAyExC;AAED,kBAAe,iBAAiB,CAAC","sourcesContent":["import React, { Component } from 'react';\nimport { AsyncAPIDocument } from '@asyncapi/parser';\n\nimport { SpecificationHelpers } from '../../helpers';\nimport { ErrorObject, PropsSchema } from '../../types';\nimport { ConfigInterface, defaultConfig } from '../../config';\n\nimport AsyncApiLayout from './Layout';\nimport { Error } from '../Error/Error';\n\nexport interface AsyncApiProps {\n schema: PropsSchema;\n config?: Partial<ConfigInterface>;\n error?: ErrorObject;\n}\n\ninterface AsyncAPIState {\n asyncapi?: AsyncAPIDocument;\n error?: ErrorObject;\n}\n\nclass AsyncApiComponent extends Component<AsyncApiProps, AsyncAPIState> {\n state: AsyncAPIState = {\n asyncapi: undefined,\n error: undefined,\n };\n\n constructor(props: AsyncApiProps) {\n super(props);\n\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(props.schema);\n if (parsedSpec) {\n this.state = { asyncapi: parsedSpec };\n }\n return;\n }\n\n async componentDidMount() {\n if (!this.state.asyncapi) {\n this.updateState(this.props.schema);\n }\n }\n\n async componentDidUpdate(prevProps: AsyncApiProps) {\n const oldSchema = prevProps.schema;\n const newSchema = this.props.schema;\n\n if (oldSchema !== newSchema) {\n this.updateState(newSchema);\n }\n }\n\n render() {\n const { config, error: propError } = this.props;\n const { asyncapi, error: stateError } = this.state;\n\n const error = propError || stateError;\n const concatenatedConfig: ConfigInterface = {\n ...defaultConfig,\n ...config,\n show: {\n ...defaultConfig.show,\n ...(!!config && config.show),\n },\n sidebar: {\n ...defaultConfig.sidebar,\n ...(!!config && config.sidebar),\n },\n };\n\n if (!asyncapi) {\n if (!error) {\n return null;\n }\n return concatenatedConfig.show?.errors && <Error error={error} />;\n }\n\n return (\n <AsyncApiLayout\n asyncapi={asyncapi}\n config={concatenatedConfig}\n error={error}\n />\n );\n }\n\n private updateState(schema: PropsSchema) {\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(schema);\n if (!parsedSpec) {\n this.setState({ asyncapi: undefined });\n return;\n }\n this.setState({ asyncapi: parsedSpec });\n }\n}\n\nexport default AsyncApiComponent;\n"]}
1
+ {"version":3,"file":"Standalone.js","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/Standalone.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AAGzC,yCAAqD;AAErD,uCAA8D;AAE9D,oDAAsC;AACtC,wCAAuC;AAavC;IAAgC,qCAAuC;IAMrE,2BAAY,KAAoB;QAAhC,YACE,kBAAM,KAAK,CAAC,SAOb;QAbD,WAAK,GAAkB;YACrB,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,SAAS;SACjB,CAAC;QAKA,IAAM,UAAU,GAAG,8BAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzE,IAAI,UAAU,EAAE;YACd,KAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;SACvC;;IAEH,CAAC;IAEK,6CAAiB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,EAAE,QAAQ,EAClB,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;IACJ,CAAC;IAEO,uCAAW,GAAnB,UAAoB,MAAmB;QACrC,IAAM,UAAU,GAAG,8BAAoB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACnE,IAAI,CAAC,UAAU,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;YACvC,OAAO;SACR;QACD,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;IACH,wBAAC;AAAD,CAAC,AA7ED,CAAgC,iBAAS,GA6ExC;AAED,kBAAe,iBAAiB,CAAC","sourcesContent":["import React, { Component } from 'react';\nimport { AsyncAPIDocument } from '@asyncapi/parser';\n\nimport { SpecificationHelpers } from '../../helpers';\nimport { ErrorObject, PropsSchema } from '../../types';\nimport { ConfigInterface, defaultConfig } from '../../config';\n\nimport AsyncApiLayout from './Layout';\nimport { Error } from '../Error/Error';\n\nexport interface AsyncApiProps {\n schema: PropsSchema;\n config?: Partial<ConfigInterface>;\n error?: ErrorObject;\n}\n\ninterface AsyncAPIState {\n asyncapi?: AsyncAPIDocument;\n error?: ErrorObject;\n}\n\nclass AsyncApiComponent extends Component<AsyncApiProps, AsyncAPIState> {\n state: AsyncAPIState = {\n asyncapi: undefined,\n error: undefined,\n };\n\n constructor(props: AsyncApiProps) {\n super(props);\n\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(props.schema);\n if (parsedSpec) {\n this.state = { asyncapi: parsedSpec };\n }\n return;\n }\n\n async componentDidMount() {\n if (!this.state.asyncapi) {\n this.updateState(this.props.schema);\n }\n }\n\n async componentDidUpdate(prevProps: AsyncApiProps) {\n const oldSchema = prevProps.schema;\n const newSchema = this.props.schema;\n\n if (oldSchema !== newSchema) {\n this.updateState(newSchema);\n }\n }\n\n render() {\n const { config, error: propError } = this.props;\n const { asyncapi, error: stateError } = this.state;\n\n const error = propError || stateError;\n const concatenatedConfig: ConfigInterface = {\n ...defaultConfig,\n ...config,\n show: {\n ...defaultConfig.show,\n ...(!!config && config.show),\n },\n expand: {\n ...defaultConfig.expand,\n ...(!!config && config.expand),\n },\n sidebar: {\n ...defaultConfig.sidebar,\n ...(!!config && config.sidebar),\n },\n };\n\n if (!asyncapi) {\n if (!error) {\n return null;\n }\n return concatenatedConfig.show?.errors && <Error error={error} />;\n }\n\n return (\n <AsyncApiLayout\n asyncapi={asyncapi}\n config={concatenatedConfig}\n error={error}\n />\n );\n }\n\n private updateState(schema: PropsSchema) {\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(schema);\n if (!parsedSpec) {\n this.setState({ asyncapi: undefined });\n return;\n }\n this.setState({ asyncapi: parsedSpec });\n }\n}\n\nexport default AsyncApiComponent;\n"]}
@@ -27,6 +27,7 @@ exports.Example = exports.MessageExample = void 0;
27
27
  var react_1 = __importStar(require("react"));
28
28
  var components_1 = require("../../components");
29
29
  var message_1 = require("../../helpers/message");
30
+ var contexts_1 = require("../../contexts");
30
31
  var MessageExample = function (_a) {
31
32
  var message = _a.message;
32
33
  if (!message) {
@@ -42,7 +43,11 @@ var MessageExample = function (_a) {
42
43
  exports.MessageExample = MessageExample;
43
44
  var Example = function (_a) {
44
45
  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), expanded = _d[0], setExpanded = _d[1];
46
+ var config = (0, contexts_1.useConfig)();
47
+ var _d = (0, react_1.useState)((config && config.expand && config.expand.messageExamples) || false), expanded = _d[0], setExpanded = _d[1];
48
+ (0, react_1.useEffect)(function () {
49
+ setExpanded((config && config.expand && config.expand.messageExamples) || false);
50
+ }, [config.expand]);
46
51
  return (react_1.default.createElement("div", { className: "mt-4" },
47
52
  react_1.default.createElement("div", null,
48
53
  react_1.default.createElement(components_1.CollapseButton, { onClick: function () { return setExpanded(function (prev) { return !prev; }); }, expanded: expanded, chevronProps: {
@@ -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,KAA0B,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAxC,QAAQ,QAAA,EAAE,WAAW,QAAmB,CAAC;IAEhD,OAAO,CACL,uCAAK,SAAS,EAAC,MAAM;QACnB;YACE,8BAAC,2BAAc,IACb,OAA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AO,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"]}
1
+ {"version":3,"file":"MessageExample.js","sourceRoot":"","sources":["../../../../src/containers/Messages/MessageExample.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAmD;AAGnD,+CAA+D;AAC/D,iDAAuD;AAEvD,2CAA2C;AAMpC,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;IAEb,IAAM,MAAM,GAAG,IAAA,oBA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AAS,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;AAnEW,QAAA,OAAO,WAmElB","sourcesContent":["import React, { useState, useEffect } 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';\nimport { useConfig } from '../../contexts';\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 config = useConfig();\n const [expanded, setExpanded] = useState(\n (config && config.expand && config.expand.messageExamples) || false,\n );\n\n useEffect(() => {\n setExpanded(\n (config && config.expand && config.expand.messageExamples) || false,\n );\n }, [config.expand]);\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"]}
@@ -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 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
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConfigInterface {\n schemaID?: string;\n show?: ShowConfig;\n expand?: ExpandConfig;\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 ExpandConfig {\n messageExamples?: boolean;\n}\n\nexport interface SideBarConfig {\n showOperations?: 'byDefault' | 'bySpecTags' | 'byOperationsTags';\n}\n"]}
@@ -10,6 +10,9 @@ export var defaultConfig = {
10
10
  schemas: true,
11
11
  errors: true,
12
12
  },
13
+ expand: {
14
+ messageExamples: false,
15
+ },
13
16
  sidebar: {
14
17
  showOperations: 'byOperationsTags',
15
18
  },
@@ -1 +1 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/config/default.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,IAAM,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,0BAA0B;IACxC,cAAc,EAAE,4BAA4B;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"]}
1
+ {"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/config/default.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,IAAM,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,MAAM,EAAE;QACN,eAAe,EAAE,KAAK;KACvB;IACD,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;KACnC;IACD,YAAY,EAAE,0BAA0B;IACxC,cAAc,EAAE,4BAA4B;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 expand: {\n messageExamples: false,\n },\n sidebar: {\n showOperations: 'byOperationsTags',\n },\n publishLabel: PUBLISH_LABEL_DEFAULT_TEXT,\n subscribeLabel: SUBSCRIBE_LABEL_DEFAULT_TEXT,\n};\n"]}
@@ -107,7 +107,7 @@ var AsyncApiComponent = (function (_super) {
107
107
  var _b = this.props, config = _b.config, propError = _b.error;
108
108
  var _c = this.state, asyncapi = _c.asyncapi, stateError = _c.error;
109
109
  var error = propError || stateError;
110
- var concatenatedConfig = __assign(__assign(__assign({}, defaultConfig), config), { show: __assign(__assign({}, defaultConfig.show), (!!config && config.show)), sidebar: __assign(__assign({}, defaultConfig.sidebar), (!!config && config.sidebar)) });
110
+ var concatenatedConfig = __assign(__assign(__assign({}, defaultConfig), config), { show: __assign(__assign({}, defaultConfig.show), (!!config && config.show)), expand: __assign(__assign({}, defaultConfig.expand), (!!config && config.expand)), sidebar: __assign(__assign({}, defaultConfig.sidebar), (!!config && config.sidebar)) });
111
111
  if (!asyncapi) {
112
112
  if (!error) {
113
113
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"Standalone.js","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/Standalone.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAmB,aAAa,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAavC;IAAgC,qCAAuC;IAMrE,2BAAY,KAAoB;QAAhC,YACE,kBAAM,KAAK,CAAC,SAOb;QAbD,WAAK,GAAkB;YACrB,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,SAAS;SACjB,CAAC;QAKA,IAAM,UAAU,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzE,IAAI,UAAU,EAAE;YACd,KAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;SACvC;;IAEH,CAAC;IAEK,6CAAiB,GAAvB;;;gBACE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACxB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK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,UAAU,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;YACvC,OAAO;SACR;QACD,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;IACH,wBAAC;AAAD,CAAC,AAzED,CAAgC,SAAS,GAyExC;AAED,eAAe,iBAAiB,CAAC","sourcesContent":["import React, { Component } from 'react';\nimport { AsyncAPIDocument } from '@asyncapi/parser';\n\nimport { SpecificationHelpers } from '../../helpers';\nimport { ErrorObject, PropsSchema } from '../../types';\nimport { ConfigInterface, defaultConfig } from '../../config';\n\nimport AsyncApiLayout from './Layout';\nimport { Error } from '../Error/Error';\n\nexport interface AsyncApiProps {\n schema: PropsSchema;\n config?: Partial<ConfigInterface>;\n error?: ErrorObject;\n}\n\ninterface AsyncAPIState {\n asyncapi?: AsyncAPIDocument;\n error?: ErrorObject;\n}\n\nclass AsyncApiComponent extends Component<AsyncApiProps, AsyncAPIState> {\n state: AsyncAPIState = {\n asyncapi: undefined,\n error: undefined,\n };\n\n constructor(props: AsyncApiProps) {\n super(props);\n\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(props.schema);\n if (parsedSpec) {\n this.state = { asyncapi: parsedSpec };\n }\n return;\n }\n\n async componentDidMount() {\n if (!this.state.asyncapi) {\n this.updateState(this.props.schema);\n }\n }\n\n async componentDidUpdate(prevProps: AsyncApiProps) {\n const oldSchema = prevProps.schema;\n const newSchema = this.props.schema;\n\n if (oldSchema !== newSchema) {\n this.updateState(newSchema);\n }\n }\n\n render() {\n const { config, error: propError } = this.props;\n const { asyncapi, error: stateError } = this.state;\n\n const error = propError || stateError;\n const concatenatedConfig: ConfigInterface = {\n ...defaultConfig,\n ...config,\n show: {\n ...defaultConfig.show,\n ...(!!config && config.show),\n },\n sidebar: {\n ...defaultConfig.sidebar,\n ...(!!config && config.sidebar),\n },\n };\n\n if (!asyncapi) {\n if (!error) {\n return null;\n }\n return concatenatedConfig.show?.errors && <Error error={error} />;\n }\n\n return (\n <AsyncApiLayout\n asyncapi={asyncapi}\n config={concatenatedConfig}\n error={error}\n />\n );\n }\n\n private updateState(schema: PropsSchema) {\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(schema);\n if (!parsedSpec) {\n this.setState({ asyncapi: undefined });\n return;\n }\n this.setState({ asyncapi: parsedSpec });\n }\n}\n\nexport default AsyncApiComponent;\n"]}
1
+ {"version":3,"file":"Standalone.js","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/Standalone.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAmB,aAAa,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAavC;IAAgC,qCAAuC;IAMrE,2BAAY,KAAoB;QAAhC,YACE,kBAAM,KAAK,CAAC,SAOb;QAbD,WAAK,GAAkB;YACrB,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,SAAS;SACjB,CAAC;QAKA,IAAM,UAAU,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzE,IAAI,UAAU,EAAE;YACd,KAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;SACvC;;IAEH,CAAC;IAEK,6CAAiB,GAAvB;;;gBACE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACxB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;iBACrC;;;;KACF;IAEK,8CAAk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kB,CAAC,MAAM,CAAC,CAAC;QACnE,IAAI,CAAC,UAAU,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;YACvC,OAAO;SACR;QACD,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;IACH,wBAAC;AAAD,CAAC,AA7ED,CAAgC,SAAS,GA6ExC;AAED,eAAe,iBAAiB,CAAC","sourcesContent":["import React, { Component } from 'react';\nimport { AsyncAPIDocument } from '@asyncapi/parser';\n\nimport { SpecificationHelpers } from '../../helpers';\nimport { ErrorObject, PropsSchema } from '../../types';\nimport { ConfigInterface, defaultConfig } from '../../config';\n\nimport AsyncApiLayout from './Layout';\nimport { Error } from '../Error/Error';\n\nexport interface AsyncApiProps {\n schema: PropsSchema;\n config?: Partial<ConfigInterface>;\n error?: ErrorObject;\n}\n\ninterface AsyncAPIState {\n asyncapi?: AsyncAPIDocument;\n error?: ErrorObject;\n}\n\nclass AsyncApiComponent extends Component<AsyncApiProps, AsyncAPIState> {\n state: AsyncAPIState = {\n asyncapi: undefined,\n error: undefined,\n };\n\n constructor(props: AsyncApiProps) {\n super(props);\n\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(props.schema);\n if (parsedSpec) {\n this.state = { asyncapi: parsedSpec };\n }\n return;\n }\n\n async componentDidMount() {\n if (!this.state.asyncapi) {\n this.updateState(this.props.schema);\n }\n }\n\n async componentDidUpdate(prevProps: AsyncApiProps) {\n const oldSchema = prevProps.schema;\n const newSchema = this.props.schema;\n\n if (oldSchema !== newSchema) {\n this.updateState(newSchema);\n }\n }\n\n render() {\n const { config, error: propError } = this.props;\n const { asyncapi, error: stateError } = this.state;\n\n const error = propError || stateError;\n const concatenatedConfig: ConfigInterface = {\n ...defaultConfig,\n ...config,\n show: {\n ...defaultConfig.show,\n ...(!!config && config.show),\n },\n expand: {\n ...defaultConfig.expand,\n ...(!!config && config.expand),\n },\n sidebar: {\n ...defaultConfig.sidebar,\n ...(!!config && config.sidebar),\n },\n };\n\n if (!asyncapi) {\n if (!error) {\n return null;\n }\n return concatenatedConfig.show?.errors && <Error error={error} />;\n }\n\n return (\n <AsyncApiLayout\n asyncapi={asyncapi}\n config={concatenatedConfig}\n error={error}\n />\n );\n }\n\n private updateState(schema: PropsSchema) {\n const parsedSpec = SpecificationHelpers.retrieveParsedSpec(schema);\n if (!parsedSpec) {\n this.setState({ asyncapi: undefined });\n return;\n }\n this.setState({ asyncapi: parsedSpec });\n }\n}\n\nexport default AsyncApiComponent;\n"]}
@@ -1,6 +1,7 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import { CollapseButton, JSONSnippet } from '../../components';
3
3
  import { MessageHelpers } from '../../helpers/message';
4
+ import { useConfig } from '../../contexts';
4
5
  export var MessageExample = function (_a) {
5
6
  var message = _a.message;
6
7
  if (!message) {
@@ -15,7 +16,11 @@ export var MessageExample = function (_a) {
15
16
  };
16
17
  export var Example = function (_a) {
17
18
  var _b = _a.type, type = _b === void 0 ? 'Payload' : _b, schema = _a.schema, _c = _a.examples, examples = _c === void 0 ? [] : _c;
18
- var _d = useState(false), expanded = _d[0], setExpanded = _d[1];
19
+ var config = useConfig();
20
+ var _d = useState((config && config.expand && config.expand.messageExamples) || false), expanded = _d[0], setExpanded = _d[1];
21
+ useEffect(function () {
22
+ setExpanded((config && config.expand && config.expand.messageExamples) || false);
23
+ }, [config.expand]);
19
24
  return (React.createElement("div", { className: "mt-4" },
20
25
  React.createElement("div", null,
21
26
  React.createElement(CollapseButton, { onClick: function () { return setExpanded(function (prev) { return !prev; }); }, expanded: expanded, chevronProps: {
@@ -1 +1 @@
1
- {"version":3,"file":"MessageExample.js","sourceRoot":"","sources":["../../../../src/containers/Messages/MessageExample.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGxC,OAA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,SAAS,EAAE,4BAA4B;iBACxC;gBAED,8BAAM,SAAS,EAAC,mGAAmG,IAChH,IAAI,CACA,CACQ,CACb;QACN,6BAAK,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,IAC1C,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CACjC,gCACG,QAAQ,CAAC,GAAG,CAAC,UAAC,OAAO,EAAE,GAAG,IAAK,OAAA,CAC9B,4BAAI,SAAS,EAAC,MAAM,EAAC,GAAG,EAAE,GAAG;YAC3B,4BAAI,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,2BAAG,SAAS,EAAC,iCAAiC,IAC3C,OAAO,CAAC,OAAO,CACd,CACL;YACD,6BAAK,SAAS,EAAC,MAAM;gBACnB,oBAAC,WAAW,IACV,OAAO,EAAE,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,GACxD,CACE,CACH,CACN,EAlB+B,CAkB/B,CAAC,CACC,CACN,CAAC,CAAC,CAAC,CACF,6BAAK,SAAS,EAAC,MAAM;YACnB,oBAAC,WAAW,IACV,OAAO,EAAE,cAAc,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,GACtD;YACF,4BAAI,SAAS,EAAC,6CAA6C,qDAEtD,CACD,CACP,CACG,CACF,CACP,CAAC;AACJ,CAAC,CAAC","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"]}
1
+ {"version":3,"file":"MessageExample.js","sourceRoot":"","sources":["../../../../src/containers/Messages/MessageExample.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGnD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAM3C,MAAM,CAAC,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,6BAAK,SAAS,EAAC,yEAAyE;QACtF,4BAAI,SAAS,EAAC,oBAAoB,eAAc;QAC/C,OAAO,IAAI,CACV,oBAAC,OAAO,IACN,IAAI,EAAC,SAAS,EACd,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,cAAc,CAAC,kBAAkB,CAAC,OAAO,CAAC,GACpD,CACH;QACA,OAAO,IAAI,CACV,oBAAC,OAAO,IACN,IAAI,EAAC,SAAS,EACd,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,cAAc,CAAC,kBAAkB,CAAC,OAAO,CAAC,GACpD,CACH,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAQF,MAAM,CAAC,IAAM,OAAO,GAA0C,UAAC,EAI9D;QAHC,YAAgB,EAAhB,IAAI,mBAAG,SAAS,KAAA,EAChB,MAAM,YAAA,EACN,gBAAa,EAAb,QAAQ,mBAAG,EAAE,KAAA;IAEb,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IACrB,IAAA,KAA0B,QAAQ,CACtC,C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,SAAS,EAAC,MAAM;gBACnB,oBAAC,WAAW,IACV,OAAO,EAAE,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,GACxD,CACE,CACH,CACN,EAlB+B,CAkB/B,CAAC,CACC,CACN,CAAC,CAAC,CAAC,CACF,6BAAK,SAAS,EAAC,MAAM;YACnB,oBAAC,WAAW,IACV,OAAO,EAAE,cAAc,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,GACtD;YACF,4BAAI,SAAS,EAAC,6CAA6C,qDAEtD,CACD,CACP,CACG,CACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useState, useEffect } 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';\nimport { useConfig } from '../../contexts';\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 config = useConfig();\n const [expanded, setExpanded] = useState(\n (config && config.expand && config.expand.messageExamples) || false,\n );\n\n useEffect(() => {\n setExpanded(\n (config && config.expand && config.expand.messageExamples) || false,\n );\n }, [config.expand]);\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"]}
@@ -1,6 +1,7 @@
1
1
  export interface ConfigInterface {
2
2
  schemaID?: string;
3
3
  show?: ShowConfig;
4
+ expand?: ExpandConfig;
4
5
  sidebar?: SideBarConfig;
5
6
  parserOptions?: any;
6
7
  publishLabel?: string;
@@ -15,6 +16,9 @@ export interface ShowConfig {
15
16
  schemas?: boolean;
16
17
  errors?: boolean;
17
18
  }
19
+ export interface ExpandConfig {
20
+ messageExamples?: boolean;
21
+ }
18
22
  export interface SideBarConfig {
19
23
  showOperations?: 'byDefault' | 'bySpecTags' | 'byOperationsTags';
20
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,I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C,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,kBAAkB,CAAC;CAClE"}
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/config/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM3C,eAAO,MAAM,aAAa,EAAE,eAgB3B,CAAC"}
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/config/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM3C,eAAO,MAAM,aAAa,EAAE,eAmB3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Standalone.d.ts","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/Standalone.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,eAAe,EAAiB,MAAM,cAAc,CAAC;AAK9D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,cAAM,iBAAkB,SAAQ,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IACrE,KAAK,EAAE,aAAa,CAGlB;gBAEU,KAAK,EAAE,aAAa;IAU1B,iBAAiB;IAMjB,kBAAkB,CAAC,SAAS,EAAE,aAAa;IASjD,MAAM;IAkCN,OAAO,CAAC,WAAW;CAQpB;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"Standalone.d.ts","sourceRoot":"","sources":["../../../../src/containers/AsyncApi/Standalone.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,eAAe,EAAiB,MAAM,cAAc,CAAC;AAK9D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,cAAM,iBAAkB,SAAQ,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IACrE,KAAK,EAAE,aAAa,CAGlB;gBAEU,KAAK,EAAE,aAAa;IAU1B,iBAAiB;IAMjB,kBAAkB,CAAC,SAAS,EAAE,aAAa;IASjD,MAAM;IAsCN,OAAO,CAAC,WAAW;CAQpB;AAED,eAAe,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MessageExample.d.ts","sourceRoot":"","sources":["../../../../src/containers/Messages/MessageExample.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE,UAAU,KAAK;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,KAAK,CA2BzD,CAAC;AAEF,UAAU,YAAY;IACpB,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACjC;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,YAAY,CA0DzD,CAAC"}
1
+ {"version":3,"file":"MessageExample.d.ts","sourceRoot":"","sources":["../../../../src/containers/Messages/MessageExample.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGnE,UAAU,KAAK;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,KAAK,CA2BzD,CAAC;AAEF,UAAU,YAAY;IACpB,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACjC;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,YAAY,CAmEzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asyncapi/react-component",
3
- "version": "1.0.0-next.43",
3
+ "version": "1.0.0-next.44",
4
4
  "private": false,
5
5
  "description": "A React component for AsyncAPI specification.",
6
6
  "repository": {