@scalar/sidebar 0.8.16 → 0.8.18

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 +1 @@
1
- {"version":3,"file":"scroll-sidebar-to-top.d.ts","sourceRoot":"","sources":["../../src/helpers/scroll-sidebar-to-top.ts"],"names":[],"mappings":"AAiDA;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,IAAI,MAAM,EAAE,YAAW,MAAkC,KAAG,IAoB9F,CAAA"}
1
+ {"version":3,"file":"scroll-sidebar-to-top.d.ts","sourceRoot":"","sources":["../../src/helpers/scroll-sidebar-to-top.ts"],"names":[],"mappings":"AAiDA;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,IAAI,MAAM,EAAE,YAAW,MAAkC,KAAG,IAmB9F,CAAA"}
@@ -40,10 +40,7 @@ var scrollSidebarToTop = (id, offsetTop = DEFAULT_SCROLL_OFFSET_TOP) => {
40
40
  const scroller = element?.closest(".custom-scroll, .custom-scrollbar") ?? null;
41
41
  if (!element || !scroller) return;
42
42
  const targetTop = getTopRelativeToScroller(getMeasurableElement(element), scroller) + getHeadingOffset(element) - offsetTop;
43
- scroller.scrollTo({
44
- top: targetTop > 0 ? targetTop : 0,
45
- behavior: "smooth"
46
- });
43
+ scroller.scrollTo({ top: targetTop > 0 ? targetTop : 0 });
47
44
  };
48
45
  //#endregion
