@pb33f/cowboy-components 0.5.3 → 0.5.5

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,5 +1,6 @@
1
1
  import './description.js';
2
2
  import './example.js';
3
+ import { TemplateResult } from "lit";
3
4
  import { Schema } from "../../model/schema.js";
4
5
  import { HasExamples } from "./clickable-ref.js";
5
6
  export declare class RenderedSchemaNodeComponent extends HasExamples {
@@ -12,8 +13,8 @@ export declare class RenderedSchemaNodeComponent extends HasExamples {
12
13
  required: string[];
13
14
  constructor();
14
15
  renderMockRequest(e: CustomEvent): void;
15
- render(): import("lit-html").TemplateResult<1>;
16
+ render(): TemplateResult<1>;
16
17
  toggleNode(id: string): void;
17
- renderNoExample(): import("lit-html").TemplateResult<1>;
18
- renderObject(key: string, obj: any, required?: string[]): import("lit-html").TemplateResult<1>;
18
+ renderNoExample(): TemplateResult<1>;
19
+ renderObject(key: string, obj: any, required?: string[]): TemplateResult<1>;
19
20
  }
@@ -276,6 +276,59 @@ let RenderedSchemaNodeComponent = class RenderedSchemaNodeComponent extends HasE
276
276
  }}>${refName}</span></div>`;
277
277
  }
278
278
  else {
279
+ //check if the mapKey is 'properties, if so, for each property, re-render
280
+ if (mapKey == 'properties') {
281
+ // child is an object, so extract the keys and treat them as schemas
282
+ const keys = Object.keys(obj[mapKey]);
283
+ // for each key, render the schema
284
+ const templates = [];
285
+ keys.forEach((key) => {
286
+ const child = obj[mapKey][key];
287
+ let sub = html ``;
288
+ if (Object.keys(obj[mapKey]).length > 1) {
289
+ sub = html `
290
+ <div class="object">
291
+ <pb33f-rendered-schema-node .schema="${child}" objectItem
292
+ skinny></pb33f-rendered-schema-node>
293
+ </div>`;
294
+ }
295
+ let v = [];
296
+ if (child.type) {
297
+ if (Array.isArray(child.type)) {
298
+ for (let i = 0; i < child.type.length; i++) {
299
+ const item = child.type[i];
300
+ v.push(html `<code>${item}</code>`);
301
+ if (i < child.type.length - 1) {
302
+ v.push(html `<span>,&nbsp;&nbsp;</span>`);
303
+ }
304
+ }
305
+ }
306
+ else {
307
+ v.push(html `<code>${child.type}</code>`);
308
+ }
309
+ }
310
+ templates.push(html `
311
+ <div class="object">
312
+ <span class="key">${key} ${v}: </span>
313
+ ${sub}
314
+ </div>`);
315
+ });
316
+ return html `
317
+ <div class="object expandable">
318
+ <span @click="${() => {
319
+ this.toggleNode(id);
320
+ }}" class="expand key">${mapKey}</span>
321
+ <span class="expand" id="${id}-toggle" @click="${() => {
322
+ this.toggleNode(id);
323
+ }}">
324
+ <sl-icon class="expand" name="chevron-right"></sl-icon>
325
+ </span>
326
+ <div class="hide mong" id="${id}">
327
+ ${templates}
328
+ </div>
329
+ </div>
330
+ `;
331
+ }
279
332
  isObject = true;
280
333
  const child = obj[mapKey];
281
334
  if (child.$ref) {
@@ -291,7 +344,7 @@ let RenderedSchemaNodeComponent = class RenderedSchemaNodeComponent extends HasE
291
344
  </div>
292
345
  `;
293
346
  }
