rapidoc 9.3.7 → 10.0.0

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.
Files changed (69) hide show
  1. package/README.md +193 -61
  2. package/dist/rapidoc-min.js +279 -3912
  3. package/package.json +24 -47
  4. package/.babelrc.json +0 -42
  5. package/.eslintrc +0 -53
  6. package/.github/FUNDING.yml +0 -13
  7. package/.github/workflow/words.yaml +0 -22
  8. package/CONTRIBUTING.md +0 -35
  9. package/dist/index.html +0 -6
  10. package/dist/index.html.gz +0 -0
  11. package/dist/rapidoc-min.js.LICENSE.txt +0 -64
  12. package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
  13. package/dist/rapidoc-min.js.gz +0 -0
  14. package/dist/rapidoc-min.js.map +0 -1
  15. package/dist/rapidoc-min.js.map.gz +0 -0
  16. package/dist/rapidoc.js +0 -21594
  17. package/dist/report.html +0 -39
  18. package/index-hashroute.html +0 -65
  19. package/index.html +0 -249
  20. package/index1.html +0 -244
  21. package/jsconfig.json +0 -11
  22. package/logo.png +0 -0
  23. package/performance.html +0 -31
  24. package/src/components/api-request.js +0 -1787
  25. package/src/components/api-response.js +0 -335
  26. package/src/components/dialog-box.js +0 -73
  27. package/src/components/json-tree.js +0 -145
  28. package/src/components/schema-table.js +0 -358
  29. package/src/components/schema-tree.js +0 -378
  30. package/src/components/tag-input.js +0 -135
  31. package/src/index.js +0 -7
  32. package/src/json-schema-viewer.js +0 -345
  33. package/src/oauth-receiver.js +0 -56
  34. package/src/rapidoc-mini.js +0 -380
  35. package/src/rapidoc.js +0 -1082
  36. package/src/styles/border-styles.js +0 -24
  37. package/src/styles/custom-styles.js +0 -10
  38. package/src/styles/dialog-box-styles.js +0 -75
  39. package/src/styles/endpoint-styles.js +0 -202
  40. package/src/styles/flex-styles.js +0 -15
  41. package/src/styles/font-styles.js +0 -268
  42. package/src/styles/info-styles.js +0 -21
  43. package/src/styles/input-styles.js +0 -202
  44. package/src/styles/nav-styles.js +0 -198
  45. package/src/styles/prism-styles.js +0 -105
  46. package/src/styles/schema-styles.js +0 -121
  47. package/src/styles/tab-styles.js +0 -47
  48. package/src/styles/table-styles.js +0 -58
  49. package/src/templates/advance-search-template.js +0 -72
  50. package/src/templates/callback-template.js +0 -73
  51. package/src/templates/code-samples-template.js +0 -34
  52. package/src/templates/components-template.js +0 -76
  53. package/src/templates/endpoint-template.js +0 -249
  54. package/src/templates/expanded-endpoint-template.js +0 -197
  55. package/src/templates/focused-endpoint-template.js +0 -110
  56. package/src/templates/header-template.js +0 -66
  57. package/src/templates/json-schema-viewer-template.js +0 -185
  58. package/src/templates/logo-template.js +0 -18
  59. package/src/templates/main-body-template.js +0 -121
  60. package/src/templates/navbar-template.js +0 -272
  61. package/src/templates/overview-template.js +0 -79
  62. package/src/templates/security-scheme-template.js +0 -610
  63. package/src/templates/server-template.js +0 -115
  64. package/src/utils/color-utils.js +0 -59
  65. package/src/utils/common-utils.js +0 -168
  66. package/src/utils/schema-utils.js +0 -1086
  67. package/src/utils/spec-parser.js +0 -462
  68. package/src/utils/theme.js +0 -288
  69. package/webpack.config.js +0 -142
