@altano/use-toc-visible-sections 3.0.0 → 4.0.1
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/index.d.ts +6 -4
- package/dist/index.js +13 -29
- package/dist/index.js.map +1 -0
- package/package.json +11 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ChildOptions, VisibleElementObserver } from
|
|
1
|
+
import { ChildOptions, VisibleElementObserver } from "@altano/use-visible-elements";
|
|
2
2
|
|
|
3
|
+
//#region src/useTocVisibleSections.d.ts
|
|
3
4
|
declare function useVisibilityOfTarget(href: string): boolean;
|
|
4
5
|
type Options = ChildOptions & {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
selector?: string;
|
|
7
|
+
intersectionOptions?: IntersectionObserverInit;
|
|
7
8
|
};
|
|
8
9
|
declare function TocVisibleSectionObserver(options: Options): ReturnType<typeof VisibleElementObserver>;
|
|
9
|
-
|
|
10
|
+
//#endregion
|
|
10
11
|
export { TocVisibleSectionObserver, useVisibilityOfTarget };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// src/useTocVisibleSections.tsx
|
|
19
|
-
import {
|
|
20
|
-
VisibleElementObserver,
|
|
21
|
-
useVisibleElements
|
|
22
|
-
} from "@altano/use-visible-elements";
|
|
1
|
+
import { VisibleElementObserver, useVisibleElements } from "@altano/use-visible-elements";
|
|
23
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/useTocVisibleSections.tsx
|
|
24
5
|
function useVisibilityOfTarget(href) {
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
const visibleElements = useVisibleElements();
|
|
7
|
+
return [...visibleElements].some((s) => s.querySelector(`:scope > ${href}`));
|
|
27
8
|
}
|
|
28
9
|
function TocVisibleSectionObserver(options) {
|
|
29
|
-
|
|
10
|
+
return /* @__PURE__ */ jsx(VisibleElementObserver, {
|
|
11
|
+
selector: "article section",
|
|
12
|
+
...options
|
|
13
|
+
});
|
|
30
14
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { TocVisibleSectionObserver, useVisibilityOfTarget };
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["href: string","options: Options"],"sources":["../src/useTocVisibleSections.tsx"],"sourcesContent":["import {\n VisibleElementObserver,\n useVisibleElements,\n type ChildOptions,\n} from \"@altano/use-visible-elements\";\n\nexport function useVisibilityOfTarget(href: string): boolean {\n const visibleElements = useVisibleElements();\n return [...visibleElements].some((s) => s.querySelector(`:scope > ${href}`));\n}\n\ntype Options = ChildOptions & {\n selector?: string;\n intersectionOptions?: IntersectionObserverInit;\n};\n\nexport function TocVisibleSectionObserver(\n options: Options,\n): ReturnType<typeof VisibleElementObserver> {\n return <VisibleElementObserver selector=\"article section\" {...options} />;\n}\n"],"mappings":";;;;AAMA,SAAgB,sBAAsBA,MAAuB;CAC3D,MAAM,kBAAkB,oBAAoB;AAC5C,QAAO,CAAC,GAAG,eAAgB,EAAC,KAAK,CAAC,MAAM,EAAE,eAAe,WAAW,KAAK,EAAE,CAAC;AAC7E;AAOD,SAAgB,0BACdC,SAC2C;AAC3C,wBAAO,IAAC;EAAuB,UAAS;EAAkB,GAAI;GAAW;AAC1E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altano/use-toc-visible-sections",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Intersection-Observer-based Table of Contents Scroll Spy React Hook",
|
|
5
5
|
"homepage": "https://github.com/altano/npm-packages/tree/main/packages/use-toc-visible-sections",
|
|
6
6
|
"repository": {
|
|
@@ -20,14 +20,15 @@
|
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
21
|
"files": [
|
|
22
22
|
"dist/**/*.js",
|
|
23
|
+
"dist/**/*.js.map",
|
|
23
24
|
"dist/**/*.d.ts"
|
|
24
25
|
],
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@altano/use-visible-elements": "
|
|
27
|
+
"@altano/use-visible-elements": "4.0.1"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@arethetypeswrong/cli": "^0.17.4",
|
|
30
|
-
"@playwright/test": "1.
|
|
31
|
+
"@playwright/test": "1.51.1",
|
|
31
32
|
"@types/node": "^22.13.10",
|
|
32
33
|
"@types/react": "^19.0.12",
|
|
33
34
|
"@types/react-dom": "^19.0.4",
|
|
@@ -36,11 +37,12 @@
|
|
|
36
37
|
"prettier": "^3.5.3",
|
|
37
38
|
"react": "^19.1.0",
|
|
38
39
|
"react-dom": "^19.1.0",
|
|
40
|
+
"tsdown": "^0.12.9",
|
|
39
41
|
"typescript": "^5.8.2",
|
|
40
|
-
"vite": "^6.2.
|
|
41
|
-
"vitest": "^3.1.
|
|
42
|
-
"@altano/build-config": "0.0.
|
|
43
|
-
"@altano/tsconfig": "0.0.
|
|
42
|
+
"vite": "^6.2.6",
|
|
43
|
+
"vitest": "^3.1.4",
|
|
44
|
+
"@altano/build-config": "0.0.1",
|
|
45
|
+
"@altano/tsconfig": "0.0.1"
|
|
44
46
|
},
|
|
45
47
|
"peerDependencies": {
|
|
46
48
|
"react": "19.x.x"
|
|
@@ -49,8 +51,8 @@
|
|
|
49
51
|
"access": "public"
|
|
50
52
|
},
|
|
51
53
|
"scripts": {
|
|
52
|
-
"build": "
|
|
53
|
-
"check:exports": "attw --pack . --
|
|
54
|
+
"build": "tsdown --config ../build-config/tsdown.config.browser.ts",
|
|
55
|
+
"check:exports": "attw --pack . --profile esm-only --quiet",
|
|
54
56
|
"check:types:src": "tsc --noEmit",
|
|
55
57
|
"check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
|
|
56
58
|
"check:unused-dependencies": "depcheck",
|