@michaelmishin/speclens 0.1.2 → 0.2.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/dist/speclens.js CHANGED
@@ -20292,8 +20292,10 @@ let SlHeader = class extends i$1 {
20292
20292
  </button>
20293
20293
 
20294
20294
  <div class="title-area">
20295
- <span class="title">${this.spec.title}</span>
20296
- <span class="version">${this.spec.version}</span>
20295
+ <slot name="logo">
20296
+ <span class="title">${this.spec.title}</span>
20297
+ <span class="version">${this.spec.version}</span>
20298
+ </slot>
20297
20299
  </div>
20298
20300
 
20299
20301
  <div class="spacer"></div>
@@ -20312,6 +20314,8 @@ let SlHeader = class extends i$1 {
20312
20314
  </button>
20313
20315
  ` : null}
20314
20316
 
20317
+ <slot name="header-actions"></slot>
20318
+
20315
20319
  <button class="action-btn" @click=${() => this.dispatchEvent(new CustomEvent("toggle-theme"))} title="Toggle theme">
20316
20320
  <svg width="18" height="18" viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.5">
20317
20321
  <circle cx="9" cy="9" r="4"/>
@@ -20471,6 +20475,8 @@ let SlSidebar = class extends i$1 {
20471
20475
  this.activeOperationId = "";
20472
20476
  this.open = false;
20473
20477
  this.searchEngine = null;
20478
+ this.layout = "page";
20479
+ this.securitySchemes = [];
20474
20480
  this._searchQuery = "";
20475
20481
  this._searchResults = [];
20476
20482
  }
@@ -20559,6 +20565,19 @@ let SlSidebar = class extends i$1 {
20559
20565
  `)}
20560
20566
  `}
20561
20567
  </div>
20568
+
20569
+ ${this.layout === "embed" && this.securitySchemes.length > 0 ? b`
20570
+ <button
20571
+ class="sidebar-auth-btn"
20572
+ @click=${() => this.dispatchEvent(new CustomEvent("toggle-auth", { bubbles: true, composed: true }))}
20573
+ >
20574
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
20575
+ <rect x="3" y="7" width="10" height="7" rx="1.5"/>
20576
+ <path d="M5.5 7V5a2.5 2.5 0 015 0v2"/>
20577
+ </svg>
20578
+ Authorize
20579
+ </button>
20580
+ ` : null}
20562
20581
  </nav>
20563
20582
  `;
20564
20583
  }
@@ -20804,6 +20823,31 @@ SlSidebar.styles = [
20804
20823
  color: var(--sl-color-text-muted);
20805
20824
  text-align: center;
20806
20825
  }
20826
+
20827
+ /* ── Embed-mode auth button ───────────── */
20828
+ .sidebar-auth-btn {
20829
+ display: flex;
20830
+ align-items: center;
20831
+ gap: 8px;
20832
+ margin: var(--sl-spacing-sm) var(--sl-spacing-md) var(--sl-spacing-md);
20833
+ padding: 8px 14px;
20834
+ border-radius: var(--sl-radius-md);
20835
+ border: 1.5px solid var(--sl-color-border);
20836
+ color: var(--sl-color-text-secondary);
20837
+ background: transparent;
20838
+ font-size: var(--sl-font-size-sm);
20839
+ font-weight: 600;
20840
+ cursor: pointer;
20841
+ transition: all var(--sl-transition-fast);
20842
+ flex-shrink: 0;
20843
+ width: calc(100% - var(--sl-spacing-xl));
20844
+ }
20845
+
20846
+ .sidebar-auth-btn:hover {
20847
+ border-color: var(--sl-color-primary);
20848
+ color: var(--sl-color-primary);
20849
+ background: var(--sl-color-sidebar-active);
20850
+ }
20807
20851
  `
20808
20852
  ];
20809
20853
  __decorateClass$9([
@@ -20818,6 +20862,12 @@ __decorateClass$9([
20818
20862
  __decorateClass$9([
20819
20863
  n2({ type: Object })
20820
20864
  ], SlSidebar.prototype, "searchEngine", 2);
20865
+ __decorateClass$9([
20866
+ n2()
20867
+ ], SlSidebar.prototype, "layout", 2);
20868
+ __decorateClass$9([
20869
+ n2({ type: Array })
20870
+ ], SlSidebar.prototype, "securitySchemes", 2);
20821
20871
  __decorateClass$9([
20822
20872
  r$1()
20823
20873
  ], SlSidebar.prototype, "_searchQuery", 2);
@@ -30111,6 +30161,7 @@ let SpecLensElement = class extends i$1 {
30111
30161
  this.theme = "auto";
30112
30162
  this.hideTryIt = false;
30113
30163
  this.hideCodeSamples = false;
30164
+ this.layout = "page";
30114
30165
  this.config = {};
30115
30166
  this._spec = null;
30116
30167
  this._loading = false;
@@ -30230,18 +30281,27 @@ let SpecLensElement = class extends i$1 {
30230
30281
  _handleTryIt(e2) {
30231
30282
  this._tryItOperation = e2.detail;
30232
30283
  }
30284
+ /** Set the color theme programmatically. Useful in embed mode where the header is hidden. */
30285
+ setTheme(preference) {
30286
+ this.theme = preference;
30287
+ }
30233
30288
  render() {
30234
30289
  var _a2, _b2;
30235
30290
  return b`