49
46
  export { scrollSidebarToTop };
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-sidebar-to-top.js","names":[],"sources":["../../src/helpers/scroll-sidebar-to-top.ts"],"sourcesContent":["const DEFAULT_SCROLL_OFFSET_TOP = 100\n\n/**\n * Returns the element that should be used for vertical position measurement.\n */\nconst getMeasurableElement = (element: HTMLElement): HTMLElement => {\n if (window.getComputedStyle(element).display !== 'contents') {\n return element\n }\n\n /**\n * `display: contents` does not render a layout box, so use the first child with\n * a measurable offset to keep the scroll target aligned with what users see.\n */\n for (const child of element.children) {\n if (child instanceof HTMLElement && child.offsetParent !== null) {\n return child\n }\n }\n\n return element\n}\n\n/**\n * Adds extra offset for heading rows so the selected item stays visible below labels.\n */\nconst getHeadingOffset = (element: HTMLElement): number => {\n if (element.dataset.sidebarType !== 'heading') {\n return 0\n }\n\n return element.querySelector<HTMLElement>('.sidebar-heading')?.offsetHeight ?? 0\n}\n\n/**\n * Computes an element top position relative to the provided scroll container.\n */\nconst getTopRelativeToScroller = (element: HTMLElement, scroller: HTMLElement): number => {\n let top = element.offsetTop\n let currentOffsetParent = element.offsetParent as HTMLElement | null\n\n while (currentOffsetParent && currentOffsetParent !== scroller) {\n top += currentOffsetParent.offsetTop\n currentOffsetParent = currentOffsetParent.offsetParent as HTMLElement | null\n }\n\n return top\n}\n\n/**\n * Scrolls the sidebar container so the requested item appears near the top.\n */\nexport const scrollSidebarToTop = (id: string, offsetTop: number = DEFAULT_SCROLL_OFFSET_TOP): void => {\n if (typeof window === 'undefined') {\n return\n }\n\n const element = document.querySelector<HTMLElement>(`[data-sidebar-id=\"${id}\"]`)\n const scroller = element?.closest<HTMLElement>('.custom-scroll, .custom-scrollbar') ?? null\n if (!element || !scroller) {\n return\n }\n\n const measurableElement = getMeasurableElement(element)\n const itemTop = getTopRelativeToScroller(measurableElement, scroller)\n const itemOffset = getHeadingOffset(element)\n const targetTop = itemTop + itemOffset - offsetTop\n\n scroller.scrollTo({\n top: targetTop > 0 ? targetTop : 0,\n behavior: 'smooth',\n })\n}\n"],"mappings":";AAAA,IAAM,4BAA4B;;;;AAKlC,IAAM,wBAAwB,YAAsC;AAClE,KAAI,OAAO,iBAAiB,QAAQ,CAAC,YAAY,WAC/C,QAAO;;;;;AAOT,MAAK,MAAM,SAAS,QAAQ,SAC1B,KAAI,iBAAiB,eAAe,MAAM,iBAAiB,KACzD,QAAO;AAIX,QAAO;;;;;AAMT,IAAM,oBAAoB,YAAiC;AACzD,KAAI,QAAQ,QAAQ,gBAAgB,UAClC,QAAO;AAGT,QAAO,QAAQ,cAA2B,mBAAmB,EAAE,gBAAgB;;;;;AAMjF,IAAM,4BAA4B,SAAsB,aAAkC;CACxF,IAAI,MAAM,QAAQ;CAClB,IAAI,sBAAsB,QAAQ;AAElC,QAAO,uBAAuB,wBAAwB,UAAU;AAC9D,SAAO,oBAAoB;AAC3B,wBAAsB,oBAAoB;;AAG5C,QAAO;;;;;AAMT,IAAa,sBAAsB,IAAY,YAAoB,8BAAoC;AACrG,KAAI,OAAO,WAAW,YACpB;CAGF,MAAM,UAAU,SAAS,cAA2B,qBAAqB,GAAG,IAAI;CAChF,MAAM,WAAW,SAAS,QAAqB,oCAAoC,IAAI;AACvF,KAAI,CAAC,WAAW,CAAC,SACf;CAMF,MAAM,YAFU,yBADU,qBAAqB,QAAQ,EACK,SAAS,GAClD,iBAAiB,QAAQ,GACH;AAEzC,UAAS,SAAS;EAChB,KAAK,YAAY,IAAI,YAAY;EACjC,UAAU;EACX,CAAC"}
1
+ {"version":3,"file":"scroll-sidebar-to-top.js","names":[],"sources":["../../src/helpers/scroll-sidebar-to-top.ts"],"sourcesContent":["const DEFAULT_SCROLL_OFFSET_TOP = 100\n\n/**\n * Returns the element that should be used for vertical position measurement.\n */\nconst getMeasurableElement = (element: HTMLElement): HTMLElement => {\n if (window.getComputedStyle(element).display !== 'contents') {\n return element\n }\n\n /**\n * `display: contents` does not render a layout box, so use the first child with\n * a measurable offset to keep the scroll target aligned with what users see.\n */\n for (const child of element.children) {\n if (child instanceof HTMLElement && child.offsetParent !== null) {\n return child\n }\n }\n\n return element\n}\n\n/**\n * Adds extra offset for heading rows so the selected item stays visible below labels.\n */\nconst getHeadingOffset = (element: HTMLElement): number => {\n if (element.dataset.sidebarType !== 'heading') {\n return 0\n }\n\n return element.querySelector<HTMLElement>('.sidebar-heading')?.offsetHeight ?? 0\n}\n\n/**\n * Computes an element top position relative to the provided scroll container.\n */\nconst getTopRelativeToScroller = (element: HTMLElement, scroller: HTMLElement): number => {\n let top = element.offsetTop\n let currentOffsetParent = element.offsetParent as HTMLElement | null\n\n while (currentOffsetParent && currentOffsetParent !== scroller) {\n top += currentOffsetParent.offsetTop\n currentOffsetParent = currentOffsetParent.offsetParent as HTMLElement | null\n }\n\n return top\n}\n\n/**\n * Scrolls the sidebar container so the requested item appears near the top.\n */\nexport const scrollSidebarToTop = (id: string, offsetTop: number = DEFAULT_SCROLL_OFFSET_TOP): void => {\n if (typeof window === 'undefined') {\n return\n }\n\n const element = document.querySelector<HTMLElement>(`[data-sidebar-id=\"${id}\"]`)\n const scroller = element?.closest<HTMLElement>('.custom-scroll, .custom-scrollbar') ?? null\n if (!element || !scroller) {\n return\n }\n\n const measurableElement = getMeasurableElement(element)\n const itemTop = getTopRelativeToScroller(measurableElement, scroller)\n const itemOffset = getHeadingOffset(element)\n const targetTop = itemTop + itemOffset - offsetTop\n\n scroller.scrollTo({\n top: targetTop > 0 ? targetTop : 0,\n })\n}\n"],"mappings":";AAAA,IAAM,4BAA4B;;;;AAKlC,IAAM,wBAAwB,YAAsC;AAClE,KAAI,OAAO,iBAAiB,QAAQ,CAAC,YAAY,WAC/C,QAAO;;;;;AAOT,MAAK,MAAM,SAAS,QAAQ,SAC1B,KAAI,iBAAiB,eAAe,MAAM,iBAAiB,KACzD,QAAO;AAIX,QAAO;;;;;AAMT,IAAM,oBAAoB,YAAiC;AACzD,KAAI,QAAQ,QAAQ,gBAAgB,UAClC,QAAO;AAGT,QAAO,QAAQ,cAA2B,mBAAmB,EAAE,gBAAgB;;;;;AAMjF,IAAM,4BAA4B,SAAsB,aAAkC;CACxF,IAAI,MAAM,QAAQ;CAClB,IAAI,sBAAsB,QAAQ;AAElC,QAAO,uBAAuB,wBAAwB,UAAU;AAC9D,SAAO,oBAAoB;AAC3B,wBAAsB,oBAAoB;;AAG5C,QAAO;;;;;AAMT,IAAa,sBAAsB,IAAY,YAAoB,8BAAoC;AACrG,KAAI,OAAO,WAAW,YACpB;CAGF,MAAM,UAAU,SAAS,cAA2B,qBAAqB,GAAG,IAAI;CAChF,MAAM,WAAW,SAAS,QAAqB,oCAAoC,IAAI;AACvF,KAAI,CAAC,WAAW,CAAC,SACf;CAMF,MAAM,YAFU,yBADU,qBAAqB,QAAQ,EACK,SAAS,GAClD,iBAAiB,QAAQ,GACH;AAEzC,UAAS,SAAS,EAChB,KAAK,YAAY,IAAI,YAAY,GAClC,CAAC"}
package/dist/style.css CHANGED
@@ -2228,10 +2228,18 @@
2228
2228
  right: 10px;
