@altano/use-toc-visible-sections 1.0.4 → 1.0.6
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/README.md +77 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +34 -0
- package/dist/useTocVisibleSections.d.ts +4 -4
- package/package.json +37 -33
- package/dist/useTocVisibleSections.js +0 -845
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# use-toc-visible-sections
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@altano/use-toc-visible-sections)  
|
|
4
|
+
|
|
5
|
+
React hook to faciliate observing visibility of sections linked to a table of contents.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
`npm install @altano/use-toc-visible-sections`
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
### App.jsx
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
import { TocVisibleSectionObserver } from "@altano/use-toc-visible-sections";
|
|
17
|
+
|
|
18
|
+
export default () => (
|
|
19
|
+
<TocVisibleSectionObserver selector="article section">
|
|
20
|
+
<TableOfContents />
|
|
21
|
+
<Article />
|
|
22
|
+
</TocVisibleSectionObserver>
|
|
23
|
+
);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### TableOfContents.jsx
|
|
27
|
+
|
|
28
|
+
```jsx
|
|
29
|
+
import { useVisibilityOfTarget } from "@altano/use-toc-visible-sections";
|
|
30
|
+
|
|
31
|
+
export default () => (
|
|
32
|
+
<nav>
|
|
33
|
+
<ul>
|
|
34
|
+
<ListItem href="#heading1">Lorem ipsum dolor sit amet.</ListItem>
|
|
35
|
+
<ListItem href="#heading2">Dignissimos aliquam dolorum</ListItem>
|
|
36
|
+
</ul>
|
|
37
|
+
</nav>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
function ListItem({ href, children }) {
|
|
41
|
+
// Is the section this `href` points to visible in the viewport?
|
|
42
|
+
const isVisible = useVisibilityOfTarget(href);
|
|
43
|
+
return (
|
|
44
|
+
<li
|
|
45
|
+
style={{
|
|
46
|
+
borderLeft: isVisible ? "3px solid black" : "3px solid transparent",
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
<a href={href}>{children}</a>
|
|
50
|
+
</li>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Article.jsx
|
|
56
|
+
|
|
57
|
+
```jsx
|
|
58
|
+
export default () => (
|
|
59
|
+
<article>
|
|
60
|
+
<section>
|
|
61
|
+
<h1 id="heading1">Lorem ipsum dolor sit amet.</h1>
|
|
62
|
+
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eius libero autem in? Dicta explicabo cum laudantium voluptas voluptate quaerat inventore eos? Facilis, quae, doloribus dolorum doloremque voluptatum, labore omnis ipsum architecto debitis quibusdam quam recusandae delectus nesciunt voluptate iusto sequi saepe voluptatibus quis officiis illo dolor hic. Laudantium harum, quas tempora nobis doloremque odit sint fugit ea non beatae maxime enim odio debitis ullam delectus minima assumenda expedita. Laboriosam magni, voluptate harum officiis, voluptatibus illum porro minima architecto inventore eaque iusto a, praesentium nihil cum veritatis sunt! Incidunt debitis dignissimos hic soluta alias nisi asperiores nulla non? Corrupti, perspiciatis ducimus.</p>
|
|
63
|
+
</section>
|
|
64
|
+
<section>
|
|
65
|
+
<h1 id="heading2">Dignissimos aliquam dolorum</h1>
|
|
66
|
+
<p>Quis veniam qui quas! Repellendus tenetur nemo explicabo laborum cumque similique dicta cum ab quae ducimus aliquam ut animi sequi accusamus, dolorem perspiciatis quis doloremque, et dolorum voluptatem sunt, hic quidem nihil eveniet! Tenetur, consequatur nemo possimus sint quo itaque accusantium, voluptatibus facilis eveniet earum voluptas veniam quidem minima dolore? Aspernatur adipisci iste expedita exercitationem pariatur ex tenetur error doloribus nihil maxime eos repudiandae dolore omnis nesciunt, delectus illum, aperiam fugit blanditiis ipsa alias quaerat cupiditate eum numquam! Sed, ipsum. Eaque animi doloremque exercitationem amet eum, accusamus deserunt in atque, excepturi sunt, unde pariatur consequuntur repellendus aut quas sit ratione!</p>
|
|
67
|
+
</section>
|
|
68
|
+
</article>
|
|
69
|
+
);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Doesn't react to DOM mutation, e.g. if you dynamically mount a `<section>` later it won't be observed.
|
|
73
|
+
|
|
74
|
+
This hook is meant to be simple and handle cases like static sites generated using MDX where:
|
|
75
|
+
|
|
76
|
+
- The subtree is static once mounted
|
|
77
|
+
- The Markdown subtree is not directly owned by the application and therefore the observed elements are best discovered through a selector instead of explicit React refs.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
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";
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
function useVisibilityOfTarget(href) {
|
|
25
|
+
const visibleElements = useVisibleElements();
|
|
26
|
+
return [...visibleElements].some((s) => s.querySelector(`:scope > ${href}`));
|
|
27
|
+
}
|
|
28
|
+
function TocVisibleSectionObserver(options) {
|
|
29
|
+
return /* @__PURE__ */ jsx(VisibleElementObserver, __spreadValues({ selector: "article section" }, options));
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
TocVisibleSectionObserver,
|
|
33
|
+
useVisibilityOfTarget
|
|
34
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { VisibleElementObserver } from "@altano/use-visible-elements";
|
|
4
|
-
declare function useVisibilityOfTarget(href: string): boolean;
|
|
3
|
+
export declare function useVisibilityOfTarget(href: string): boolean;
|
|
5
4
|
type Options = {
|
|
6
5
|
children: React.ReactNode;
|
|
7
6
|
useWrapperDiv?: true;
|
|
@@ -13,5 +12,6 @@ type Options = {
|
|
|
13
12
|
selector?: string;
|
|
14
13
|
intersectionOptions?: IntersectionObserverInit;
|
|
15
14
|
};
|
|
16
|
-
declare function TocVisibleSectionObserver(options: Options): ReturnType<typeof VisibleElementObserver>;
|
|
17
|
-
export {
|
|
15
|
+
export declare function TocVisibleSectionObserver(options: Options): ReturnType<typeof VisibleElementObserver>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=useTocVisibleSections.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altano/use-toc-visible-sections",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Intersection-Observer-based Table of Contents Scroll Spy React Hook",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"exports": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
7
9
|
"files": [
|
|
8
|
-
"dist
|
|
10
|
+
"dist/**/*.js",
|
|
11
|
+
"dist/**/*.d.ts"
|
|
9
12
|
],
|
|
10
|
-
"prepublishOnly": "npm run build",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "rollup -c",
|
|
13
|
-
"start": "rollup -c --watch"
|
|
14
|
-
},
|
|
15
13
|
"author": {
|
|
16
14
|
"name": "Alan Norbauer",
|
|
17
15
|
"email": "altano@gmail.com",
|
|
@@ -20,32 +18,38 @@
|
|
|
20
18
|
"license": "UNLICENSED",
|
|
21
19
|
"repository": {
|
|
22
20
|
"type": "git",
|
|
23
|
-
"url": "https://github.com/altano/
|
|
21
|
+
"url": "https://github.com/altano/npm-packages",
|
|
22
|
+
"directory": "packages/use-toc-visible-sections"
|
|
24
23
|
},
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
"@
|
|
28
|
-
"@rollup/plugin-typescript": "^3.0.0",
|
|
29
|
-
"@types/react": "^16.9.19",
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "^2.25.0",
|
|
31
|
-
"@typescript-eslint/parser": "^2.25.0",
|
|
32
|
-
"@wessberg/rollup-plugin-ts": "^1.2.16",
|
|
33
|
-
"babel-eslint": "^10.1.0",
|
|
34
|
-
"eslint": "^6.8.0",
|
|
35
|
-
"eslint-config-react-app": "^5.2.1",
|
|
36
|
-
"eslint-plugin-flowtype": "^4.6.0",
|
|
37
|
-
"eslint-plugin-import": "^2.20.1",
|
|
38
|
-
"eslint-plugin-jsx-a11y": "^6.2.3",
|
|
39
|
-
"eslint-plugin-react": "^7.19.0",
|
|
40
|
-
"eslint-plugin-react-hooks": "^2.5.1",
|
|
41
|
-
"prettier": "^2.0.1",
|
|
42
|
-
"rollup": "^1.31.0",
|
|
43
|
-
"typescript": "^3.8.3"
|
|
24
|
+
"homepage": "https://github.com/altano/npm-packages/tree/main/packages/use-toc-visible-sections",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@altano/use-visible-elements": "1.0.6"
|
|
44
27
|
},
|
|
45
28
|
"peerDependencies": {
|
|
46
|
-
"react": "^
|
|
29
|
+
"react": "^18"
|
|
47
30
|
},
|
|
48
|
-
"
|
|
49
|
-
"@
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/react": "^18.0.38",
|
|
33
|
+
"@types/react-dom": "^18.0.11",
|
|
34
|
+
"eslint": "^8.39.0",
|
|
35
|
+
"prettier": "^2.8.7",
|
|
36
|
+
"react": "^18",
|
|
37
|
+
"tsup": "^7.2.0",
|
|
38
|
+
"typescript": "^5.1.6",
|
|
39
|
+
"@altano/tsconfig": "0.0.0",
|
|
40
|
+
"eslint-config-altano": "0.0.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsup src/index.tsx --format esm --onSuccess \"pnpm build:types\"",
|
|
47
|
+
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
48
|
+
"dev": "tsup src/index.tsx --watch --format esm",
|
|
49
|
+
"lint": "eslint src/**/*.ts*",
|
|
50
|
+
"lint:timing": "TIMING=1 eslint src/**/*.ts*",
|
|
51
|
+
"lint:fix": "TIMING=1 eslint src/**/*.ts* --fix",
|
|
52
|
+
"format": "prettier --write src",
|
|
53
|
+
"clean": "rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist"
|
|
50
54
|
}
|
|
51
|
-
}
|
|
55
|
+
}
|
|
@@ -1,845 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var react = _interopDefault(require('react'));
|
|
8
|
-
|
|
9
|
-
function unwrapExports (x) {
|
|
10
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function createCommonjsModule(fn, module) {
|
|
14
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var useVisibleElements_1 = createCommonjsModule(function (module, exports) {
|
|
18
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
19
|
-
function _interopDefault(ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
20
|
-
var React = _interopDefault(react);
|
|
21
|
-
function unwrapExports(x) {
|
|
22
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
23
|
-
}
|
|
24
|
-
function createCommonjsModule(fn, module) {
|
|
25
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
26
|
-
}
|
|
27
|
-
var useElementObserver_1 = createCommonjsModule(function (module, exports) {
|
|
28
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
29
|
-
function _interopDefault(ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
30
|
-
var React__default = _interopDefault(React);
|
|
31
|
-
function unwrapExports(x) {
|
|
32
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
33
|
-
}
|
|
34
|
-
function createCommonjsModule(fn, module) {
|
|
35
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
36
|
-
}
|
|
37
|
-
/*! *****************************************************************************
|
|
38
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
39
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
40
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
41
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
-
|
|
43
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
44
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
45
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
46
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
47
|
-
|
|
48
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
49
|
-
and limitations under the License.
|
|
50
|
-
***************************************************************************** */
|
|
51
|
-
/* global Reflect, Promise */
|
|
52
|
-
var extendStatics = function (d, b) {
|
|
53
|
-
extendStatics = Object.setPrototypeOf ||
|
|
54
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
55
|
-
function (d, b) {
|
|
56
|
-
for (var p in b)
|
|
57
|
-
if (b.hasOwnProperty(p))
|
|
58
|
-
d[p] = b[p];
|
|
59
|
-
};
|
|
60
|
-
return extendStatics(d, b);
|
|
61
|
-
};
|
|
62
|
-
function __extends(d, b) {
|
|
63
|
-
extendStatics(d, b);
|
|
64
|
-
function __() { this.constructor = d; }
|
|
65
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
66
|
-
}
|
|
67
|
-
var __assign = function () {
|
|
68
|
-
__assign = Object.assign || function __assign(t) {
|
|
69
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
70
|
-
s = arguments[i];
|
|
71
|
-
for (var p in s)
|
|
72
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
73
|
-
t[p] = s[p];
|
|
74
|
-
}
|
|
75
|
-
return t;
|
|
76
|
-
};
|
|
77
|
-
return __assign.apply(this, arguments);
|
|
78
|
-
};
|
|
79
|
-
function __rest(s, e) {
|
|
80
|
-
var t = {};
|
|
81
|
-
for (var p in s)
|
|
82
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
83
|
-
t[p] = s[p];
|
|
84
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
85
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
86
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
87
|
-
t[p[i]] = s[p[i]];
|
|
88
|
-
}
|
|
89
|
-
return t;
|
|
90
|
-
}
|
|
91
|
-
function __decorate(decorators, target, key, desc) {
|
|
92
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
93
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
94
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
95
|
-
else
|
|
96
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
97
|
-
if (d = decorators[i])
|
|
98
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
99
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
100
|
-
}
|
|
101
|
-
function __param(paramIndex, decorator) {
|
|
102
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
103
|
-
}
|
|
104
|
-
function __metadata(metadataKey, metadataValue) {
|
|
105
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
106
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
107
|
-
}
|
|
108
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
109
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
110
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
111
|
-
function fulfilled(value) {
|
|
112
|
-
try {
|
|
113
|
-
step(generator.next(value));
|
|
114
|
-
}
|
|
115
|
-
catch (e) {
|
|
116
|
-
reject(e);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function rejected(value) {
|
|
120
|
-
try {
|
|
121
|
-
step(generator["throw"](value));
|
|
122
|
-
}
|
|
123
|
-
catch (e) {
|
|
124
|
-
reject(e);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
128
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function __generator(thisArg, body) {
|
|
132
|
-
var _ = { label: 0, sent: function () {
|
|
133
|
-
if (t[0] & 1)
|
|
134
|
-
throw t[1];
|
|
135
|
-
return t[1];
|
|
136
|
-
}, trys: [], ops: [] }, f, y, t, g;
|
|
137
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
138
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
139
|
-
function step(op) {
|
|
140
|
-
if (f)
|
|
141
|
-
throw new TypeError("Generator is already executing.");
|
|
142
|
-
while (_)
|
|
143
|
-
try {
|
|
144
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
145
|
-
return t;
|
|
146
|
-
if (y = 0, t)
|
|
147
|
-
op = [op[0] & 2, t.value];
|
|
148
|
-
switch (op[0]) {
|
|
149
|
-
case 0:
|
|
150
|
-
case 1:
|
|
151
|
-
t = op;
|
|
152
|
-
break;
|
|
153
|
-
case 4:
|
|
154
|
-
_.label++;
|
|
155
|
-
return { value: op[1], done: false };
|
|
156
|
-
case 5:
|
|
157
|
-
_.label++;
|
|
158
|
-
y = op[1];
|
|
159
|
-
op = [0];
|
|
160
|
-
continue;
|
|
161
|
-
case 7:
|
|
162
|
-
op = _.ops.pop();
|
|
163
|
-
_.trys.pop();
|
|
164
|
-
continue;
|
|
165
|
-
default:
|
|
166
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
167
|
-
_ = 0;
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
171
|
-
_.label = op[1];
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
175
|
-
_.label = t[1];
|
|
176
|
-
t = op;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
if (t && _.label < t[2]) {
|
|
180
|
-
_.label = t[2];
|
|
181
|
-
_.ops.push(op);
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
if (t[2])
|
|
185
|
-
_.ops.pop();
|
|
186
|
-
_.trys.pop();
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
op = body.call(thisArg, _);
|
|
190
|
-
}
|
|
191
|
-
catch (e) {
|
|
192
|
-
op = [6, e];
|
|
193
|
-
y = 0;
|
|
194
|
-
}
|
|
195
|
-
finally {
|
|
196
|
-
f = t = 0;
|
|
197
|
-
}
|
|
198
|
-
if (op[0] & 5)
|
|
199
|
-
throw op[1];
|
|
200
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function __exportStar(m, exports) {
|
|
204
|
-
for (var p in m)
|
|
205
|
-
if (!exports.hasOwnProperty(p))
|
|
206
|
-
exports[p] = m[p];
|
|
207
|
-
}
|
|
208
|
-
function __values(o) {
|
|
209
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
210
|
-
if (m)
|
|
211
|
-
return m.call(o);
|
|
212
|
-
if (o && typeof o.length === "number")
|
|
213
|
-
return {
|
|
214
|
-
next: function () {
|
|
215
|
-
if (o && i >= o.length)
|
|
216
|
-
o = void 0;
|
|
217
|
-
return { value: o && o[i++], done: !o };
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
221
|
-
}
|
|
222
|
-
function __read(o, n) {
|
|
223
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
224
|
-
if (!m)
|
|
225
|
-
return o;
|
|
226
|
-
var i = m.call(o), r, ar = [], e;
|
|
227
|
-
try {
|
|
228
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
229
|
-
ar.push(r.value);
|
|
230
|
-
}
|
|
231
|
-
catch (error) {
|
|
232
|
-
e = { error: error };
|
|
233
|
-
}
|
|
234
|
-
finally {
|
|
235
|
-
try {
|
|
236
|
-
if (r && !r.done && (m = i["return"]))
|
|
237
|
-
m.call(i);
|
|
238
|
-
}
|
|
239
|
-
finally {
|
|
240
|
-
if (e)
|
|
241
|
-
throw e.error;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return ar;
|
|
245
|
-
}
|
|
246
|
-
function __spread() {
|
|
247
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
248
|
-
ar = ar.concat(__read(arguments[i]));
|
|
249
|
-
return ar;
|
|
250
|
-
}
|
|
251
|
-
function __spreadArrays() {
|
|
252
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
253
|
-
s += arguments[i].length;
|
|
254
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
255
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
256
|
-
r[k] = a[j];
|
|
257
|
-
return r;
|
|
258
|
-
}
|
|
259
|
-
function __await(v) {
|
|
260
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
261
|
-
}
|
|
262
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
263
|
-
if (!Symbol.asyncIterator)
|
|
264
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
265
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
266
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
267
|
-
function verb(n) {
|
|
268
|
-
if (g[n])
|
|
269
|
-
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); };
|
|
270
|
-
}
|
|
271
|
-
function resume(n, v) {
|
|
272
|
-
try {
|
|
273
|
-
step(g[n](v));
|
|
274
|
-
}
|
|
275
|
-
catch (e) {
|
|
276
|
-
settle(q[0][3], e);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
280
|
-
function fulfill(value) { resume("next", value); }
|
|
281
|
-
function reject(value) { resume("throw", value); }
|
|
282
|
-
function settle(f, v) {
|
|
283
|
-
if (f(v), q.shift(), q.length)
|
|
284
|
-
resume(q[0][0], q[0][1]);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
function __asyncDelegator(o) {
|
|
288
|
-
var i, p;
|
|
289
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
290
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
291
|
-
}
|
|
292
|
-
function __asyncValues(o) {
|
|
293
|
-
if (!Symbol.asyncIterator)
|
|
294
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
295
|
-
var m = o[Symbol.asyncIterator], i;
|
|
296
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
297
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
298
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
299
|
-
}
|
|
300
|
-
function __makeTemplateObject(cooked, raw) {
|
|
301
|
-
if (Object.defineProperty) {
|
|
302
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
cooked.raw = raw;
|
|
306
|
-
}
|
|
307
|
-
return cooked;
|
|
308
|
-
}
|
|
309
|
-
function __importStar(mod) {
|
|
310
|
-
if (mod && mod.__esModule)
|
|
311
|
-
return mod;
|
|
312
|
-
var result = {};
|
|
313
|
-
if (mod != null)
|
|
314
|
-
for (var k in mod)
|
|
315
|
-
if (Object.hasOwnProperty.call(mod, k))
|
|
316
|
-
result[k] = mod[k];
|
|
317
|
-
result.default = mod;
|
|
318
|
-
return result;
|
|
319
|
-
}
|
|
320
|
-
function __importDefault(mod) {
|
|
321
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
322
|
-
}
|
|
323
|
-
function __classPrivateFieldGet(receiver, privateMap) {
|
|
324
|
-
if (!privateMap.has(receiver)) {
|
|
325
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
326
|
-
}
|
|
327
|
-
return privateMap.get(receiver);
|
|
328
|
-
}
|
|
329
|
-
function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
330
|
-
if (!privateMap.has(receiver)) {
|
|
331
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
332
|
-
}
|
|
333
|
-
privateMap.set(receiver, value);
|
|
334
|
-
return value;
|
|
335
|
-
}
|
|
336
|
-
var tslib_es6 = /*#__PURE__*/ Object.freeze({
|
|
337
|
-
__proto__: null,
|
|
338
|
-
__extends: __extends,
|
|
339
|
-
get __assign() { return __assign; },
|
|
340
|
-
__rest: __rest,
|
|
341
|
-
__decorate: __decorate,
|
|
342
|
-
__param: __param,
|
|
343
|
-
__metadata: __metadata,
|
|
344
|
-
__awaiter: __awaiter,
|
|
345
|
-
__generator: __generator,
|
|
346
|
-
__exportStar: __exportStar,
|
|
347
|
-
__values: __values,
|
|
348
|
-
__read: __read,
|
|
349
|
-
__spread: __spread,
|
|
350
|
-
__spreadArrays: __spreadArrays,
|
|
351
|
-
__await: __await,
|
|
352
|
-
__asyncGenerator: __asyncGenerator,
|
|
353
|
-
__asyncDelegator: __asyncDelegator,
|
|
354
|
-
__asyncValues: __asyncValues,
|
|
355
|
-
__makeTemplateObject: __makeTemplateObject,
|
|
356
|
-
__importStar: __importStar,
|
|
357
|
-
__importDefault: __importDefault,
|
|
358
|
-
__classPrivateFieldGet: __classPrivateFieldGet,
|
|
359
|
-
__classPrivateFieldSet: __classPrivateFieldSet
|
|
360
|
-
});
|
|
361
|
-
var useSet_1 = createCommonjsModule(function (module, exports) {
|
|
362
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
363
|
-
/* eslint-disable */
|
|
364
|
-
var useSet = function (initialSet) {
|
|
365
|
-
if (initialSet === void 0) {
|
|
366
|
-
initialSet = new Set();
|
|
367
|
-
}
|
|
368
|
-
var _a = React__default.useState(initialSet), set = _a[0], setSet = _a[1];
|
|
369
|
-
var stableActions = React__default.useMemo(function () {
|
|
370
|
-
var add = function (item) { return setSet(function (prevSet) { return new Set(tslib_es6.__spreadArrays(Array.from(prevSet), [item])); }); };
|
|
371
|
-
var remove = function (item) { return setSet(function (prevSet) { return new Set(Array.from(prevSet).filter(function (i) { return i !== item; })); }); };
|
|
372
|
-
var toggle = function (item) {
|
|
373
|
-
return setSet(function (prevSet) {
|
|
374
|
-
return prevSet.has(item)
|
|
375
|
-
? new Set(Array.from(prevSet).filter(function (i) { return i !== item; }))
|
|
376
|
-
: new Set(tslib_es6.__spreadArrays(Array.from(prevSet), [item]));
|
|
377
|
-
});
|
|
378
|
-
};
|
|
379
|
-
return { add: add, remove: remove, toggle: toggle, reset: function () { return setSet(initialSet); } };
|
|
380
|
-
}, [setSet]);
|
|
381
|
-
var utils = tslib_es6.__assign({ has: React__default.useCallback(function (item) { return set.has(item); }, [set]) }, stableActions);
|
|
382
|
-
return [set, utils];
|
|
383
|
-
};
|
|
384
|
-
exports.default = useSet;
|
|
385
|
-
});
|
|
386
|
-
var useSet = unwrapExports(useSet_1);
|
|
387
|
-
const ElementObserverContext = React__default.createContext(null);
|
|
388
|
-
function useMountRef({ onMount, onUnmount }) {
|
|
389
|
-
const newRef = React.useRef(null);
|
|
390
|
-
React.useEffect(() => {
|
|
391
|
-
const ref = newRef.current;
|
|
392
|
-
if (ref == null) {
|
|
393
|
-
return () => { };
|
|
394
|
-
}
|
|
395
|
-
onMount(ref);
|
|
396
|
-
return () => onUnmount(ref);
|
|
397
|
-
}, [newRef, onMount, onUnmount]);
|
|
398
|
-
return newRef;
|
|
399
|
-
}
|
|
400
|
-
function ObserveChildWithWrapperDiv({ children, onMount, onUnmount, }) {
|
|
401
|
-
const ref = useMountRef({ onMount, onUnmount });
|
|
402
|
-
return (React__default.createElement("div", { style: { all: "inherit" }, ref: ref }, children));
|
|
403
|
-
}
|
|
404
|
-
function ObserveChild({ children, onMount, onUnmount, }) {
|
|
405
|
-
const newRef = useMountRef({ onMount, onUnmount });
|
|
406
|
-
const child = React__default.Children.only(children);
|
|
407
|
-
return React__default.cloneElement(child, { ref: newRef });
|
|
408
|
-
}
|
|
409
|
-
function Observer({ children, selector, useWrapperDiv, }) {
|
|
410
|
-
const context = React.useContext(ElementObserverContext);
|
|
411
|
-
if (context == null) {
|
|
412
|
-
throw new Error("Observer context was null");
|
|
413
|
-
}
|
|
414
|
-
const { methods } = context;
|
|
415
|
-
const { add, reset } = methods;
|
|
416
|
-
const onMount = React.useCallback((ref) => {
|
|
417
|
-
Array.from(ref.querySelectorAll(selector)).forEach(add);
|
|
418
|
-
}, [selector, add]);
|
|
419
|
-
const onUnmount = React.useCallback(() => reset, [reset]);
|
|
420
|
-
const Component = useWrapperDiv ? ObserveChildWithWrapperDiv : ObserveChild;
|
|
421
|
-
return (React__default.createElement(Component, { onMount: onMount, onUnmount: onUnmount }, children));
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Allows observing mount/unmount of elements that match a given selector in the
|
|
425
|
-
* given React tree. Tree must be static: only the mounting of the tree itself
|
|
426
|
-
* is monitored. If the tree's DOM is dynamically changed those mounts and
|
|
427
|
-
* unmounts will not be detected.
|
|
428
|
-
*
|
|
429
|
-
* @param tree The React tree to observe.
|
|
430
|
-
* @param onMount The callback that will be passed any elements in the tree that
|
|
431
|
-
* match the given selector, as they mount.
|
|
432
|
-
* @param onUnmount The callback that will be passed any elements in the tree
|
|
433
|
-
* that match the given selector, as they unmount.
|
|
434
|
-
* @param selector The css selector used to select which elements are observed.
|
|
435
|
-
* @param useWrapperDiv If `true`, a 'div' will wrap the observed children. If
|
|
436
|
-
* `false`, `children` must be a single child element that can take a ref (which
|
|
437
|
-
* will be overwritten).
|
|
438
|
-
* @returns A tuple of: (1) array of elements and (2) the observed tree to be
|
|
439
|
-
* rendered.
|
|
440
|
-
*/
|
|
441
|
-
function useElementObserver({ tree, selector, useWrapperDiv = true, }) {
|
|
442
|
-
// @TODO Add mutation observer to catch changes to grandchildren?
|
|
443
|
-
const [mountedElements, methods] = useSet();
|
|
444
|
-
const observedTree = (React__default.createElement(ElementObserverContext.Provider, { value: { mountedElements, methods } }, React__default.createElement(Observer, { selector: selector, useWrapperDiv: useWrapperDiv }, tree)));
|
|
445
|
-
return [mountedElements, observedTree];
|
|
446
|
-
}
|
|
447
|
-
exports.useElementObserver = useElementObserver;
|
|
448
|
-
});
|
|
449
|
-
unwrapExports(useElementObserver_1);
|
|
450
|
-
var useElementObserver_2 = useElementObserver_1.useElementObserver;
|
|
451
|
-
/*! *****************************************************************************
|
|
452
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
453
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
454
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
455
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
456
|
-
|
|
457
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
458
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
459
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
460
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
461
|
-
|
|
462
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
463
|
-
and limitations under the License.
|
|
464
|
-
***************************************************************************** */
|
|
465
|
-
/* global Reflect, Promise */
|
|
466
|
-
var extendStatics = function (d, b) {
|
|
467
|
-
extendStatics = Object.setPrototypeOf ||
|
|
468
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
469
|
-
function (d, b) {
|
|
470
|
-
for (var p in b)
|
|
471
|
-
if (b.hasOwnProperty(p))
|
|
472
|
-
d[p] = b[p];
|
|
473
|
-
};
|
|
474
|
-
return extendStatics(d, b);
|
|
475
|
-
};
|
|
476
|
-
function __extends(d, b) {
|
|
477
|
-
extendStatics(d, b);
|
|
478
|
-
function __() { this.constructor = d; }
|
|
479
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
480
|
-
}
|
|
481
|
-
var __assign = function () {
|
|
482
|
-
__assign = Object.assign || function __assign(t) {
|
|
483
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
484
|
-
s = arguments[i];
|
|
485
|
-
for (var p in s)
|
|
486
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
487
|
-
t[p] = s[p];
|
|
488
|
-
}
|
|
489
|
-
return t;
|
|
490
|
-
};
|
|
491
|
-
return __assign.apply(this, arguments);
|
|
492
|
-
};
|
|
493
|
-
function __rest(s, e) {
|
|
494
|
-
var t = {};
|
|
495
|
-
for (var p in s)
|
|
496
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
497
|
-
t[p] = s[p];
|
|
498
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
499
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
500
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
501
|
-
t[p[i]] = s[p[i]];
|
|
502
|
-
}
|
|
503
|
-
return t;
|
|
504
|
-
}
|
|
505
|
-
function __decorate(decorators, target, key, desc) {
|
|
506
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
507
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
508
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
509
|
-
else
|
|
510
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
511
|
-
if (d = decorators[i])
|
|
512
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
513
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
514
|
-
}
|
|
515
|
-
function __param(paramIndex, decorator) {
|
|
516
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
517
|
-
}
|
|
518
|
-
function __metadata(metadataKey, metadataValue) {
|
|
519
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
520
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
521
|
-
}
|
|
522
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
523
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
524
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
525
|
-
function fulfilled(value) {
|
|
526
|
-
try {
|
|
527
|
-
step(generator.next(value));
|
|
528
|
-
}
|
|
529
|
-
catch (e) {
|
|
530
|
-
reject(e);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
function rejected(value) {
|
|
534
|
-
try {
|
|
535
|
-
step(generator["throw"](value));
|
|
536
|
-
}
|
|
537
|
-
catch (e) {
|
|
538
|
-
reject(e);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
542
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
function __generator(thisArg, body) {
|
|
546
|
-
var _ = { label: 0, sent: function () {
|
|
547
|
-
if (t[0] & 1)
|
|
548
|
-
throw t[1];
|
|
549
|
-
return t[1];
|
|
550
|
-
}, trys: [], ops: [] }, f, y, t, g;
|
|
551
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
552
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
553
|
-
function step(op) {
|
|
554
|
-
if (f)
|
|
555
|
-
throw new TypeError("Generator is already executing.");
|
|
556
|
-
while (_)
|
|
557
|
-
try {
|
|
558
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
559
|
-
return t;
|
|
560
|
-
if (y = 0, t)
|
|
561
|
-
op = [op[0] & 2, t.value];
|
|
562
|
-
switch (op[0]) {
|
|
563
|
-
case 0:
|
|
564
|
-
case 1:
|
|
565
|
-
t = op;
|
|
566
|
-
break;
|
|
567
|
-
case 4:
|
|
568
|
-
_.label++;
|
|
569
|
-
return { value: op[1], done: false };
|
|
570
|
-
case 5:
|
|
571
|
-
_.label++;
|
|
572
|
-
y = op[1];
|
|
573
|
-
op = [0];
|
|
574
|
-
continue;
|
|
575
|
-
case 7:
|
|
576
|
-
op = _.ops.pop();
|
|
577
|
-
_.trys.pop();
|
|
578
|
-
continue;
|
|
579
|
-
default:
|
|
580
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
581
|
-
_ = 0;
|
|
582
|
-
continue;
|
|
583
|
-
}
|
|
584
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
585
|
-
_.label = op[1];
|
|
586
|
-
break;
|
|
587
|
-
}
|
|
588
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
589
|
-
_.label = t[1];
|
|
590
|
-
t = op;
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
if (t && _.label < t[2]) {
|
|
594
|
-
_.label = t[2];
|
|
595
|
-
_.ops.push(op);
|
|
596
|
-
break;
|
|
597
|
-
}
|
|
598
|
-
if (t[2])
|
|
599
|
-
_.ops.pop();
|
|
600
|
-
_.trys.pop();
|
|
601
|
-
continue;
|
|
602
|
-
}
|
|
603
|
-
op = body.call(thisArg, _);
|
|
604
|
-
}
|
|
605
|
-
catch (e) {
|
|
606
|
-
op = [6, e];
|
|
607
|
-
y = 0;
|
|
608
|
-
}
|
|
609
|
-
finally {
|
|
610
|
-
f = t = 0;
|
|
611
|
-
}
|
|
612
|
-
if (op[0] & 5)
|
|
613
|
-
throw op[1];
|
|
614
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
function __exportStar(m, exports) {
|
|
618
|
-
for (var p in m)
|
|
619
|
-
if (!exports.hasOwnProperty(p))
|
|
620
|
-
exports[p] = m[p];
|
|
621
|
-
}
|
|
622
|
-
function __values(o) {
|
|
623
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
624
|
-
if (m)
|
|
625
|
-
return m.call(o);
|
|
626
|
-
if (o && typeof o.length === "number")
|
|
627
|
-
return {
|
|
628
|
-
next: function () {
|
|
629
|
-
if (o && i >= o.length)
|
|
630
|
-
o = void 0;
|
|
631
|
-
return { value: o && o[i++], done: !o };
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
635
|
-
}
|
|
636
|
-
function __read(o, n) {
|
|
637
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
638
|
-
if (!m)
|
|
639
|
-
return o;
|
|
640
|
-
var i = m.call(o), r, ar = [], e;
|
|
641
|
-
try {
|
|
642
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
643
|
-
ar.push(r.value);
|
|
644
|
-
}
|
|
645
|
-
catch (error) {
|
|
646
|
-
e = { error: error };
|
|
647
|
-
}
|
|
648
|
-
finally {
|
|
649
|
-
try {
|
|
650
|
-
if (r && !r.done && (m = i["return"]))
|
|
651
|
-
m.call(i);
|
|
652
|
-
}
|
|
653
|
-
finally {
|
|
654
|
-
if (e)
|
|
655
|
-
throw e.error;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
return ar;
|
|
659
|
-
}
|
|
660
|
-
function __spread() {
|
|
661
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
662
|
-
ar = ar.concat(__read(arguments[i]));
|
|
663
|
-
return ar;
|
|
664
|
-
}
|
|
665
|
-
function __spreadArrays() {
|
|
666
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
667
|
-
s += arguments[i].length;
|
|
668
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
669
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
670
|
-
r[k] = a[j];
|
|
671
|
-
return r;
|
|
672
|
-
}
|
|
673
|
-
function __await(v) {
|
|
674
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
675
|
-
}
|
|
676
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
677
|
-
if (!Symbol.asyncIterator)
|
|
678
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
679
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
680
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
681
|
-
function verb(n) {
|
|
682
|
-
if (g[n])
|
|
683
|
-
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); };
|
|
684
|
-
}
|
|
685
|
-
function resume(n, v) {
|
|
686
|
-
try {
|
|
687
|
-
step(g[n](v));
|
|
688
|
-
}
|
|
689
|
-
catch (e) {
|
|
690
|
-
settle(q[0][3], e);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
694
|
-
function fulfill(value) { resume("next", value); }
|
|
695
|
-
function reject(value) { resume("throw", value); }
|
|
696
|
-
function settle(f, v) {
|
|
697
|
-
if (f(v), q.shift(), q.length)
|
|
698
|
-
resume(q[0][0], q[0][1]);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
function __asyncDelegator(o) {
|
|
702
|
-
var i, p;
|
|
703
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
704
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
705
|
-
}
|
|
706
|
-
function __asyncValues(o) {
|
|
707
|
-
if (!Symbol.asyncIterator)
|
|
708
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
709
|
-
var m = o[Symbol.asyncIterator], i;
|
|
710
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
711
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
712
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
713
|
-
}
|
|
714
|
-
function __makeTemplateObject(cooked, raw) {
|
|
715
|
-
if (Object.defineProperty) {
|
|
716
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
717
|
-
}
|
|
718
|
-
else {
|
|
719
|
-
cooked.raw = raw;
|
|
720
|
-
}
|
|
721
|
-
return cooked;
|
|
722
|
-
}
|
|
723
|
-
function __importStar(mod) {
|
|
724
|
-
if (mod && mod.__esModule)
|
|
725
|
-
return mod;
|
|
726
|
-
var result = {};
|
|
727
|
-
if (mod != null)
|
|
728
|
-
for (var k in mod)
|
|
729
|
-
if (Object.hasOwnProperty.call(mod, k))
|
|
730
|
-
result[k] = mod[k];
|
|
731
|
-
result.default = mod;
|
|
732
|
-
return result;
|
|
733
|
-
}
|
|
734
|
-
function __importDefault(mod) {
|
|
735
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
736
|
-
}
|
|
737
|
-
function __classPrivateFieldGet(receiver, privateMap) {
|
|
738
|
-
if (!privateMap.has(receiver)) {
|
|
739
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
740
|
-
}
|
|
741
|
-
return privateMap.get(receiver);
|
|
742
|
-
}
|
|
743
|
-
function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
744
|
-
if (!privateMap.has(receiver)) {
|
|
745
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
746
|
-
}
|
|
747
|
-
privateMap.set(receiver, value);
|
|
748
|
-
return value;
|
|
749
|
-
}
|
|
750
|
-
var tslib_es6 = /*#__PURE__*/ Object.freeze({
|
|
751
|
-
__proto__: null,
|
|
752
|
-
__extends: __extends,
|
|
753
|
-
get __assign() { return __assign; },
|
|
754
|
-
__rest: __rest,
|
|
755
|
-
__decorate: __decorate,
|
|
756
|
-
__param: __param,
|
|
757
|
-
__metadata: __metadata,
|
|
758
|
-
__awaiter: __awaiter,
|
|
759
|
-
__generator: __generator,
|
|
760
|
-
__exportStar: __exportStar,
|
|
761
|
-
__values: __values,
|
|
762
|
-
__read: __read,
|
|
763
|
-
__spread: __spread,
|
|
764
|
-
__spreadArrays: __spreadArrays,
|
|
765
|
-
__await: __await,
|
|
766
|
-
__asyncGenerator: __asyncGenerator,
|
|
767
|
-
__asyncDelegator: __asyncDelegator,
|
|
768
|
-
__asyncValues: __asyncValues,
|
|
769
|
-
__makeTemplateObject: __makeTemplateObject,
|
|
770
|
-
__importStar: __importStar,
|
|
771
|
-
__importDefault: __importDefault,
|
|
772
|
-
__classPrivateFieldGet: __classPrivateFieldGet,
|
|
773
|
-
__classPrivateFieldSet: __classPrivateFieldSet
|
|
774
|
-
});
|
|
775
|
-
var useSet_1 = createCommonjsModule(function (module, exports) {
|
|
776
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
777
|
-
/* eslint-disable */
|
|
778
|
-
var useSet = function (initialSet) {
|
|
779
|
-
if (initialSet === void 0) {
|
|
780
|
-
initialSet = new Set();
|
|
781
|
-
}
|
|
782
|
-
var _a = React.useState(initialSet), set = _a[0], setSet = _a[1];
|
|
783
|
-
var stableActions = React.useMemo(function () {
|
|
784
|
-
var add = function (item) { return setSet(function (prevSet) { return new Set(tslib_es6.__spreadArrays(Array.from(prevSet), [item])); }); };
|
|
785
|
-
var remove = function (item) { return setSet(function (prevSet) { return new Set(Array.from(prevSet).filter(function (i) { return i !== item; })); }); };
|
|
786
|
-
var toggle = function (item) {
|
|
787
|
-
return setSet(function (prevSet) {
|
|
788
|
-
return prevSet.has(item)
|
|
789
|
-
? new Set(Array.from(prevSet).filter(function (i) { return i !== item; }))
|
|
790
|
-
: new Set(tslib_es6.__spreadArrays(Array.from(prevSet), [item]));
|
|
791
|
-
});
|
|
792
|
-
};
|
|
793
|
-
return { add: add, remove: remove, toggle: toggle, reset: function () { return setSet(initialSet); } };
|
|
794
|
-
}, [setSet]);
|
|
795
|
-
var utils = tslib_es6.__assign({ has: React.useCallback(function (item) { return set.has(item); }, [set]) }, stableActions);
|
|
796
|
-
return [set, utils];
|
|
797
|
-
};
|
|
798
|
-
exports.default = useSet;
|
|
799
|
-
});
|
|
800
|
-
var useSet = unwrapExports(useSet_1);
|
|
801
|
-
const VisibleElementsContext = React.createContext(null);
|
|
802
|
-
function VisibleElementObserver({ children, useWrapperDiv, selector, intersectionOptions, }) {
|
|
803
|
-
const [visibleElements, { add, remove }] = useSet();
|
|
804
|
-
const handleIntersect = React.useCallback((entries) => {
|
|
805
|
-
entries.forEach((e) => e.isIntersecting ? add(e.target) : remove(e.target));
|
|
806
|
-
}, [add, remove]);
|
|
807
|
-
const [mountedElements, observedTree] = useElementObserver_2({
|
|
808
|
-
tree: children,
|
|
809
|
-
selector,
|
|
810
|
-
useWrapperDiv,
|
|
811
|
-
});
|
|
812
|
-
React.useEffect(() => {
|
|
813
|
-
const observer = new IntersectionObserver(handleIntersect, intersectionOptions);
|
|
814
|
-
mountedElements.forEach((e) => observer.observe(e));
|
|
815
|
-
return () => {
|
|
816
|
-
observer.disconnect();
|
|
817
|
-
};
|
|
818
|
-
}, [mountedElements, handleIntersect, intersectionOptions]);
|
|
819
|
-
return (React.createElement(VisibleElementsContext.Provider, { value: visibleElements }, observedTree));
|
|
820
|
-
}
|
|
821
|
-
function useVisibleElements() {
|
|
822
|
-
const value = React.useContext(VisibleElementsContext);
|
|
823
|
-
if (value == null) {
|
|
824
|
-
throw new Error(`useVisibleElements must be used within a context provider`);
|
|
825
|
-
}
|
|
826
|
-
return value;
|
|
827
|
-
}
|
|
828
|
-
exports.VisibleElementObserver = VisibleElementObserver;
|
|
829
|
-
exports.useVisibleElements = useVisibleElements;
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
unwrapExports(useVisibleElements_1);
|
|
833
|
-
var useVisibleElements_2 = useVisibleElements_1.VisibleElementObserver;
|
|
834
|
-
var useVisibleElements_3 = useVisibleElements_1.useVisibleElements;
|
|
835
|
-
|
|
836
|
-
function useVisibilityOfTarget(href) {
|
|
837
|
-
const visibleElements = useVisibleElements_3();
|
|
838
|
-
return [...visibleElements].some((s) => s.querySelector(`:scope > ${href}`));
|
|
839
|
-
}
|
|
840
|
-
function TocVisibleSectionObserver(options) {
|
|
841
|
-
return react.createElement(useVisibleElements_2, Object.assign({ selector: "article section" }, options));
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
exports.TocVisibleSectionObserver = TocVisibleSectionObserver;
|
|
845
|
-
exports.useVisibilityOfTarget = useVisibilityOfTarget;
|