@@ -1,197 +0,0 @@
1
- import { html } from 'lit';
2
- import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
3
- import { marked } from 'marked';
4
- import { rapidocApiKey } from '~/utils/common-utils';
5
- import { pathSecurityTemplate } from '~/templates/security-scheme-template';
6
- import codeSamplesTemplate from '~/templates/code-samples-template';
7
- import callbackTemplate from '~/templates/callback-template';
8
- import '~/components/api-request';
9
- import '~/components/api-response';
10
-
11
- /* eslint-disable indent */
12
- function headingRenderer(tagElementId) {
13
- const renderer = new marked.Renderer();
14
- renderer.heading = ((text, level, raw, slugger) => `<h${level} class="observe-me" id="${tagElementId}--${slugger.slug(raw)}">${text}</h${level}>`);
15
- return renderer;
16
- }
17
-
18
- function expandCollapseTagDescription(e) {
19
- const tagDescriptionEl = e.target.closest('.tag-container').querySelector('.tag-description');
20
- const tagIconEl = e.target.closest('.tag-container').querySelector('.tag-icon');
21
- if (tagDescriptionEl && tagIconEl) {
22
- const isExpanded = tagDescriptionEl.classList.contains('expanded');
23
- if (isExpanded) {
24
- tagDescriptionEl.style.maxHeight = 0;
25
- tagDescriptionEl.classList.replace('expanded', 'collapsed');
26
- tagIconEl.classList.replace('expanded', 'collapsed');
27
- } else {
28
- tagDescriptionEl.style.maxHeight = `${tagDescriptionEl.scrollHeight}px`;
29
- tagDescriptionEl.classList.replace('collapsed', 'expanded');
30
- tagIconEl.classList.replace('collapsed', 'expanded');
31
- }
32
- }
33
- }
34
-
35
- export function expandedEndpointBodyTemplate(path, tagName = '', tagDescription = '') {
36
- const acceptContentTypes = new Set();
37
- for (const respStatus in path.responses) {
38
- for (const acceptContentType in (path.responses[respStatus]?.content)) {
39
- acceptContentTypes.add(acceptContentType.trim());
40
- }
41
- }
42
- const accept = [...acceptContentTypes].join(', ');
43
-
44
- // Filter API Keys that are non-empty and are applicable to the the path
45
- const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter((v) => (v.finalKeyValue && path.security?.some((ps) => (v.securitySchemeId in ps)))) || [];
46
-
47
- // If a RapiDoc API Key is specified on the element and its value is not hyphen(-) then include it for all paths
48
- const rapiDocApiKey = this.resolvedSpec.securitySchemes.find((v) => (v.securitySchemeId === rapidocApiKey && v.value !== '-'));
49
- if (rapiDocApiKey) {
50
- nonEmptyApiKeys.push(rapiDocApiKey);
51
- }
52
-
53
- const codeSampleTabPanel = path.xCodeSamples ? codeSamplesTemplate.call(this, path.xCodeSamples) : '';
54
- return html`
55
- ${this.renderStyle === 'read' ? html`<div class='divider' part="operation-divider"></div>` : ''}
56
- <div class='expanded-endpoint-body observe-me ${path.method} ${path.deprecated ? 'deprecated' : ''} ' part="section-operation ${path.elementId}" id='${path.elementId}'>
57
- ${(this.renderStyle === 'focused' && tagName !== 'General ⦂')
58
- ? html`
59
- <div class="tag-container" part="section-operation-tag">
60
- <span class="upper" style="font-weight:bold; font-size:18px;"> ${tagName} </span>
61
- ${tagDescription
62
- ? html`
63
- <svg class="tag-icon collapsed" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" fill="none" style="stroke:var(--primary-color); vertical-align:top; cursor:pointer"
64
- @click="${(e) => { expandCollapseTagDescription.call(this, e); }}"
65
- >
66
- <path d="M12 20h-6a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h8"></path><path d="M18 4v17"></path><path d="M15 18l3 3l3 -3"></path>
67
- </svg>
68
- <div class="tag-description collapsed" style="max-height:0px; overflow:hidden; margin-top:16px; border:1px solid var(--border-color)">
69
- <div class="m-markdown" style="padding:8px"> ${unsafeHTML(marked(tagDescription))}</div>
70
- </div>`
71
- : ''
72
- }
73
- </div>
74
- `
75
- : ''
76
- }
77
- ${path.deprecated ? html`<div class="bold-text red-text"> DEPRECATED </div>` : ''}
78
- ${html`
79
- ${path.xBadges && path.xBadges?.length > 0
80
- ? html`
81
- <div style="display:flex; flex-wrap:wrap; margin-bottom: -24px; font-size: var(--font-size-small);">
82
- ${path.xBadges.map((v) => (
83
- v.color === 'none'
84
- ? ''
85
- : html`<span style="margin:1px; margin-right:5px; padding:1px 8px; font-weight:bold; border-radius:12px; background-color: var(--light-${v.color}, var(--input-bg)); color:var(--${v.color}); border:1px solid var(--${v.color})">${v.label}</span>`
86
- ))
87
- }
88
- </div>
89
- `
90
- : ''
91
- }
92
- <h2 part="section-operation-summary"> ${path.shortSummary || `${path.method.toUpperCase()} ${path.path}`}</h2>
93
- ${path.isWebhook
94
- ? html`<span part="section-operation-webhook" style="color:var(--primary-color); font-weight:bold; font-size: var(--font-size-regular);"> WEBHOOK </span>`
95
- : html`
96
- <div part="section-operation-webhook-method" class="mono-font regular-font-size" style="text-align:left; direction:ltr; padding: 8px 0; color:var(--fg3)">
97
- <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method}</span>
98
- <span part="label-operation-path">${path.path}</span>
99
- </div>
100
- `
101
- }
102
- <slot name="${path.elementId}"></slot>`
103
- }
104
- ${path.description ? html`<div class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''}
105
- ${pathSecurityTemplate.call(this, path.security)}
106
- ${path.externalDocs?.url || path.externalDocs?.description
107
- ? html`<div style="background-color:var(--bg3); padding:2px 8px 8px 8px; margin:8px 0; border-radius:var(--border-radius)">
108
- <div class="m-markdown"> ${unsafeHTML(marked(path.externalDocs?.description || ''))} </div>
109
- ${path.externalDocs?.url
110
- ? html`<a style="font-family:var(--font-mono); font-size:var(--font-size-small)" href="${path.externalDocs?.url}" target="_blank">
111
- ${path.externalDocs?.url} <div style="transform: rotate(270deg) scale(1.5); display: inline-block; margin-left:5px">⇲</div>
112
- </a>`
113
- : ''
114
- }
115
- </div>`
116
- : ''
117
- }
118
- ${codeSampleTabPanel}
119
- <div class='expanded-req-resp-container'>
120
- <api-request
121
- class = "${this.renderStyle}-mode"
122
- style = "width:100%;"
123
- webhook = "${path.isWebhook}"
124
- method = "${path.method}"
125
- path = "${path.path}"
126
- .security = "${path.security}"
127
- .parameters = "${path.parameters}"
128
- .request_body = "${path.requestBody}"
129
- .api_keys = "${nonEmptyApiKeys}"
130
- .servers = "${path.servers}"
131
- server-url = "${path.servers?.[0]?.url || this.selectedServer?.computedUrl}"
132
- fill-request-fields-with-example = "${this.fillRequestFieldsWithExample}"
133
- allow-try = "${this.allowTry}"
134
- show-curl-before-try = "${this.showCurlBeforeTry}"
135
- accept = "${accept}"
136
- render-style="${this.renderStyle}"
137
- schema-style = "${this.schemaStyle}"
138
- active-schema-tab = "${this.defaultSchemaTab}"
139
- schema-expand-level = "${this.schemaExpandLevel}"
140
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
141
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
142
- schema-hide-read-only = "${this.schemaHideReadOnly === 'never' ? 'false' : path.isWebhook ? 'false' : 'true'}"
143
- schema-hide-write-only = "${this.schemaHideWriteOnly === 'never' ? 'false' : path.isWebhook ? 'true' : 'false'}"
144
- fetch-credentials = "${this.fetchCredentials}"
145
- exportparts = "wrap-request-btn:wrap-request-btn, btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
146
- file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
147
- anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
148
- > </api-request>
149
-
150
- ${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''}
151
-
152
- <api-response
153
- class = "${this.renderStyle}-mode"
154
- style = "width:100%;"
155
- webhook = "${path.isWebhook}"
156
- .responses = "${path.responses}"
157
- render-style = "${this.renderStyle}"
158
- schema-style = "${this.schemaStyle}"
159
- active-schema-tab = "${this.defaultSchemaTab}"
160
- schema-expand-level = "${this.schemaExpandLevel}"
161
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
162
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
163
- schema-hide-read-only = "${this.schemaHideReadOnly === 'never' ? 'false' : path.isWebhook ? 'true' : 'false'}"
164
- schema-hide-write-only = "${this.schemaHideWriteOnly === 'never' ? 'false' : path.isWebhook ? 'false' : 'true'}"
165
- selected-status = "${Object.keys(path.responses || {})[0] || ''}"
166
- exportparts = "btn:btn, btn-response-status:btn-response-status, btn-selected-response-status:btn-selected-response-status, btn-fill:btn-fill, btn-copy:btn-copy,
167
- schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
168
- > </api-response>
169
- </div>
170
- </div>
171
- `;
172
- }
173
-
174
- export default function expandedEndpointTemplate() {
175
- if (!this.resolvedSpec) { return ''; }
176
- return html`
177
- ${this.resolvedSpec.tags.map((tag) => html`
178
- <section id="${tag.elementId}" part="section-tag" class="regular-font section-gap--read-mode observe-me" style="border-top:1px solid var(--primary-color);">
179
- <div class="title tag" part="section-tag-title label-tag-title">${tag.displayName || tag.name}</div>
180
- <slot name="${tag.elementId}"></slot>
181
- <div class="regular-font-size">
182
- ${
183
- unsafeHTML(`
184
- <div class="m-markdown regular-font">
185
- ${marked(tag.description || '', this.infoDescriptionHeadingsInNavBar === 'true' ? { renderer: headingRenderer(tag.elementId) } : undefined)}
186
- </div>`)
187
- }
188
- </div>
189
- </section>
190
- <section class="regular-font section-gap--read-mode" part="section-operations-in-tag">
191
- ${tag.paths.map((path) => expandedEndpointBodyTemplate.call(this, path))}
192
- </section>
193
- `)
194
- }
195
- `;
196
- }
197
- /* eslint-enable indent */
@@ -1,110 +0,0 @@
1
- import { html } from 'lit';
2
- import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
3
- import { marked } from 'marked';
4
- import { expandedEndpointBodyTemplate } from '~/templates/expanded-endpoint-template';
5
- import '~/components/api-request';
6
- import '~/components/api-response';
7
- import componentsTemplate from '~/templates/components-template';
8
- import overviewTemplate from '~/templates/overview-template';
9
- import serverTemplate from '~/templates/server-template';
10
- import securitySchemeTemplate from '~/templates/security-scheme-template';
11
- import { expandCollapseNavBarTag } from '~/templates/navbar-template';
12
-
13
- function headingRenderer(tagElementId) {
14
- const renderer = new marked.Renderer();
15
- renderer.heading = ((text, level, raw, slugger) => `<h${level} class="observe-me" id="${tagElementId}--${slugger.slug(raw)}">${text}</h${level}>`);
16
- return renderer;
17
- }
18
-
19
- function wrapFocusedTemplate(templateToWrap) {
20
- return html`
21
- <div class='regular-font section-gap--focused-mode' part="section-operations-in-tag">
22
- ${templateToWrap}
23
- </div>`;
24
- }
25
-
26
- function defaultContentTemplate() {
27
- // In focused mode default content is overview or first path
28
- if (this.showInfo === 'true') {
29
- return wrapFocusedTemplate(overviewTemplate.call(this));
30
- }
31
- const selectedTagObj = this.resolvedSpec.tags[0];
32
- const selectedPathObj = this.resolvedSpec.tags[0]?.paths[0];
33
- return (selectedTagObj && selectedPathObj)
34
- ? wrapFocusedTemplate(expandedEndpointBodyTemplate.call(this, selectedPathObj, selectedTagObj.name))
35
- : wrapFocusedTemplate('');
36
- }
37
-
38
- /* eslint-disable indent */
39
- function focusedTagBodyTemplate(tag) {
40
- return html`
41
- <h1 id="${tag.elementId}">${tag.displayName || tag.name}</h1>
42
- ${this.onNavTagClick === 'show-description' && tag.description
43
- ? html`
44
- <div class="m-markdown">
45
- ${
46
- unsafeHTML(`
47
- <div class="m-markdown regular-font">
48
- ${marked(tag.description || '', this.infoDescriptionHeadingsInNavBar === 'true' ? { renderer: headingRenderer(tag.elementId) } : undefined)}
49
- </div>`)
50
- }
51
- </div>`
52
- : ''
53
- }
54
- `;
55
- }
56
-
57
- export default function focusedEndpointTemplate() {
58
- if (!this.focusedElementId || !this.resolvedSpec) {
59
- return;
60
- }
61
- const focusElId = this.focusedElementId;
62
- let selectedPathObj = null;
63
- let selectedTagObj = null;
64
- let focusedTemplate;
65
- let i = 0;
66
- if (focusElId.startsWith('overview') && this.showInfo === 'true') {
67
- focusedTemplate = overviewTemplate.call(this);
68
- } else if (focusElId === 'auth' && this.allowAuthentication === 'true') {
69
- focusedTemplate = securitySchemeTemplate.call(this);
70
- } else if (focusElId === 'servers' && this.allowServerSelection === 'true') {
71
- focusedTemplate = serverTemplate.call(this);
72
- } else if (focusElId === 'operations-top') {
73
- focusedTemplate = html`
74
- <div id="operations-top" class="observe-me">
75
- <slot name="operations-top"></slot>
76
- </div>`;
77
- } else if (focusElId.startsWith('cmp--') && this.showComponents === 'true') {
78
- focusedTemplate = componentsTemplate.call(this);
79
- } else if (focusElId.startsWith('tag--')) {
80
- const idToFocus = focusElId.indexOf('--', 4) > 0 ? focusElId.substring(0, focusElId.indexOf('--', 5)) : focusElId;
81
- selectedTagObj = this.resolvedSpec.tags.find((v) => v.elementId === idToFocus);
82
- if (selectedTagObj) {
83
- focusedTemplate = wrapFocusedTemplate.call(this, focusedTagBodyTemplate.call(this, selectedTagObj));
84
- } else {
85
- focusedTemplate = defaultContentTemplate.call(this);
86
- }
87
- } else {
88
- for (i = 0; i < this.resolvedSpec.tags.length; i += 1) {
89
- selectedTagObj = this.resolvedSpec.tags[i];
90
- selectedPathObj = this.resolvedSpec.tags[i].paths.find((v) => `${v.elementId}` === focusElId);
91
- if (selectedPathObj) {
92
- break;
93
- }
94
- }
95
- if (selectedPathObj) {
96
- // In focused mode we must expand the nav-bar tag element if it is collapsed
97
- const newNavEl = this.shadowRoot.getElementById(`link-${focusElId}`);
98
- expandCollapseNavBarTag(newNavEl, 'expand');
99
- focusedTemplate = wrapFocusedTemplate.call(
100
- this,
101
- expandedEndpointBodyTemplate.call(this, selectedPathObj, (selectedTagObj.name || ''), (selectedTagObj.description || '')),
102
- );
103
- } else {
104
- // if focusedElementId is not found then show the default content (overview or first-path)
105
- focusedTemplate = defaultContentTemplate.call(this);
106
- }
107
- }
108
- return focusedTemplate;
109
- }
110
- /* eslint-enable indent */
@@ -1,66 +0,0 @@
1
- import { html } from 'lit';
2
- import logoTemplate from '~/templates/logo-template';
3
-
4
- /* eslint-disable indent */
5
- export default function headerTemplate() {
6
- return html`
7
- <header class="row main-header regular-font" part="section-header" style="padding:8px 4px 8px 4px;min-height:48px;">
8
- <div class="only-large-screen-flex" style="align-items: center;">
9
- <slot name="logo" class="logo" part="section-logo">
10
- ${logoTemplate('height:36px;width:36px;margin-left:5px')}
11
- <!-- m-logo style="height:36px;width:36px;margin-left:5px"></m-logo -->
12
- </slot>
13
- <div class="header-title" part="label-header-title">${this.headingText}</div>
14
- </div>
15
- <div style="margin: 0px 8px;display:flex;flex:1">
16
- ${(this.allowSpecUrlLoad === 'false')
17
- ? ''
18
- : html`
19
- <input id="spec-url"
20
- type="text"
21
- style="font-size:var(--font-size-small)"
22
- class="header-input mono-font"
23
- part="textbox textbox-spec-url"
24
- placeholder="Spec URL"
25
- value="${this.specUrl || ''}"
26
- @change="${this.onSpecUrlChange}"
27
- spellcheck="false"
28
- >
29
- <div style="margin: 6px 5px 0 -24px; font-size:var(--font-size-regular); cursor:pointer;">&#x21a9;</div>
30
- `
31
- }
32
- ${(this.allowSpecFileLoad === 'false')
33
- ? ''
34
- : html`
35
- <input id="spec-file"
36
- part = "file-input"
37
- type="file"
38
- style="display:none"
39
- value="${this.specFile || ''}"
40
- @change="${this.onSpecFileChange}"
41
- spellcheck="false"
42
- >
43
- <button class="m-btn primary only-large-screen" style="margin-left:10px;" part="btn btn-fill" @click="${this.onFileLoadClick}"> LOCAL JSON FILE </button>
44
- `
45
- }
46
- <slot name="header"></slot>
47
- ${(this.allowSearch === 'false' || 'read focused'.includes(this.renderStyle))
48
- ? ''
49
- : html`
50
- <input id="search" class="header-input" type="text" part="textbox textbox-header-filter" placeholder="Filter" @change="${this.onSearchChange}" style="max-width:130px;margin-left:10px;" spellcheck="false" >
51
- <div style="margin: 6px 5px 0 -24px; font-size:var(--font-size-regular); cursor:pointer;">&#x21a9;</div>
52
- `
53
- }
54
-
55
- ${(this.allowAdvancedSearch === 'false' || 'read focused'.includes(this.renderStyle))
56
- ? ''
57
- : html`
58
- <button class="m-btn primary only-large-screen" part="btn btn-fill btn-search" style="margin-left:10px;" @click="${this.onShowSearchModalClicked}">
59
- Search
60
- </button>
61
- `
62
- }
63
- </div>
64
- </header>`;
65
- }
66
- /* eslint-enable indent */
@@ -1,185 +0,0 @@
1
- import { html } from 'lit';
2
- import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
3
- import { marked } from 'marked';
4
-
5
- // Templates
6
- import overviewTemplate from '~/templates/overview-template';
7
- import headerTemplate from '~/templates/header-template';
8
- import { schemaInObjectNotation, generateExample, standardizeExample } from '~/utils/schema-utils';
9
- import '~/components/json-tree';
10
- import '~/components/schema-tree';
11
- import SetTheme from '~/utils/theme';
12
- import { isValidHexColor } from '~/utils/color-utils';
13
-
14
- /* eslint-disable indent */
15
- // Json Schema Nav Template
16
- function jsonSchemaNavTemplate() {
17
- return html`
18
- <nav class='nav-bar' part="section-navbar">
19
- <slot name="nav-logo" class="logo"></slot>
20
- <div style="display:flex;line-height:22px; padding:8px">
21
- <input id="nav-bar-search"
22
- part = "textbox textbox-nav-filter"
23
- style = "width:100%; height: 26px; padding-right:20px; color:var(--nav-hover-text-color); border-color:var(--nav-accent-color); background-color:var(--nav-hover-bg-color)"
24
- type = "text"
25
- placeholder = "Filter"
26
- @change = "${this.onSearchChange}"
27
- spellcheck = "false"
28
- >
29
- <div style="margin: 6px 5px 0 -24px; font-size:var(--font-size-regular); cursor:pointer;">&#x21a9;</div>
30
- </div>
31
- <nav style="flex:1" class='nav-scroll' part="section-navbar-scroll">
32
- ${this.resolvedSpec.schemaAndExamples.map((v) => html`
33
- <div class='nav-bar-path' data-content-id='${v.elementId}' id='link-${v.elementId}'
34
- @click = '${(e) => {
35
- this.scrollToEventTarget(e, false);
36
- }}'
37
- >
38
- ${v.name}
39
- </div>`)
40
- }
41
- </nav>
42
- </nav>
43
- `;
44
- }
45
-
46
- // Json Schema Body Template
47
- function jsonSchemaBodyTemplate() {
48
- return html`
49
- ${this.showInfo === 'true' ? overviewTemplate.call(this) : ''}
50
- <div style="font-size:var(--font-size-regular);">
51
- ${this.resolvedSpec.schemaAndExamples.map((jSchemaBody) => {
52
- const examplesObj = generateExample(jSchemaBody.schema, 'json', standardizeExample(jSchemaBody.examples), standardizeExample(jSchemaBody.example), true, false, 'json', true);
53
- jSchemaBody.selectedExample = examplesObj[0]?.exampleId;
54
- return html`
55
- <section id='${jSchemaBody.elementId}' class='json-schema-and-example regular-font' style="display:flex; flex-direction: column; border:1px solid var(--border-color); margin-bottom:32px; border-top: 5px solid var(--border-color)">
56
- <div style="padding:16px; border-bottom: 1px solid var(--border-color)">
57
- <div style="font-size:var(--font-size-small); font-weight:bold">${jSchemaBody.name}</div>
58
- <span class="json-schema-description m-markdown ">${unsafeHTML(marked(jSchemaBody.description || ''))}</span>
59
- </div>
60
- <div style="display:flex; flex-direction: row; gap:16px;">
61
- <div class="json-schema-def" style="flex:1; padding:16px 0 16px 16px; ">
62
- <schema-tree
63
- .data = "${schemaInObjectNotation(jSchemaBody.schema, {})}"
64
- schema-expand-level = "${this.schemaExpandLevel}"
65
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
66
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
67
- schema-hide-read-only = "false"
68
- schema-hide-write-only = "false"
69
- > </schema-tree>
70
- </div>
71
- <div class="json-schema-example-panel" style="width:400px; background-color: var(--input-bg); padding:16px 0 16px 16px; border-left: 1px dashed var(--border-color);">
72
- ${examplesObj.length > 1
73
- ? html`<select style="min-width:100px; max-width:100%" @change='${(e) => this.onSelectExample(e, jSchemaBody)}'>
74
- ${examplesObj.map((v) => html`
75
- <option value="${v.exampleId}" ?selected=${(v.exampleId === jSchemaBody.selectedExample)}>
76
- ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary}
77
- </option>`)
78
- }
79
- </select>`
80
- : html`<div style="font-size: var(--font-size-small);font-weight:700; margin:5px 0"> ${examplesObj[0].exampleSummary}</div>`
81
- }
82
- ${examplesObj.map((v) => html`
83
- <json-tree
84
- .data = "${v.exampleValue}"
85
- data-example = "${v.exampleId}"
86
- class = "example"
87
- style = "margin-top:16px; display: ${v.exampleId === jSchemaBody.selectedExample ? 'flex' : 'none'}"
88
- ></json-tree>`)
89
- }
90
- </div>
91
- </div>
92
- </section>`;
93
- })
94
- }
95
- </div>
96
- `;
97
- }
98
- /* eslint-enable indent */
99
-
100
- // Json Schema Root Template
101
- export default function jsonSchemaViewerTemplate(isMini = false) {
102
- // export default function jsonSchemaViewerTemplate(isMini = false, pathsExpanded = false) {
103
- if (!this.resolvedSpec) {
104
- return '';
105
- }
106
- const newTheme = {
107
- bg1: isValidHexColor(this.bgColor) ? this.bgColor : '',
108
- fg1: isValidHexColor(this.textColor) ? this.textColor : '',
109
- headerColor: isValidHexColor(this.headerColor) ? this.headerColor : '',
110
- primaryColor: isValidHexColor(this.primaryColor) ? this.primaryColor : '',
111
- navBgColor: isValidHexColor(this.navBgColor) ? this.navBgColor : '',
112
- navTextColor: isValidHexColor(this.navTextColor) ? this.navTextColor : '',
113
- navHoverBgColor: isValidHexColor(this.navHoverBgColor) ? this.navHoverBgColor : '',
114
- navHoverTextColor: isValidHexColor(this.navHoverTextColor) ? this.navHoverTextColor : '',
115
- navAccentColor: isValidHexColor(this.navAccentColor) ? this.navAccentColor : '',
116
- navAccenttextColor: isValidHexColor(this.navAccentTextColor) ? this.navAccentTextColor : '',
117
- };
118
- /* eslint-disable indent */
119
- if (this.resolvedSpec.specLoadError) {
120
- if (isMini) {
121
- return html`
122
- ${this.theme === 'dark' ? SetTheme.call(this, 'dark', newTheme) : SetTheme.call(this, 'light', newTheme)}
123
- <div style="display:flex; align-items:center; border:1px dashed var(--border-color); height:42px; padding:5px; font-size:var(--font-size-small); color:var(--red); font-family:var(--font-mono)"> ${this.resolvedSpec.info.description} </div>
124
- `;
125
- }
126
- return html`
127
- ${this.theme === 'dark' ? SetTheme.call(this, 'dark', newTheme) : SetTheme.call(this, 'light', newTheme)}
128
- <!-- Header -->
129
- ${headerTemplate.call(this)}
130
- <h1> Header </h1>
131
- <main class="main-content regular-font" part="section-main-content">
132
- <slot></slot>
133
- <div style="margin:24px; text-align: center;">
134
- <h1 style="color: var(--red)"> ${this.resolvedSpec.info.title} </h1>
135
- <div style="font-family:var(--font-mono)"> ${this.resolvedSpec.info.description} </div>
136
- </div>
137
- </main>
138
- `;
139
- }
140
- if (this.resolvedSpec.isSpecLoading) {
141
- return html`
142
- ${this.theme === 'dark' ? SetTheme.call(this, 'dark', newTheme) : SetTheme.call(this, 'light', newTheme)}
143
- <main class="main-content regular-font" part="section-main-content">
144
- <slot></slot>
145
- <div class="main-content-inner--${this.renderStyle}-mode">
146
- <div class="loader"></div>
147
- </div>
148
- </main>
149
- `;
150
- }
151
-
152
- return html`
153
- ${this.theme === 'dark' ? SetTheme.call(this, 'dark', newTheme) : SetTheme.call(this, 'light', newTheme)}
154
-
155
- <!-- Header -->
156
- ${this.showHeader === 'false' ? '' : headerTemplate.call(this)}
157
-
158
- <div id='the-main-body' class="body ${this.cssClasses}" dir= ${this.pageDirection}>
159
-
160
- <!-- Side Nav -->
161
- ${jsonSchemaNavTemplate.call(this)}
162
-
163
- <!-- Main Content -->
164
- <main class="main-content regular-font" part="section-main-content">
165
- <slot></slot>
166
- <div class="main-content-inner--${this.renderStyle}-mode">
167
- ${this.loading === true
168
- ? html`<div class="loader"></div>`
169
- : html`
170
- ${this.loadFailed === true
171
- ? html`<div style="text-align: center;margin: 16px;"> Unable to load the Spec</div>`
172
- : html`
173
- <div class="operations-root" @click="${(e) => { this.handleHref(e); }}">
174
- ${jsonSchemaBodyTemplate.call(this)}
175
- </div>
176
- `
177
- }`
178
- }
179
- </div>
180
- <slot name="footer"></slot>
181
- </main>
182
- </div>
183
- `;
184
- }
185
- /* eslint-enable indent */
@@ -1,18 +0,0 @@
1
- import { html } from 'lit';
2
-
3
- /* eslint-disable indent */
4
- export default function logoTemplate(style) {
5
- return html`
6
- <div style=${style}>
7
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="1 0 511 512">
8
- <path d="M351 411a202 202 0 01-350 0 203 203 0 01333-24 203 203 0 0117 24zm0 0" fill="#adc165"/>
9
- <path d="M334 387a202 202 0 01-216-69 202 202 0 01216 69zm78 32H85a8 8 0 01-8-8 8 8 0 018-8h327a8 8 0 017 8 8 8 0 01-7 8zm0 0" fill="#99aa52"/>
10
- <path d="M374 338l-5 30a202 202 0 01-248-248 203 203 0 01253 218zm0 0" fill="#ffc73b"/>
11
- <path d="M374 338a202 202 0 01-100-197 203 203 0 01100 197zm38 81l-6-2-231-231a8 8 0 0111-11l231 230a8 8 0 01-5 14zm0 0" fill="#efb025"/>
12
- <path d="M311 175c0 75 40 140 101 175a202 202 0 000-350 202 202 0 00-101 175zm0 0" fill="#ff903e"/>
13
- <path d="M412 419a8 8 0 01-8-8V85a8 8 0 0115 0v326a8 8 0 01-7 8zm0 0" fill="#e87425"/>
14
- </svg>
15
- </div>
16
- `;
17
- }
18
- /* eslint-enable indent */