@c-rex/components 0.1.31 → 0.1.33
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/package.json +1 -1
- package/src/article/article-action-bar.analysis.md +15 -0
- package/src/article/article-content.analysis.md +15 -0
- package/src/article/article-content.tsx +3 -3
- package/src/autocomplete.analysis.md +17 -0
- package/src/autocomplete.tsx +2 -2
- package/src/breadcrumb.analysis.md +15 -0
- package/src/breadcrumb.tsx +4 -4
- package/src/carousel/carousel.analysis.md +17 -0
- package/src/carousel/carousel.tsx +2 -2
- package/src/check-article-lang.analysis.md +15 -0
- package/src/directoryNodes/tree-of-content.analysis.md +14 -0
- package/src/documents/result-list.analysis.md +14 -0
- package/src/documents/result-list.tsx +2 -2
- package/src/favorites/bookmark-button.analysis.md +15 -0
- package/src/favorites/bookmark-button.tsx +39 -37
- package/src/favorites/favorite-button.analysis.md +17 -0
- package/src/favorites/favorite-button.tsx +30 -7
- package/src/generated/create-client-request.tsx +15 -6
- package/src/icons/file-icon.analysis.md +14 -0
- package/src/icons/flag-icon.analysis.md +14 -0
- package/src/icons/loading.analysis.md +14 -0
- package/src/info/info-table.analysis.md +15 -0
- package/src/info/info-table.tsx +8 -8
- package/src/info/shared.analysis.md +14 -0
- package/src/navbar/language-switcher/content-language-switch.analysis.md +15 -0
- package/src/navbar/language-switcher/shared.analysis.md +14 -0
- package/src/navbar/language-switcher/ui-language-switch.analysis.md +15 -0
- package/src/navbar/navbar.analysis.md +14 -0
- package/src/navbar/settings.analysis.md +14 -0
- package/src/navbar/sign-in-out-btns.analysis.md +14 -0
- package/src/navbar/user-menu.analysis.md +14 -0
- package/src/page-wrapper.analysis.md +14 -0
- package/src/render-article.analysis.md +15 -0
- package/src/renditions/file-download.analysis.md +14 -0
- package/src/renditions/html.analysis.md +17 -0
- package/src/renditions/image/container.analysis.md +15 -0
- package/src/renditions/image/rendition.analysis.md +14 -0
- package/src/restriction-menu/restriction-menu-container.analysis.md +14 -0
- package/src/restriction-menu/restriction-menu-container.tsx +2 -2
- package/src/restriction-menu/restriction-menu-item.analysis.md +14 -0
- package/src/restriction-menu/restriction-menu.analysis.md +17 -0
- package/src/restriction-menu/restriction-menu.tsx +4 -6
- package/src/results/cards.analysis.md +14 -0
- package/src/results/dialog-filter.analysis.md +17 -0
- package/src/results/dialog-filter.tsx +32 -27
- package/src/results/empty.analysis.md +14 -0
- package/src/results/filter-navbar.analysis.md +16 -0
- package/src/results/filter-sidebar/index.analysis.md +14 -0
- package/src/results/generic/table-result-list.analysis.md +15 -0
- package/src/results/generic/table-result-list.tsx +3 -3
- package/src/results/pagination.analysis.md +14 -0
- package/src/results/table-with-images.analysis.md +15 -0
- package/src/results/table-with-images.tsx +2 -2
- package/src/results/table.analysis.md +15 -0
- package/src/results/table.tsx +4 -4
- package/src/search-input.analysis.md +15 -0
- package/src/share-button.analysis.md +19 -0
- package/src/stores/favorites-store.ts +21 -21
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Analysis: article-action-bar
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/article/article-action-bar.tsx
|
|
4
|
+
- Type: Client component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=yes, window/document=no, effects=yes, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- Store subscriptions can re-render this component whenever the selected slice changes.
|
|
9
|
+
- Effects that update state can add extra renders on mount and dependency changes.
|
|
10
|
+
|
|
11
|
+
## Possible bugs/risks
|
|
12
|
+
- No critical bug is evident in this quick static pass; keep tests for error and loading paths.
|
|
13
|
+
|
|
14
|
+
## Recommended improvements
|
|
15
|
+
- Standardize loading/error handling and add regression tests to prevent divergent behavior across consuming apps.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Analysis: article-content
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/article/article-content.tsx
|
|
4
|
+
- Type: Server component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=yes
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- Async flows can hit race conditions during fast param/route changes.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Consider cancellation guards (isMounted or AbortController) and standardized error handling.
|
|
15
|
+
|
|
@@ -43,8 +43,8 @@ export const ArticleContent: FC<Props> = async ({ renditions }) => {
|
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
45
|
<>
|
|
46
|
-
{metaTags.map((tag
|
|
47
|
-
<meta key={
|
|
46
|
+
{metaTags.map((tag) => (
|
|
47
|
+
<meta key={`${tag.name}-${tag.content}`} name={tag.name} content={tag.content} />
|
|
48
48
|
))}
|
|
49
49
|
<div className="pr-4 relative">
|
|
50
50
|
<RenderArticle htmlContent={articleHtml} contentLang="" />
|
|
@@ -52,4 +52,4 @@ export const ArticleContent: FC<Props> = async ({ renditions }) => {
|
|
|
52
52
|
<ArticleActionBar />
|
|
53
53
|
</>
|
|
54
54
|
)
|
|
55
|
-
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Analysis: autocomplete
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/autocomplete.tsx
|
|
4
|
+
- Type: Client component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=yes, effects=yes, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- Effects that update state can add extra renders on mount and dependency changes.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- Access to window/document needs care to avoid hydration mismatch and non-browser runtime issues.
|
|
12
|
+
- The component renders list-heavy UI; key stability and memoization strongly affect perceived performance.
|
|
13
|
+
|
|
14
|
+
## Recommended improvements
|
|
15
|
+
- Keep browser-only access inside event handlers or useEffect, not in initial render paths.
|
|
16
|
+
- Review key strategy and extract memoized subcomponents for large-list rendering.
|
|
17
|
+
|
package/src/autocomplete.tsx
CHANGED
|
@@ -135,9 +135,9 @@ export const AutoComplete = ({
|
|
|
135
135
|
<>
|
|
136
136
|
{suggestions.length > 0 ? (
|
|
137
137
|
<>
|
|
138
|
-
{suggestions.map((option
|
|
138
|
+
{suggestions.map((option) => (
|
|
139
139
|
<li
|
|
140
|
-
key={
|
|
140
|
+
key={option}
|
|
141
141
|
className="px-4 py-2 hover:bg-accent cursor-pointer text-sm"
|
|
142
142
|
onClick={() => handleSelect(`"${option}"`)}
|
|
143
143
|
>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Analysis: breadcrumb
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/breadcrumb.tsx
|
|
4
|
+
- Type: Client component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- The component renders list-heavy UI; key stability and memoization strongly affect perceived performance.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Review key strategy and extract memoized subcomponents for large-list rendering.
|
|
15
|
+
|
package/src/breadcrumb.tsx
CHANGED
|
@@ -53,9 +53,9 @@ export const Breadcrumb: FC<BreadcrumbProps> = ({ tree, lang }) => {
|
|
|
53
53
|
</DrawerHeader>
|
|
54
54
|
|
|
55
55
|
<div className="grid gap-1 px-4">
|
|
56
|
-
{items.slice(0, -1).map((item
|
|
56
|
+
{items.slice(0, -1).map((item) => (
|
|
57
57
|
<Link
|
|
58
|
-
key={
|
|
58
|
+
key={item.linkId}
|
|
59
59
|
href={`/topics/${item.linkId}/content`}
|
|
60
60
|
className="py-1 text-sm"
|
|
61
61
|
>
|
|
@@ -103,7 +103,7 @@ export const Breadcrumb: FC<BreadcrumbProps> = ({ tree, lang }) => {
|
|
|
103
103
|
|
|
104
104
|
return (
|
|
105
105
|
<Fragment key={`${item.label}-fragment`}>
|
|
106
|
-
<BreadcrumbItem key={`${item.label}-item`}
|
|
106
|
+
<BreadcrumbItem key={`${item.label}-item`}>
|
|
107
107
|
{renderLink(!isLast, item)}
|
|
108
108
|
</BreadcrumbItem>
|
|
109
109
|
{!isLast && (
|
|
@@ -121,4 +121,4 @@ export const Breadcrumb: FC<BreadcrumbProps> = ({ tree, lang }) => {
|
|
|
121
121
|
</BreadcrumbList>
|
|
122
122
|
</BreadcrumbComponent>
|
|
123
123
|
);
|
|
124
|
-
};
|
|
124
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Analysis: carousel
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/carousel/carousel.tsx
|
|
4
|
+
- Type: Client component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=yes, effects=yes, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- Effects that update state can add extra renders on mount and dependency changes.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- Access to window/document needs care to avoid hydration mismatch and non-browser runtime issues.
|
|
12
|
+
- The component renders list-heavy UI; key stability and memoization strongly affect perceived performance.
|
|
13
|
+
|
|
14
|
+
## Recommended improvements
|
|
15
|
+
- Keep browser-only access inside event handlers or useEffect, not in initial render paths.
|
|
16
|
+
- Review key strategy and extract memoized subcomponents for large-list rendering.
|
|
17
|
+
|
|
@@ -283,7 +283,7 @@ const CarouselIndicators: FC<{ className?: string }> = ({ className }) => {
|
|
|
283
283
|
return (
|
|
284
284
|
<ol className={cn("flex gap-2 z-20 list-none p-0 m-0", className)}>
|
|
285
285
|
{Array.from({ length: totalOfIndicators }).map((_, index) => (
|
|
286
|
-
<li key={index}>
|
|
286
|
+
<li key={`indicator-${index}`}>
|
|
287
287
|
<Button
|
|
288
288
|
className={`w-3 h-3 rounded-full border-0 cursor-pointer transition-colors ${index === current ? "bg-gray-800" : "bg-gray-300"}`}
|
|
289
289
|
size="xs"
|
|
@@ -349,4 +349,4 @@ const DefaultRenderCarouselItem: FC<{ item: CommonItemsModel; showImages: boolea
|
|
|
349
349
|
</Card>
|
|
350
350
|
</div>
|
|
351
351
|
);
|
|
352
|
-
};
|
|
352
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Analysis: check-article-lang
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/check-article-lang.tsx
|
|
4
|
+
- Type: Client component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=yes, effects=yes, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- Effects that update state can add extra renders on mount and dependency changes.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- Access to window/document needs care to avoid hydration mismatch and non-browser runtime issues.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Keep browser-only access inside event handlers or useEffect, not in initial render paths.
|
|
15
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Analysis: tree-of-content
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/directoryNodes/tree-of-content.tsx
|
|
4
|
+
- Type: Server component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- No critical bug is evident in this quick static pass; keep tests for error and loading paths.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Standardize loading/error handling and add regression tests to prevent divergent behavior across consuming apps.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Analysis: result-list
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/documents/result-list.tsx
|
|
4
|
+
- Type: Server component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- No critical bug is evident in this quick static pass; keep tests for error and loading paths.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Standardize loading/error handling and add regression tests to prevent divergent behavior across consuming apps.
|
|
@@ -56,7 +56,7 @@ export const DocumentsResultList: FC<Props> = ({
|
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
58
|
<div
|
|
59
|
-
key={
|
|
59
|
+
key={item.shortId}
|
|
60
60
|
className={cn(
|
|
61
61
|
"min-h-12 flex flex-wrap items-center border px-4 py-2 gap-2 rounded",
|
|
62
62
|
index == items.length - 1 ? "" : "mb-4",
|
|
@@ -124,4 +124,4 @@ export const DocumentsResultList: FC<Props> = ({
|
|
|
124
124
|
})}
|
|
125
125
|
</div>
|
|
126
126
|
);
|
|
127
|
-
};
|
|
127
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Analysis: bookmark-button
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/favorites/bookmark-button.tsx
|
|
4
|
+
- Type: Client component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=yes, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- Store updates for the selected document topics will re-render this component (expected and desired for live badge updates).
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- Dynamic Tailwind class name interpolation (`text-${item.color}`) may be purged depending on Tailwind safelist config.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Keep the direct Zustand selector approach (`documents[shortId]?.topics`) to preserve reactive UI behavior.
|
|
15
|
+
- If marker colors are dynamic, safelist all expected `text-*` classes or map colors to explicit class names.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { ComponentProps, FC,
|
|
4
|
-
import { Button
|
|
3
|
+
import { ComponentProps, FC, useState } from "react";
|
|
4
|
+
import { Button } from "@c-rex/ui/button";
|
|
5
5
|
import { Trash } from "lucide-react";
|
|
6
6
|
import { cn } from "@c-rex/utils";
|
|
7
7
|
import Link from "next/link";
|
|
@@ -20,17 +20,18 @@ type BookmarkProps = {
|
|
|
20
20
|
triggerVariant?: ComponentProps<typeof Button>["variant"];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const EMPTY_TOPICS: Array<{ id: string; label: string; color: string }> = [];
|
|
24
|
+
|
|
23
25
|
export const BookmarkButton: FC<BookmarkProps> = ({
|
|
24
26
|
shortId,
|
|
25
27
|
triggerVariant = "outline"
|
|
26
28
|
}) => {
|
|
27
|
-
const [
|
|
29
|
+
const [open, setOpen] = useState(false);
|
|
30
|
+
const document = useFavoritesStore((state) => state.documents[shortId]);
|
|
31
|
+
const markersList = document?.topics ?? EMPTY_TOPICS;
|
|
28
32
|
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
setMarkersList(useFavoritesStore.getState().documents[shortId]?.topics || []);
|
|
31
|
-
}, [shortId]);
|
|
32
33
|
return (
|
|
33
|
-
<Dialog>
|
|
34
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
34
35
|
<DialogTrigger asChild>
|
|
35
36
|
<Button variant={triggerVariant} size="icon" className="relative">
|
|
36
37
|
<FaRegBookmark className="text-primary" />
|
|
@@ -43,37 +44,38 @@ export const BookmarkButton: FC<BookmarkProps> = ({
|
|
|
43
44
|
</span>
|
|
44
45
|
)}
|
|
45
46
|
</Button>
|
|
46
|
-
|
|
47
47
|
</DialogTrigger>
|
|
48
|
-
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<
|
|
64
|
-
{item.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
48
|
+
{open && (
|
|
49
|
+
<DialogContent>
|
|
50
|
+
<DialogHeader>
|
|
51
|
+
<DialogTitle>Bookmarks</DialogTitle>
|
|
52
|
+
<DialogDescription>
|
|
53
|
+
Manage your bookmarks here
|
|
54
|
+
</DialogDescription>
|
|
55
|
+
</DialogHeader>
|
|
56
|
+
<Table>
|
|
57
|
+
<TableBody>
|
|
58
|
+
{markersList.map((item) => (
|
|
59
|
+
<TableRow key={item.id} className="min-h-12">
|
|
60
|
+
<TableCell>
|
|
61
|
+
<FaRegBookmark className={cn("w-5", `text-${item.color}`)} />
|
|
62
|
+
</TableCell>
|
|
63
|
+
<TableCell>
|
|
64
|
+
<Link href={`/topics/${item.id}`}>
|
|
65
|
+
{item.label}
|
|
66
|
+
</Link>
|
|
67
|
+
</TableCell>
|
|
68
|
+
<TableCell>
|
|
69
|
+
<Button variant="destructive" size="icon">
|
|
70
|
+
<Trash className="w-5 hover:text-red-600 cursor-pointer" />
|
|
71
|
+
</Button>
|
|
72
|
+
</TableCell>
|
|
73
|
+
</TableRow>
|
|
74
|
+
))}
|
|
75
|
+
</TableBody>
|
|
76
|
+
</Table>
|
|
77
|
+
</DialogContent>
|
|
78
|
+
)}
|
|
77
79
|
</Dialog>
|
|
78
80
|
)
|
|
79
81
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Analysis: favorite-button
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/favorites/favorite-button.tsx
|
|
4
|
+
- Type: Client component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=yes, window/document=no, effects=yes, fetch/call=yes
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- Store subscriptions can re-render this component whenever the selected slice changes.
|
|
9
|
+
- Effects that update state can add extra renders on mount and dependency changes.
|
|
10
|
+
|
|
11
|
+
## Possible bugs/risks
|
|
12
|
+
- Async flows can hit race conditions during fast param/route changes.
|
|
13
|
+
- Residual risk: fetch errors are silently ignored (except abort), which can hide API issues.
|
|
14
|
+
|
|
15
|
+
## Recommended improvements
|
|
16
|
+
- Keep cancellation guards (AbortController + unmount guard) in place as currently implemented.
|
|
17
|
+
- Consider surfacing non-abort fetch failures through logging or telemetry.
|
|
@@ -19,10 +19,32 @@ export const FavoriteButton: FC<{ id: string, type: ResultTypes, label: string }
|
|
|
19
19
|
const [documentData, setDocumentData] = useState<{ id: string, label: string }>({ id, label });
|
|
20
20
|
|
|
21
21
|
useEffect(() => {
|
|
22
|
-
if (type
|
|
23
|
-
|
|
22
|
+
if (type !== RESULT_TYPES.TOPIC) {
|
|
23
|
+
setDocumentData({ id, label });
|
|
24
|
+
return;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
let isCancelled = false;
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
|
|
30
|
+
const loadTopicDocumentData = async () => {
|
|
31
|
+
try {
|
|
32
|
+
const data = await getTopicDocumentData(id, controller.signal);
|
|
33
|
+
if (!isCancelled) {
|
|
34
|
+
setDocumentData(data);
|
|
35
|
+
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if ((error as Error).name === "AbortError") return;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
loadTopicDocumentData();
|
|
42
|
+
|
|
43
|
+
return () => {
|
|
44
|
+
isCancelled = true;
|
|
45
|
+
controller.abort();
|
|
46
|
+
};
|
|
47
|
+
}, [id, label, type]);
|
|
26
48
|
|
|
27
49
|
const addFavorite = async (id: string) => {
|
|
28
50
|
if (type === RESULT_TYPES.DOCUMENT) {
|
|
@@ -45,17 +67,18 @@ export const FavoriteButton: FC<{ id: string, type: ResultTypes, label: string }
|
|
|
45
67
|
removeFavoriteTopic(documentData.id, id);
|
|
46
68
|
}
|
|
47
69
|
|
|
48
|
-
const getTopicDocumentData = async (topicId: string): Promise<
|
|
70
|
+
const getTopicDocumentData = async (topicId: string, signal?: AbortSignal): Promise<{ id: string, label: string }> => {
|
|
49
71
|
|
|
50
72
|
const response = await fetch(`/api/information-units/document-by-topic-id?shortId=${topicId}`, {
|
|
51
|
-
method: "GET"
|
|
73
|
+
method: "GET",
|
|
74
|
+
signal,
|
|
52
75
|
});
|
|
53
76
|
|
|
54
77
|
if (!response.ok) throw new Error("Failed to fetch document by topic id")
|
|
55
78
|
|
|
56
|
-
const { documentId, label } = await response.json();
|
|
79
|
+
const { documentId, label: documentLabel } = await response.json();
|
|
57
80
|
|
|
58
|
-
|
|
81
|
+
return { id: documentId, label: documentLabel };
|
|
59
82
|
}
|
|
60
83
|
|
|
61
84
|
if (isFavorite) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
"use client";
|
|
9
9
|
|
|
10
|
-
import { useState, useEffect, useCallback } from 'react';
|
|
10
|
+
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
11
11
|
import { replacePathParams, call } from "@c-rex/utils"
|
|
12
12
|
|
|
13
13
|
type SerializedError = {
|
|
@@ -40,11 +40,21 @@ export function createClientDataRequest<T, PathParams, QueryParams>(
|
|
|
40
40
|
isLoading: true,
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
const pathParamsKey = useMemo(
|
|
44
|
+
() => JSON.stringify(pathParams ?? {}),
|
|
45
|
+
[pathParams]
|
|
46
|
+
);
|
|
47
|
+
const queryParamsKey = useMemo(
|
|
48
|
+
() => JSON.stringify(queryParams ?? {}),
|
|
49
|
+
[queryParams]
|
|
50
|
+
);
|
|
51
|
+
|
|
43
52
|
const fetchData = useCallback(async () => {
|
|
44
|
-
setState({
|
|
45
|
-
...
|
|
53
|
+
setState((prev) => ({
|
|
54
|
+
...prev,
|
|
46
55
|
error: null,
|
|
47
|
-
|
|
56
|
+
isLoading: true,
|
|
57
|
+
}));
|
|
48
58
|
|
|
49
59
|
try {
|
|
50
60
|
const url = replacePathParams(endpointTemplate, pathParams as Record<string, string>);
|
|
@@ -66,8 +76,7 @@ export function createClientDataRequest<T, PathParams, QueryParams>(
|
|
|
66
76
|
isLoading: false,
|
|
67
77
|
});
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
}, [endpointTemplate, pathParams]);
|
|
79
|
+
}, [endpointTemplate, pathParamsKey, queryParamsKey]);
|
|
71
80
|
|
|
72
81
|
|
|
73
82
|
// Initial fetch
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Analysis: file-icon
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/icons/file-icon.tsx
|
|
4
|
+
- Type: Server component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- No critical bug is evident in this quick static pass; keep tests for error and loading paths.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Standardize loading/error handling and add regression tests to prevent divergent behavior across consuming apps.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Analysis: flag-icon
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/icons/flag-icon.tsx
|
|
4
|
+
- Type: Server component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- No critical bug is evident in this quick static pass; keep tests for error and loading paths.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Standardize loading/error handling and add regression tests to prevent divergent behavior across consuming apps.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Analysis: loading
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/icons/loading.tsx
|
|
4
|
+
- Type: Server component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- No critical bug is evident in this quick static pass; keep tests for error and loading paths.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Standardize loading/error handling and add regression tests to prevent divergent behavior across consuming apps.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Analysis: info-table
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/info/info-table.tsx
|
|
4
|
+
- Type: Server component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- The component renders list-heavy UI; key stability and memoization strongly affect perceived performance.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Review key strategy and extract memoized subcomponents for large-list rendering.
|
|
15
|
+
|
package/src/info/info-table.tsx
CHANGED
|
@@ -56,8 +56,8 @@ export const InfoTable: FC<Props> = async ({
|
|
|
56
56
|
<CardContent className="space-y-3 !p-0">
|
|
57
57
|
<Table>
|
|
58
58
|
<TableBody>
|
|
59
|
-
{processDataToLabelValuePairs(data).map((item
|
|
60
|
-
<TableRow key={
|
|
59
|
+
{processDataToLabelValuePairs(data).map((item) => (
|
|
60
|
+
<TableRow key={item.label} className="min-h-12">
|
|
61
61
|
<TableCell className="font-medium w-28 pl-4">
|
|
62
62
|
<h4 className="text-sm font-medium capitalize">{t(item.label)}</h4>
|
|
63
63
|
</TableCell>
|
|
@@ -108,24 +108,24 @@ export const InfoTable: FC<Props> = async ({
|
|
|
108
108
|
</TableCell>
|
|
109
109
|
<TableCell className="text-xs text-muted-foreground flex items-center gap-2 min-h-12">
|
|
110
110
|
|
|
111
|
-
{Object.keys(files).map((
|
|
112
|
-
if (!files[
|
|
111
|
+
{Object.keys(files).map((fileKey) => {
|
|
112
|
+
if (!files[fileKey]) return null
|
|
113
113
|
|
|
114
114
|
return (
|
|
115
|
-
<DropdownMenu key={
|
|
115
|
+
<DropdownMenu key={fileKey}>
|
|
116
116
|
<DropdownMenuTrigger className="mr-2" asChild >
|
|
117
117
|
<Button variant="outline" size="icon" >
|
|
118
|
-
<FileIcon extension={
|
|
118
|
+
<FileIcon extension={fileKey} />
|
|
119
119
|
</Button>
|
|
120
120
|
</DropdownMenuTrigger>
|
|
121
121
|
<DropdownMenuContent>
|
|
122
122
|
<DropdownMenuItem>
|
|
123
|
-
<a href={files[
|
|
123
|
+
<a href={files[fileKey].view} target="_blank" rel="noreferrer" className="flex items-center">
|
|
124
124
|
<Eye className="mr-2" /> Open
|
|
125
125
|
</a>
|
|
126
126
|
</DropdownMenuItem>
|
|
127
127
|
<DropdownMenuItem>
|
|
128
|
-
<a href={files[
|
|
128
|
+
<a href={files[fileKey].download} target="_blank" rel="noreferrer" className="flex items-center">
|
|
129
129
|
<CloudDownload className="mr-2" /> Download
|
|
130
130
|
</a>
|
|
131
131
|
</DropdownMenuItem>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Analysis: shared
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/info/shared.tsx
|
|
4
|
+
- Type: Server component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- No critical bug is evident in this quick static pass; keep tests for error and loading paths.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Standardize loading/error handling and add regression tests to prevent divergent behavior across consuming apps.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Analysis: content-language-switch
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/navbar/language-switcher/content-language-switch.tsx
|
|
4
|
+
- Type: Client component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=yes, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- Access to window/document needs care to avoid hydration mismatch and non-browser runtime issues.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Keep browser-only access inside event handlers or useEffect, not in initial render paths.
|
|
15
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Analysis: shared
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/navbar/language-switcher/shared.tsx
|
|
4
|
+
- Type: Server component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=no, window/document=no, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- No obvious excessive re-render trigger beyond normal prop/context updates.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- No critical bug is evident in this quick static pass; keep tests for error and loading paths.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Standardize loading/error handling and add regression tests to prevent divergent behavior across consuming apps.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Analysis: ui-language-switch
|
|
2
|
+
|
|
3
|
+
- Component: packages/components/src/navbar/language-switcher/ui-language-switch.tsx
|
|
4
|
+
- Type: Client component
|
|
5
|
+
- Detected signals: useQueryStates=no, stores=yes, window/document=yes, effects=no, fetch/call=no
|
|
6
|
+
|
|
7
|
+
## Possible re-render causes
|
|
8
|
+
- Store subscriptions can re-render this component whenever the selected slice changes.
|
|
9
|
+
|
|
10
|
+
## Possible bugs/risks
|
|
11
|
+
- Access to window/document needs care to avoid hydration mismatch and non-browser runtime issues.
|
|
12
|
+
|
|
13
|
+
## Recommended improvements
|
|
14
|
+
- Keep browser-only access inside event handlers or useEffect, not in initial render paths.
|
|
15
|
+
|