tycho-components 0.45.14 → 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.
@@ -5,11 +5,13 @@ export type ApiErrorHandled = AxiosError & {
5
5
  authErrorHandled?: boolean;
6
6
  };
7
7
  export declare function isServerError(status: number | undefined): boolean;
8
+ /** Statuses that createApiClient auto-toasts via dispatchServerApiError (5xx + 422). */
9
+ export declare function isAutoHandledHttpError(status: number | undefined): boolean;
8
10
  export declare function isAccessDeniedStatus(status: number | undefined): boolean;
9
11
  /** HTTP status from an Axios error or a thrown Response-like object. */
10
12
  export declare function getHttpErrorStatus(reason: unknown): number | undefined;
11
13
  export declare function markApiErrorHandled(error: AxiosError): void;
12
- /** True when the API client already surfaced a 5xx error via dispatchApiError. */
14
+ /** True when the API client already surfaced a 5xx/422 error via dispatchServerApiError. */
13
15
  export declare function isHandledApiError(reason: unknown): boolean;
14
16
  /**
15
17
  * Unmarked 401/403 from the API (or a Response with that status).
@@ -1,6 +1,10 @@
1
1
  export function isServerError(status) {
2
2
  return status !== undefined && status >= 500 && status < 600;
3
3
  }
4
+ /** Statuses that createApiClient auto-toasts via dispatchServerApiError (5xx + 422). */
5
+ export function isAutoHandledHttpError(status) {
6
+ return isServerError(status) || status === 422;
7
+ }
4
8
  export function isAccessDeniedStatus(status) {
5
9
  return status === 401 || status === 403;
6
10
  }
