${recursiveResult}
`;
@@ -301,20 +307,20 @@ export default class SchemaTable extends LitElement {
}
const result = html`
-
-
+
+
${keyLabel?.endsWith('*')
- ? html`${keyLabel.substring(0, keyLabel.length - 1)}`
+ ? html`${keyLabel.substring(0, keyLabel.length - 1)}`
: key.startsWith('::OPTION')
? html`${keyLabel}${keyDescr}`
: html`${keyLabel ? html` ${keyLabel}` : html`${schemaTitle}`}`
}
-
+
${dataType === 'array' ? '[' : ''}${format || type}${dataType === 'array' ? ']' : ''}
${readOrWriteOnly}
-
+
${unsafeHTML(toMarkdown(`${`${(schemaTitle || title) ? `**${schemaTitle || title}${schemaDescription || description ? ':' : ''}**` : ''} ${schemaDescription || description}` || ''}`))}
@@ -333,6 +339,62 @@ export default class SchemaTable extends LitElement {
toggleObjectExpand(e) {
const rowEl = e.target.closest('.tr');
rowEl.classList.toggle('collapsed');
+ e.target.setAttribute('aria-expanded', !rowEl.classList.contains('collapsed'));
+ }
+
+ treegridKeydown(e) {
+ if (e.shiftKey) {return true;}
+ const cell = e.target;
+ if (cell.getAttribute('role') !== 'gridcell') {return true;}
+ const row = Array.from(cell.parentNode.children);
+ const table = Array.from(cell.closest('.table').querySelectorAll('.tr'));
+ const index = row.indexOf(cell);
+ const rIndex = table.indexOf(cell.parentNode);
+ switch (e.key) {
+ case 'ArrowRight':
+ if (index < row.length - 1) {
+ row[index + 1].tabIndex = 0;
+ row[index + 1].focus();
+ cell.tabIndex = '-1';
+ }
+ break;
+ case 'ArrowLeft':
+ if (index > 0) {
+ row[index - 1].tabIndex = 0;
+ row[index - 1].focus();
+ cell.tabIndex = '-1';
+ }
+ break;
+ case 'ArrowDown':
+ if (rIndex < table.length - 1) {
+ table[rIndex + 1].children[index].tabIndex = 0;
+ table[rIndex + 1].children[index].focus();
+ cell.tabIndex = '-1';
+ }
+ break;
+ case 'ArrowUp':
+ if (rIndex > 0) {
+ table[rIndex - 1].children[index].tabIndex = 0;
+ table[rIndex - 1].children[index].focus();
+ cell.tabIndex = '-1';
+ }
+ break;
+ case 'Home':
+ e.preventDefault();
+ cell.tabIndex = '-1';
+ row[0].tabIndex = 0;
+ row[0].focus();
+ break;
+ case 'End':
+ e.preventDefault();
+ cell.tabIndex = '-1';
+ row[row.length - 1].tabIndex = 0;
+ row[row.length - 1].focus();
+ break;
+ default:
+ break;
+ }
+ return true;
}
}
if (!customElements.get('openapi-explorer')) {
diff --git a/src/styles/schema-styles.js b/src/styles/schema-styles.js
index 19f5d098..5f369aaa 100644
--- a/src/styles/schema-styles.js
+++ b/src/styles/schema-styles.js
@@ -33,6 +33,7 @@ export default css`
.key-descr {
font-family:var(--font-regular);
flex-shrink: 1;
+ flex-grow: 1;
text-overflow: ellipsis;
overflow: hidden;
display: none;