starlight-cannoli-plugins 2.10.3 → 2.10.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.
@@ -3,6 +3,57 @@ import { fileURLToPath } from "url";
3
3
  var css = String.raw;
4
4
  var js = String.raw;
5
5
  var CONDITIONAL_CSS = {
6
+ offerTabbedContent: {
7
+ enabled: css`
8
+ /* Suppress the default crossfade for the named panel transition. */
9
+ ::view-transition-old(tabbed-panel),
10
+ ::view-transition-new(tabbed-panel) {
11
+ animation: none;
12
+ mix-blend-mode: normal;
13
+ }
14
+
15
+ /* Slide animation — only when the user has no motion preference. */
16
+ @media (prefers-reduced-motion: no-preference) {
17
+ :root[data-tab-direction="next"]::view-transition-old(tabbed-panel) {
18
+ animation: tabbed-slide-out-to-left 250ms ease both;
19
+ }
20
+ :root[data-tab-direction="next"]::view-transition-new(tabbed-panel) {
21
+ animation: tabbed-slide-in-from-right 250ms ease both;
22
+ }
23
+ :root[data-tab-direction="prev"]::view-transition-old(tabbed-panel) {
24
+ animation: tabbed-slide-out-to-right 250ms ease both;
25
+ }
26
+ :root[data-tab-direction="prev"]::view-transition-new(tabbed-panel) {
27
+ animation: tabbed-slide-in-from-left 250ms ease both;
28
+ }
29
+ }
30
+
31
+ @keyframes tabbed-slide-out-to-left {
32
+ to {
33
+ transform: translateX(-30%);
34
+ opacity: 0;
35
+ }
36
+ }
37
+ @keyframes tabbed-slide-in-from-right {
38
+ from {
39
+ transform: translateX(30%);
40
+ opacity: 0;
41
+ }
42
+ }
43
+ @keyframes tabbed-slide-out-to-right {
44
+ to {
45
+ transform: translateX(30%);
46
+ opacity: 0;
47
+ }
48
+ }
49
+ @keyframes tabbed-slide-in-from-left {
50
+ from {
51
+ transform: translateX(-30%);
52
+ opacity: 0;
53
+ }
54
+ }
55
+ `
56
+ },
6
57
  limitDetailsElementHeight: {
7
58
  enabled: css`
8
59
  .main-pane details[open] {
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  } from "./chunk-NCXV367P.js";
25
25
  import {
26
26
  starlightDomPatches
27
- } from "./chunk-RHYQUYJ3.js";
27
+ } from "./chunk-PPNIMJPX.js";
28
28
  import "./chunk-4VNS5WPM.js";
29
29
 
30
30
  // src/plugins/starlight-index-sourced-sidebar/index.ts
@@ -146,29 +146,33 @@ function tabbedH2Content() {
146
146
  contentContainer.appendChild(tabbedWrapper);
147
147
  contentContainer.appendChild(paginationBar);
148
148
  let activeTabIndex = 0;
149
- function isTabNavVisible() {
150
- const rect = tabNav.getBoundingClientRect();
151
- return rect.top < window.innerHeight && rect.bottom > 0;
152
- }
153
- function activateTab(targetIndex, updateHash = true, scrollToNav = false) {
154
- activeTabIndex = targetIndex;
155
- tabButtons.forEach((tabButton, buttonIndex) => {
156
- tabButton.dataset.active = String(buttonIndex === targetIndex);
157
- });
158
- tabPanels.forEach((tabPanel, panelIndex) => {
159
- tabPanel.hidden = panelIndex !== targetIndex;
160
- });
161
- prevTabButton.disabled = targetIndex === 0;
162
- nextTabButton.disabled = targetIndex === allSections.length - 1;
149
+ function activateTab(targetIndex, updateHash = true) {
150
+ const applySwitch = () => {
151
+ tabPanels[activeTabIndex].style.viewTransitionName = "";
152
+ activeTabIndex = targetIndex;
153
+ tabButtons.forEach((tabButton, buttonIndex) => {
154
+ tabButton.dataset.active = String(buttonIndex === targetIndex);
155
+ });
156
+ tabPanels.forEach((tabPanel, panelIndex) => {
157
+ tabPanel.hidden = panelIndex !== targetIndex;
158
+ });
159
+ tabPanels[targetIndex].style.viewTransitionName = "tabbed-panel";
160
+ prevTabButton.disabled = targetIndex === 0;
161
+ nextTabButton.disabled = targetIndex === allSections.length - 1;
162
+ };
163
+ if (targetIndex !== activeTabIndex && "startViewTransition" in document) {
164
+ document.documentElement.dataset.tabDirection = targetIndex > activeTabIndex ? "next" : "prev";
165
+ tabPanels[activeTabIndex].style.viewTransitionName = "tabbed-panel";
166
+ document.startViewTransition(applySwitch);
167
+ } else {
168
+ applySwitch();
169
+ }
163
170
  const scrollBehavior = getComputedStyle(document.documentElement).scrollBehavior;
164
171
  tabButtons[targetIndex].scrollIntoView({
165
172
  behavior: scrollBehavior,
166
173
  block: "nearest",
167
174
  inline: "nearest"
168
175
  });
169
- if (scrollToNav) {
170
- tabNav.scrollIntoView({ behavior: scrollBehavior, block: "nearest" });
171
- }
172
176
  if (updateHash) {
173
177
  const targetHeadingId = allSections[targetIndex].headingId;
174
178
  if (targetHeadingId) {
@@ -207,17 +211,23 @@ function tabbedH2Content() {
207
211
  if (targetPanelIndex >= 0 && targetPanelIndex !== activeTabIndex)
208
212
  activateTab(targetPanelIndex, false);
209
213
  }
214
+ function isTabNavVisible() {
215
+ const rect = tabNav.getBoundingClientRect();
216
+ return rect.top < window.innerHeight && rect.bottom > 0;
217
+ }
210
218
  function wireInteractions(viewToggleCheckbox2) {
211
219
  prevTabButton.addEventListener("click", () => {
212
220
  if (activeTabIndex > 0) {
213
- const scrollToNav = !isTabNavVisible();
214
- activateTab(activeTabIndex - 1, true, scrollToNav);
221
+ if (!isTabNavVisible())
222
+ window.scrollTo({ top: 0, behavior: "instant" });
223
+ activateTab(activeTabIndex - 1);
215
224
  }
216
225
  });
217
226
  nextTabButton.addEventListener("click", () => {
218
227
  if (activeTabIndex < allSections.length - 1) {
219
- const scrollToNav = !isTabNavVisible();
220
- activateTab(activeTabIndex + 1, true, scrollToNav);
228
+ if (!isTabNavVisible())
229
+ window.scrollTo({ top: 0, behavior: "instant" });
230
+ activateTab(activeTabIndex + 1);
221
231
  }
222
232
  });
223
233
  tabButtons.forEach((tabButton, buttonIndex) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  starlightDomPatches
3
- } from "../chunk-RHYQUYJ3.js";
3
+ } from "../chunk-PPNIMJPX.js";
4
4
  import "../chunk-4VNS5WPM.js";
5
5
  export {
6
6
  starlightDomPatches
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "starlight-cannoli-plugins",
3
3
  "type": "module",
4
- "version": "2.10.3",
4
+ "version": "2.10.5",
5
5
  "description": "Starlight plugins for automatic sidebar generation and link validation",
6
6
  "license": "ISC",
7
7
  "main": "./dist/index.js",