294
- if (child.type && !child.type.includes('object')) {
347
+ if (child.type && (!child.type.includes('object') || child.type != 'object')) {
295
348
  // check if obj[key] has any other properties other than a type, if so render
296
349
  let sub = html ``;
297
350
  if (Object.keys(obj[mapKey]).length > 1) {
@@ -21,7 +21,7 @@ export default css `
21
21
  }
22
22
 
23
23
  .no-values {
24
- min-height: 550px;
24
+ //min-height: 550px;
25
25
  width: 500px;
26
26
  margin: 0 auto;
27
27
  padding-top: 50px;
@@ -53,7 +53,7 @@ export default css `
53
53
 
54
54
  sl-split-panel {
55
55
  width: 100%;
56
- // height: calc(100% - 65px);
56
+ height: 100%;
57
57
  --divider-width: 2px;
58
58
  }
59
59
 
@@ -188,6 +188,10 @@ export default css `
188
188
  width: 100%;
189
189
  }
190
190
 
191
+ .tab-group {
192
+ height: 100%
193
+ }
194
+
191
195
  sl-tab-panel.tab-panel::part(base) {
192
196
  height: 100%;
193
197
  padding-top: 5px;
@@ -74,9 +74,11 @@ export declare class TheDoctor extends LitElement {
74
74
  splitPanelExplorer: SlSplitPanel;
75
75
  splitPanelRolodex: SlSplitPanel;
76
76
  splitPanelInspector: SlSplitPanel;
77
+ private randomTicker;
77
78
  private rulesetPulse;
78
79
  explorerVisible: boolean;
79
80
  minimapVisible: boolean;
81
+ minimapIconVisible: boolean;
80
82
  explorerBooted: boolean;
81
83
  activeURL: string;
82
84
  rolodexNeedsReset: boolean;
@@ -161,6 +163,7 @@ export declare class TheDoctor extends LitElement {
161
163
  private pendingLine;
162
164
  private rolodexDividerPosition;
163
165
  constructor(doctorEndpoint?: string);
166
+ tickRandomly(): void;
164
167
  nukeWorkspaceHandler(): void;
165
168
  minimapToggled(): void;
166
169
  firstUpdated(): void;
@@ -224,6 +227,8 @@ export declare class TheDoctor extends LitElement {
224
227
  selectControlTab(event: CustomEvent): void;
225
228
  toggleSidebar(): void;
226
229
  toggleExplorer(): void;
230
+ hideMinimapIcon(): void;
231
+ showMinimapIcon(): void;
227
232
  closeExplorer(): void;
228
233
  render(): import("lit-html").TemplateResult<1>;
229
234
  fetchUrl(event: CustomEvent<ArchiveURLRequestedEvent>): void;
@@ -142,7 +142,9 @@ let TheDoctor = class TheDoctor extends LitElement {
142
142
  this.renderedNode = new RenderedNodeComponent();
143
143
  this.references = [];
144
144
  this.minimapVisible = true;
145
+ this.minimapIconVisible = true;
145
146
  this.nodeLimit = 150;
147
+ this.randomTicker = 0;
146
148
  // extract the doctor endpoint from session storage.
147
149
  const sessionEndpoint = sessionStorage.getItem(DoctorEndpoint);
148
150
  if (sessionEndpoint) {
@@ -229,6 +231,9 @@ let TheDoctor = class TheDoctor extends LitElement {
229
231
  }
230
232
  });
231
233
  }
234
+ tickRandomly() {
235
+ this.randomTicker = Math.floor(Math.random() * 9999999);
236
+ }
232
237
  nukeWorkspaceHandler() {
233
238
  this.bagManager.resetBags();
234
239
  ModelService.resetWorkspace().then(() => {
@@ -266,9 +271,7 @@ let TheDoctor = class TheDoctor extends LitElement {
266
271
  this.whoAmI();
267
272
  }
268
273
  };
269
- // TODO re-enable
270
274
  this.bus.connectToBroker(config);
271
- //this.startTheDoctor()
272
275
  }
273
276
  addClickTrack(node) {
274
277
  history.pushState({ activeNode: node.idHash }, "", `?view=explore&node=${node.idHash}`);
@@ -1046,6 +1049,7 @@ let TheDoctor = class TheDoctor extends LitElement {
1046
1049
  }
1047
1050
  // determine if the score went up or down and toast it!
1048
1051
  this.problemsOverview.statistics = result;
1052
+ this.tickRandomly(); // tick randomly to refresh docs iframe.
1049
1053
  // TODO: re-evaluate these toasts, they get annoying, fucking fast.
1050
1054
  // if (this.problemsOverview.statistics) {
1051
1055
  // const newScore = result.statistics.overallScore;
@@ -1674,6 +1678,13 @@ let TheDoctor = class TheDoctor extends LitElement {
1674
1678
  this.creditTicker.credits = this.session.creditsRemaining;
1675
1679
  }
1676
1680
  this.creditTicker.visible = true;
1681
+ const url = new URL(window.location.href);
1682
+ const urlParam = url.searchParams.get('url');
1683
+ if (urlParam) {
1684
+ //this.urlInput.value = urlParam;
1685
+ this.activeURL = urlParam;
1686
+ this.lintSpec('', urlParam);
1687
+ }
1677
1688
  LintingService.fetchAllHowToFix().then((result) => {
1678
1689
  if (result) {
1679
1690
  result.forEach((howToFix) => {
@@ -1741,7 +1752,7 @@ let TheDoctor = class TheDoctor extends LitElement {
1741
1752
  }
1742
1753
  }).catch((e) => {
1743
1754
  this.platformUnavailable(e);
1744
- console.error("cannot start session");
1755
+ console.error("cannot start session", e);
1745
1756
  });
1746
1757
  }
1747
1758
  fetchRulesetMap() {
@@ -1868,7 +1879,7 @@ let TheDoctor = class TheDoctor extends LitElement {
1868
1879
  const url = new URL(window.location.href);
1869
1880
  const urlParam = url.searchParams.get('url');
1870
1881
  if (urlParam) {
1871
- this.urlInput.value = urlParam;
1882
+ //this.urlInput.value = urlParam;
1872
1883
  this.activeURL = urlParam;
1873
1884
  this.lintSpec('', urlParam);
1874
1885
  return;
@@ -1986,6 +1997,7 @@ let TheDoctor = class TheDoctor extends LitElement {
1986
1997
  if (this.explorerVisible && this.activeNode) {
1987
1998
  this.explorer.moveToNode(this.activeNode);
1988
1999
  }
2000
+ this.hideMinimapIcon();
1989
2001
  this.explorerBooted = true;
1990
2002
  // check if ths is safari and fire a warning toast!
1991
2003
  const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
@@ -1998,8 +2010,17 @@ let TheDoctor = class TheDoctor extends LitElement {
1998
2010
  });
1999
2011
  }
2000
2012
  }
2013
+ hideMinimapIcon() {
2014
+ console.log('hiding minimap icon');
2015
+ this.minimapIconVisible = false;
2016
+ }
2017
+ showMinimapIcon() {
2018
+ console.log('showing minimap icon');
2019
+ this.minimapIconVisible = true;
2020
+ }
2001
2021
  closeExplorer() {
2002
2022
  this.explorerVisible = false;
2023
+ this.showMinimapIcon();
2003
2024
  setTimeout(() => {
2004
2025
  if (this.pendingLine > 0) {
2005
2026
  this.editor.editor?.setPosition({ lineNumber: this.pendingLine, column: 1 });
@@ -2136,10 +2157,11 @@ let TheDoctor = class TheDoctor extends LitElement {
2136
2157
  class="divider-vert"></sl-icon>
2137
2158
  <div class="editor" slot="start">
2138
2159
 
2139
- <sl-tooltip class="minimap-tip" content="Toggle source mini-map" hoist>
2160
+ <sl-tooltip class="minimap-tip" content="Toggle source mini-map" hoist style="${!this.minimapIconVisible ? 'display: none' : ''}">
2140
2161
  <sl-icon-button @click="${this.minimapToggled}"
2141
2162
  name="map"
2142
- class="minimap-toggle ${this.minimapVisible ? 'active' : ''}"></sl-icon-button>
2163
+ class="minimap-toggle ${this.minimapVisible ? 'active' : ''}"
2164
+ style="${!this.minimapIconVisible ? 'display: none' : ''}"></sl-icon-button>
2143
2165
  </sl-tooltip>
2144
2166
 
2145
2167
  ${this.detailsDrawer}
@@ -2158,6 +2180,11 @@ let TheDoctor = class TheDoctor extends LitElement {
2158
2180
  Ruleset ${rulesetPulsePill}
2159
2181
  </sl-tab>
2160
2182
 
2183
+ <sl-tab slot="nav" panel="docs" class="tab" id="docs" @click="${this.hideMinimapIcon}">
2184
+ API Docs
2185
+ </sl-tab>
2186
+
2187
+
2161
2188
  <sl-tab-panel name="spec" class="tab-panel">
2162
2189
  <div class="main-view">
2163
2190
  ${this.statusBar}
@@ -2181,7 +2208,6 @@ let TheDoctor = class TheDoctor extends LitElement {
2181
2208
  </div>
2182
2209
  </div>
2183
2210
 
2184
-
2185
2211
  <!-- EDITOR -->
2186
2212
  <slot name="spec-editor"></slot>
2187
2213
  <!-- EDITOR -->
@@ -2197,6 +2223,10 @@ let TheDoctor = class TheDoctor extends LitElement {
2197
2223
  @mouseleave="${this.ungrabExplorer}">${this.explorer}
2198
2224
  </sl-tab-panel>
2199
2225
 
2226
+ <sl-tab-panel name="docs" class="tab-panel" style="height: calc(100vh - 100px)">
2227
+ <iframe src="${this.doctorEndpoint}/model/scalar-template?z=${this.randomTicker}" width="100%" height="100%" style="border: none"></iframe>
2228
+ </sl-tab-panel>
2229
+
2200
2230
  </sl-tab-group>
2201
2231
  </div>
2202
2232
  ${mainPanelView}
@@ -2205,14 +2235,6 @@ let TheDoctor = class TheDoctor extends LitElement {
2205
2235
  </sl-split-panel>
2206
2236
 
2207
2237
  </div>`;
2208
- //
2209
- // docs <iframe src="/docs.html" width="100%" height="100%"
2210
- // style="border: none"></iframe>
2211
- // <sl-tab slot="nav" panel="docs" class="tab" id="docs">
2212
- // Docs
2213
- // </sl-tab>
2214
- // <sl-tab-panel name="docs" class="tab-panel">
2215
- // </sl-tab-panel>
2216
2238
  }
2217
2239
  fetchUrl(event) {
2218
2240
  this.activeURL = event.detail.url;
@@ -2315,6 +2337,9 @@ __decorate([
2315
2337
  __decorate([
2316
2338
  query('#inspector-split-panel')
2317
2339
  ], TheDoctor.prototype, "splitPanelInspector", void 0);
2340
+ __decorate([
2341
+ state()
2342
+ ], TheDoctor.prototype, "randomTicker", void 0);
2318
2343
  __decorate([
2319
2344
  state()
2320
2345
  ], TheDoctor.prototype, "rulesetPulse", void 0);
@@ -2324,6 +2349,9 @@ __decorate([
2324
2349
  __decorate([
2325
2350
  state()
2326
2351
  ], TheDoctor.prototype, "minimapVisible", void 0);
2352
+ __decorate([
2353
+ state()
2354
+ ], TheDoctor.prototype, "minimapIconVisible", void 0);
2327
2355
  __decorate([
2328
2356
  state()
2329
2357
  ], TheDoctor.prototype, "activeURL", void 0);