2229
2229
  }
2230
2230
 
2231
+ .scalar-app .bottom-4 {
2232
+ bottom: 16px;
2233
+ }
2234
+
2231
2235
  .scalar-app .left-0 {
2232
2236
  left: 0;
2233
2237
  }
2234
2238
 
2239
+ .scalar-app .left-1\/2 {
2240
+ left: 50%;
2241
+ }
2242
+
2235
2243
  .scalar-app .left-2 {
2236
2244
  left: 8px;
2237
2245
  }
@@ -2348,6 +2356,10 @@
2348
2356
  margin: -6px;
2349
2357
  }
2350
2358
 
2359
+ .scalar-app .-m-2 {
2360
+ margin: -8px;
2361
+ }
2362
+
2351
2363
  .scalar-app .-m-px {
2352
2364
  margin: -1px;
2353
2365
  }
@@ -2547,11 +2559,6 @@
2547
2559
  height: 14px;
2548
2560
  }
2549
2561
 
2550
- .scalar-app .size-3\.25 {
2551
- width: 13px;
2552
- height: 13px;
2553
- }
2554
-
2555
2562
  .scalar-app .size-4 {
2556
2563
  width: 16px;
2557
2564
  height: 16px;
@@ -2768,6 +2775,10 @@
2768
2775
  width: var(--scalar-border-width);
2769
2776
  }
2770
2777
 
2778
+ .scalar-app .w-content {
2779
+ width: 720px;
2780
+ }
2781
+
2771
2782
  .scalar-app .w-dvw {
2772
2783
  width: 100dvw;
2773
2784
  }
@@ -2816,6 +2827,10 @@
2816
2827
  max-width: inherit;
2817
2828
  }
2818
2829
 
2830
+ .scalar-app .max-w-screen-padded-4 {
2831
+ max-width: calc(100vw - 32px);
2832
+ }
2833
+
2819
2834
  .scalar-app .max-w-xs {
2820
2835
  max-width: 320px;
2821
2836
  }
@@ -2848,6 +2863,11 @@
2848
2863
  flex-shrink: 0;
2849
2864
  }
2850
2865
 
