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.
- package/README.md +193 -61
- package/dist/rapidoc-min.js +279 -3912
- package/package.json +24 -47
- package/.babelrc.json +0 -42
- package/.eslintrc +0 -53
- package/.github/FUNDING.yml +0 -13
- package/.github/workflow/words.yaml +0 -22
- package/CONTRIBUTING.md +0 -35
- package/dist/index.html +0 -6
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js.LICENSE.txt +0 -64
- package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
- package/dist/rapidoc-min.js.gz +0 -0
- package/dist/rapidoc-min.js.map +0 -1
- package/dist/rapidoc-min.js.map.gz +0 -0
- package/dist/rapidoc.js +0 -21594
- package/dist/report.html +0 -39
- package/index-hashroute.html +0 -65
- package/index.html +0 -249
- package/index1.html +0 -244
- package/jsconfig.json +0 -11
- package/logo.png +0 -0
- package/performance.html +0 -31
- package/src/components/api-request.js +0 -1787
- package/src/components/api-response.js +0 -335
- package/src/components/dialog-box.js +0 -73
- package/src/components/json-tree.js +0 -145
- package/src/components/schema-table.js +0 -358
- package/src/components/schema-tree.js +0 -378
- package/src/components/tag-input.js +0 -135
- package/src/index.js +0 -7
- package/src/json-schema-viewer.js +0 -345
- package/src/oauth-receiver.js +0 -56
- package/src/rapidoc-mini.js +0 -380
- package/src/rapidoc.js +0 -1082
- package/src/styles/border-styles.js +0 -24
- package/src/styles/custom-styles.js +0 -10
- package/src/styles/dialog-box-styles.js +0 -75
- package/src/styles/endpoint-styles.js +0 -202
- package/src/styles/flex-styles.js +0 -15
- package/src/styles/font-styles.js +0 -268
- package/src/styles/info-styles.js +0 -21
- package/src/styles/input-styles.js +0 -202
- package/src/styles/nav-styles.js +0 -198
- package/src/styles/prism-styles.js +0 -105
- package/src/styles/schema-styles.js +0 -121
- package/src/styles/tab-styles.js +0 -47
- package/src/styles/table-styles.js +0 -58
- package/src/templates/advance-search-template.js +0 -72
- package/src/templates/callback-template.js +0 -73
- package/src/templates/code-samples-template.js +0 -34
- package/src/templates/components-template.js +0 -76
- package/src/templates/endpoint-template.js +0 -249
- package/src/templates/expanded-endpoint-template.js +0 -197
- package/src/templates/focused-endpoint-template.js +0 -110
- package/src/templates/header-template.js +0 -66
- package/src/templates/json-schema-viewer-template.js +0 -185
- package/src/templates/logo-template.js +0 -18
- package/src/templates/main-body-template.js +0 -121
- package/src/templates/navbar-template.js +0 -272
- package/src/templates/overview-template.js +0 -79
- package/src/templates/security-scheme-template.js +0 -610
- package/src/templates/server-template.js +0 -115
- package/src/utils/color-utils.js +0 -59
- package/src/utils/common-utils.js +0 -168
- package/src/utils/schema-utils.js +0 -1086
- package/src/utils/spec-parser.js +0 -462
- package/src/utils/theme.js +0 -288
- package/webpack.config.js +0 -142
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit';
|
|
2
|
-
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
|
|
3
|
-
import { marked } from 'marked';
|
|
4
|
-
import FontStyles from '~/styles/font-styles';
|
|
5
|
-
import SchemaStyles from '~/styles/schema-styles';
|
|
6
|
-
import BorderStyles from '~/styles/border-styles';
|
|
7
|
-
import CustomStyles from '~/styles/custom-styles';
|
|
8
|
-
|
|
9
|
-
export default class SchemaTree extends LitElement {
|
|
10
|
-
static get properties() {
|
|
11
|
-
return {
|
|
12
|
-
data: { type: Object },
|
|
13
|
-
schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
|
|
14
|
-
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
|
|
15
|
-
allowSchemaDescriptionExpandToggle: { type: String, attribute: 'allow-schema-description-expand-toggle' },
|
|
16
|
-
schemaHideReadOnly: { type: String, attribute: 'schema-hide-read-only' },
|
|
17
|
-
schemaHideWriteOnly: { type: String, attribute: 'schema-hide-write-only' },
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
connectedCallback() {
|
|
22
|
-
super.connectedCallback();
|
|
23
|
-
if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
|
|
24
|
-
if (!this.schemaDescriptionExpanded || !'true false'.includes(this.schemaDescriptionExpanded)) { this.schemaDescriptionExpanded = 'false'; }
|
|
25
|
-
if (!this.schemaHideReadOnly || !'true false'.includes(this.schemaHideReadOnly)) { this.schemaHideReadOnly = 'true'; }
|
|
26
|
-
if (!this.schemaHideWriteOnly || !'true false'.includes(this.schemaHideWriteOnly)) { this.schemaHideWriteOnly = 'true'; }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static get styles() {
|
|
30
|
-
return [
|
|
31
|
-
FontStyles,
|
|
32
|
-
SchemaStyles,
|
|
33
|
-
BorderStyles,
|
|
34
|
-
css`
|
|
35
|
-
.tree {
|
|
36
|
-
font-size:var(--font-size-small);
|
|
37
|
-
text-align: left;
|
|
38
|
-
direction: ltr;
|
|
39
|
-
line-height:calc(var(--font-size-small) + 6px);
|
|
40
|
-
}
|
|
41
|
-
.tree .tr:hover{
|
|
42
|
-
background-color:var(--hover-color);
|
|
43
|
-
}
|
|
44
|
-
.collapsed-all-descr .tr:not(.expanded-descr) {
|
|
45
|
-
overflow: hidden;
|
|
46
|
-
max-height:calc(var(--font-size-small) + 8px);
|
|
47
|
-
}
|
|
48
|
-
.tree .key {
|
|
49
|
-
max-width: 300px;
|
|
50
|
-
}
|
|
51
|
-
.key.deprecated .key-label {
|
|
52
|
-
color: var(--red);
|
|
53
|
-
}
|
|
54
|
-
.tr.expanded:hover > .td.key > .open-bracket {
|
|
55
|
-
color: var(--primary-color);
|
|
56
|
-
}
|
|
57
|
-
.tr.expanded:hover + .inside-bracket {
|
|
58
|
-
border-left: 1px solid var(--fg3);
|
|
59
|
-
}
|
|
60
|
-
.tr.expanded:hover + .inside-bracket + .close-bracket {
|
|
61
|
-
color: var(--primary-color);
|
|
62
|
-
}
|
|
63
|
-
.inside-bracket.xxx-of-option {
|
|
64
|
-
border-left: 1px solid transparent;
|
|
65
|
-
}
|
|
66
|
-
.open-bracket{
|
|
67
|
-
display:inline-block;
|
|
68
|
-
padding: 0 20px 0 0;
|
|
69
|
-
cursor:pointer;
|
|
70
|
-
border: 1px solid transparent;
|
|
71
|
-
border-radius:3px;
|
|
72
|
-
}
|
|
73
|
-
.open-bracket:hover {
|
|
74
|
-
color:var(--primary-color);
|
|
75
|
-
background-color:var(--hover-color);
|
|
76
|
-
border: 1px solid var(--border-color);
|
|
77
|
-
}
|
|
78
|
-
.close-bracket{
|
|
79
|
-
display:inline-block;
|
|
80
|
-
font-family: var(--font-mono);
|
|
81
|
-
}
|
|
82
|
-
.tr.collapsed + .inside-bracket,
|
|
83
|
-
.tr.collapsed + .inside-bracket + .close-bracket{
|
|
84
|
-
overflow: hidden;
|
|
85
|
-
display:none;
|
|
86
|
-
}
|
|
87
|
-
.inside-bracket.object,
|
|
88
|
-
.inside-bracket.array {
|
|
89
|
-
border-left: 1px dotted var(--border-color);
|
|
90
|
-
}`,
|
|
91
|
-
CustomStyles,
|
|
92
|
-
];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/* eslint-disable indent */
|
|
96
|
-
render() {
|
|
97
|
-
return html`
|
|
98
|
-
<div class="tree ${this.schemaDescriptionExpanded === 'true' ? 'expanded-all-descr' : 'collapsed-all-descr'}" @click="${(e) => this.handleAllEvents(e)}">
|
|
99
|
-
<div class="toolbar">
|
|
100
|
-
<div class="toolbar-item schema-root-type ${this.data?.['::type'] || ''} "> ${this.data?.['::type'] || ''} </div>
|
|
101
|
-
${this.allowSchemaDescriptionExpandToggle === 'true'
|
|
102
|
-
? html`
|
|
103
|
-
<div style="flex:1"></div>
|
|
104
|
-
<div part="schema-toolbar-item schema-multiline-toggle" class='toolbar-item schema-multiline-toggle'>
|
|
105
|
-
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
|
|
106
|
-
</div>`
|
|
107
|
-
: ''
|
|
108
|
-
}
|
|
109
|
-
</div>
|
|
110
|
-
<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data?.['::description'] || ''))}</span>
|
|
111
|
-
${this.data
|
|
112
|
-
? html`
|
|
113
|
-
${this.generateTree(
|
|
114
|
-
this.data['::type'] === 'array' ? this.data['::props'] : this.data,
|
|
115
|
-
this.data['::type'],
|
|
116
|
-
this.data['::array-type'] || '',
|
|
117
|
-
)}`
|
|
118
|
-
: html`<span class='mono-font' style='color:var(--red)'> Schema not found </span>`
|
|
119
|
-
}
|
|
120
|
-
</div>
|
|
121
|
-
`;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
generateTree(data, dataType = 'object', arrayType = '', key = '', description = '', schemaLevel = 0, indentLevel = 0, readOrWrite = '', isDeprecated = false) {
|
|
125
|
-
if (this.schemaHideReadOnly === 'true') {
|
|
126
|
-
if (dataType === 'array') {
|
|
127
|
-
if (readOrWrite === 'readonly') {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (data?.['::readwrite'] === 'readonly') {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (this.schemaHideWriteOnly === 'true') {
|
|
136
|
-
if (dataType === 'array') {
|
|
137
|
-
if (readOrWrite === 'writeonly') {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (data?.['::readwrite'] === 'writeonly') {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (!data) {
|
|
147
|
-
return html`<div class="null" style="display:inline;">
|
|
148
|
-
<span class="key-label xxx-of-key"> ${key.replace('::OPTION~', '')}</span>
|
|
149
|
-
${
|
|
150
|
-
dataType === 'array'
|
|
151
|
-
? html`<span class='mono-font'> [ ] </span>`
|
|
152
|
-
: dataType === 'object'
|
|
153
|
-
? html`<span class='mono-font'> { } </span>`
|
|
154
|
-
: html`<span class='mono-font'> schema undefined </span>`
|
|
155
|
-
}
|
|
156
|
-
</div>`;
|
|
157
|
-
}
|
|
158
|
-
if (Object.keys(data).length === 0) {
|
|
159
|
-
return html`<span class="key object">${key}:{ }</span>`;
|
|
160
|
-
}
|
|
161
|
-
let keyLabel = '';
|
|
162
|
-
let keyDescr = '';
|
|
163
|
-
if (key.startsWith('::ONE~OF') || key.startsWith('::ANY~OF')) {
|
|
164
|
-
keyLabel = key.replace('::', '').replace('~', ' ');
|
|
165
|
-
} else if (key.startsWith('::OPTION')) {
|
|
166
|
-
const parts = key.split('~');
|
|
167
|
-
[, keyLabel, keyDescr] = parts;
|
|
168
|
-
} else {
|
|
169
|
-
keyLabel = key;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const leftPadding = 12;
|
|
173
|
-
const minFieldColWidth = 400 - (indentLevel * leftPadding);
|
|
174
|
-
let openBracket = '';
|
|
175
|
-
let closeBracket = '';
|
|
176
|
-
const newSchemaLevel = data['::type']?.startsWith('xxx-of') ? schemaLevel : (schemaLevel + 1);
|
|
177
|
-
// const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' ? indentLevel : (indentLevel + 1);
|
|
178
|
-
const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? indentLevel : (indentLevel + 1);
|
|
179
|
-
if (data['::type'] === 'object') {
|
|
180
|
-
if (dataType === 'array') {
|
|
181
|
-
if (schemaLevel < this.schemaExpandLevel) {
|
|
182
|
-
openBracket = html`<span class="open-bracket array-of-object" >[{</span>`;
|
|
183
|
-
} else {
|
|
184
|
-
openBracket = html`<span class="open-bracket array-of-object">[{...}]</span>`;
|
|
185
|
-
}
|
|
186
|
-
closeBracket = '}]';
|
|
187
|
-
} else {
|
|
188
|
-
if (schemaLevel < this.schemaExpandLevel) {
|
|
189
|
-
openBracket = html`<span class="open-bracket object">${data['::nullable'] ? 'null┃' : ''}{</span>`;
|
|
190
|
-
} else {
|
|
191
|
-
openBracket = html`<span class="open-bracket object">${data['::nullable'] ? 'null┃' : ''}{...}</span>`;
|
|
192
|
-
}
|
|
193
|
-
closeBracket = '}';
|
|
194
|
-
}
|
|
195
|
-
} else if (data['::type'] === 'array') {
|
|
196
|
-
if (dataType === 'array') {
|
|
197
|
-
const arrType = arrayType !== 'object' ? arrayType : '';
|
|
198
|
-
if (schemaLevel < this.schemaExpandLevel) {
|
|
199
|
-
openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}">[[ ${arrType} </span>`;
|
|
200
|
-
} else {
|
|
201
|
-
openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}">[[...]]</span>`;
|
|
202
|
-
}
|
|
203
|
-
closeBracket = ']]';
|
|
204
|
-
} else {
|
|
205
|
-
if (schemaLevel < this.schemaExpandLevel) {
|
|
206
|
-
openBracket = html`<span class="open-bracket array">[</span>`;
|
|
207
|
-
} else {
|
|
208
|
-
openBracket = html`<span class="open-bracket array">[...]</span>`;
|
|
209
|
-
}
|
|
210
|
-
closeBracket = ']';
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
if (typeof data === 'object') {
|
|
214
|
-
return html`
|
|
215
|
-
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}${data['::nullable'] ? ' nullable' : ''}" title="${(isDeprecated || data['::deprecated']) ? 'Deprecated' : ''}">
|
|
216
|
-
<div class="td key ${(isDeprecated || data['::deprecated']) ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
|
|
217
|
-
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
|
|
218
|
-
? html`<span class='key-label xxx-of-key'> ${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
|
|
219
|
-
: keyLabel === '::props' || keyLabel === '::ARRAY~OF'
|
|
220
|
-
? ''
|
|
221
|
-
: schemaLevel > 0
|
|
222
|
-
? html`<span class="key-label" title="${readOrWrite === 'readonly' ? 'Read-Only' : readOrWrite === 'writeonly' ? 'Write-Only' : ''}">
|
|
223
|
-
${(isDeprecated || data['::deprecated']) ? '✗' : ''}
|
|
224
|
-
${keyLabel.replace(/\*$/, '')}${keyLabel.endsWith('*') ? html`<span style="color:var(--red)">*</span>` : ''}${readOrWrite === 'readonly' ? html` 🆁` : readOrWrite === 'writeonly' ? html` 🆆` : readOrWrite}:
|
|
225
|
-
</span>`
|
|
226
|
-
: ''
|
|
227
|
-
}
|
|
228
|
-
${openBracket}
|
|
229
|
-
</div>
|
|
230
|
-
<div class='td key-descr m-markdown-small'>${unsafeHTML(marked(description || ''))}</div>
|
|
231
|
-
</div>
|
|
232
|
-
<div class='inside-bracket ${data['::type'] || 'no-type-info'}' style='padding-left:${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' ? 0 : leftPadding}px;'>
|
|
233
|
-
${Array.isArray(data) && data[0]
|
|
234
|
-
? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, data[0]['::readwrite'], (isDeprecated || data[0]['::deprecated']))}`
|
|
235
|
-
: html`
|
|
236
|
-
${Object.keys(data).map((dataKey) => html`
|
|
237
|
-
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel', '::nullable'].includes(dataKey)
|
|
238
|
-
? data[dataKey]['::type'] === 'array' || data[dataKey]['::type'] === 'object'
|
|
239
|
-
? html`${this.generateTree(
|
|
240
|
-
data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
|
|
241
|
-
data[dataKey]['::type'],
|
|
242
|
-
data[dataKey]['::array-type'] || '',
|
|
243
|
-
dataKey,
|
|
244
|
-
data[dataKey]['::description'],
|
|
245
|
-
newSchemaLevel,
|
|
246
|
-
newIndentLevel,
|
|
247
|
-
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
|
|
248
|
-
(isDeprecated || data[dataKey]['::deprecated']),
|
|
249
|
-
)}`
|
|
250
|
-
: ''
|
|
251
|
-
: html`${this.generateTree(
|
|
252
|
-
data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
|
|
253
|
-
data[dataKey]['::type'],
|
|
254
|
-
data[dataKey]['::array-type'] || '',
|
|
255
|
-
dataKey,
|
|
256
|
-
data[dataKey]?.['::description'] || '',
|
|
257
|
-
newSchemaLevel,
|
|
258
|
-
newIndentLevel,
|
|
259
|
-
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
|
|
260
|
-
(isDeprecated || data[dataKey]['::deprecated']),
|
|
261
|
-
)}`
|
|
262
|
-
}
|
|
263
|
-
`)}
|
|
264
|
-
`
|
|
265
|
-
}
|
|
266
|
-
</div>
|
|
267
|
-
${data['::type'] && data['::type'].includes('xxx-of')
|
|
268
|
-
? ''
|
|
269
|
-
: html`<div class='close-bracket'> ${closeBracket} </div>`
|
|
270
|
-
}
|
|
271
|
-
`;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// For Primitive types and array of Primitives
|
|
275
|
-
// eslint-disable-next-line no-unused-vars
|
|
276
|
-
const [type, primitiveReadOrWrite, constraint, defaultValue, allowedValues, pattern, schemaDescription, schemaTitle, deprecated] = data.split('~|~');
|
|
277
|
-
if (primitiveReadOrWrite === '🆁' && this.schemaHideReadOnly === 'true') {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
if (primitiveReadOrWrite === '🆆' && this.schemaHideWriteOnly === 'true') {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
const dataTypeCss = type.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').substring(0, 4).toLowerCase();
|
|
284
|
-
const descrExpander = `${constraint || defaultValue || allowedValues || pattern ? `<span class="descr-expand-toggle ${this.schemaDescriptionExpanded === 'true' ? 'expanded-descr' : ''}">➔</span>` : ''}`;
|
|
285
|
-
let finalReadWriteText = '';
|
|
286
|
-
let finalReadWriteTip = '';
|
|
287
|
-
if (dataType === 'array') {
|
|
288
|
-
if (readOrWrite === 'readonly') {
|
|
289
|
-
finalReadWriteText = '🆁';
|
|
290
|
-
finalReadWriteTip = 'Read-Only';
|
|
291
|
-
} else if (readOrWrite === 'writeonly') {
|
|
292
|
-
finalReadWriteText = '🆆';
|
|
293
|
-
finalReadWriteTip = 'Write-Only';
|
|
294
|
-
}
|
|
295
|
-
} else if (primitiveReadOrWrite === '🆁') {
|
|
296
|
-
finalReadWriteText = '🆁';
|
|
297
|
-
finalReadWriteTip = 'Read-Only';
|
|
298
|
-
} else if (primitiveReadOrWrite === '🆆') {
|
|
299
|
-
finalReadWriteText = '🆆';
|
|
300
|
-
finalReadWriteTip = 'Write-Only';
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return html`
|
|
304
|
-
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
|
|
305
|
-
<div class="td key ${isDeprecated || deprecated}" style='min-width:${minFieldColWidth}px'>
|
|
306
|
-
${isDeprecated || deprecated ? html`<span style='color:var(--red);'>✗</span>` : ''}
|
|
307
|
-
${keyLabel.endsWith('*')
|
|
308
|
-
? html`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>:`
|
|
309
|
-
: key.startsWith('::OPTION')
|
|
310
|
-
? html`<span class='key-label xxx-of-key'>${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
|
|
311
|
-
: html`<span class="key-label">${keyLabel}:</span>`
|
|
312
|
-
}
|
|
313
|
-
<span class="${dataTypeCss}" title="${finalReadWriteTip}">
|
|
314
|
-
${dataType === 'array' ? `[${type}]` : `${type}`}
|
|
315
|
-
${finalReadWriteText}
|
|
316
|
-
</span>
|
|
317
|
-
</div>
|
|
318
|
-
<div class='td key-descr'>
|
|
319
|
-
${description || schemaTitle || schemaDescription
|
|
320
|
-
? html`${html`<span class="m-markdown-small">
|
|
321
|
-
${unsafeHTML(marked(dataType === 'array'
|
|
322
|
-
? `${descrExpander} ${description}`
|
|
323
|
-
: schemaTitle
|
|
324
|
-
? `${descrExpander} <b>${schemaTitle}:</b> ${schemaDescription}`
|
|
325
|
-
: `${descrExpander} ${schemaDescription}`))}
|
|
326
|
-
</span>`
|
|
327
|
-
}`
|
|
328
|
-
: ''
|
|
329
|
-
}
|
|
330
|
-
${constraint ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Constraints: </span>${constraint}</div>` : ''}
|
|
331
|
-
${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
|
|
332
|
-
${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>${type === 'const' ? 'Value' : 'Allowed'}: </span>${allowedValues}</div>` : ''}
|
|
333
|
-
${pattern ? html`<div style='display:inline-block; line-break: anywhere; margin-right:8px'><span class='bold-text'>Pattern: </span>${pattern}</div>` : ''}
|
|
334
|
-
</div>
|
|
335
|
-
</div>
|
|
336
|
-
`;
|
|
337
|
-
}
|
|
338
|
-
/* eslint-enable indent */
|
|
339
|
-
|
|
340
|
-
handleAllEvents(e) {
|
|
341
|
-
if (e.target.classList.contains('open-bracket')) {
|
|
342
|
-
this.toggleObjectExpand(e);
|
|
343
|
-
} else if (e.target.classList.contains('schema-multiline-toggle')) {
|
|
344
|
-
this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true');
|
|
345
|
-
} else if (e.target.classList.contains('descr-expand-toggle')) {
|
|
346
|
-
const trEl = e.target.closest('.tr');
|
|
347
|
-
if (trEl) {
|
|
348
|
-
trEl.classList.toggle('expanded-descr');
|
|
349
|
-
trEl.style.maxHeight = trEl.scrollHeight;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
toggleObjectExpand(e) {
|
|
355
|
-
const rowEl = e.target.closest('.tr');
|
|
356
|
-
const nullable = rowEl.classList.contains('nullable');
|
|
357
|
-
if (rowEl.classList.contains('expanded')) {
|
|
358
|
-
rowEl.classList.replace('expanded', 'collapsed');
|
|
359
|
-
e.target.innerHTML = e.target.classList.contains('array-of-object')
|
|
360
|
-
? '[{...}]'
|
|
361
|
-
: e.target.classList.contains('array-of-array')
|
|
362
|
-
? '[[...]]'
|
|
363
|
-
: e.target.classList.contains('array')
|
|
364
|
-
? '[...]'
|
|
365
|
-
: `${nullable ? 'null┃' : ''}{...}`;
|
|
366
|
-
} else {
|
|
367
|
-
rowEl.classList.replace('collapsed', 'expanded');
|
|
368
|
-
e.target.innerHTML = e.target.classList.contains('array-of-object')
|
|
369
|
-
? '[{'
|
|
370
|
-
: e.target.classList.contains('array-of-array')
|
|
371
|
-
? `[[ ${e.target.dataset.arrayType}`
|
|
372
|
-
: e.target.classList.contains('object')
|
|
373
|
-
? `${nullable ? 'null┃' : ''}{`
|
|
374
|
-
: '[';
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
customElements.define('schema-tree', SchemaTree);
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit';
|
|
2
|
-
|
|
3
|
-
export default class TagInput extends LitElement {
|
|
4
|
-
/* eslint-disable indent */
|
|
5
|
-
render() {
|
|
6
|
-
let tagItemTmpl = '';
|
|
7
|
-
if (Array.isArray(this.value)) {
|
|
8
|
-
tagItemTmpl = html`${this.value
|
|
9
|
-
.filter((v) => typeof v === 'string' && v.trim() !== '')
|
|
10
|
-
.map((v) => html`<span class='tag'>${v}</span>`)
|
|
11
|
-
}`;
|
|
12
|
-
}
|
|
13
|
-
return html`
|
|
14
|
-
<div class='tags'>
|
|
15
|
-
${tagItemTmpl}
|
|
16
|
-
<input type="text" class='editor' @paste="${(e) => this.afterPaste(e)}" @keydown="${this.afterKeyDown}" @blur="${this.onBlur}" placeholder="${this.placeholder || ''}">
|
|
17
|
-
</div>
|
|
18
|
-
`;
|
|
19
|
-
}
|
|
20
|
-
/* eslint-enable indent */
|
|
21
|
-
|
|
22
|
-
static get properties() {
|
|
23
|
-
return {
|
|
24
|
-
placeholder: { type: String },
|
|
25
|
-
value: { type: Array, attribute: 'value' },
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
30
|
-
if (name === 'value') {
|
|
31
|
-
if (newVal && oldVal !== newVal) {
|
|
32
|
-
this.value = newVal.split(',').filter((v) => v.trim() !== '');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
super.attributeChangedCallback(name, oldVal, newVal);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
afterPaste(e) {
|
|
39
|
-
const clipboardData = e.clipboardData || window.clipboardData;
|
|
40
|
-
const pastedData = clipboardData.getData('Text');
|
|
41
|
-
const pastedArray = pastedData ? pastedData.split(',').filter((v) => v.trim() !== '') : '';
|
|
42
|
-
if (pastedArray) {
|
|
43
|
-
if (Array.isArray(this.value)) {
|
|
44
|
-
this.value = [...this.value, ...pastedArray];
|
|
45
|
-
} else {
|
|
46
|
-
this.value = pastedArray;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
e.preventDefault();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
afterKeyDown(e) {
|
|
53
|
-
if (e.keyCode === 13) {
|
|
54
|
-
e.stopPropagation();
|
|
55
|
-
e.preventDefault();
|
|
56
|
-
if (e.target.value) {
|
|
57
|
-
if (Array.isArray(this.value)) {
|
|
58
|
-
this.value = [...this.value, e.target.value];
|
|
59
|
-
} else {
|
|
60
|
-
this.value = [e.target.value];
|
|
61
|
-
}
|
|
62
|
-
e.target.value = '';
|
|
63
|
-
}
|
|
64
|
-
} else if (e.keyCode === 8) {
|
|
65
|
-
if (e.target.value.length === 0) {
|
|
66
|
-
if (Array.isArray(this.value) && this.value.length > 0) {
|
|
67
|
-
this.value.splice(-1);
|
|
68
|
-
this.value = [...this.value];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
onBlur(e) {
|
|
75
|
-
if (e.target.value) {
|
|
76
|
-
if (Array.isArray(this.value)) {
|
|
77
|
-
this.value = [...this.value, e.target.value];
|
|
78
|
-
} else {
|
|
79
|
-
this.value = [e.target.value];
|
|
80
|
-
}
|
|
81
|
-
e.target.value = '';
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
static get styles() {
|
|
86
|
-
return [css`
|
|
87
|
-
.tags {
|
|
88
|
-
display:flex;
|
|
89
|
-
flex-wrap: wrap;
|
|
90
|
-
outline: none;
|
|
91
|
-
padding:0;
|
|
92
|
-
border-radius:var(--border-radius);
|
|
93
|
-
border:1px solid var(--border-color);
|
|
94
|
-
cursor:text;
|
|
95
|
-
overflow:hidden;
|
|
96
|
-
background:var(--input-bg);
|
|
97
|
-
}
|
|
98
|
-
.tag, .editor {
|
|
99
|
-
padding:3px;
|
|
100
|
-
margin:2px;
|
|
101
|
-
}
|
|
102
|
-
.tag{
|
|
103
|
-
border:1px solid var(--border-color);
|
|
104
|
-
background-color:var(--bg3);
|
|
105
|
-
color:var(--fg3);
|
|
106
|
-
border-radius:var(--border-radius);
|
|
107
|
-
word-break: break-all;
|
|
108
|
-
font-size: var(--font-size-small);
|
|
109
|
-
}
|
|
110
|
-
.tag:hover ~ #cursor {
|
|
111
|
-
display: block;
|
|
112
|
-
}
|
|
113
|
-
.editor {
|
|
114
|
-
flex:1;
|
|
115
|
-
border:1px solid transparent;
|
|
116
|
-
color:var(--fg);
|
|
117
|
-
min-width:60px;
|
|
118
|
-
outline: none;
|
|
119
|
-
line-height: inherit;
|
|
120
|
-
font-family:inherit;
|
|
121
|
-
background:transparent;
|
|
122
|
-
font-size: calc(var(--font-size-small) + 1px);
|
|
123
|
-
}
|
|
124
|
-
.editor:focus-visible {
|
|
125
|
-
outline: 1px solid;
|
|
126
|
-
}
|
|
127
|
-
.editor::placeholder {
|
|
128
|
-
color: var(--placeholder-color);
|
|
129
|
-
opacity:1;
|
|
130
|
-
}
|
|
131
|
-
`];
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// Register the element with the browser
|
|
135
|
-
customElements.define('tag-input', TagInput);
|
package/src/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import RapiDoc from '~/rapidoc';
|
|
2
|
-
import RapiDocMini from '~/rapidoc-mini';
|
|
3
|
-
import OAuthReceiver from '~/oauth-receiver';
|
|
4
|
-
import JsonSchemaViewer from '~/json-schema-viewer';
|
|
5
|
-
|
|
6
|
-
export default { RapiDoc };
|
|
7
|
-
export { RapiDocMini, OAuthReceiver, JsonSchemaViewer };
|