@ainsleydev/sveltekit-helper 0.6.4 → 0.6.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.
|
@@ -36,6 +36,11 @@ export type TableOfContentsProps = {
|
|
|
36
36
|
* @default 80
|
|
37
37
|
*/
|
|
38
38
|
scrollOffset?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Optional callback invoked when a TOC link is clicked.
|
|
41
|
+
* Useful for closing a sidebar or drawer on navigation.
|
|
42
|
+
*/
|
|
43
|
+
onLinkClick?: (event: MouseEvent, item: TOCItem) => void;
|
|
39
44
|
};
|
|
40
45
|
</script>
|
|
41
46
|
|
|
@@ -49,6 +54,7 @@ export type TableOfContentsProps = {
|
|
|
49
54
|
contentSelector = '[data-sidebar-content="true"]',
|
|
50
55
|
headingSelector,
|
|
51
56
|
scrollOffset = 80,
|
|
57
|
+
onLinkClick,
|
|
52
58
|
}: TableOfContentsProps = $props()
|
|
53
59
|
|
|
54
60
|
let activeId = $state<string | null>(null)
|
|
@@ -146,6 +152,7 @@ export type TableOfContentsProps = {
|
|
|
146
152
|
class:toc__link--active={activeId ===
|
|
147
153
|
(item.href.startsWith('#') ? item.href.slice(1) : item.href)}
|
|
148
154
|
href="#{item.href}"
|
|
155
|
+
onclick={(e) => onLinkClick?.(e, item)}
|
|
149
156
|
>
|
|
150
157
|
<small>{item.label}</small>
|
|
151
158
|
</a>
|
|
@@ -34,6 +34,11 @@ export type TableOfContentsProps = {
|
|
|
34
34
|
* @default 80
|
|
35
35
|
*/
|
|
36
36
|
scrollOffset?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Optional callback invoked when a TOC link is clicked.
|
|
39
|
+
* Useful for closing a sidebar or drawer on navigation.
|
|
40
|
+
*/
|
|
41
|
+
onLinkClick?: (event: MouseEvent, item: TOCItem) => void;
|
|
37
42
|
};
|
|
38
43
|
/**
|
|
39
44
|
* Table of Contents with scrollspy, designed to be used alongside a richtext
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableOfContents.svelte.d.ts","sourceRoot":"","sources":["../../src/components/TableOfContents.svelte.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"TableOfContents.svelte.d.ts","sourceRoot":"","sources":["../../src/components/TableOfContents.svelte.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACzD,CAAC;AA6FF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,QAAA,MAAM,eAAe,0DAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
|