2866
+ .scalar-app .-translate-x-1\/2 {
2867
+ --tw-translate-x: calc(calc(1 / 2 * 100%) * -1);
2868
+ translate: var(--tw-translate-x) var(--tw-translate-y);
2869
+ }
2870
+
2851
2871
  .scalar-app .-translate-x-full {
2852
2872
  --tw-translate-x: -100%;
2853
2873
  translate: var(--tw-translate-x) var(--tw-translate-y);
@@ -2893,6 +2913,11 @@
2893
2913
  translate: var(--tw-translate-x) var(--tw-translate-y);
2894
2914
  }
2895
2915
 
2916
+ .scalar-app .translate-y-\[200\%\] {
2917
+ --tw-translate-y: 200%;
2918
+ translate: var(--tw-translate-x) var(--tw-translate-y);
2919
+ }
2920
+
2896
2921
  .scalar-app .scale-0 {
2897
2922
  --tw-scale-x: 0%;
2898
2923
  --tw-scale-y: 0%;
@@ -3852,6 +3877,11 @@
3852
3877
  transition-duration: .3s;
3853
3878
  }
3854
3879
 
3880
+ .scalar-app .duration-400 {
3881
+ --tw-duration: .4s;
3882
+ transition-duration: .4s;
3883
+ }
3884
+
3855
3885
  .scalar-app .ease-in {
3856
3886
  --tw-ease: var(--ease-in);
3857
3887
  transition-timing-function: var(--ease-in);
@@ -3867,6 +3897,29 @@
3867
3897
  transition-timing-function: var(--ease-out);
3868
3898
  }
3869
3899
 
3900
+ .scalar-app .ease-spring {
3901
+ --tw-ease: linear(0,
3902
+ .008 1.1%,
3903
+ .034 2.3%,
3904
+ .134 4.9%,
3905
+ .264 7.3%,
3906
+ .683 14.3%,
3907
+ .797 16.5%,
3908
+ .89 18.6%,
3909
+ .967 20.7%,
3910
+ 1.027 22.8%,
3911
+ 1.073 25%,
3912
+ 1.104 27.3%,
3913
+ 1.123 30.6%,
3914
+ 1.119 34.3%,
3915
+ 1.018 49.5%,
3916
+ .988 58.6%,
3917
+ .985 65.2%,
3918
+ 1 84.5%,
3919
+ 1);
3920
+ transition-timing-function: linear(0, .008 1.1%, .034 2.3%, .134 4.9%, .264 7.3%, .683 14.3%, .797 16.5%, .89 18.6%, .967 20.7%, 1.027 22.8%, 1.073 25%, 1.104 27.3%, 1.123 30.6%, 1.119 34.3%, 1.018 49.5%, .988 58.6%, .985 65.2%, 1 84.5%, 1);
3921
+ }
3922
+
3870
3923
  .scalar-app .outline-none {
3871
3924
  --tw-outline-style: none;
3872
3925
  outline-style: none;
package/package.json CHANGED
@@ -10,12 +10,12 @@
10
10
  "url": "git+https://github.com/scalar/scalar.git",
11
11
  "directory": "packages/sidebar"
12
12
  },
13
- "version": "0.8.16",
13
+ "version": "0.8.18",
14
14
  "engines": {
15
15
  "node": ">=22"
16
16
  },
17
17
  "type": "module",
18
- "main": "./dist/index.cjs",
18
+ "main": "./dist/index.js",
19
19
  "module": "./dist/index.js",
20
20
  "types": "./dist/index.d.ts",
21
21
  "exports": {
@@ -30,13 +30,13 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "vue": "^3.5.26",
34
- "@scalar/components": "0.21.2",
35
- "@scalar/icons": "0.7.1",
36
- "@scalar/helpers": "0.4.2",
37
- "@scalar/themes": "0.15.1",
38
- "@scalar/use-hooks": "0.4.1",
39
- "@scalar/workspace-store": "0.42.0"
33
+ "vue": "^3.5.30",
34
+ "@scalar/components": "0.21.3",
35
+ "@scalar/helpers": "0.4.3",
36
+ "@scalar/icons": "0.7.2",
37
+ "@scalar/themes": "0.15.2",
38
+ "@scalar/use-hooks": "0.4.2",
39
+ "@scalar/workspace-store": "0.43.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@tailwindcss/vite": "^4.2.0",