xertica-ui 2.3.0 → 2.4.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/README.md +33 -22
  3. package/bin/cli.ts +136 -47
  4. package/bin/language-config.ts +5 -8
  5. package/components/assistant/modern-chat-input/ModernChatInput.tsx +17 -7
  6. package/components/assistant/xertica-assistant/parts/AssistantConversationList.tsx +1 -3
  7. package/components/assistant/xertica-assistant/parts/AssistantFeedbackDialog.tsx +13 -3
  8. package/components/assistant/xertica-assistant/parts/AssistantMessageBubble.tsx +10 -6
  9. package/components/assistant/xertica-assistant/xertica-assistant.tsx +1 -3
  10. package/components/blocks/card-patterns/FeatureCardSkeleton.tsx +1 -6
  11. package/components/blocks/card-patterns/ProfileCard.tsx +1 -3
  12. package/components/blocks/card-patterns/ProjectCardSkeleton.tsx +1 -6
  13. package/components/brand/language-selector/language-selector.stories.tsx +1 -4
  14. package/components/brand/theme-toggle/ThemeToggle.tsx +5 -1
  15. package/components/brand/xertica-provider/XerticaProvider.tsx +1 -4
  16. package/components/index.ts +1 -5
  17. package/components/layout/sidebar/sidebar.tsx +9 -3
  18. package/components/media/audio-player/AudioPlayer.tsx +4 -2
  19. package/components/pages/forgot-password-page/ForgotPasswordPage.tsx +188 -188
  20. package/components/pages/home-content/HomeContent.tsx +55 -55
  21. package/components/pages/home-page/HomePage.tsx +5 -1
  22. package/components/pages/login-page/LoginPage.tsx +4 -2
  23. package/components/pages/reset-password-page/ResetPasswordPage.tsx +7 -3
  24. package/components/pages/template-content/TemplateContent.tsx +268 -149
  25. package/components/pages/verify-email-page/VerifyEmailPage.tsx +9 -9
  26. package/components/shared/error-boundary.stories.tsx +114 -132
  27. package/components/shared/error-boundary.tsx +150 -154
  28. package/components/shared/error-fallbacks.tsx +222 -226
  29. package/components/ui/stats-card/stats-card-skeleton.tsx +1 -3
  30. package/components/ui/stats-card/stats-card.stories.tsx +18 -0
  31. package/components/ui/stats-card/stats-card.tsx +18 -2
  32. package/components.json +512 -892
  33. package/contexts/AuthContext.tsx +121 -118
  34. package/contexts/LanguageContext.tsx +1 -2
  35. package/dist/AssistantChart-BKVtGUKF.js +3383 -0
  36. package/dist/AssistantChart-WeycT5Pd.cjs +3551 -0
  37. package/dist/VerifyEmailPage-Bp1XXl3H.cjs +3305 -0
  38. package/dist/VerifyEmailPage-DGhuIqkb.js +3296 -0
  39. package/dist/XerticaProvider-BErr83Bg.js +42 -0
  40. package/dist/XerticaProvider-CwOkHxiT.cjs +44 -0
  41. package/dist/XerticaXLogo-BX3ueACh.js +255 -0
  42. package/dist/XerticaXLogo-qBPhwK3g.cjs +260 -0
  43. package/dist/assistant.cjs.js +1 -1
  44. package/dist/assistant.es.js +1 -1
  45. package/dist/brand.cjs.js +2 -2
  46. package/dist/brand.es.js +2 -2
  47. package/dist/cli.js +90 -37
  48. package/dist/components/brand/theme-toggle/ThemeToggle.d.ts +1 -1
  49. package/dist/components/index.d.ts +1 -1
  50. package/dist/components/ui/stats-card/stats-card.d.ts +10 -0
  51. package/dist/index.cjs.js +6 -6
  52. package/dist/index.es.js +6 -6
  53. package/dist/layout.cjs.js +1 -1
  54. package/dist/layout.es.js +1 -1
  55. package/dist/pages.cjs.js +1 -1
  56. package/dist/pages.es.js +1 -1
  57. package/dist/sidebar-B4ZWaMrE.js +792 -0
  58. package/dist/sidebar-BS1p2V7t.cjs +795 -0
  59. package/dist/ui.cjs.js +1 -1
  60. package/dist/ui.es.js +1 -1
  61. package/dist/xertica-assistant-B1NaSFFj.js +2173 -0
  62. package/dist/xertica-assistant-CIaUlbIt.cjs +2180 -0
  63. package/dist/xertica-ui.css +1 -1
  64. package/docs/architecture-improvements.md +5 -5
  65. package/docs/architecture.md +16 -10
  66. package/docs/components/card-patterns.md +19 -17
  67. package/docs/components/error-boundary.md +201 -191
  68. package/docs/components/hooks.md +15 -13
  69. package/docs/components/language-selector.md +20 -16
  70. package/docs/components/pages.md +323 -309
  71. package/docs/components/stats-card.md +20 -2
  72. package/docs/doc-audit.md +12 -11
  73. package/docs/getting-started.md +41 -28
  74. package/docs/guidelines.md +14 -12
  75. package/docs/i18n.md +61 -57
  76. package/docs/installation.md +268 -267
  77. package/docs/llms.md +17 -17
  78. package/docs/state-management.md +17 -17
  79. package/guidelines/Guidelines.md +17 -14
  80. package/llms-compact.txt +1 -1
  81. package/llms-full.txt +11553 -7133
  82. package/llms.txt +1 -1
  83. package/package.json +1 -1
  84. package/styles/xertica/base.css +90 -84
  85. package/templates/CLAUDE.md +16 -1
  86. package/templates/guidelines/Guidelines.md +42 -18
  87. package/templates/package.json +3 -3
  88. package/templates/src/app/components/AuthGuard.tsx +131 -82
  89. package/templates/src/features/auth/ui/AuthPageShell.tsx +32 -32
  90. package/templates/src/features/auth/ui/ForgotPasswordContent.tsx +1 -3
  91. package/templates/src/features/auth/ui/ResetPasswordContent.tsx +6 -2
  92. package/templates/src/features/auth/ui/VerifyEmailContent.tsx +2 -6
  93. package/templates/src/features/home/data/mock.ts +41 -35
  94. package/templates/src/features/home/ui/HomeContent.tsx +62 -64
  95. package/templates/src/features/template/ui/CrudTemplate.tsx +1 -4
  96. package/templates/src/features/template/ui/LoginTemplate.tsx +1 -1
  97. package/templates/src/features/template/ui/TemplateContent.tsx +28 -20
  98. package/templates/src/locales/en/pages/templates.json +17 -17
  99. package/templates/src/locales/es/pages/templates.json +17 -17
  100. package/templates/src/locales/pt-BR/pages/templates.json +17 -17
  101. package/templates/src/pages/AssistantPage.tsx +26 -20
  102. package/templates/src/pages/HomePage.tsx +5 -1
  103. package/templates/src/shared/error-boundary.tsx +150 -154
  104. package/templates/src/shared/error-fallbacks.tsx +222 -226
  105. package/templates/vite.config.ts +12 -9
