xertica-ui 2.1.2 → 2.1.4
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/CHANGELOG.md +46 -0
- package/README.md +1 -1
- package/bin/cli.ts +1 -1
- package/bin/generate-tokens.ts +13 -7
- package/components/assistant/xertica-assistant/index.ts +2 -0
- package/components/assistant/xertica-assistant/parts/AssistantCollapsedView.tsx +97 -0
- package/components/assistant/xertica-assistant/parts/AssistantConversationList.tsx +104 -0
- package/components/assistant/xertica-assistant/parts/AssistantDocumentEditor.tsx +81 -0
- package/components/assistant/xertica-assistant/parts/AssistantFeedbackDialog.tsx +86 -0
- package/components/assistant/xertica-assistant/parts/AssistantHeader.tsx +77 -0
- package/components/assistant/xertica-assistant/parts/AssistantMessageBubble.tsx +573 -0
- package/components/assistant/xertica-assistant/parts/AssistantTabBar.tsx +65 -0
- package/components/assistant/xertica-assistant/parts/AssistantTypingIndicator.tsx +41 -0
- package/components/assistant/xertica-assistant/parts/AssistantWelcomeScreen.tsx +98 -0
- package/components/assistant/xertica-assistant/parts/index.ts +16 -0
- package/components/assistant/xertica-assistant/types.ts +139 -0
- package/components/assistant/xertica-assistant/use-assistant.ts +559 -0
- package/components/assistant/xertica-assistant/xertica-assistant.stories.tsx +200 -0
- package/components/assistant/xertica-assistant/xertica-assistant.tsx +198 -1460
- package/components/brand/theme-toggle/ThemeToggle.tsx +8 -27
- package/components/hooks/index.ts +3 -0
- package/components/hooks/use-layout-shortcuts.ts +46 -0
- package/components/layout/sidebar/index.ts +2 -0
- package/components/layout/sidebar/sidebar.stories.tsx +160 -8
- package/components/layout/sidebar/sidebar.tsx +606 -497
- package/components/layout/sidebar/use-sidebar.ts +104 -0
- package/components/media/audio-player/AudioPlayer.tsx +131 -206
- package/components/media/audio-player/use-audio-player.ts +298 -0
- package/components/pages/home-page/HomePage.tsx +1 -1
- package/components/pages/template-content/TemplateContent.tsx +5 -5
- package/components/pages/template-page/TemplatePage.tsx +5 -5
- package/components/shared/CustomTooltipContent.tsx +52 -0
- package/components/shared/layout-constants.ts +1 -1
- package/components/ui/chart/chart.stories.tsx +966 -7
- package/components/ui/chart/chart.tsx +918 -45
- package/components/ui/file-upload/file-upload.stories.tsx +100 -0
- package/components/ui/file-upload/file-upload.tsx +14 -74
- package/components/ui/file-upload/index.ts +1 -0
- package/components/ui/file-upload/use-file-upload.ts +181 -0
- package/components/ui/pagination/index.ts +2 -0
- package/components/ui/pagination/pagination.stories.tsx +94 -0
- package/components/ui/pagination/use-pagination.ts +194 -0
- package/components/ui/rich-text-editor/index.ts +2 -0
- package/components/ui/rich-text-editor/rich-text-editor.stories.tsx +129 -1
- package/components/ui/rich-text-editor/rich-text-editor.tsx +86 -305
- package/components/ui/rich-text-editor/use-rich-text-editor.ts +439 -0
- package/components/ui/stepper/index.ts +3 -1
- package/components/ui/stepper/stepper.stories.tsx +116 -0
- package/components/ui/stepper/stepper.tsx +4 -4
- package/components/ui/stepper/use-stepper.ts +137 -0
- package/components/ui/tree-view/index.ts +4 -1
- package/components/ui/tree-view/tree-view.stories.tsx +110 -4
- package/components/ui/tree-view/tree-view.tsx +17 -125
- package/components/ui/tree-view/use-tree-view.ts +229 -0
- package/contexts/AssistenteContext.tsx +17 -54
- package/contexts/BrandColorsContext.tsx +6 -17
- package/contexts/LayoutContext.tsx +5 -31
- package/dist/AssistantChart-BAudAfne.cjs +3591 -0
- package/dist/AssistantChart-BP8upjMk.js +3565 -0
- package/dist/AudioPlayer-1ypwE2Wh.cjs +936 -0
- package/dist/AudioPlayer-DuKXrCfy.js +937 -0
- package/dist/CustomTooltipContent-DHjkY0ww.js +40 -0
- package/dist/CustomTooltipContent-c_K-DWRr.cjs +56 -0
- package/dist/LanguageContext-BwhwC3G2.js +657 -0
- package/dist/LanguageContext-DvUt5jBg.cjs +656 -0
- package/dist/LayoutContext-BDmcZfMH.cjs +84 -0
- package/dist/LayoutContext-dbQvdC4O.js +85 -0
- package/dist/ThemeContext-RTy1m2Uq.js +82 -0
- package/dist/ThemeContext-bSzuOit2.cjs +81 -0
- package/dist/VerifyEmailPage-C_ihbcth.js +2828 -0
- package/dist/VerifyEmailPage-Dt7zgA4w.cjs +2827 -0
- package/dist/XerticaProvider-CW9hpCdF.cjs +39 -0
- package/dist/XerticaProvider-siSt9uG2.js +40 -0
- package/dist/XerticaXLogo-D8jf0SNv.cjs +214 -0
- package/dist/XerticaXLogo-fAJMy3H4.js +215 -0
- package/dist/assistant.cjs.js +2 -1
- package/dist/assistant.es.js +3 -2
- package/dist/brand.cjs.js +2 -2
- package/dist/brand.es.js +2 -2
- package/dist/cli.js +14 -8
- package/dist/components/assistant/xertica-assistant/index.d.ts +2 -0
- package/dist/components/assistant/xertica-assistant/parts/AssistantCollapsedView.d.ts +13 -0
- package/dist/components/assistant/xertica-assistant/parts/AssistantConversationList.d.ts +16 -0
- package/dist/components/assistant/xertica-assistant/parts/AssistantDocumentEditor.d.ts +17 -0
- package/dist/components/assistant/xertica-assistant/parts/AssistantFeedbackDialog.d.ts +19 -0
- package/dist/components/assistant/xertica-assistant/parts/AssistantHeader.d.ts +11 -0
- package/dist/components/assistant/xertica-assistant/parts/AssistantMessageBubble.d.ts +29 -0
- package/dist/components/assistant/xertica-assistant/parts/AssistantTabBar.d.ts +13 -0
- package/dist/components/assistant/xertica-assistant/parts/AssistantTypingIndicator.d.ts +4 -0
- package/dist/components/assistant/xertica-assistant/parts/AssistantWelcomeScreen.d.ts +17 -0
- package/dist/components/assistant/xertica-assistant/parts/index.d.ts +16 -0
- package/dist/components/assistant/xertica-assistant/types.d.ts +106 -0
- package/dist/components/assistant/xertica-assistant/use-assistant.d.ts +125 -0
- package/dist/components/assistant/xertica-assistant/xertica-assistant.d.ts +8 -97
- package/dist/components/hooks/index.d.ts +3 -0
- package/dist/components/hooks/use-layout-shortcuts.d.ts +22 -0
- package/dist/components/layout/sidebar/index.d.ts +2 -0
- package/dist/components/layout/sidebar/sidebar.d.ts +80 -0
- package/dist/components/layout/sidebar/use-sidebar.d.ts +22 -0
- package/dist/components/media/audio-player/AudioPlayer.d.ts +4 -1
- package/dist/components/media/audio-player/use-audio-player.d.ts +72 -0
- package/dist/components/shared/CustomTooltipContent.d.ts +20 -0
- package/dist/components/shared/layout-constants.d.ts +1 -1
- package/dist/components/ui/alert/alert.d.ts +1 -1
- package/dist/components/ui/badge/badge.d.ts +1 -1
- package/dist/components/ui/button/button.d.ts +2 -2
- package/dist/components/ui/chart/chart.d.ts +162 -5
- package/dist/components/ui/file-upload/file-upload.d.ts +2 -0
- package/dist/components/ui/file-upload/index.d.ts +1 -0
- package/dist/components/ui/file-upload/use-file-upload.d.ts +49 -0
- package/dist/components/ui/pagination/index.d.ts +2 -0
- package/dist/components/ui/pagination/use-pagination.d.ts +78 -0
- package/dist/components/ui/rich-text-editor/index.d.ts +2 -0
- package/dist/components/ui/rich-text-editor/use-rich-text-editor.d.ts +107 -0
- package/dist/components/ui/stepper/index.d.ts +3 -1
- package/dist/components/ui/stepper/stepper.d.ts +2 -2
- package/dist/components/ui/stepper/use-stepper.d.ts +60 -0
- package/dist/components/ui/tree-view/index.d.ts +4 -1
- package/dist/components/ui/tree-view/tree-view.d.ts +4 -6
- package/dist/components/ui/tree-view/use-tree-view.d.ts +60 -0
- package/dist/contexts/AssistenteContext.d.ts +10 -49
- package/dist/hooks.cjs.js +30 -10
- package/dist/hooks.es.js +25 -4
- package/dist/index.cjs.js +20 -9
- package/dist/index.es.js +38 -27
- package/dist/layout.cjs.js +82 -1
- package/dist/layout.es.js +83 -2
- package/dist/media.cjs.js +1 -1
- package/dist/media.es.js +1 -1
- package/dist/pages.cjs.js +1 -1
- package/dist/pages.es.js +1 -1
- package/dist/rich-text-editor-BmsjY03B.js +2949 -0
- package/dist/rich-text-editor-GS2kpTAK.cjs +2966 -0
- package/dist/sidebar-CVUGHOS_.cjs +756 -0
- package/dist/sidebar-CmvwjnVb.js +757 -0
- package/dist/ui.cjs.js +12 -2
- package/dist/ui.es.js +24 -14
- package/dist/use-audio-player-Bkh23vQ3.js +177 -0
- package/dist/use-audio-player-Dn1NR9xN.cjs +176 -0
- package/dist/utils/color-utils.d.ts +51 -0
- package/dist/xertica-assistant-BMqdyRVi.js +2082 -0
- package/dist/xertica-assistant-Bj3vBCq_.cjs +2081 -0
- package/dist/xertica-ui.css +1 -1
- package/docs/ai-usage.md +28 -10
- package/docs/architecture-improvements.md +463 -0
- package/docs/architecture.md +77 -1
- package/docs/components/assistant-chart.md +1 -1
- package/docs/components/assistant.md +159 -0
- package/docs/components/audio-player.md +46 -0
- package/docs/components/branding.md +251 -0
- package/docs/components/chart.md +354 -39
- package/docs/components/code-block.md +108 -0
- package/docs/components/file-upload.md +119 -2
- package/docs/components/formatted-document.md +113 -0
- package/docs/components/hooks.md +430 -0
- package/docs/components/image-with-fallback.md +106 -0
- package/docs/components/map-layers.md +140 -0
- package/docs/components/modern-chat-input.md +163 -0
- package/docs/components/pages.md +351 -0
- package/docs/components/pagination.md +187 -0
- package/docs/components/rich-text-editor.md +164 -0
- package/docs/components/sidebar.md +153 -4
- package/docs/components/stepper.md +157 -12
- package/docs/components/tree-view.md +164 -6
- package/docs/doc-audit.md +223 -0
- package/docs/getting-started.md +155 -1
- package/docs/guidelines.md +14 -8
- package/docs/layout.md +2 -2
- package/docs/llms.md +29 -9
- package/docs/patterns/detail-page.md +276 -0
- package/docs/patterns/settings.md +346 -0
- package/docs/patterns/wizard.md +217 -0
- package/guidelines/Guidelines.md +5 -3
- package/llms.txt +1 -1
- package/package.json +10 -10
- package/styles/xertica/tokens.css +41 -12
- package/templates/CLAUDE.md +16 -6
- package/templates/guidelines/Guidelines.md +16 -4
- package/templates/package.json +3 -3
- package/templates/src/styles/xertica/tokens.css +39 -10
- package/utils/color-utils.ts +72 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { XerticaAssistant } from './xertica-assistant';
|
|
3
|
+
import { useAssistant } from './use-assistant';
|
|
3
4
|
import { Button } from '../../ui/button';
|
|
4
5
|
import { useLayout } from '../../../contexts/LayoutContext';
|
|
6
|
+
import { Send, Bot, User, RotateCcw } from 'lucide-react';
|
|
5
7
|
import React, { useState } from 'react';
|
|
6
8
|
|
|
7
9
|
const meta: Meta<typeof XerticaAssistant> = {
|
|
@@ -56,6 +58,10 @@ const meta: Meta<typeof XerticaAssistant> = {
|
|
|
56
58
|
control: 'boolean',
|
|
57
59
|
description: 'Whether to enable the "Search" action in the chat input.',
|
|
58
60
|
},
|
|
61
|
+
welcomeMessage: {
|
|
62
|
+
control: 'text',
|
|
63
|
+
description: 'Subtitle shown below the user name in the empty state.',
|
|
64
|
+
},
|
|
59
65
|
},
|
|
60
66
|
};
|
|
61
67
|
|
|
@@ -199,3 +205,197 @@ export const MinimalInput: Story = {
|
|
|
199
205
|
enableSearch: false,
|
|
200
206
|
},
|
|
201
207
|
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Custom welcome message: demonstrates the `welcomeMessage` prop.
|
|
211
|
+
* The subtitle below the user's name is fully customisable — useful when
|
|
212
|
+
* the assistant is scoped to a specific domain (e.g. HR, Finance, Legal).
|
|
213
|
+
*/
|
|
214
|
+
export const CustomWelcome: Story = {
|
|
215
|
+
decorators: [
|
|
216
|
+
(Story) => {
|
|
217
|
+
return (
|
|
218
|
+
<div className="h-screen w-full flex relative overflow-hidden bg-muted/30">
|
|
219
|
+
<div className="flex-1 flex flex-col p-8 gap-4">
|
|
220
|
+
<h1 className="text-2xl font-bold text-foreground">Custom Welcome Message</h1>
|
|
221
|
+
<p className="text-muted-foreground">
|
|
222
|
+
The <code>welcomeMessage</code> prop replaces the default "Como posso ajudar?" subtitle.
|
|
223
|
+
</p>
|
|
224
|
+
</div>
|
|
225
|
+
<Story />
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
args: {
|
|
231
|
+
mode: 'expanded',
|
|
232
|
+
isExpanded: true,
|
|
233
|
+
userName: 'Jane Smith',
|
|
234
|
+
demoMode: true,
|
|
235
|
+
welcomeMessage: 'How can I help you with your HR request today?',
|
|
236
|
+
suggestions: [],
|
|
237
|
+
richSuggestions: [],
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* No suggestions mode: both `suggestions` and `richSuggestions` are empty arrays.
|
|
243
|
+
* The empty state shows only the welcome message — no suggestion chips and no
|
|
244
|
+
* "Mais sugestões" button are rendered.
|
|
245
|
+
*/
|
|
246
|
+
export const NoSuggestions: Story = {
|
|
247
|
+
decorators: [
|
|
248
|
+
(Story) => {
|
|
249
|
+
return (
|
|
250
|
+
<div className="h-screen w-full flex relative overflow-hidden bg-muted/30">
|
|
251
|
+
<div className="flex-1 flex flex-col p-8 gap-4">
|
|
252
|
+
<h1 className="text-2xl font-bold text-foreground">No Suggestions Mode</h1>
|
|
253
|
+
<p className="text-muted-foreground">
|
|
254
|
+
Both <code>suggestions</code> and <code>richSuggestions</code> are empty — only the
|
|
255
|
+
welcome message is shown in the empty state.
|
|
256
|
+
</p>
|
|
257
|
+
</div>
|
|
258
|
+
<Story />
|
|
259
|
+
</div>
|
|
260
|
+
);
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
args: {
|
|
264
|
+
mode: 'expanded',
|
|
265
|
+
isExpanded: true,
|
|
266
|
+
userName: 'Jane Smith',
|
|
267
|
+
demoMode: true,
|
|
268
|
+
suggestions: [],
|
|
269
|
+
richSuggestions: [],
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* **Headless Hook** — demonstrates `useAssistant()` with a fully custom chat UI.
|
|
275
|
+
*
|
|
276
|
+
* The hook manages all assistant state (messages, conversations, suggestions,
|
|
277
|
+
* demo responses) while you supply your own markup. This story renders a
|
|
278
|
+
* minimal custom chat panel without using `<XerticaAssistant>` at all.
|
|
279
|
+
*/
|
|
280
|
+
export const HeadlessHook: Story = {
|
|
281
|
+
render: () => {
|
|
282
|
+
const CustomChat = () => {
|
|
283
|
+
const {
|
|
284
|
+
mensagens,
|
|
285
|
+
mensagem,
|
|
286
|
+
setMensagem,
|
|
287
|
+
sugestoes,
|
|
288
|
+
messagesEndRef,
|
|
289
|
+
handleEnviarMensagem,
|
|
290
|
+
handleNovaConversa,
|
|
291
|
+
} = useAssistant({ demoMode: true });
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<div className="h-screen w-full flex items-center justify-center bg-muted/30 p-8">
|
|
295
|
+
<div className="w-full max-w-xl h-[600px] flex flex-col bg-background border border-border rounded-xl shadow-lg overflow-hidden">
|
|
296
|
+
|
|
297
|
+
{/* Custom header */}
|
|
298
|
+
<div className="flex items-center justify-between px-4 py-3 border-b border-border bg-card">
|
|
299
|
+
<div className="flex items-center gap-2">
|
|
300
|
+
<Bot className="w-5 h-5 text-primary" />
|
|
301
|
+
<span className="font-semibold text-sm">Custom AI Chat</span>
|
|
302
|
+
<span className="text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded-full">
|
|
303
|
+
useAssistant()
|
|
304
|
+
</span>
|
|
305
|
+
</div>
|
|
306
|
+
<button
|
|
307
|
+
onClick={handleNovaConversa}
|
|
308
|
+
className="text-muted-foreground hover:text-foreground transition-colors"
|
|
309
|
+
title="New conversation"
|
|
310
|
+
>
|
|
311
|
+
<RotateCcw className="w-4 h-4" />
|
|
312
|
+
</button>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
{/* Custom message list */}
|
|
316
|
+
<div className="flex-1 overflow-y-auto p-4 space-y-3">
|
|
317
|
+
{mensagens.length === 0 ? (
|
|
318
|
+
<div className="h-full flex flex-col items-center justify-center gap-4 text-center">
|
|
319
|
+
<Bot className="w-10 h-10 text-muted-foreground/40" />
|
|
320
|
+
<p className="text-sm text-muted-foreground">
|
|
321
|
+
How can I help you today?
|
|
322
|
+
</p>
|
|
323
|
+
{sugestoes.length > 0 && (
|
|
324
|
+
<div className="flex flex-wrap gap-2 justify-center max-w-sm">
|
|
325
|
+
{sugestoes.slice(0, 3).map((s) => (
|
|
326
|
+
<button
|
|
327
|
+
key={s.id}
|
|
328
|
+
onClick={() => handleEnviarMensagem(s.text)}
|
|
329
|
+
className="text-xs px-3 py-1.5 rounded-full border border-border bg-muted hover:bg-muted/80 text-foreground transition-colors"
|
|
330
|
+
>
|
|
331
|
+
{s.text}
|
|
332
|
+
</button>
|
|
333
|
+
))}
|
|
334
|
+
</div>
|
|
335
|
+
)}
|
|
336
|
+
</div>
|
|
337
|
+
) : (
|
|
338
|
+
mensagens.map((msg) => (
|
|
339
|
+
<div
|
|
340
|
+
key={msg.id}
|
|
341
|
+
className={`flex gap-2 ${msg.type === 'user' ? 'justify-end' : 'justify-start'}`}
|
|
342
|
+
>
|
|
343
|
+
{msg.type === 'assistant' && (
|
|
344
|
+
<div className="w-7 h-7 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5">
|
|
345
|
+
<Bot className="w-4 h-4 text-primary" />
|
|
346
|
+
</div>
|
|
347
|
+
)}
|
|
348
|
+
<div
|
|
349
|
+
className={`max-w-[80%] px-3 py-2 rounded-xl text-sm leading-relaxed ${msg.type === 'user'
|
|
350
|
+
? 'bg-primary text-primary-foreground rounded-br-sm'
|
|
351
|
+
: 'bg-muted text-foreground rounded-bl-sm'
|
|
352
|
+
}`}
|
|
353
|
+
>
|
|
354
|
+
{msg.content}
|
|
355
|
+
</div>
|
|
356
|
+
{msg.type === 'user' && (
|
|
357
|
+
<div className="w-7 h-7 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5">
|
|
358
|
+
<User className="w-4 h-4 text-muted-foreground" />
|
|
359
|
+
</div>
|
|
360
|
+
)}
|
|
361
|
+
</div>
|
|
362
|
+
))
|
|
363
|
+
)}
|
|
364
|
+
<div ref={messagesEndRef} />
|
|
365
|
+
</div>
|
|
366
|
+
|
|
367
|
+
{/* Custom input */}
|
|
368
|
+
<div className="px-4 py-3 border-t border-border bg-card">
|
|
369
|
+
<div className="flex gap-2">
|
|
370
|
+
<input
|
|
371
|
+
type="text"
|
|
372
|
+
value={mensagem}
|
|
373
|
+
onChange={(e) => setMensagem(e.target.value)}
|
|
374
|
+
onKeyDown={(e) => {
|
|
375
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
376
|
+
e.preventDefault();
|
|
377
|
+
handleEnviarMensagem();
|
|
378
|
+
}
|
|
379
|
+
}}
|
|
380
|
+
placeholder="Type a message…"
|
|
381
|
+
className="flex-1 text-sm px-3 py-2 rounded-lg border border-border bg-background focus:outline-none focus:ring-2 focus:ring-ring"
|
|
382
|
+
/>
|
|
383
|
+
<Button
|
|
384
|
+
size="sm"
|
|
385
|
+
onClick={() => handleEnviarMensagem()}
|
|
386
|
+
disabled={!mensagem.trim()}
|
|
387
|
+
className="gap-1.5"
|
|
388
|
+
>
|
|
389
|
+
<Send className="w-3.5 h-3.5" />
|
|
390
|
+
Send
|
|
391
|
+
</Button>
|
|
392
|
+
</div>
|
|
393
|
+
</div>
|
|
394
|
+
</div>
|
|
395
|
+
</div>
|
|
396
|
+
);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
return <CustomChat />;
|
|
400
|
+
},
|
|
401
|
+
};
|