tycho-components 0.46.0 → 0.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import './style.scss';
|
|
2
2
|
import { CollapsedPageRenderElement, PageRenderViewProps } from './types';
|
|
3
|
-
export default function PageRenderView({ elements, selectedTier, corpus, displayTags, showLineNumbers, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, wrapToken, renderTokenSuffix, }: PageRenderViewProps): import("react").JSX.Element;
|
|
3
|
+
export default function PageRenderView({ elements, selectedTier, corpus, displayTags, showLineNumbers, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }: PageRenderViewProps): import("react").JSX.Element;
|
|
4
4
|
export declare function findPunctuationAfterCollapsedJunction(items: CollapsedPageRenderElement[], junctionIndex: number): number | undefined;
|
|
@@ -5,7 +5,7 @@ import './style.scss';
|
|
|
5
5
|
import collapseElementsForTier from './collapseElementsForTier';
|
|
6
6
|
import isTokenRefVisible, { tokenRefToToken } from './tokenUtils';
|
|
7
7
|
import { PageRenderElementType, } from './types';
|
|
8
|
-
export default function PageRenderView({ elements, selectedTier, corpus, displayTags = false, showLineNumbers = true, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, wrapToken, renderTokenSuffix, }) {
|
|
8
|
+
export default function PageRenderView({ elements, selectedTier, corpus, displayTags = false, showLineNumbers = true, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }) {
|
|
9
9
|
const collapsed = collapseElementsForTier(elements, selectedTier, corpus);
|
|
10
10
|
const punctuationBeforeBreak = new Map();
|
|
11
11
|
const punctuationIndexes = new Set();
|
|
@@ -17,7 +17,7 @@ export default function PageRenderView({ elements, selectedTier, corpus, display
|
|
|
17
17
|
punctuationIndexes.add(punctuationIndex);
|
|
18
18
|
});
|
|
19
19
|
const renderItem = (item) => (_jsx(PageRenderElementItem, { item: item, highlight: highlightSentenceUid != null &&
|
|
20
|
-
sentenceUidForItem(item) === highlightSentenceUid, showLineNumbers: showLineNumbers, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, getParticipantName: getParticipantName, getParticipantColor: getParticipantColor, onTokenClick: onTokenClick, onTokenHover: onTokenHover, onParticipantHover: onParticipantHover, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }, item.key));
|
|
20
|
+
sentenceUidForItem(item) === highlightSentenceUid, showLineNumbers: showLineNumbers, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, getParticipantName: getParticipantName, getParticipantColor: getParticipantColor, onTokenClick: onTokenClick, onTokenHover: onTokenHover, onParticipantHover: onParticipantHover, onParticipantClick: onParticipantClick, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }, item.key));
|
|
21
21
|
return (_jsx("div", { className: "page-render-elements", children: collapsed.map((item, index) => {
|
|
22
22
|
if (punctuationIndexes.has(index))
|
|
23
23
|
return null;
|
|
@@ -58,9 +58,11 @@ function sentenceUidForItem(item) {
|
|
|
58
58
|
return item.token.uid;
|
|
59
59
|
if (item.kind === 'single' && item.element.token)
|
|
60
60
|
return item.element.token.uid;
|
|
61
|
+
if (item.kind === 'single' && item.element.uid)
|
|
62
|
+
return item.element.uid;
|
|
61
63
|
return undefined;
|
|
62
64
|
}
|
|
63
|
-
function PageRenderElementItem({ item, highlight, showLineNumbers, displayTags, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, wrapToken, renderTokenSuffix, }) {
|
|
65
|
+
function PageRenderElementItem({ item, highlight, showLineNumbers, displayTags, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }) {
|
|
64
66
|
if (item.kind === 'collapsedJunction') {
|
|
65
67
|
return (_jsx(TokenNode, { refToken: item.token, splitIdx: item.splitIdx ?? 0, isSplit: true, isCollapsedJunction: true, highlight: highlight, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, onTokenClick: onTokenClick, onTokenHover: onTokenHover, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }));
|
|
66
68
|
}
|
|
@@ -71,7 +73,12 @@ function PageRenderElementItem({ item, highlight, showLineNumbers, displayTags,
|
|
|
71
73
|
return null;
|
|
72
74
|
return (_jsx("span", { className: "participant", style: getParticipantColor
|
|
73
75
|
? { backgroundColor: getParticipantColor(element.participant) }
|
|
74
|
-
: undefined, onMouseEnter: () => onParticipantHover?.(element.participant), onMouseLeave: () => onParticipantHover?.(undefined),
|
|
76
|
+
: undefined, onMouseEnter: () => onParticipantHover?.(element.participant), onMouseLeave: () => onParticipantHover?.(undefined), onClick: (event) => {
|
|
77
|
+
if (!onParticipantClick || !element.uid)
|
|
78
|
+
return;
|
|
79
|
+
event.stopPropagation();
|
|
80
|
+
onParticipantClick(element.participant, element.uid);
|
|
81
|
+
}, children: getParticipantName
|
|
75
82
|
? getParticipantName(element.participant)
|
|
76
83
|
: element.participant }));
|
|
77
84
|
case PageRenderElementType.LINE_BREAK:
|
|
@@ -33,6 +33,8 @@ export type PageRenderElement = {
|
|
|
33
33
|
line?: number;
|
|
34
34
|
mstart?: boolean;
|
|
35
35
|
participant?: string;
|
|
36
|
+
/** Sentence uid for PARTICIPANT labels. */
|
|
37
|
+
uid?: string;
|
|
36
38
|
token?: TokenRef;
|
|
37
39
|
};
|
|
38
40
|
export type CollapsedPageRenderElement = {
|
|
@@ -79,6 +81,7 @@ export type PageRenderViewProps = {
|
|
|
79
81
|
onTokenClick?: (ref: TokenRef, splitIdx: number | undefined, source: TokenClickSource, modifiers: TokenClickModifiers) => void;
|
|
80
82
|
onTokenHover?: (sentenceUid: string | undefined) => void;
|
|
81
83
|
onParticipantHover?: (code: string | undefined) => void;
|
|
84
|
+
onParticipantClick?: (code: string, sentenceUid: string) => void;
|
|
82
85
|
wrapToken?: (ref: TokenRef, token: Token, content: ReactNode, ctx: PageRenderTokenContext) => ReactNode;
|
|
83
86
|
renderTokenSuffix?: (ref: TokenRef, token: Token, ctx: PageRenderTokenContext) => ReactNode;
|
|
84
87
|
};
|