30236
30291
  <div class="sl-root" data-theme=${((_a2 = this._themeManager) == null ? void 0 : _a2.resolved) ?? "light"}>
30237
30292
  ${this._spec ? b`
30238
- <sl-header
30239
- .spec=${this._spec}
30240
- .authOpen=${this._authOpen}
30241
- @toggle-theme=${this._handleThemeToggle}
30242
- @toggle-sidebar=${() => this._sidebarOpen = !this._sidebarOpen}
30243
- @toggle-auth=${() => this._authOpen = !this._authOpen}
30244
- ></sl-header>
30293
+ ${this.layout === "page" ? b`
30294
+ <sl-header
30295
+ .spec=${this._spec}
30296
+ .authOpen=${this._authOpen}
30297
+ @toggle-theme=${this._handleThemeToggle}
30298
+ @toggle-sidebar=${() => this._sidebarOpen = !this._sidebarOpen}
30299
+ @toggle-auth=${() => this._authOpen = !this._authOpen}
30300
+ >
30301
+ <slot name="logo" slot="logo"></slot>
30302
+ <slot name="header-actions" slot="header-actions"></slot>
30303
+ </sl-header>
30304
+ ` : null}
30245
30305
 
30246
30306
  <div class="sl-body">
30247
30307
  <sl-sidebar
@@ -30249,12 +30309,15 @@ let SpecLensElement = class extends i$1 {
30249
30309
  .activeOperationId=${this._activeOperationId}
30250
30310
  .open=${this._sidebarOpen}
30251
30311
  .searchEngine=${this._search}
30312
+ .layout=${this.layout}
30313
+ .securitySchemes=${this._spec.securitySchemes}
30252
30314
  @navigate=${(e2) => {
30253
30315
  var _a3;
30254
30316
  return (_a3 = this._router) == null ? void 0 : _a3.navigateTo(e2.detail);
30255
30317
  }}
30256
30318
  @navigate-intro=${() => this._scrollToIntro()}
30257
30319
  @close-sidebar=${() => this._sidebarOpen = false}
30320
+ @toggle-auth=${() => this._authOpen = !this._authOpen}
30258
30321
  ></sl-sidebar>
30259
30322
 
30260
30323
  <main class="sl-main">
@@ -30892,6 +30955,12 @@ SpecLensElement.styles = [
30892
30955
  padding: var(--sl-spacing-md);
30893
30956
  }
30894
30957
  }
30958
+
30959
+ /* ── Embed mode ──────────────────────── */
30960
+ :host([layout="embed"]) {
30961
+ --sl-header-height: 0px;
30962
+ min-height: unset;
30963
+ }
30895
30964
  `
30896
30965
  ];
30897
30966
  __decorateClass([
@@ -30909,6 +30978,9 @@ __decorateClass([
30909
30978
  __decorateClass([
30910
30979
  n2({ type: Boolean, attribute: "hide-code-samples" })
30911
30980
  ], SpecLensElement.prototype, "hideCodeSamples", 2);
30981
+ __decorateClass([
30982
+ n2({ reflect: true, attribute: "layout" })
30983
+ ], SpecLensElement.prototype, "layout", 2);
30912
30984
  __decorateClass([
30913
30985
  r$1()
30914
30986
  ], SpecLensElement.prototype, "_spec", 2);