@@ -260,24 +260,33 @@ export function AssistantPage() {
260
260
 
261
261
  const selectedConversation = conversations.find(c => c.id === selectedId) ?? null;
262
262
 
263
- const GROUP_CONFIG = useMemo(() => [
264
- { id: 'hoje', label: t('assistant.page.today') },
265
- { id: 'ontem', label: t('assistant.page.yesterday') },
266
- { id: 'semana', label: t('assistant.page.thisWeek') },
267
- ], [t]);
263
+ const GROUP_CONFIG = useMemo(
264
+ () => [
265
+ { id: 'hoje', label: t('assistant.page.today') },
266
+ { id: 'ontem', label: t('assistant.page.yesterday') },
267
+ { id: 'semana', label: t('assistant.page.thisWeek') },
268
+ ],
269
+ [t]
270
+ );
268
271
 
269
- const richSuggestions = useMemo(() => [
270
- { id: 'chart-1', text: t('assistant.richSuggestions.viewPerformance') },
271
- { id: 'table-1', text: t('assistant.richSuggestions.generateReport') },
272
- { id: 'doc-1', text: t('assistant.richSuggestions.createDocument') },
273
- { id: 'pod-1', text: t('assistant.richSuggestions.generatePodcast') },
274
- ], [t]);
272
+ const richSuggestions = useMemo(
273
+ () => [
274
+ { id: 'chart-1', text: t('assistant.richSuggestions.viewPerformance') },
275
+ { id: 'table-1', text: t('assistant.richSuggestions.generateReport') },
276
+ { id: 'doc-1', text: t('assistant.richSuggestions.createDocument') },
277
+ { id: 'pod-1', text: t('assistant.richSuggestions.generatePodcast') },
278
+ ],
279
+ [t]
280
+ );
275
281
 
276
- const feedbackOptions = useMemo(() => [
277
- t('assistant.feedback.notWhatIWanted'),
278
- t('assistant.feedback.incorrectInfo'),
279
- t('assistant.feedback.incompleteAnswer'),
280
- ], [t]);
282
+ const feedbackOptions = useMemo(
283
+ () => [
284
+ t('assistant.feedback.notWhatIWanted'),
285
+ t('assistant.feedback.incorrectInfo'),
286
+ t('assistant.feedback.incompleteAnswer'),
287
+ ],
288
+ [t]
289
+ );
281
290
 
282
291
  const navigationGroups = useMemo(() => {
283
292
  const query = searchValue.toLowerCase();
@@ -364,10 +373,7 @@ export function AssistantPage() {
364
373
 
365
374
  return (
366
375
  <>
367
- <AppLayout
368
- sidebarVariant="assistant"
369
- sidebarProps={sidebarProps}
370
- >
376
+ <AppLayout sidebarVariant="assistant" sidebarProps={sidebarProps}>
371
377
  <div
372
378
  style={{ paddingLeft: sidebarExpanded ? '320px' : '80px' }}
373
379
  className="flex-1 flex flex-col overflow-hidden transition-all duration-300"
@@ -4,7 +4,11 @@ import { useLayout } from 'xertica-ui/hooks';
4
4
  import { useNavigate } from 'react-router-dom';
5
5
  import { AppLayout } from '../app/components/AppLayout';
6
6
  import { HomeContent } from '../features/home';
7
- import { useAssistantConfig, getMockRichSuggestions, getMockFeedbackOptions } from '../features/assistant';
7
+ import {
8
+ useAssistantConfig,
9
+ getMockRichSuggestions,
10
+ getMockFeedbackOptions,
11
+ } from '../features/assistant';
8
12
 
9
13
  /**
10
14
  * Home page — thin layout shell.
@@ -1,154 +1,150 @@
1
- import React from 'react';
2
-
3
- // ─────────────────────────────────────────────────────────────────────────────
4
- // ErrorBoundary — reusable class-based error boundary
5
- //
6
- // React error boundaries MUST be class components. This is the single base
7
- // implementation used throughout the app via three pre-configured wrappers:
8
- //
9
- // <AppErrorBoundary> — Root level: catches provider/context crashes
10
- // <PageErrorBoundary> — Route level: catches page-level render errors
11
- // <SectionErrorBoundary>— Feature level: catches isolated section errors
12
- //
13
- // Usage:
14
- // import { PageErrorBoundary } from '@/components/shared/error-boundary';
15
- // <PageErrorBoundary><MyPage /></PageErrorBoundary>
16
- // ─────────────────────────────────────────────────────────────────────────────
17
-
18
- // ── Types ─────────────────────────────────────────────────────────────────────
19
-
20
- export interface FallbackProps {
21
- error: Error;
22
- reset: () => void;
23
- }
24
-
25
- interface ErrorBoundaryProps {
26
- children: React.ReactNode;
27
- /** Custom fallback UI. Receives the error and a reset callback. */
28
- fallback: React.ComponentType<FallbackProps>;
29
- /**
30
- * Optional callback fired when an error is caught.
31
- * Use to log to Sentry, Datadog, etc.
32
- */
33
- onError?: (error: Error, info: React.ErrorInfo) => void;
34
- /**
35
- * List of values that, when changed, automatically reset the boundary.
36
- * Useful for resetting on route changes (pass `location.pathname`).
37
- */
38
- resetKeys?: unknown[];
39
- }
40
-
41
- interface ErrorBoundaryState {
42
- hasError: boolean;
43
- error: Error | null;
44
- }
45
-
46
- // ── Core class ────────────────────────────────────────────────────────────────
47
-
48
- export class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
49
- constructor(props: ErrorBoundaryProps) {
50
- super(props);
51
- this.state = { hasError: false, error: null };
52
- this.reset = this.reset.bind(this);
53
- }
54
-
55
- static getDerivedStateFromError(error: Error): ErrorBoundaryState {
56
- return { hasError: true, error };
57
- }
58
-
59
- componentDidCatch(error: Error, info: React.ErrorInfo) {
60
- this.props.onError?.(error, info);
61
-
62
- if (import.meta.env.DEV) {
63
- console.group('[ErrorBoundary] Uncaught error');
64
- console.error(error);
65
- console.error('Component stack:', info.componentStack);
66
- console.groupEnd();
67
- }
68
- }
69
-
70
- componentDidUpdate(prevProps: ErrorBoundaryProps) {
71
- if (!this.state.hasError) return;
72
-
73
- const { resetKeys } = this.props;
74
- if (!resetKeys?.length) return;
75
-
76
- const prevKeys = prevProps.resetKeys ?? [];
77
- const changed = resetKeys.some((key, i) => key !== prevKeys[i]);
78
- if (changed) this.reset();
79
- }
80
-
81
- reset() {
82
- this.setState({ hasError: false, error: null });
83
- }
84
-
85
- render() {
86
- const { hasError, error } = this.state;
87
- const { children, fallback: Fallback } = this.props;
88
-
89
- if (hasError && error) {
90
- return <Fallback error={error} reset={this.reset} />;
91
- }
92
-
93
- return children;
94
- }
95
- }
96
-
97
- // ── Pre-configured variants ───────────────────────────────────────────────────
98
- // Import the fallbacks from error-fallbacks.tsx to avoid circular deps.
99
- // These are thin wrappers so callers never need to wire up the fallback prop.
100
-
101
- import {
102
- AppErrorFallback,
103
- PageErrorFallback,
104
- SectionErrorFallback,
105
- } from './error-fallbacks';
106
-
107
- interface BoundaryProps {
108
- children: React.ReactNode;
109
- onError?: (error: Error, info: React.ErrorInfo) => void;
110
- resetKeys?: unknown[];
111
- }
112
-
113
- /**
114
- * `AppErrorBoundary` — root level.
115
- *
116
- * Place at the very top of the tree, outside all providers. If something inside
117
- * the provider stack crashes during setup, this boundary prevents a blank screen.
118
- */
119
- export function AppErrorBoundary({ children, onError, resetKeys }: BoundaryProps) {
120
- return (
121
- <ErrorBoundary fallback={AppErrorFallback} onError={onError} resetKeys={resetKeys}>
122
- {children}
123
- </ErrorBoundary>
124
- );
125
- }
126
-
127
- /**
128
- * `PageErrorBoundary` route level.
129
- *
130
- * Wrap `<AppRoutes>` / `<AuthGuard>` inside the router. When a lazy page chunk
131
- * fails to load, or a page component throws, the rest of the app (providers,
132
- * nav chrome) stays alive and only the page area shows the error UI.
133
- */
134
- export function PageErrorBoundary({ children, onError, resetKeys }: BoundaryProps) {
135
- return (
136
- <ErrorBoundary fallback={PageErrorFallback} onError={onError} resetKeys={resetKeys}>
137
- {children}
138
- </ErrorBoundary>
139
- );
140
- }
141
-
142
- /**
143
- * `SectionErrorBoundary` — feature/section level.
144
- *
145
- * Use around individual sections within a page (e.g., a data table, a chart,
146
- * the assistant panel). An error in one section does not crash the entire page.
147
- */
148
- export function SectionErrorBoundary({ children, onError, resetKeys }: BoundaryProps) {
149
- return (
150
- <ErrorBoundary fallback={SectionErrorFallback} onError={onError} resetKeys={resetKeys}>
151
- {children}
152
- </ErrorBoundary>
153
- );
154
- }
1
+ import React from 'react';
2
+
3
+ // ─────────────────────────────────────────────────────────────────────────────
4
+ // ErrorBoundary — reusable class-based error boundary
5
+ //
6
+ // React error boundaries MUST be class components. This is the single base
7
+ // implementation used throughout the app via three pre-configured wrappers:
8
+ //
9
+ // <AppErrorBoundary> — Root level: catches provider/context crashes
10
+ // <PageErrorBoundary> — Route level: catches page-level render errors
11
+ // <SectionErrorBoundary>— Feature level: catches isolated section errors
12
+ //
13
+ // Usage:
14
+ // import { PageErrorBoundary } from '@/components/shared/error-boundary';
15
+ // <PageErrorBoundary><MyPage /></PageErrorBoundary>
16
+ // ─────────────────────────────────────────────────────────────────────────────
17
+
18
+ // ── Types ─────────────────────────────────────────────────────────────────────
19
+
20
+ export interface FallbackProps {
21
+ error: Error;
22
+ reset: () => void;
23
+ }
24
+
25
+ interface ErrorBoundaryProps {
26
+ children: React.ReactNode;
27
+ /** Custom fallback UI. Receives the error and a reset callback. */
28
+ fallback: React.ComponentType<FallbackProps>;
29
+ /**
30
+ * Optional callback fired when an error is caught.
31
+ * Use to log to Sentry, Datadog, etc.
32
+ */
33
+ onError?: (error: Error, info: React.ErrorInfo) => void;
34
+ /**
35
+ * List of values that, when changed, automatically reset the boundary.
36
+ * Useful for resetting on route changes (pass `location.pathname`).
37
+ */
38
+ resetKeys?: unknown[];
39
+ }
40
+
41
+ interface ErrorBoundaryState {
42
+ hasError: boolean;
43
+ error: Error | null;
44
+ }
45
+
46
+ // ── Core class ────────────────────────────────────────────────────────────────
47
+
48
+ export class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
49
+ constructor(props: ErrorBoundaryProps) {
50
+ super(props);
51
+ this.state = { hasError: false, error: null };
52
+ this.reset = this.reset.bind(this);
53
+ }
54
+
55
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState {
56
+ return { hasError: true, error };
57
+ }
58
+
59
+ componentDidCatch(error: Error, info: React.ErrorInfo) {
60
+ this.props.onError?.(error, info);
61
+
62
+ if (import.meta.env.DEV) {
63
+ console.group('[ErrorBoundary] Uncaught error');
64
+ console.error(error);
65
+ console.error('Component stack:', info.componentStack);
66
+ console.groupEnd();
67
+ }
68
+ }
69
+
70
+ componentDidUpdate(prevProps: ErrorBoundaryProps) {
71
+ if (!this.state.hasError) return;
72
+
73
+ const { resetKeys } = this.props;
74
+ if (!resetKeys?.length) return;
75
+
76
+ const prevKeys = prevProps.resetKeys ?? [];
77
+ const changed = resetKeys.some((key, i) => key !== prevKeys[i]);
78
+ if (changed) this.reset();
79
+ }
80
+
81
+ reset() {
82
+ this.setState({ hasError: false, error: null });
83
+ }
84
+
85
+ render() {
86
+ const { hasError, error } = this.state;
87
+ const { children, fallback: Fallback } = this.props;
88
+
89
+ if (hasError && error) {
90
+ return <Fallback error={error} reset={this.reset} />;
91
+ }
92
+
93
+ return children;
94
+ }
95
+ }
96
+
97
+ // ── Pre-configured variants ───────────────────────────────────────────────────
98
+ // Import the fallbacks from error-fallbacks.tsx to avoid circular deps.
99
+ // These are thin wrappers so callers never need to wire up the fallback prop.
100
+
101
+ import { AppErrorFallback, PageErrorFallback, SectionErrorFallback } from './error-fallbacks';
102
+
103
+ interface BoundaryProps {
104
+ children: React.ReactNode;
105
+ onError?: (error: Error, info: React.ErrorInfo) => void;
106
+ resetKeys?: unknown[];
107
+ }
108
+
109
+ /**
110
+ * `AppErrorBoundary` — root level.
111
+ *
112
+ * Place at the very top of the tree, outside all providers. If something inside
113
+ * the provider stack crashes during setup, this boundary prevents a blank screen.
114
+ */
115
+ export function AppErrorBoundary({ children, onError, resetKeys }: BoundaryProps) {
116
+ return (
117
+ <ErrorBoundary fallback={AppErrorFallback} onError={onError} resetKeys={resetKeys}>
118
+ {children}
119
+ </ErrorBoundary>
120
+ );
121
+ }
122
+
123
+ /**
124
+ * `PageErrorBoundary` — route level.
125
+ *
126
+ * Wrap `<AppRoutes>` / `<AuthGuard>` inside the router. When a lazy page chunk
127
+ * fails to load, or a page component throws, the rest of the app (providers,
128
+ * nav chrome) stays alive and only the page area shows the error UI.
129
+ */
130
+ export function PageErrorBoundary({ children, onError, resetKeys }: BoundaryProps) {
131
+ return (
132
+ <ErrorBoundary fallback={PageErrorFallback} onError={onError} resetKeys={resetKeys}>
133
+ {children}
134
+ </ErrorBoundary>
135
+ );
136
+ }
137
+
138
+ /**
139
+ * `SectionErrorBoundary` — feature/section level.
140
+ *
141
+ * Use around individual sections within a page (e.g., a data table, a chart,
142
+ * the assistant panel). An error in one section does not crash the entire page.
143
+ */
144
+ export function SectionErrorBoundary({ children, onError, resetKeys }: BoundaryProps) {
145
+ return (
146
+ <ErrorBoundary fallback={SectionErrorFallback} onError={onError} resetKeys={resetKeys}>
147
+ {children}
148
+ </ErrorBoundary>
149
+ );
150
+ }