@@ -20,7 +24,7 @@ export function getHttpErrorStatus(reason) {
20
24
  export function markApiErrorHandled(error) {
21
25
  error.apiErrorHandled = true;
22
26
  }
23
- /** True when the API client already surfaced a 5xx error via dispatchApiError. */
27
+ /** True when the API client already surfaced a 5xx/422 error via dispatchServerApiError. */
24
28
  export function isHandledApiError(reason) {
25
29
  if (!reason || typeof reason !== 'object')
26
30
  return false;
@@ -30,7 +34,7 @@ export function isHandledApiError(reason) {
30
34
  const status = err.response?.status;
31
35
  if (!err.config || status === undefined)
32
36
  return false;
33
- return isServerError(status);
37
+ return isAutoHandledHttpError(status);
34
38
  }
35
39
  /**
36
40
  * Unmarked 401/403 from the API (or a Response with that status).
@@ -3,14 +3,14 @@ export type ServerErrorHandling = 'toast' | 'none';
3
3
  export type CreateApiClientOptions = {
4
4
  baseURL: string;
5
5
  attachJwt?: boolean;
6
- /** How to surface 5xx responses. Defaults to 'toast'. */
6
+ /** How to surface 5xx/422 responses. Defaults to 'toast'. */
7
7
  serverErrorHandling?: ServerErrorHandling;
8
8
  augmentRequest?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig;
9
9
  };
10
10
  /**
11
- * Shared API client: JWT attachment + global 5xx dispatchError toast.
12
- * Handled 5xx responses resolve (they do not reach .catch()).
13
- * 4xx are left to front-end callers unless the app opts in via
11
+ * Shared API client: JWT attachment + global 5xx/422 report toast.
12
+ * Handled 5xx/422 responses resolve (they do not reach .catch()).
13
+ * Other 4xx are left to front-end callers unless the app opts in via
14
14
  * applyAuthErrorHandling() in its local api.ts wrapper.
15
15
  */
16
16
  export declare function createApiClient(options: CreateApiClientOptions): AxiosInstance;
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { isServerError, markApiErrorHandled } from './apiHandledError';
2
+ import { isAutoHandledHttpError, markApiErrorHandled } from './apiHandledError';
3
3
  import CookieStorage from '../CookieStorage';
4
4
  import { dispatchServerApiError } from './dispatchApiError';
5
5
  const DEFAULT_HEADERS = {
@@ -19,9 +19,9 @@ function toHandledServerErrorResponse(error) {
19
19
  };
20
20
  }
21
21
  /**
22
- * Shared API client: JWT attachment + global 5xx dispatchError toast.
23
- * Handled 5xx responses resolve (they do not reach .catch()).
24
- * 4xx are left to front-end callers unless the app opts in via
22
+ * Shared API client: JWT attachment + global 5xx/422 report toast.
23
+ * Handled 5xx/422 responses resolve (they do not reach .catch()).
24
+ * Other 4xx are left to front-end callers unless the app opts in via
25
25
  * applyAuthErrorHandling() in its local api.ts wrapper.
26
26
  */
27
27
  export function createApiClient(options) {
@@ -32,7 +32,7 @@ export function createApiClient(options) {
32
32
  });
33
33
  api.interceptors.response.use((response) => response, async (error) => {
34
34
  const status = error.response?.status;
35
- if (isServerError(status) && serverErrorHandling === 'toast') {
35
+ if (isAutoHandledHttpError(status) && serverErrorHandling === 'toast') {
36
36
  dispatchServerApiError({ err: error });
37
37
  markApiErrorHandled(error);
38
38
  return toHandledServerErrorResponse(error);
@@ -12,7 +12,7 @@ export { createApiClient } from './createApiClient';
12
12
  export type { CreateApiClientOptions, ServerErrorHandling } from './createApiClient';
13
13
  export { applyAuthErrorHandling } from './applyAuthErrorHandling';
14
14
  export type { ApplyAuthErrorHandlingOptions, AuthErrorHandling, } from './applyAuthErrorHandling';
15
- export { isHandledApiError, isHandledAuthError, isAccessDeniedApiError, getHttpErrorStatus, markApiErrorHandled, markAuthErrorHandled, } from './apiHandledError';
15
+ export { isHandledApiError, isHandledAuthError, isAccessDeniedApiError, isAutoHandledHttpError, isServerError, getHttpErrorStatus, markApiErrorHandled, markAuthErrorHandled, } from './apiHandledError';
16
16
  export type { ApiErrorHandled, AuthErrorHandled } from './apiHandledError';
17
17
  export { buildClientErrorContext, dispatchApiError, dispatchAccessDeniedError, dispatchClientError, dispatchServerApiError, } from './dispatchApiError';
18
18
  export { resolveAccessDeniedMessage } from './resolveAccessDeniedMessage';
@@ -15,7 +15,7 @@ export const lexiconApiBase = import.meta.env.VITE_APP_LEXICON_API ||
15
15
  const api = applyAuthErrorHandling(createApiClient({ baseURL: platformApiBase }), { authErrorHandling: 'redirect' });
16
16
  export { createApiClient } from './createApiClient';
17
17
  export { applyAuthErrorHandling } from './applyAuthErrorHandling';
18
- export { isHandledApiError, isHandledAuthError, isAccessDeniedApiError, getHttpErrorStatus, markApiErrorHandled, markAuthErrorHandled, } from './apiHandledError';
18
+ export { isHandledApiError, isHandledAuthError, isAccessDeniedApiError, isAutoHandledHttpError, isServerError, getHttpErrorStatus, markApiErrorHandled, markAuthErrorHandled, } from './apiHandledError';
19
19
  export { buildClientErrorContext, dispatchApiError, dispatchAccessDeniedError, dispatchClientError, dispatchServerApiError, } from './dispatchApiError';
20
20
  export { resolveAccessDeniedMessage } from './resolveAccessDeniedMessage';
21
21
  export default api;
@@ -4,7 +4,7 @@
4
4
  * (not bundled per app — upload packs on each host / shared nginx).
5
5
  */
6
6
  export type BrandId = 'tycho' | 'corpushub';
7
- export type AppCode = 'admin' | 'auth' | 'cs-analyzer' | 'dictionary' | 'editor' | 'io' | 'lexicon' | 'parser' | 'psd-reindexer' | 'reserved' | 'search' | 'syntrees' | 'viewer';
7
+ export type AppCode = 'admin' | 'annotald' | 'auth' | 'cs-analyzer' | 'dictionary' | 'editor' | 'io' | 'lexicon' | 'parser' | 'psd-reindexer' | 'reserved' | 'search' | 'syntrees' | 'viewer';
8
8
  export type BrandConfig = {
9
9
  id: BrandId;
10
10
  name: string;
@@ -5,6 +5,7 @@
5
5
  */
6
6
  const APP_TITLE_SUFFIX = {
7
7
  admin: 'Admin',
8
+ annotald: 'Annotald',
8
9
  auth: 'Auth',
9
10
  'cs-analyzer': 'CS Analyzer',
10
11
  dictionary: 'Dictionary',
@@ -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), children: getParticipantName
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
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.45.14",
4
+ "version": "0.46.1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {