@deepcitation/deepcitation-js 1.1.27 → 1.1.29
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/LICENSE +21 -21
- package/README.md +253 -253
- package/lib/chunk-2IZXUOQR.js +66 -0
- package/lib/chunk-3GR7VKUJ.cjs +1 -0
- package/lib/chunk-4FGOHQFP.cjs +66 -0
- package/lib/chunk-CFXDRAJL.cjs +1 -0
- package/lib/chunk-F2MMVEVC.cjs +1 -0
- package/lib/chunk-LSKISWWH.cjs +2 -0
- package/lib/chunk-O2XFH626.js +1 -0
- package/lib/chunk-QGXCOW3E.js +1 -0
- package/lib/chunk-RCHWBA6D.js +2 -0
- package/lib/chunk-RQPZSRID.js +1 -0
- package/lib/client/index.cjs +1 -0
- package/lib/client/{DeepCitation.d.ts → index.d.cts} +159 -3
- package/lib/client/index.d.ts +342 -2
- package/lib/client/index.js +1 -1
- package/lib/index.cjs +1 -0
- package/lib/index.d.cts +105 -0
- package/lib/index.d.ts +103 -21
- package/lib/index.js +1 -20
- package/lib/prompts/index.cjs +1 -0
- package/lib/prompts/index.d.cts +196 -0
- package/lib/prompts/index.d.ts +196 -3
- package/lib/prompts/index.js +1 -3
- package/lib/react/index.cjs +4 -0
- package/lib/react/{types.d.ts → index.d.cts} +173 -22
- package/lib/react/index.d.ts +461 -12
- package/lib/react/index.js +4 -20
- package/lib/types/index.cjs +1 -0
- package/lib/types/index.d.cts +96 -0
- package/lib/types/index.d.ts +96 -11
- package/lib/types/index.js +1 -7
- package/lib/utils-CSqRI6NU.d.cts +45 -0
- package/lib/{react/utils.d.ts → utils-D_wxy_ni.d.ts} +13 -12
- package/package.json +46 -11
- package/lib/client/DeepCitation.js +0 -374
- package/lib/client/types.d.ts +0 -154
- package/lib/client/types.js +0 -1
- package/lib/parsing/normalizeCitation.d.ts +0 -5
- package/lib/parsing/normalizeCitation.js +0 -198
- package/lib/parsing/parseCitation.d.ts +0 -79
- package/lib/parsing/parseCitation.js +0 -431
- package/lib/parsing/parseWorkAround.d.ts +0 -2
- package/lib/parsing/parseWorkAround.js +0 -73
- package/lib/prompts/citationPrompts.d.ts +0 -138
- package/lib/prompts/citationPrompts.js +0 -168
- package/lib/prompts/promptCompression.d.ts +0 -14
- package/lib/prompts/promptCompression.js +0 -127
- package/lib/prompts/types.d.ts +0 -4
- package/lib/prompts/types.js +0 -1
- package/lib/react/CitationComponent.d.ts +0 -106
- package/lib/react/CitationComponent.js +0 -419
- package/lib/react/CitationVariants.d.ts +0 -132
- package/lib/react/CitationVariants.js +0 -277
- package/lib/react/DiffDisplay.d.ts +0 -10
- package/lib/react/DiffDisplay.js +0 -33
- package/lib/react/Popover.d.ts +0 -15
- package/lib/react/Popover.js +0 -20
- package/lib/react/UrlCitationComponent.d.ts +0 -83
- package/lib/react/UrlCitationComponent.js +0 -224
- package/lib/react/VerificationTabs.d.ts +0 -10
- package/lib/react/VerificationTabs.js +0 -36
- package/lib/react/icons.d.ts +0 -22
- package/lib/react/icons.js +0 -16
- package/lib/react/primitives.d.ts +0 -99
- package/lib/react/primitives.js +0 -187
- package/lib/react/types.js +0 -1
- package/lib/react/useSmartDiff.d.ts +0 -16
- package/lib/react/useSmartDiff.js +0 -64
- package/lib/react/utils.js +0 -88
- package/lib/types/boxes.d.ts +0 -11
- package/lib/types/boxes.js +0 -1
- package/lib/types/citation.d.ts +0 -39
- package/lib/types/citation.js +0 -1
- package/lib/types/search.d.ts +0 -19
- package/lib/types/search.js +0 -1
- package/lib/types/verification.d.ts +0 -27
- package/lib/types/verification.js +0 -11
- package/lib/utils/diff.d.ts +0 -60
- package/lib/utils/diff.js +0 -414
- package/lib/utils/sha.d.ts +0 -10
- package/lib/utils/sha.js +0 -108
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useMemo, useCallback, forwardRef, } from "react";
|
|
3
|
-
import { getCitationStatus } from "../parsing/parseCitation.js";
|
|
4
|
-
import { generateCitationKey, generateCitationInstanceId, getCitationDisplayText, getCitationNumber, classNames, } from "./utils.js";
|
|
5
|
-
const TWO_DOTS_THINKING_CONTENT = "..";
|
|
6
|
-
/**
|
|
7
|
-
* Hook to get common citation data.
|
|
8
|
-
* NOTE: Status is not memoized because verification may be mutated in place.
|
|
9
|
-
*/
|
|
10
|
-
function useCitationData(citation, verification) {
|
|
11
|
-
const citationKey = useMemo(() => generateCitationKey(citation), [citation]);
|
|
12
|
-
const citationInstanceId = useMemo(() => generateCitationInstanceId(citationKey), [citationKey]);
|
|
13
|
-
// Don't memoize - object reference as dependency causes stale values on mutation
|
|
14
|
-
const status = getCitationStatus(verification ?? null);
|
|
15
|
-
return { citationKey, citationInstanceId, status };
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Default verified indicator (checkmark)
|
|
19
|
-
*/
|
|
20
|
-
const DefaultVerifiedIndicator = () => (_jsx("span", { className: "text-green-600 dark:text-green-500 ml-0.5", "aria-hidden": "true", children: "\u2713" }));
|
|
21
|
-
/**
|
|
22
|
-
* Default partial match indicator (asterisk)
|
|
23
|
-
*/
|
|
24
|
-
const DefaultPartialIndicator = () => (_jsx("span", { className: "text-amber-600 dark:text-amber-500 ml-0.5", "aria-hidden": "true", children: "*" }));
|
|
25
|
-
/**
|
|
26
|
-
* Chip/Badge style citation component.
|
|
27
|
-
* Displays citation as a rounded pill/badge.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* <ChipCitation citation={citation} verification={found} size="md" />
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export const ChipCitation = forwardRef(({ citation, children, className, fallbackDisplay, verification, eventHandlers, isMobile = false, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), size = "md", showIcon = false, icon, }, ref) => {
|
|
35
|
-
const { citationKey, citationInstanceId, status } = useCitationData(citation, verification);
|
|
36
|
-
const { isVerified, isMiss, isPartialMatch, isPending } = status;
|
|
37
|
-
// ChipCitation shows keySpan by default
|
|
38
|
-
const displayText = useMemo(() => getCitationDisplayText(citation, { fallbackDisplay }), [citation, fallbackDisplay]);
|
|
39
|
-
const handleClick = useCallback((e) => {
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
e.stopPropagation();
|
|
42
|
-
eventHandlers?.onClick?.(citation, citationKey, e);
|
|
43
|
-
}, [eventHandlers, citation, citationKey]);
|
|
44
|
-
const handleMouseEnter = useCallback(() => {
|
|
45
|
-
eventHandlers?.onMouseEnter?.(citation, citationKey);
|
|
46
|
-
}, [eventHandlers, citation, citationKey]);
|
|
47
|
-
const handleMouseLeave = useCallback(() => {
|
|
48
|
-
eventHandlers?.onMouseLeave?.(citation, citationKey);
|
|
49
|
-
}, [eventHandlers, citation, citationKey]);
|
|
50
|
-
const sizeClasses = {
|
|
51
|
-
sm: "text-xs px-1.5 py-px",
|
|
52
|
-
md: "text-sm px-2 py-0.5",
|
|
53
|
-
lg: "text-base px-3 py-1",
|
|
54
|
-
};
|
|
55
|
-
// Check partial first since isVerified is true when isPartialMatch is true
|
|
56
|
-
const statusClass = isPartialMatch
|
|
57
|
-
? "bg-amber-100 text-amber-600 dark:bg-amber-900/30 dark:text-amber-500"
|
|
58
|
-
: isMiss
|
|
59
|
-
? "bg-red-100 text-red-600 dark:bg-red-900/30 dark:text-red-400 line-through"
|
|
60
|
-
: isVerified
|
|
61
|
-
? "bg-green-100 text-green-600 dark:bg-green-900/30 dark:text-green-500"
|
|
62
|
-
: isPending
|
|
63
|
-
? "bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400"
|
|
64
|
-
: "bg-blue-100 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400";
|
|
65
|
-
return (_jsxs(_Fragment, { children: [children, _jsxs("span", { ref: ref, "data-citation-id": citationKey, "data-citation-instance": citationInstanceId, "data-variant": "chip", className: classNames("inline-flex items-center gap-1 rounded-full font-medium cursor-pointer transition-colors hover:brightness-95", sizeClasses[size], statusClass, className), onMouseEnter: preventTooltips ? undefined : handleMouseEnter, onMouseLeave: preventTooltips ? undefined : handleMouseLeave, onMouseDown: handleClick, onClick: (e) => e.stopPropagation(), "aria-label": displayText ? `Citation: ${displayText}` : undefined, children: [showIcon &&
|
|
66
|
-
(icon || _jsx("span", { className: "text-[0.9em]", children: "\uD83D\uDCC4" })), _jsx("span", { className: "font-medium", children: displayText }), isPartialMatch && renderPartialIndicator(status), isVerified && !isPartialMatch && renderVerifiedIndicator(status), isPending && (_jsx("span", { className: "opacity-70", children: pendingContent }))] })] }));
|
|
67
|
-
});
|
|
68
|
-
ChipCitation.displayName = "ChipCitation";
|
|
69
|
-
/**
|
|
70
|
-
* Superscript style citation component.
|
|
71
|
-
* Displays citation as a superscript number like academic papers.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```tsx
|
|
75
|
-
* <SuperscriptCitation citation={citation} verification={found} />
|
|
76
|
-
* // Renders: Text content¹
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
export const SuperscriptCitation = forwardRef(({ citation, children, className, fallbackDisplay, verification, eventHandlers, isMobile = false, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), hideBrackets = false, }, ref) => {
|
|
80
|
-
const { citationKey, citationInstanceId, status } = useCitationData(citation, verification);
|
|
81
|
-
const { isVerified, isMiss, isPartialMatch, isPending } = status;
|
|
82
|
-
// SuperscriptCitation shows number by default
|
|
83
|
-
const displayText = useMemo(() => getCitationNumber(citation), [citation]);
|
|
84
|
-
const handleClick = useCallback((e) => {
|
|
85
|
-
e.preventDefault();
|
|
86
|
-
e.stopPropagation();
|
|
87
|
-
eventHandlers?.onClick?.(citation, citationKey, e);
|
|
88
|
-
}, [eventHandlers, citation, citationKey]);
|
|
89
|
-
const handleMouseEnter = useCallback(() => {
|
|
90
|
-
eventHandlers?.onMouseEnter?.(citation, citationKey);
|
|
91
|
-
}, [eventHandlers, citation, citationKey]);
|
|
92
|
-
const handleMouseLeave = useCallback(() => {
|
|
93
|
-
eventHandlers?.onMouseLeave?.(citation, citationKey);
|
|
94
|
-
}, [eventHandlers, citation, citationKey]);
|
|
95
|
-
// Check partial first since isVerified is true when isPartialMatch is true
|
|
96
|
-
const statusClass = isPartialMatch
|
|
97
|
-
? "text-amber-600 dark:text-amber-500"
|
|
98
|
-
: isMiss
|
|
99
|
-
? "text-red-500 dark:text-red-400 line-through"
|
|
100
|
-
: isVerified
|
|
101
|
-
? "text-green-600 dark:text-green-500"
|
|
102
|
-
: isPending
|
|
103
|
-
? "text-gray-400 dark:text-gray-500"
|
|
104
|
-
: "text-blue-600 dark:text-blue-400";
|
|
105
|
-
return (_jsxs(_Fragment, { children: [children, _jsxs("sup", { ref: ref, "data-citation-id": citationKey, "data-citation-instance": citationInstanceId, "data-variant": "superscript", className: classNames("text-xs cursor-pointer font-medium transition-colors hover:underline", statusClass, className), onMouseEnter: preventTooltips ? undefined : handleMouseEnter, onMouseLeave: preventTooltips ? undefined : handleMouseLeave, onMouseDown: handleClick, onClick: (e) => e.stopPropagation(), "aria-label": `Citation ${displayText}`, children: [!hideBrackets && "[", displayText, isPartialMatch && renderPartialIndicator(status), isVerified && !isPartialMatch && renderVerifiedIndicator(status), isPending && pendingContent, !hideBrackets && "]"] })] }));
|
|
106
|
-
});
|
|
107
|
-
SuperscriptCitation.displayName = "SuperscriptCitation";
|
|
108
|
-
const FOOTNOTE_SYMBOLS = ["*", "†", "‡", "§", "‖", "¶"];
|
|
109
|
-
/**
|
|
110
|
-
* Footnote style citation component.
|
|
111
|
-
* Displays citation as a footnote marker.
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```tsx
|
|
115
|
-
* <FootnoteCitation citation={citation} symbolStyle="asterisk" />
|
|
116
|
-
* // Renders: Text content*
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
export const FootnoteCitation = forwardRef(({ citation, children, className, fallbackDisplay, verification, eventHandlers, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), symbolStyle = "number", customSymbol, }, ref) => {
|
|
120
|
-
const { citationKey, citationInstanceId, status } = useCitationData(citation, verification);
|
|
121
|
-
const { isVerified, isMiss, isPartialMatch, isPending } = status;
|
|
122
|
-
const displaySymbol = useMemo(() => {
|
|
123
|
-
if (symbolStyle === "custom" && customSymbol)
|
|
124
|
-
return customSymbol;
|
|
125
|
-
if (symbolStyle === "number")
|
|
126
|
-
return citation.citationNumber?.toString() || "1";
|
|
127
|
-
if (symbolStyle === "asterisk")
|
|
128
|
-
return "*";
|
|
129
|
-
if (symbolStyle === "dagger") {
|
|
130
|
-
const num = (citation.citationNumber || 1) - 1;
|
|
131
|
-
return FOOTNOTE_SYMBOLS[num % FOOTNOTE_SYMBOLS.length];
|
|
132
|
-
}
|
|
133
|
-
return "*";
|
|
134
|
-
}, [symbolStyle, customSymbol, citation.citationNumber]);
|
|
135
|
-
const handleClick = useCallback((e) => {
|
|
136
|
-
e.preventDefault();
|
|
137
|
-
e.stopPropagation();
|
|
138
|
-
eventHandlers?.onClick?.(citation, citationKey, e);
|
|
139
|
-
}, [eventHandlers, citation, citationKey]);
|
|
140
|
-
const handleMouseEnter = useCallback(() => {
|
|
141
|
-
eventHandlers?.onMouseEnter?.(citation, citationKey);
|
|
142
|
-
}, [eventHandlers, citation, citationKey]);
|
|
143
|
-
const handleMouseLeave = useCallback(() => {
|
|
144
|
-
eventHandlers?.onMouseLeave?.(citation, citationKey);
|
|
145
|
-
}, [eventHandlers, citation, citationKey]);
|
|
146
|
-
// Check partial first since isVerified is true when isPartialMatch is true
|
|
147
|
-
const statusClass = isPartialMatch
|
|
148
|
-
? "text-amber-600 dark:text-amber-500"
|
|
149
|
-
: isMiss
|
|
150
|
-
? "text-red-500 dark:text-red-400 line-through"
|
|
151
|
-
: isVerified
|
|
152
|
-
? "text-green-600 dark:text-green-500"
|
|
153
|
-
: isPending
|
|
154
|
-
? "text-gray-400 dark:text-gray-500"
|
|
155
|
-
: "text-gray-500 hover:text-blue-600 dark:text-gray-400 dark:hover:text-blue-400";
|
|
156
|
-
return (_jsxs(_Fragment, { children: [children, _jsxs("sup", { ref: ref, "data-citation-id": citationKey, "data-citation-instance": citationInstanceId, "data-variant": "footnote", className: classNames("text-xs cursor-pointer font-normal transition-colors", statusClass, className), onMouseEnter: preventTooltips ? undefined : handleMouseEnter, onMouseLeave: preventTooltips ? undefined : handleMouseLeave, onMouseDown: handleClick, onClick: (e) => e.stopPropagation(), "aria-label": `Footnote ${displaySymbol}`, children: [displaySymbol, isPartialMatch && renderPartialIndicator(status), isVerified && !isPartialMatch && renderVerifiedIndicator(status), isPending && pendingContent] })] }));
|
|
157
|
-
});
|
|
158
|
-
FootnoteCitation.displayName = "FootnoteCitation";
|
|
159
|
-
/**
|
|
160
|
-
* Inline style citation component.
|
|
161
|
-
* Displays citation inline with subtle underline decoration.
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```tsx
|
|
165
|
-
* <InlineCitation citation={citation} underlineStyle="dotted" />
|
|
166
|
-
* // Renders: "quoted text" with subtle underline
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
export const InlineCitation = forwardRef(({ citation, children, className, fallbackDisplay, verification, eventHandlers, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), underlineStyle = "dotted", }, ref) => {
|
|
170
|
-
const { citationKey, citationInstanceId, status } = useCitationData(citation, verification);
|
|
171
|
-
const { isVerified, isMiss, isPartialMatch, isPending } = status;
|
|
172
|
-
// InlineCitation shows keySpan by default
|
|
173
|
-
const displayText = useMemo(() => getCitationDisplayText(citation, { fallbackDisplay }), [citation, fallbackDisplay]);
|
|
174
|
-
const handleClick = useCallback((e) => {
|
|
175
|
-
e.preventDefault();
|
|
176
|
-
e.stopPropagation();
|
|
177
|
-
eventHandlers?.onClick?.(citation, citationKey, e);
|
|
178
|
-
}, [eventHandlers, citation, citationKey]);
|
|
179
|
-
const handleMouseEnter = useCallback(() => {
|
|
180
|
-
eventHandlers?.onMouseEnter?.(citation, citationKey);
|
|
181
|
-
}, [eventHandlers, citation, citationKey]);
|
|
182
|
-
const handleMouseLeave = useCallback(() => {
|
|
183
|
-
eventHandlers?.onMouseLeave?.(citation, citationKey);
|
|
184
|
-
}, [eventHandlers, citation, citationKey]);
|
|
185
|
-
// Check partial first since isVerified is true when isPartialMatch is true
|
|
186
|
-
const statusClass = isPartialMatch
|
|
187
|
-
? "text-amber-600 dark:text-amber-500"
|
|
188
|
-
: isMiss
|
|
189
|
-
? "text-red-500 dark:text-red-400 line-through"
|
|
190
|
-
: isVerified
|
|
191
|
-
? "text-green-600 dark:text-green-500"
|
|
192
|
-
: isPending
|
|
193
|
-
? "text-gray-400 dark:text-gray-500"
|
|
194
|
-
: "";
|
|
195
|
-
const underlineClasses = {
|
|
196
|
-
solid: "border-b border-current",
|
|
197
|
-
dotted: "border-b border-dotted border-current",
|
|
198
|
-
dashed: "border-b border-dashed border-current",
|
|
199
|
-
none: "",
|
|
200
|
-
};
|
|
201
|
-
return (_jsxs(_Fragment, { children: [children, _jsxs("span", { ref: ref, "data-citation-id": citationKey, "data-citation-instance": citationInstanceId, "data-variant": "inline", className: classNames("cursor-pointer transition-colors hover:bg-blue-500/5", underlineClasses[underlineStyle], statusClass, className), onMouseEnter: preventTooltips ? undefined : handleMouseEnter, onMouseLeave: preventTooltips ? undefined : handleMouseLeave, onMouseDown: handleClick, onClick: (e) => e.stopPropagation(), "aria-label": `Citation: ${displayText}`, children: [displayText, isPartialMatch && renderPartialIndicator(status), isVerified && !isPartialMatch && renderVerifiedIndicator(status), isPending && (_jsx("span", { className: "opacity-70 ml-1", children: pendingContent }))] })] }));
|
|
202
|
-
});
|
|
203
|
-
InlineCitation.displayName = "InlineCitation";
|
|
204
|
-
/**
|
|
205
|
-
* Minimal style citation component.
|
|
206
|
-
* Displays just the citation number with minimal decoration.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```tsx
|
|
210
|
-
* <MinimalCitation citation={citation} />
|
|
211
|
-
* // Renders: 1
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
export const MinimalCitation = forwardRef(({ citation, children, className, fallbackDisplay, verification, eventHandlers, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), showStatusIndicator = true, }, ref) => {
|
|
215
|
-
const { citationKey, citationInstanceId, status } = useCitationData(citation, verification);
|
|
216
|
-
const { isVerified, isMiss, isPartialMatch, isPending } = status;
|
|
217
|
-
// MinimalCitation shows number by default
|
|
218
|
-
const displayText = useMemo(() => getCitationNumber(citation), [citation]);
|
|
219
|
-
const handleClick = useCallback((e) => {
|
|
220
|
-
e.preventDefault();
|
|
221
|
-
e.stopPropagation();
|
|
222
|
-
eventHandlers?.onClick?.(citation, citationKey, e);
|
|
223
|
-
}, [eventHandlers, citation, citationKey]);
|
|
224
|
-
const handleMouseEnter = useCallback(() => {
|
|
225
|
-
eventHandlers?.onMouseEnter?.(citation, citationKey);
|
|
226
|
-
}, [eventHandlers, citation, citationKey]);
|
|
227
|
-
const handleMouseLeave = useCallback(() => {
|
|
228
|
-
eventHandlers?.onMouseLeave?.(citation, citationKey);
|
|
229
|
-
}, [eventHandlers, citation, citationKey]);
|
|
230
|
-
// Check partial first since isVerified is true when isPartialMatch is true
|
|
231
|
-
const statusClass = isPartialMatch
|
|
232
|
-
? "text-amber-600 dark:text-amber-500"
|
|
233
|
-
: isMiss
|
|
234
|
-
? "text-red-500 dark:text-red-400 line-through"
|
|
235
|
-
: isVerified
|
|
236
|
-
? "text-green-600 dark:text-green-500"
|
|
237
|
-
: isPending
|
|
238
|
-
? "text-gray-400 dark:text-gray-500"
|
|
239
|
-
: "text-blue-600 dark:text-blue-400";
|
|
240
|
-
return (_jsxs(_Fragment, { children: [children, _jsxs("span", { ref: ref, "data-citation-id": citationKey, "data-citation-instance": citationInstanceId, "data-variant": "minimal", className: classNames("cursor-pointer transition-colors hover:underline", statusClass, className), onMouseEnter: preventTooltips ? undefined : handleMouseEnter, onMouseLeave: preventTooltips ? undefined : handleMouseLeave, onMouseDown: handleClick, onClick: (e) => e.stopPropagation(), "aria-label": `Citation ${displayText}`, children: [displayText, showStatusIndicator && (_jsxs(_Fragment, { children: [isPartialMatch && renderPartialIndicator(status), isVerified && !isPartialMatch && renderVerifiedIndicator(status), isPending && pendingContent] }))] })] }));
|
|
241
|
-
});
|
|
242
|
-
MinimalCitation.displayName = "MinimalCitation";
|
|
243
|
-
/**
|
|
244
|
-
* Factory component that renders the appropriate citation variant.
|
|
245
|
-
*
|
|
246
|
-
* @example
|
|
247
|
-
* ```tsx
|
|
248
|
-
* <CitationVariantFactory variant="chip" citation={citation} chipProps={{ size: "lg" }} />
|
|
249
|
-
* ```
|
|
250
|
-
*/
|
|
251
|
-
export const CitationVariantFactory = forwardRef(({ variant = "bracket", chipProps, superscriptProps, footnoteProps, inlineProps, minimalProps, ...props }, ref) => {
|
|
252
|
-
switch (variant) {
|
|
253
|
-
case "chip":
|
|
254
|
-
return _jsx(ChipCitation, { ref: ref, ...props, ...chipProps });
|
|
255
|
-
case "superscript":
|
|
256
|
-
return (_jsx(SuperscriptCitation, { ref: ref, ...props, ...superscriptProps }));
|
|
257
|
-
case "footnote":
|
|
258
|
-
return _jsx(FootnoteCitation, { ref: ref, ...props, ...footnoteProps });
|
|
259
|
-
case "inline":
|
|
260
|
-
return _jsx(InlineCitation, { ref: ref, ...props, ...inlineProps });
|
|
261
|
-
case "minimal":
|
|
262
|
-
return _jsx(MinimalCitation, { ref: ref, ...props, ...minimalProps });
|
|
263
|
-
case "bracket":
|
|
264
|
-
default:
|
|
265
|
-
// For bracket variant, we return null here as CitationComponent handles it
|
|
266
|
-
// This factory is meant to be used for alternate variants
|
|
267
|
-
return null;
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
CitationVariantFactory.displayName = "CitationVariantFactory";
|
|
271
|
-
// Memoized versions for performance
|
|
272
|
-
export const MemoizedChipCitation = memo(ChipCitation);
|
|
273
|
-
export const MemoizedSuperscriptCitation = memo(SuperscriptCitation);
|
|
274
|
-
export const MemoizedFootnoteCitation = memo(FootnoteCitation);
|
|
275
|
-
export const MemoizedInlineCitation = memo(InlineCitation);
|
|
276
|
-
export const MemoizedMinimalCitation = memo(MinimalCitation);
|
|
277
|
-
export const MemoizedCitationVariantFactory = memo(CitationVariantFactory);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface DiffDisplayProps {
|
|
3
|
-
expected: string;
|
|
4
|
-
actual: string;
|
|
5
|
-
label?: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
sanitize?: (text: string) => string;
|
|
8
|
-
}
|
|
9
|
-
declare const DiffDisplay: React.FC<DiffDisplayProps>;
|
|
10
|
-
export default DiffDisplay;
|
package/lib/react/DiffDisplay.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useSmartDiff } from "./useSmartDiff.js";
|
|
4
|
-
import { classNames } from "./utils.js";
|
|
5
|
-
const DiffDisplay = ({ expected, actual, label, className, sanitize }) => {
|
|
6
|
-
// 1. Sanitize Inputs if sanitization function provided
|
|
7
|
-
const { sanitizedExpected, sanitizedActual } = useMemo(() => {
|
|
8
|
-
if (sanitize) {
|
|
9
|
-
return {
|
|
10
|
-
sanitizedExpected: sanitize(expected),
|
|
11
|
-
sanitizedActual: sanitize(actual),
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
sanitizedExpected: expected,
|
|
16
|
-
sanitizedActual: actual,
|
|
17
|
-
};
|
|
18
|
-
}, [expected, actual, sanitize]);
|
|
19
|
-
// 2. Run the Smart Diff Hook
|
|
20
|
-
const { diffResult } = useSmartDiff(sanitizedExpected, sanitizedActual);
|
|
21
|
-
return (_jsxs("div", { className: classNames("dc-diff-display", className), children: [label && _jsx("div", { className: "dc-diff-label", children: label }), _jsx("div", { className: "dc-diff-content", children: _jsx("div", { className: "dc-diff-blocks", children: diffResult.map((block, blockIndex) => (_jsx("div", { className: classNames("dc-diff-block", `dc-diff-block--${block.type}`, block.type === "added" ? "dc-diff-block-added" : ""), children: block.parts.map((part, partIndex) => {
|
|
22
|
-
const key = `p-${blockIndex}-${partIndex}`;
|
|
23
|
-
if (part.removed) {
|
|
24
|
-
return (_jsx("span", { className: "dc-diff-part dc-diff-part--removed", title: "Expected text", children: part.value }, key));
|
|
25
|
-
}
|
|
26
|
-
if (part.added) {
|
|
27
|
-
return (_jsx("span", { className: "dc-diff-part dc-diff-part--added", title: "Actual text found", children: part.value }, key));
|
|
28
|
-
}
|
|
29
|
-
// Unchanged text
|
|
30
|
-
return (_jsx("span", { className: "dc-diff-part dc-diff-part--unchanged", children: part.value }, key));
|
|
31
|
-
}) }, `block-${blockIndex}`))) }) })] }));
|
|
32
|
-
};
|
|
33
|
-
export default DiffDisplay;
|
package/lib/react/Popover.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Popover component built on Radix UI primitives.
|
|
3
|
-
* This is a shadcn-style component - copy/paste friendly.
|
|
4
|
-
*
|
|
5
|
-
* @see https://ui.shadcn.com/docs/components/popover
|
|
6
|
-
* @see https://www.radix-ui.com/primitives/docs/components/popover
|
|
7
|
-
*/
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
10
|
-
declare const Popover: React.FC<PopoverPrimitive.PopoverProps>;
|
|
11
|
-
declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
12
|
-
declare const PopoverAnchor: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
-
declare const PopoverPortal: React.FC<PopoverPrimitive.PopoverPortalProps>;
|
|
14
|
-
declare const PopoverContent: React.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
-
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverPortal };
|
package/lib/react/Popover.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Popover component built on Radix UI primitives.
|
|
4
|
-
* This is a shadcn-style component - copy/paste friendly.
|
|
5
|
-
*
|
|
6
|
-
* @see https://ui.shadcn.com/docs/components/popover
|
|
7
|
-
* @see https://www.radix-ui.com/primitives/docs/components/popover
|
|
8
|
-
*/
|
|
9
|
-
import * as React from "react";
|
|
10
|
-
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
11
|
-
function cn(...classes) {
|
|
12
|
-
return classes.filter(Boolean).join(" ");
|
|
13
|
-
}
|
|
14
|
-
const Popover = PopoverPrimitive.Root;
|
|
15
|
-
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
16
|
-
const PopoverAnchor = PopoverPrimitive.Anchor;
|
|
17
|
-
const PopoverPortal = PopoverPrimitive.Portal;
|
|
18
|
-
const PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, className: cn("z-50 rounded-md border bg-white p-1 shadow-md outline-none", "border-gray-200 dark:border-gray-700 dark:bg-gray-900", "data-[state=open]:animate-in data-[state=closed]:animate-out", "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", "data-[side=bottom]:slide-in-from-top-2", "data-[side=left]:slide-in-from-right-2", "data-[side=right]:slide-in-from-left-2", "data-[side=top]:slide-in-from-bottom-2", className), ...props }) })));
|
|
19
|
-
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
20
|
-
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverPortal };
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { UrlCitationMeta, UrlCitationProps, UrlFetchStatus } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Extracts domain from URL for compact display.
|
|
5
|
-
*/
|
|
6
|
-
export declare function extractDomain(url: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* Truncates a string to max length with ellipsis.
|
|
9
|
-
*/
|
|
10
|
-
declare function truncateString(str: string, maxLength: number): string;
|
|
11
|
-
/**
|
|
12
|
-
* Get path from URL for display.
|
|
13
|
-
*/
|
|
14
|
-
declare function getUrlPath(url: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Status indicator icons for URL fetch states.
|
|
17
|
-
*/
|
|
18
|
-
declare const STATUS_ICONS: Record<UrlFetchStatus, {
|
|
19
|
-
icon: string;
|
|
20
|
-
label: string;
|
|
21
|
-
className: string;
|
|
22
|
-
}>;
|
|
23
|
-
/**
|
|
24
|
-
* Checks if status is a blocked status.
|
|
25
|
-
*/
|
|
26
|
-
export declare function isBlockedStatus(status: UrlFetchStatus): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Checks if status is an error status.
|
|
29
|
-
*/
|
|
30
|
-
export declare function isErrorStatus(status: UrlFetchStatus): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Checks if URL was successfully verified.
|
|
33
|
-
*/
|
|
34
|
-
export declare function isVerifiedStatus(status: UrlFetchStatus): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* URL Citation Component
|
|
37
|
-
*
|
|
38
|
-
* Displays a URL citation with compact domain display,
|
|
39
|
-
* verification status, and blocked/error indicators.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```tsx
|
|
43
|
-
* <UrlCitationComponent
|
|
44
|
-
* urlMeta={{
|
|
45
|
-
* url: "https://example.com/article",
|
|
46
|
-
* fetchStatus: "verified",
|
|
47
|
-
* }}
|
|
48
|
-
* />
|
|
49
|
-
* // Renders: [example.com ✓]
|
|
50
|
-
*
|
|
51
|
-
* <UrlCitationComponent
|
|
52
|
-
* urlMeta={{
|
|
53
|
-
* url: "https://protected-site.com/page",
|
|
54
|
-
* fetchStatus: "blocked_login",
|
|
55
|
-
* }}
|
|
56
|
-
* />
|
|
57
|
-
* // Renders: [protected-site.com 🔒]
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare const UrlCitationComponent: React.ForwardRefExoticComponent<UrlCitationProps & React.RefAttributes<HTMLSpanElement>>;
|
|
61
|
-
/**
|
|
62
|
-
* Memoized version for performance.
|
|
63
|
-
*/
|
|
64
|
-
export declare const MemoizedUrlCitationComponent: React.NamedExoticComponent<UrlCitationProps & React.RefAttributes<HTMLSpanElement>>;
|
|
65
|
-
/**
|
|
66
|
-
* Hook to parse URL and create UrlCitationMeta.
|
|
67
|
-
*/
|
|
68
|
-
export declare function useUrlMeta(url: string, fetchStatus?: UrlFetchStatus, additionalMeta?: Partial<UrlCitationMeta>): UrlCitationMeta;
|
|
69
|
-
/**
|
|
70
|
-
* Compact URL display utilities.
|
|
71
|
-
*/
|
|
72
|
-
export declare const urlDisplayUtils: {
|
|
73
|
-
extractDomain: typeof extractDomain;
|
|
74
|
-
truncateString: typeof truncateString;
|
|
75
|
-
getUrlPath: typeof getUrlPath;
|
|
76
|
-
isBlockedStatus: typeof isBlockedStatus;
|
|
77
|
-
isErrorStatus: typeof isErrorStatus;
|
|
78
|
-
isVerifiedStatus: typeof isVerifiedStatus;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Status configuration for custom styling.
|
|
82
|
-
*/
|
|
83
|
-
export { STATUS_ICONS };
|