@trii/components 2.0.103 → 2.0.104
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/async-state/package.json +9 -0
- package/dist/async-state.d.ts +184 -0
- package/dist/cjs/async-state.js +2 -0
- package/dist/cjs/async-state.js.map +1 -0
- package/dist/cjs/index.js +26 -26
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/async-state.js +2 -0
- package/dist/esm/async-state.js.map +1 -0
- package/dist/esm/index.js +32 -32
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +329 -2
- package/dist/types/asyncState/asyncState.d.ts +99 -0
- package/dist/types/asyncState/getErrorMessage.d.ts +16 -0
- package/dist/types/asyncState/index.d.ts +15 -0
- package/dist/types/asyncState/types.d.ts +17 -0
- package/dist/types/asyncState/useAsyncData.d.ts +51 -0
- package/dist/types/components/AsyncContent/AsyncContent.d.ts +48 -0
- package/dist/types/components/AsyncContent/index.d.ts +2 -0
- package/dist/types/components/EmptyState/EmptyState.d.ts +22 -0
- package/dist/types/components/EmptyState/index.d.ts +2 -0
- package/dist/types/components/ErrorState/ErrorState.d.ts +23 -0
- package/dist/types/components/ErrorState/index.d.ts +2 -0
- package/dist/types/components/PanelErrorBoundary/PanelErrorBoundary.d.ts +55 -0
- package/dist/types/components/PanelErrorBoundary/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +8 -0
- package/dist/types/i18n/config.d.ts +6 -0
- package/dist/types/i18n/useComponentsTranslation.d.ts +17 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
export interface PanelErrorBoundaryProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* Fallback custom ante un crash de render. Puede ser un nodo o una función
|
|
6
|
+
* que recibe el error y `resetErrorBoundary` (para reintentar).
|
|
7
|
+
*/
|
|
8
|
+
fallback?: ReactNode | ((args: {
|
|
9
|
+
error: Error | null;
|
|
10
|
+
resetErrorBoundary: () => void;
|
|
11
|
+
}) => ReactNode);
|
|
12
|
+
/** Telemetría/logging del error (p.ej. enviar a un servicio externo). */
|
|
13
|
+
onError?: (error: Error, info: ErrorInfo) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Claves que al cambiar resetean el boundary automáticamente
|
|
16
|
+
* (p.ej. el id de la ruta actual, para reintentar al navegar).
|
|
17
|
+
*/
|
|
18
|
+
resetKeys?: ReadonlyArray<unknown>;
|
|
19
|
+
/** Overrides de textos del fallback por defecto. */
|
|
20
|
+
title?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
/** Idioma de los textos por defecto ('es' | 'en'). Opcional: ver useComponentsTranslation. */
|
|
23
|
+
language?: string;
|
|
24
|
+
}
|
|
25
|
+
interface PanelErrorBoundaryState {
|
|
26
|
+
hasError: boolean;
|
|
27
|
+
error: Error | null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Aísla fallos de RENDER por panel: si el contenido explota, el resto de la
|
|
31
|
+
* UI (hermanos, otros paneles, la navegación) sigue funcionando y el panel
|
|
32
|
+
* muestra un fallback con reintento.
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <PanelErrorBoundary resetKeys={[conversationId]}>
|
|
36
|
+
* <ContactInfoPanel />
|
|
37
|
+
* </PanelErrorBoundary>
|
|
38
|
+
* <PanelErrorBoundary>
|
|
39
|
+
* <MessagesPanel />
|
|
40
|
+
* </PanelErrorBoundary>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* NOTA: los boundaries NO capturan errores de fetching (para eso está
|
|
44
|
+
* `<AsyncContent>`), ni de event handlers, ni de código asíncrono.
|
|
45
|
+
* Guía completa: docs/ASYNC_STATE.md
|
|
46
|
+
*/
|
|
47
|
+
declare class PanelErrorBoundary extends Component<PanelErrorBoundaryProps, PanelErrorBoundaryState> {
|
|
48
|
+
state: PanelErrorBoundaryState;
|
|
49
|
+
static getDerivedStateFromError(error: Error): PanelErrorBoundaryState;
|
|
50
|
+
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
51
|
+
componentDidUpdate(prevProps: PanelErrorBoundaryProps): void;
|
|
52
|
+
reset: () => void;
|
|
53
|
+
render(): ReactNode;
|
|
54
|
+
}
|
|
55
|
+
export default PanelErrorBoundary;
|
|
@@ -4,5 +4,13 @@ export type { EditContactModalProps, EditContactMode } from './EditContactModal'
|
|
|
4
4
|
export { default as EventsDialog } from './EventsDialog';
|
|
5
5
|
export type { EventsDialogProps, EventData, TaskData } from './EventsDialog';
|
|
6
6
|
export type { ModalMode, ItemType, Calendar, Contact, Notification } from './EventsDialog/types';
|
|
7
|
+
export { default as AsyncContent } from './AsyncContent';
|
|
8
|
+
export type { AsyncContentProps } from './AsyncContent';
|
|
9
|
+
export { default as EmptyState } from './EmptyState';
|
|
10
|
+
export type { EmptyStateProps } from './EmptyState';
|
|
11
|
+
export { default as ErrorState } from './ErrorState';
|
|
12
|
+
export type { ErrorStateProps } from './ErrorState';
|
|
13
|
+
export { default as PanelErrorBoundary } from './PanelErrorBoundary';
|
|
14
|
+
export type { PanelErrorBoundaryProps } from './PanelErrorBoundary';
|
|
7
15
|
export { default as ContactSidebar } from './ContactSidebar';
|
|
8
16
|
export type { ContactSidebarProps, SidebarChatIntegration, StartConversationTarget, } from './ContactSidebar';
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
declare const i18nInstance: import("i18next").i18n;
|
|
2
|
+
/**
|
|
3
|
+
* Normaliza lo que venga del anfitrión ('ES', 'En', 'es-AR', ...) a un idioma
|
|
4
|
+
* soportado por el paquete. El default es 'en' porque es el `fallbackLng` de
|
|
5
|
+
* esta instancia.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeLanguage(language?: string): 'en' | 'es';
|
|
2
8
|
export default i18nInstance;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TFunction } from 'i18next';
|
|
2
|
+
/**
|
|
3
|
+
* `t` atado a la instancia del paquete, SIN montar un `I18nextProvider`.
|
|
4
|
+
*
|
|
5
|
+
* Es la diferencia con el patrón de EditContactModal/ContactSidebar: esos
|
|
6
|
+
* componentes son un árbol cerrado y pueden pisar el context. Las primitivas
|
|
7
|
+
* de estado asíncrono (`AsyncContent`, `PanelErrorBoundary`) renderizan
|
|
8
|
+
* children DEL ANFITRIÓN; si montaran un provider, esos children resolverían
|
|
9
|
+
* sus claves contra la instancia del paquete y quedarían sin traducir.
|
|
10
|
+
* Pasando `{ i18n }` a `useTranslation`, solo los textos propios se atan.
|
|
11
|
+
*
|
|
12
|
+
* `language` es opcional: si el anfitrión ya sincroniza el idioma con
|
|
13
|
+
* `i18n.changeLanguage(...)` (exportado desde el índice del paquete), no hace
|
|
14
|
+
* falta pasarlo.
|
|
15
|
+
*/
|
|
16
|
+
export declare const useComponentsTranslation: (language?: string) => TFunction;
|
|
17
|
+
export default useComponentsTranslation;
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trii/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.104",
|
|
4
4
|
"description": "Trii components package",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"dist"
|
|
9
|
+
"dist",
|
|
10
|
+
"async-state"
|
|
10
11
|
],
|
|
11
12
|
"scripts": {
|
|
12
13
|
"dev": "npm-run-all --parallel dev:types dev:js",
|
|
@@ -15,7 +16,8 @@
|
|
|
15
16
|
"build": "npm-run-all --serial build:types build:js",
|
|
16
17
|
"build:types": "tsc --project tsconfig.build.json --emitDeclarationOnly",
|
|
17
18
|
"build:js": "rollup -c",
|
|
18
|
-
"test": "jest
|
|
19
|
+
"test": "jest",
|
|
20
|
+
"test:watch": "jest --watchAll --verbose",
|
|
19
21
|
"storybook": "storybook dev -p 6006",
|
|
20
22
|
"build-storybook": "storybook build"
|
|
21
23
|
},
|