rapidoc 9.3.8 → 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 -3914
  3. package/package.json +23 -46
  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 -1010
  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 -21603
  17. package/dist/report.html +0 -39
  18. package/index-hashroute.html +0 -65
  19. package/index.html +0 -1045
  20. package/index_bak.html +0 -251
  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 -1793
  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 -367
  29. package/src/components/schema-tree.js +0 -381
  30. package/src/components/tag-input.js +0 -135
  31. package/src/index.js +0 -7
  32. package/src/json-schema-viewer.js +0 -346
  33. package/src/oauth-receiver.js +0 -56
  34. package/src/rapidoc-mini.js +0 -382
  35. package/src/rapidoc.js +0 -1083
  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 -207
  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 -75
  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 -251
  54. package/src/templates/expanded-endpoint-template.js +0 -199
  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 -110
  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 -612
  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,381 +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
- .tr.expanded:hover > .td.key > .open-bracket {
52
- color: var(--primary-color);
53
- }
54
- .tr.expanded:hover + .inside-bracket {
55
- border-left: 1px solid var(--fg3);
56
- }
57
- .tr.expanded:hover + .inside-bracket + .close-bracket {
58
- color: var(--primary-color);
59
- }
60
- .inside-bracket.xxx-of-option {
61
- border-left: 1px solid transparent;
62
- }
63
- .open-bracket{
64
- display:inline-block;
65
- padding: 0 20px 0 0;
66
- cursor:pointer;
67
- border: 1px solid transparent;
68
- border-radius:3px;
69
- }
70
- .open-bracket:hover {
71
- color:var(--primary-color);
72
- background-color:var(--hover-color);
73
- border: 1px solid var(--border-color);
74
- }
75
- .close-bracket{
76
- display:inline-block;
77
- font-family: var(--font-mono);
78
- }
79
- .tr.collapsed + .inside-bracket,
80
- .tr.collapsed + .inside-bracket + .close-bracket{
81
- overflow: hidden;
82
- display:none;
83
- }
84
- .inside-bracket.object,
85
- .inside-bracket.array {
86
- border-left: 1px dotted var(--border-color);
87
- }`,
88
- CustomStyles,
89
- ];
90
- }
91
-
92
- /* eslint-disable indent */
93
- render() {
94
- return html`
95
- <div class="tree ${this.schemaDescriptionExpanded === 'true' ? 'expanded-all-descr' : 'collapsed-all-descr'}" @click="${(e) => this.handleAllEvents(e)}">
96
- <div class="toolbar">
97
- <div class="toolbar-item schema-root-type ${this.data?.['::type'] || ''} "> ${this.data?.['::type'] || ''} </div>
98
- ${this.allowSchemaDescriptionExpandToggle === 'true'
99
- ? html`
100
- <div style="flex:1"></div>
101
- <div part="schema-toolbar-item schema-multiline-toggle" class='toolbar-item schema-multiline-toggle'>
102
- ${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
103
- </div>`
104
- : ''
105
- }
106
- </div>
107
- <span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data?.['::description'] || ''))}</span>
108
- ${this.data
109
- ? html`
110
- ${this.generateTree(
111
- this.data['::type'] === 'array' ? this.data['::props'] : this.data,
112
- this.data['::type'],
113
- this.data['::array-type'] || '',
114
- )}`
115
- : html`<span class='mono-font' style='color:var(--red)'> Schema not found </span>`
116
- }
117
- </div>
118
- `;
119
- }
120
-
121
- generateTree(data, dataType = 'object', arrayType = '', key = '', description = '', schemaLevel = 0, indentLevel = 0, readOrWrite = '', isDeprecated = false) {
122
- if (this.schemaHideReadOnly === 'true') {
123
- if (dataType === 'array') {
124
- if (readOrWrite === 'readonly') {
125
- return;
126
- }
127
- }
128
- if (data?.['::readwrite'] === 'readonly') {
129
- return;
130
- }
131
- }
132
- if (this.schemaHideWriteOnly === 'true') {
133
- if (dataType === 'array') {
134
- if (readOrWrite === 'writeonly') {
135
- return;
136
- }
137
- }
138
- if (data?.['::readwrite'] === 'writeonly') {
139
- return;
140
- }
141
- }
142
-
143
- if (!data) {
144
- return html`<div class="null" style="display:inline;">
145
- <span class="key-label xxx-of-key"> ${key.replace('::OPTION~', '')}</span>
146
- ${
147
- dataType === 'array'
148
- ? html`<span class='mono-font'> [ ] </span>`
149
- : dataType === 'object'
150
- ? html`<span class='mono-font'> { } </span>`
151
- : html`<span class='mono-font'> schema undefined </span>`
152
- }
153
- </div>`;
154
- }
155
- if (Object.keys(data).length === 0) {
156
- return html`<span class="key object">${key}:{ }</span>`;
157
- }
158
- let keyLabel = '';
159
- let keyDescr = '';
160
- if (key.startsWith('::ONE~OF') || key.startsWith('::ANY~OF')) {
161
- keyLabel = key.replace('::', '').replace('~', ' ');
162
- } else if (key.startsWith('::OPTION')) {
163
- const parts = key.split('~');
164
- [, keyLabel, keyDescr] = parts;
165
- } else {
166
- keyLabel = key;
167
- }
168
-
169
- const leftPadding = 12;
170
- const minFieldColWidth = 400 - (indentLevel * leftPadding);
171
- let openBracket = '';
172
- let closeBracket = '';
173
- const newSchemaLevel = data['::type']?.startsWith('xxx-of') ? schemaLevel : (schemaLevel + 1);
174
- // const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' ? indentLevel : (indentLevel + 1);
175
- const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? indentLevel : (indentLevel + 1);
176
- if (data['::type'] === 'object') {
177
- if (dataType === 'array') {
178
- if (schemaLevel < this.schemaExpandLevel) {
179
- openBracket = html`<span class="open-bracket array-of-object" >[{</span>`;
180
- } else {
181
- openBracket = html`<span class="open-bracket array-of-object">[{...}]</span>`;
182
- }
183
- closeBracket = '}]';
184
- } else {
185
- if (schemaLevel < this.schemaExpandLevel) {
186
- openBracket = html`<span class="open-bracket object">${data['::nullable'] ? 'null┃' : ''}{</span>`;
187
- } else {
188
- openBracket = html`<span class="open-bracket object">${data['::nullable'] ? 'null┃' : ''}{...}</span>`;
189
- }
190
- closeBracket = '}';
191
- }
192
- } else if (data['::type'] === 'array') {
193
- if (dataType === 'array') {
194
- const arrType = arrayType !== 'object' ? arrayType : '';
195
- if (schemaLevel < this.schemaExpandLevel) {
196
- openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}">[[ ${arrType} </span>`;
197
- } else {
198
- openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}">[[...]]</span>`;
199
- }
200
- closeBracket = ']]';
201
- } else {
202
- if (schemaLevel < this.schemaExpandLevel) {
203
- openBracket = html`<span class="open-bracket array">[</span>`;
204
- } else {
205
- openBracket = html`<span class="open-bracket array">[...]</span>`;
206
- }
207
- closeBracket = ']';
208
- }
209
- }
210
- if (typeof data === 'object') {
211
- return html`
212
- <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' : ''}">
213
- <div class="td key ${(isDeprecated || data['::deprecated']) ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
214
- ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
215
- ? html`<span class='key-label xxx-of-key'> ${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
216
- : keyLabel === '::props' || keyLabel === '::ARRAY~OF'
217
- ? ''
218
- : schemaLevel > 0
219
- ? html`<span class="key-label" title="${readOrWrite === 'readonly' ? 'Read-Only' : readOrWrite === 'writeonly' ? 'Write-Only' : ''}">
220
- ${(isDeprecated || data['::deprecated'])
221
- ? html`<svg viewBox="0 0 10 10" width="10" height="10" style="stroke:var(--red); margin-right:-6px"><path d="M2 2L8 8M2 8L8 2"/></svg>`
222
- : ''
223
- }
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
307
- ? html`<svg viewBox="0 0 10 10" width="10" height="10" style="stroke:var(--red); margin-right:-6px"><path d="M2 2L8 8M2 8L8 2"/></svg>`
308
- : ''
309
- }
310
- ${keyLabel.endsWith('*')
311
- ? html`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>:`
312
- : key.startsWith('::OPTION')
313
- ? html`<span class='key-label xxx-of-key'>${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
314
- : html`<span class="key-label">${keyLabel}:</span>`
315
- }
316
- <span class="${dataTypeCss}" title="${finalReadWriteTip}">
317
- ${dataType === 'array' ? `[${type}]` : `${type}`}
318
- ${finalReadWriteText}
319
- </span>
320
- </div>
321
- <div class='td key-descr'>
322
- ${description || schemaTitle || schemaDescription
323
- ? html`${html`<span class="m-markdown-small">
324
- ${unsafeHTML(marked(dataType === 'array'
325
- ? `${descrExpander} ${description}`
326
- : schemaTitle
327
- ? `${descrExpander} <b>${schemaTitle}:</b> ${schemaDescription}`
328
- : `${descrExpander} ${schemaDescription}`))}
329
- </span>`
330
- }`
331
- : ''
332
- }
333
- ${constraint ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Constraints: </span>${constraint}</div>` : ''}
334
- ${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
335
- ${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>${type === 'const' ? 'Value' : 'Allowed'}: </span>${allowedValues}</div>` : ''}
336
- ${pattern ? html`<div style='display:inline-block; line-break: anywhere; margin-right:8px'><span class='bold-text'>Pattern: </span>${pattern}</div>` : ''}
337
- </div>
338
- </div>
339
- `;
340
- }
341
- /* eslint-enable indent */
342
-
343
- handleAllEvents(e) {
344
- if (e.target.classList.contains('open-bracket')) {
345
- this.toggleObjectExpand(e);
346
- } else if (e.target.classList.contains('schema-multiline-toggle')) {
347
- this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true');
348
- } else if (e.target.classList.contains('descr-expand-toggle')) {
349
- const trEl = e.target.closest('.tr');
350
- if (trEl) {
351
- trEl.classList.toggle('expanded-descr');
352
- trEl.style.maxHeight = trEl.scrollHeight;
353
- }
354
- }
355
- }
356
-
357
- toggleObjectExpand(e) {
358
- const rowEl = e.target.closest('.tr');
359
- const nullable = rowEl.classList.contains('nullable');
360
- if (rowEl.classList.contains('expanded')) {
361
- rowEl.classList.replace('expanded', 'collapsed');
362
- e.target.innerHTML = e.target.classList.contains('array-of-object')
363
- ? '[{...}]'
364
- : e.target.classList.contains('array-of-array')
365
- ? '[[...]]'
366
- : e.target.classList.contains('array')
367
- ? '[...]'
368
- : `${nullable ? 'null┃' : ''}{...}`;
369
- } else {
370
- rowEl.classList.replace('collapsed', 'expanded');
371
- e.target.innerHTML = e.target.classList.contains('array-of-object')
372
- ? '[{'
373
- : e.target.classList.contains('array-of-array')
374
- ? `[[ ${e.target.dataset.arrayType}`
375
- : e.target.classList.contains('object')
376
- ? `${nullable ? 'null┃' : ''}{`
377
- : '[';
378
- }
379
- }
380
- }
381
- 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 };