@locusgraph/components 0.2.1 → 0.2.2
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/action/button-group.js +33 -136
- package/dist/action/button.js +15 -62
- package/dist/display/badge.js +13 -54
- package/dist/display/chat/attachment/attachment-parts.js +52 -218
- package/dist/display/chat/attachment/attachment.js +46 -186
- package/dist/display/chat/bubble.js +47 -192
- package/dist/display/chat/marker.js +32 -131
- package/dist/display/chat/message.js +56 -236
- package/dist/display/content/item.js +101 -415
- package/dist/display/content/kbd.js +18 -77
- package/dist/display/rule-grid/rule-grid.js +69 -292
- package/dist/display/skeletons/layouts/skeleton-rule-grid.js +25 -74
- package/dist/display/skeletons/layouts/skeleton-table.js +38 -158
- package/dist/display/skeletons/shapes/skeleton-avatar.js +19 -83
- package/dist/display/skeletons/shapes/skeleton-button.js +19 -83
- package/dist/display/skeletons/shapes/skeleton-text.js +18 -71
- package/dist/display/skeletons/skeleton-parts.js +17 -58
- package/dist/display/status/alert.js +30 -122
- package/dist/display/status/empty.js +57 -238
- package/dist/display/status/skeleton.js +9 -39
- package/dist/display/status/spinner.js +10 -40
- package/dist/display/table.js +75 -308
- package/dist/form/field/field-error.js +24 -107
- package/dist/form/field/field-separator.js +14 -65
- package/dist/form/field/field-set.js +20 -84
- package/dist/form/field/field-text.js +27 -115
- package/dist/form/field/field.js +31 -125
- package/dist/form/input.js +11 -45
- package/dist/form/native-select.js +31 -139
- package/dist/form/textarea.js +9 -39
- package/dist/layout/use-mobile.js +7 -20
- package/dist/navigation/breadcrumb.js +75 -294
- package/dist/navigation/navigation-menu.js +83 -359
- package/dist/navigation/pagination.js +78 -315
- package/dist/shell/app-header.js +21 -73
- package/dist/shell/app-shell.js +17 -56
- package/dist/shell/breadcrumbs.js +39 -97
- package/dist/shell/docs/docs-shell.js +35 -99
- package/dist/shell/docs/docs-sidebar.js +39 -86
- package/dist/shell/docs/use-active-section.js +31 -75
- package/dist/shell/navigation/app-sidebar.js +52 -174
- package/dist/shell/navigation/nav-group.js +40 -149
- package/package.json +1 -1
|
@@ -1,108 +1,50 @@
|
|
|
1
|
-
import { c as _c } from "react/compiler-runtime";
|
|
2
1
|
import { ChevronRight as ChevronRightIcon } from "@carbon/icons-react";
|
|
3
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
function CrumbLabel(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Link
|
|
10
|
-
} = t0;
|
|
3
|
+
function CrumbLabel({
|
|
4
|
+
crumb,
|
|
5
|
+
last,
|
|
6
|
+
Link
|
|
7
|
+
}) {
|
|
11
8
|
if (last) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
children: crumb.label
|
|
18
|
-
});
|
|
19
|
-
$[0] = crumb.label;
|
|
20
|
-
$[1] = t1;
|
|
21
|
-
} else {
|
|
22
|
-
t1 = $[1];
|
|
23
|
-
}
|
|
24
|
-
return t1;
|
|
9
|
+
return /*#__PURE__*/_jsx("span", {
|
|
10
|
+
"aria-current": "page",
|
|
11
|
+
className: "truncate font-medium",
|
|
12
|
+
children: crumb.label
|
|
13
|
+
});
|
|
25
14
|
}
|
|
26
15
|
if (crumb.href === undefined) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
t1 = /*#__PURE__*/_jsx("span", {
|
|
30
|
-
className: "truncate text-soft",
|
|
31
|
-
children: crumb.label
|
|
32
|
-
});
|
|
33
|
-
$[2] = crumb.label;
|
|
34
|
-
$[3] = t1;
|
|
35
|
-
} else {
|
|
36
|
-
t1 = $[3];
|
|
37
|
-
}
|
|
38
|
-
return t1;
|
|
39
|
-
}
|
|
40
|
-
let t1;
|
|
41
|
-
if ($[4] !== Link || $[5] !== crumb.href || $[6] !== crumb.label) {
|
|
42
|
-
t1 = /*#__PURE__*/_jsx(Link, {
|
|
43
|
-
href: crumb.href,
|
|
44
|
-
className: "truncate text-soft transition-colors hover:text-foreground",
|
|
16
|
+
return /*#__PURE__*/_jsx("span", {
|
|
17
|
+
className: "truncate text-soft",
|
|
45
18
|
children: crumb.label
|
|
46
19
|
});
|
|
47
|
-
$[4] = Link;
|
|
48
|
-
$[5] = crumb.href;
|
|
49
|
-
$[6] = crumb.label;
|
|
50
|
-
$[7] = t1;
|
|
51
|
-
} else {
|
|
52
|
-
t1 = $[7];
|
|
53
20
|
}
|
|
54
|
-
return
|
|
21
|
+
return /*#__PURE__*/_jsx(Link, {
|
|
22
|
+
href: crumb.href,
|
|
23
|
+
className: "truncate text-soft transition-colors hover:text-foreground",
|
|
24
|
+
children: crumb.label
|
|
25
|
+
});
|
|
55
26
|
}
|
|
56
|
-
function Breadcrumbs(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
})]
|
|
79
|
-
}, crumb.href ?? index);
|
|
80
|
-
};
|
|
81
|
-
$[3] = items.length;
|
|
82
|
-
$[4] = linkComponent;
|
|
83
|
-
$[5] = t3;
|
|
84
|
-
} else {
|
|
85
|
-
t3 = $[5];
|
|
86
|
-
}
|
|
87
|
-
t2 = items.map(t3);
|
|
88
|
-
$[0] = items;
|
|
89
|
-
$[1] = linkComponent;
|
|
90
|
-
$[2] = t2;
|
|
91
|
-
} else {
|
|
92
|
-
t2 = $[2];
|
|
93
|
-
}
|
|
94
|
-
let t3;
|
|
95
|
-
if ($[6] !== t2) {
|
|
96
|
-
t3 = /*#__PURE__*/_jsx("nav", {
|
|
97
|
-
"aria-label": "Breadcrumb",
|
|
98
|
-
className: "flex min-w-0 items-center gap-1.5 text-sm",
|
|
99
|
-
children: t2
|
|
100
|
-
});
|
|
101
|
-
$[6] = t2;
|
|
102
|
-
$[7] = t3;
|
|
103
|
-
} else {
|
|
104
|
-
t3 = $[7];
|
|
105
|
-
}
|
|
106
|
-
return t3;
|
|
27
|
+
function Breadcrumbs({
|
|
28
|
+
items,
|
|
29
|
+
linkComponent = "a"
|
|
30
|
+
}) {
|
|
31
|
+
return /*#__PURE__*/_jsx("nav", {
|
|
32
|
+
"aria-label": "Breadcrumb",
|
|
33
|
+
className: "flex min-w-0 items-center gap-1.5 text-sm",
|
|
34
|
+
children: items.map((crumb, index) => {
|
|
35
|
+
const last = index === items.length - 1;
|
|
36
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
37
|
+
className: last ? "flex min-w-0 items-center gap-1.5" : "hidden items-center gap-1.5 sm:flex",
|
|
38
|
+
children: [/*#__PURE__*/_jsx(CrumbLabel, {
|
|
39
|
+
crumb: crumb,
|
|
40
|
+
last: last,
|
|
41
|
+
Link: linkComponent
|
|
42
|
+
}), last ? null : /*#__PURE__*/_jsx(ChevronRightIcon, {
|
|
43
|
+
className: "size-3.5 shrink-0 text-faint",
|
|
44
|
+
"aria-hidden": true
|
|
45
|
+
})]
|
|
46
|
+
}, crumb.href ?? index);
|
|
47
|
+
})
|
|
48
|
+
});
|
|
107
49
|
}
|
|
108
50
|
export { Breadcrumbs };
|
|
@@ -1,104 +1,40 @@
|
|
|
1
|
-
import { c as _c } from "react/compiler-runtime";
|
|
2
1
|
import { cn } from "cn";
|
|
3
2
|
import { TooltipProvider } from "../../overlay/tooltip.js";
|
|
4
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
function DocsShell(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
$[4] = children;
|
|
42
|
-
$[5] = t4;
|
|
43
|
-
} else {
|
|
44
|
-
t4 = $[5];
|
|
45
|
-
}
|
|
46
|
-
let t5;
|
|
47
|
-
if ($[6] !== aside) {
|
|
48
|
-
t5 = aside && /*#__PURE__*/_jsx("aside", {
|
|
49
|
-
"data-slot": "docs-aside",
|
|
50
|
-
className: "sticky top-[calc(var(--docs-header-height)+1px)] hidden h-[90svh] w-72 shrink-0 flex-col gap-8 overflow-hidden pt-10 xl:flex",
|
|
51
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
52
|
-
className: "no-scrollbar flex flex-col gap-8 overflow-y-auto px-8",
|
|
53
|
-
children: aside
|
|
54
|
-
})
|
|
55
|
-
});
|
|
56
|
-
$[6] = aside;
|
|
57
|
-
$[7] = t5;
|
|
58
|
-
} else {
|
|
59
|
-
t5 = $[7];
|
|
60
|
-
}
|
|
61
|
-
let t6;
|
|
62
|
-
if ($[8] !== t4 || $[9] !== t5) {
|
|
63
|
-
t6 = /*#__PURE__*/_jsxs("div", {
|
|
64
|
-
className: "flex min-w-0 items-stretch",
|
|
65
|
-
children: [t4, t5]
|
|
66
|
-
});
|
|
67
|
-
$[8] = t4;
|
|
68
|
-
$[9] = t5;
|
|
69
|
-
$[10] = t6;
|
|
70
|
-
} else {
|
|
71
|
-
t6 = $[10];
|
|
72
|
-
}
|
|
73
|
-
let t7;
|
|
74
|
-
if ($[11] !== t2 || $[12] !== t3 || $[13] !== t6) {
|
|
75
|
-
t7 = /*#__PURE__*/_jsxs("div", {
|
|
76
|
-
className: t2,
|
|
77
|
-
children: [t3, t6]
|
|
78
|
-
});
|
|
79
|
-
$[11] = t2;
|
|
80
|
-
$[12] = t3;
|
|
81
|
-
$[13] = t6;
|
|
82
|
-
$[14] = t7;
|
|
83
|
-
} else {
|
|
84
|
-
t7 = $[14];
|
|
85
|
-
}
|
|
86
|
-
let t8;
|
|
87
|
-
if ($[15] !== header || $[16] !== t7) {
|
|
88
|
-
t8 = /*#__PURE__*/_jsx(TooltipProvider, {
|
|
89
|
-
delayDuration: 0,
|
|
90
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
91
|
-
"data-slot": "docs-shell",
|
|
92
|
-
className: "flex min-h-svh flex-col bg-background [--docs-header-height:3.5rem] lg:[--docs-header-height:4rem]",
|
|
93
|
-
children: [header, t7]
|
|
94
|
-
})
|
|
95
|
-
});
|
|
96
|
-
$[15] = header;
|
|
97
|
-
$[16] = t7;
|
|
98
|
-
$[17] = t8;
|
|
99
|
-
} else {
|
|
100
|
-
t8 = $[17];
|
|
101
|
-
}
|
|
102
|
-
return t8;
|
|
4
|
+
function DocsShell({
|
|
5
|
+
header,
|
|
6
|
+
sidebar,
|
|
7
|
+
aside,
|
|
8
|
+
children
|
|
9
|
+
}) {
|
|
10
|
+
return /*#__PURE__*/_jsx(TooltipProvider, {
|
|
11
|
+
delayDuration: 0,
|
|
12
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
13
|
+
"data-slot": "docs-shell",
|
|
14
|
+
className: "flex min-h-svh flex-col bg-background [--docs-header-height:3.5rem] lg:[--docs-header-height:4rem]",
|
|
15
|
+
children: [header, /*#__PURE__*/_jsxs("div", {
|
|
16
|
+
className: cn("mx-auto w-full max-w-[1536px] flex-1 items-start px-2", sidebar && "lg:grid lg:grid-cols-[18rem_minmax(0,1fr)]"),
|
|
17
|
+
children: [sidebar && /*#__PURE__*/_jsx("aside", {
|
|
18
|
+
"data-slot": "docs-sidebar",
|
|
19
|
+
className: "sticky top-[calc(var(--docs-header-height)+0.6rem)] hidden h-[calc(100svh-10rem)] lg:block",
|
|
20
|
+
children: sidebar
|
|
21
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
22
|
+
className: "flex min-w-0 items-stretch",
|
|
23
|
+
children: [/*#__PURE__*/_jsx("main", {
|
|
24
|
+
"data-slot": "docs-body",
|
|
25
|
+
className: "min-w-0 flex-1 px-4 pt-6 pb-16 md:px-6 lg:pt-10",
|
|
26
|
+
children: children
|
|
27
|
+
}), aside && /*#__PURE__*/_jsx("aside", {
|
|
28
|
+
"data-slot": "docs-aside",
|
|
29
|
+
className: "sticky top-[calc(var(--docs-header-height)+1px)] hidden h-[90svh] w-72 shrink-0 flex-col gap-8 overflow-hidden pt-10 xl:flex",
|
|
30
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
31
|
+
className: "no-scrollbar flex flex-col gap-8 overflow-y-auto px-8",
|
|
32
|
+
children: aside
|
|
33
|
+
})
|
|
34
|
+
})]
|
|
35
|
+
})]
|
|
36
|
+
})]
|
|
37
|
+
})
|
|
38
|
+
});
|
|
103
39
|
}
|
|
104
40
|
export { DocsShell };
|
|
@@ -1,93 +1,46 @@
|
|
|
1
|
-
import { c as _c } from "react/compiler-runtime";
|
|
2
1
|
import { cn } from "cn";
|
|
3
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
function DocsNavList(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
className: "flex flex-col",
|
|
18
|
-
children:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, item.href);
|
|
33
|
-
})
|
|
34
|
-
})]
|
|
35
|
-
}, group.label);
|
|
36
|
-
$[4] = Link;
|
|
37
|
-
$[5] = activeHref;
|
|
38
|
-
$[6] = t3;
|
|
39
|
-
} else {
|
|
40
|
-
t3 = $[6];
|
|
41
|
-
}
|
|
42
|
-
t2 = groups.map(t3);
|
|
43
|
-
$[0] = Link;
|
|
44
|
-
$[1] = activeHref;
|
|
45
|
-
$[2] = groups;
|
|
46
|
-
$[3] = t2;
|
|
47
|
-
} else {
|
|
48
|
-
t2 = $[3];
|
|
49
|
-
}
|
|
50
|
-
let t3;
|
|
51
|
-
if ($[7] !== t2) {
|
|
52
|
-
t3 = /*#__PURE__*/_jsx("div", {
|
|
53
|
-
className: "flex flex-col gap-4",
|
|
54
|
-
children: t2
|
|
55
|
-
});
|
|
56
|
-
$[7] = t2;
|
|
57
|
-
$[8] = t3;
|
|
58
|
-
} else {
|
|
59
|
-
t3 = $[8];
|
|
60
|
-
}
|
|
61
|
-
return t3;
|
|
3
|
+
function DocsNavList({
|
|
4
|
+
groups,
|
|
5
|
+
activeHref,
|
|
6
|
+
linkComponent: Link = "a"
|
|
7
|
+
}) {
|
|
8
|
+
return /*#__PURE__*/_jsx("div", {
|
|
9
|
+
className: "flex flex-col gap-4",
|
|
10
|
+
children: groups.map(group => /*#__PURE__*/_jsxs("div", {
|
|
11
|
+
className: "flex flex-col",
|
|
12
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
13
|
+
className: "eyebrow flex h-8 items-center px-2",
|
|
14
|
+
children: group.label
|
|
15
|
+
}), /*#__PURE__*/_jsx("ul", {
|
|
16
|
+
className: "flex flex-col gap-0.5",
|
|
17
|
+
children: group.items.map(item => {
|
|
18
|
+
const active = item.href === activeHref;
|
|
19
|
+
return /*#__PURE__*/_jsx("li", {
|
|
20
|
+
children: /*#__PURE__*/_jsx(Link, {
|
|
21
|
+
href: item.href,
|
|
22
|
+
"aria-current": active ? "page" : undefined,
|
|
23
|
+
className: cn("flex h-[30px] w-fit items-center rounded-md border border-transparent px-2 text-sm font-medium transition-colors hover:bg-accent", active && "border-accent bg-accent"),
|
|
24
|
+
children: item.title
|
|
25
|
+
})
|
|
26
|
+
}, item.href);
|
|
27
|
+
})
|
|
28
|
+
})]
|
|
29
|
+
}, group.label))
|
|
30
|
+
});
|
|
62
31
|
}
|
|
63
32
|
function DocsSidebar(props) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
t0 = /*#__PURE__*/_jsx("div", {
|
|
33
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
34
|
+
className: "relative h-full",
|
|
35
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
68
36
|
className: "absolute top-12 right-2 bottom-0 w-px bg-[linear-gradient(to_bottom,transparent_0%,var(--border)_10%,var(--border)_90%,transparent_100%)]"
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
className: "relative h-full",
|
|
78
|
-
children: [t0, /*#__PURE__*/_jsx("nav", {
|
|
79
|
-
"aria-label": "Documentation",
|
|
80
|
-
className: "no-scrollbar h-full w-56 overflow-y-auto pt-10 pb-12 pl-2.5 [mask-image:linear-gradient(to_bottom,transparent,black_2rem,black_calc(100%-3rem),transparent)]",
|
|
81
|
-
children: /*#__PURE__*/_jsx(DocsNavList, {
|
|
82
|
-
...props
|
|
83
|
-
})
|
|
84
|
-
})]
|
|
85
|
-
});
|
|
86
|
-
$[1] = props;
|
|
87
|
-
$[2] = t1;
|
|
88
|
-
} else {
|
|
89
|
-
t1 = $[2];
|
|
90
|
-
}
|
|
91
|
-
return t1;
|
|
37
|
+
}), /*#__PURE__*/_jsx("nav", {
|
|
38
|
+
"aria-label": "Documentation",
|
|
39
|
+
className: "no-scrollbar h-full w-56 overflow-y-auto pt-10 pb-12 pl-2.5 [mask-image:linear-gradient(to_bottom,transparent,black_2rem,black_calc(100%-3rem),transparent)]",
|
|
40
|
+
children: /*#__PURE__*/_jsx(DocsNavList, {
|
|
41
|
+
...props
|
|
42
|
+
})
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
92
45
|
}
|
|
93
46
|
export { DocsNavList, DocsSidebar };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { c as _c } from "react/compiler-runtime";
|
|
2
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
2
|
const SMOOTH_SCROLL_MS = 800;
|
|
4
3
|
function isWindowScrolledToBottom() {
|
|
@@ -18,83 +17,40 @@ function lastSectionAboveLine(ids) {
|
|
|
18
17
|
return current;
|
|
19
18
|
}
|
|
20
19
|
function useActiveSection(sectionIds) {
|
|
21
|
-
const $ = _c(9);
|
|
22
20
|
const [activeId, setActiveId] = useState(sectionIds[0] ?? "");
|
|
23
21
|
const pinnedUntil = useRef(0);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
const pinSection = t1;
|
|
47
|
-
let t2;
|
|
48
|
-
if ($[2] !== sectionIds) {
|
|
49
|
-
t2 = sectionIds.join(" ");
|
|
50
|
-
$[2] = sectionIds;
|
|
51
|
-
$[3] = t2;
|
|
52
|
-
} else {
|
|
53
|
-
t2 = $[3];
|
|
54
|
-
}
|
|
55
|
-
const idsKey = t2;
|
|
56
|
-
let t3;
|
|
57
|
-
let t4;
|
|
58
|
-
if ($[4] !== idsKey) {
|
|
59
|
-
t3 = () => {
|
|
60
|
-
const ids = idsKey.split(" ").filter(Boolean);
|
|
61
|
-
let frame = 0;
|
|
62
|
-
const updateActiveSection = () => {
|
|
63
|
-
cancelAnimationFrame(frame);
|
|
64
|
-
frame = requestAnimationFrame(() => {
|
|
65
|
-
const lastId = ids.at(-1);
|
|
66
|
-
const current = isWindowScrolledToBottom() && lastId ? lastId : lastSectionAboveLine(ids);
|
|
67
|
-
if (current) {
|
|
68
|
-
followScroll(current);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
updateActiveSection();
|
|
73
|
-
window.addEventListener("scroll", updateActiveSection, {
|
|
74
|
-
passive: true
|
|
22
|
+
const followScroll = useCallback(id => {
|
|
23
|
+
if (Date.now() > pinnedUntil.current) {
|
|
24
|
+
setActiveId(id);
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
const pinSection = useCallback(id => {
|
|
28
|
+
pinnedUntil.current = Date.now() + SMOOTH_SCROLL_MS;
|
|
29
|
+
setActiveId(id);
|
|
30
|
+
}, []);
|
|
31
|
+
const idsKey = sectionIds.join(" ");
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const ids = idsKey.split(" ").filter(Boolean);
|
|
34
|
+
let frame = 0;
|
|
35
|
+
const updateActiveSection = () => {
|
|
36
|
+
cancelAnimationFrame(frame);
|
|
37
|
+
frame = requestAnimationFrame(() => {
|
|
38
|
+
const lastId = ids.at(-1);
|
|
39
|
+
const current = isWindowScrolledToBottom() && lastId ? lastId : lastSectionAboveLine(ids);
|
|
40
|
+
if (current) {
|
|
41
|
+
followScroll(current);
|
|
42
|
+
}
|
|
75
43
|
});
|
|
76
|
-
return () => {
|
|
77
|
-
cancelAnimationFrame(frame);
|
|
78
|
-
window.removeEventListener("scroll", updateActiveSection);
|
|
79
|
-
};
|
|
80
44
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if ($[7] !== activeId) {
|
|
92
|
-
t5 = [activeId, pinSection];
|
|
93
|
-
$[7] = activeId;
|
|
94
|
-
$[8] = t5;
|
|
95
|
-
} else {
|
|
96
|
-
t5 = $[8];
|
|
97
|
-
}
|
|
98
|
-
return t5;
|
|
45
|
+
updateActiveSection();
|
|
46
|
+
window.addEventListener("scroll", updateActiveSection, {
|
|
47
|
+
passive: true
|
|
48
|
+
});
|
|
49
|
+
return () => {
|
|
50
|
+
cancelAnimationFrame(frame);
|
|
51
|
+
window.removeEventListener("scroll", updateActiveSection);
|
|
52
|
+
};
|
|
53
|
+
}, [idsKey, followScroll]);
|
|
54
|
+
return [activeId, pinSection];
|
|
99
55
|
}
|
|
100
56
|
export { useActiveSection };
|