@gntik-ai/blocks 0.11.0 → 0.12.0

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 (182) hide show
  1. package/dist/index.d.ts +1501 -1232
  2. package/dist/index.js +1884 -836
  3. package/dist/index.js.map +1 -1
  4. package/package.json +6 -6
  5. package/src/ai/PromptEditor/PromptEditor.tsx +2 -2
  6. package/src/ai/PromptEditor/examples/controlled-variables.tsx +1 -1
  7. package/src/ai/TraceWaterfall/TraceWaterfall.tsx +2 -2
  8. package/src/auth/ForgotPasswordForm/ForgotPasswordForm.test.tsx +6 -0
  9. package/src/auth/ForgotPasswordForm/ForgotPasswordForm.tsx +4 -1
  10. package/src/auth/ForgotPasswordForm/block.meta.ts +1 -1
  11. package/src/auth/ForgotPasswordForm/examples/LargeFields.tsx +6 -0
  12. package/src/auth/MfaChallenge/MfaChallenge.test.tsx +9 -0
  13. package/src/auth/MfaChallenge/MfaChallenge.tsx +5 -2
  14. package/src/auth/MfaChallenge/block.meta.ts +1 -1
  15. package/src/auth/MfaChallenge/examples/LargeFields.tsx +6 -0
  16. package/src/auth/ResetPasswordForm/ResetPasswordForm.test.tsx +7 -0
  17. package/src/auth/ResetPasswordForm/ResetPasswordForm.tsx +5 -3
  18. package/src/auth/ResetPasswordForm/block.meta.ts +1 -1
  19. package/src/auth/ResetPasswordForm/examples/LargeFields.tsx +6 -0
  20. package/src/auth/SignInForm/SignInForm.test.tsx +7 -0
  21. package/src/auth/SignInForm/SignInForm.tsx +5 -1
  22. package/src/auth/SignInForm/block.meta.ts +1 -1
  23. package/src/auth/SignInForm/examples/LargeFields.tsx +6 -0
  24. package/src/auth/SignUpForm/SignUpForm.test.tsx +22 -0
  25. package/src/auth/SignUpForm/SignUpForm.tsx +7 -1
  26. package/src/auth/SignUpForm/block.meta.ts +1 -1
  27. package/src/auth/SignUpForm/examples/LargeFields.tsx +6 -0
  28. package/src/auth/__snapshots__/field-size.test.tsx.snap +11 -0
  29. package/src/auth/field-size.test.tsx +21 -0
  30. package/src/auth/large-examples.test.tsx +30 -0
  31. package/src/auth/shared.tsx +7 -2
  32. package/src/billing/PaymentMethodCard/PaymentMethodCard.tsx +1 -1
  33. package/src/billing/PlanCard/PlanCard.baseline.test.tsx +3 -2
  34. package/src/billing/PlanCard/__snapshots__/PlanCard.baseline.test.tsx.snap +2 -2
  35. package/src/billing/PlanDefinitionCard/examples/Compact.tsx +1 -4
  36. package/src/billing/PlanDefinitionCard/examples/Full.tsx +1 -4
  37. package/src/builders/CodePanel/CodePanel.tsx +2 -2
  38. package/src/builders/FlowBuilder/FlowBuilder.tsx +4 -19
  39. package/src/builders/FlowBuilder/parts.tsx +4 -4
  40. package/src/builders/LogViewer/LogViewer.follow.test.tsx +29 -0
  41. package/src/builders/LogViewer/LogViewer.test.tsx +24 -0
  42. package/src/builders/LogViewer/LogViewer.tsx +67 -20
  43. package/src/builders/LogViewer/block.meta.ts +2 -1
  44. package/src/builders/LogViewer/examples/Spanish.tsx +2 -1
  45. package/src/data-display/ActivityFeed/ActivityFeed.tsx +1 -1
  46. package/src/data-display/ChartCard/ChartCard.tsx +2 -2
  47. package/src/data-display/ChartCard/examples/ContainerPanel.tsx +16 -0
  48. package/src/data-display/CommentThread/CommentThread.test.tsx +70 -1
  49. package/src/data-display/CommentThread/CommentThread.tsx +22 -6
  50. package/src/data-display/CommentThread/block.meta.ts +1 -1
  51. package/src/data-display/CommentThread/examples/RenderedBody.tsx +20 -0
  52. package/src/data-display/DescriptionListCard/DescriptionListCard.test.tsx +24 -1
  53. package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +14 -20
  54. package/src/data-display/DescriptionListCard/block.meta.ts +2 -1
  55. package/src/data-display/DescriptionListCard/examples/Spanish.tsx +2 -1
  56. package/src/data-display/KpiRow/KpiRow.doc.ts +14 -0
  57. package/src/data-display/KpiRow/KpiRow.test.tsx +11 -0
  58. package/src/data-display/KpiRow/KpiRow.tsx +72 -55
  59. package/src/data-display/KpiRow/examples/ContainerPanel.tsx +47 -0
  60. package/src/data-display/ResourceCardGrid/ResourceCardGrid.doc.ts +19 -0
  61. package/src/data-display/ResourceCardGrid/ResourceCardGrid.test.tsx +13 -0
  62. package/src/data-display/ResourceCardGrid/ResourceCardGrid.tsx +49 -40
  63. package/src/data-display/ResourceCardGrid/examples/ContainerPanel.tsx +18 -0
  64. package/src/data-display/StatusTimeline/StatusTimeline.tsx +1 -1
  65. package/src/feedback/EmptyStates/EmptyStates.test.tsx +42 -0
  66. package/src/feedback/EmptyStates/EmptyStates.tsx +5 -3
  67. package/src/feedback/EmptyStates/block.meta.ts +1 -1
  68. package/src/feedback/EmptyStates/examples/HiddenAction.tsx +13 -0
  69. package/src/feedback/ErrorPanel/ErrorPanel.tsx +13 -15
  70. package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.lifecycle.test.tsx +123 -0
  71. package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.tsx +128 -139
  72. package/src/forms/CreateApiKeyDialog/block.meta.ts +12 -1
  73. package/src/forms/FileUploadPanel/FileUploadPanel.controlled.test.tsx +482 -0
  74. package/src/forms/FileUploadPanel/FileUploadPanel.drag.test.tsx +60 -0
  75. package/src/forms/FileUploadPanel/FileUploadPanel.lifecycle.test.tsx +165 -0
  76. package/src/forms/FileUploadPanel/FileUploadPanel.tsx +267 -69
  77. package/src/forms/FileUploadPanel/block.meta.ts +5 -1
  78. package/src/forms/FileUploadPanel/examples/AutoCancel.tsx +38 -0
  79. package/src/forms/FileUploadPanel/examples/Labels.tsx +1 -1
  80. package/src/forms/FileUploadPanel/examples/ManualForm.tsx +36 -0
  81. package/src/forms/FileUploadPanel/fixtures.ts +31 -16
  82. package/src/forms/FileUploadPanel/simulate-upload.test.ts +24 -0
  83. package/src/forms/FormSection/FormSection.test.tsx +11 -0
  84. package/src/forms/FormSection/FormSection.tsx +20 -22
  85. package/src/forms/FormSection/block.meta.ts +1 -1
  86. package/src/forms/FormSection/examples/ContainerPanel.tsx +16 -0
  87. package/src/forms/InviteMembersDialog/InviteMembersDialog.lifecycle.test.tsx +80 -0
  88. package/src/forms/InviteMembersDialog/InviteMembersDialog.tsx +90 -109
  89. package/src/forms/InviteMembersDialog/block.meta.ts +1 -1
  90. package/src/forms/ValidationSummary/ValidationSummary.tsx +1 -4
  91. package/src/hooks/index.ts +2 -0
  92. package/src/hooks/useTableData.integration.test.tsx +89 -0
  93. package/src/hooks/useTableData.test.tsx +613 -0
  94. package/src/hooks/useTableData.ts +377 -0
  95. package/src/index.ts +1 -0
  96. package/src/marketing/ComparisonTable/ComparisonTable.tsx +2 -2
  97. package/src/marketing/FeatureGrid/FeatureGrid.tsx +1 -1
  98. package/src/marketing/LogoCloud/LogoCloud.doc.ts +13 -0
  99. package/src/marketing/LogoCloud/LogoCloud.test.tsx +155 -0
  100. package/src/marketing/LogoCloud/LogoCloud.tsx +89 -0
  101. package/src/marketing/LogoCloud/block.meta.ts +10 -0
  102. package/src/marketing/LogoCloud/examples/CaptionStart.tsx +6 -0
  103. package/src/marketing/LogoCloud/examples/Custom.tsx +25 -0
  104. package/src/marketing/LogoCloud/examples/Empty.tsx +6 -0
  105. package/src/marketing/LogoCloud/examples/Grid.tsx +13 -0
  106. package/src/marketing/LogoCloud/examples/Row.tsx +6 -0
  107. package/src/marketing/LogoCloud/examples/UnderHero.tsx +13 -0
  108. package/src/marketing/LogoCloud/fixtures.ts +23 -0
  109. package/src/marketing/PricingTable/PricingTable.tsx +1 -1
  110. package/src/marketing/SiteFooter/SiteFooter.doc.ts +18 -0
  111. package/src/marketing/SiteFooter/SiteFooter.test.tsx +236 -0
  112. package/src/marketing/SiteFooter/SiteFooter.tsx +160 -0
  113. package/src/marketing/SiteFooter/block.meta.ts +10 -0
  114. package/src/marketing/SiteFooter/examples/Centered.tsx +15 -0
  115. package/src/marketing/SiteFooter/examples/Columns.tsx +15 -0
  116. package/src/marketing/SiteFooter/examples/Custom.tsx +35 -0
  117. package/src/marketing/SiteFooter/examples/Empty.tsx +6 -0
  118. package/src/marketing/SiteFooter/examples/Simple.tsx +14 -0
  119. package/src/marketing/SiteFooter/fixtures.ts +36 -0
  120. package/src/marketing/index.ts +6 -0
  121. package/src/page-chrome/PageHeader/EditableTitle.test.tsx +26 -0
  122. package/src/page-chrome/PageHeader/PageHeader.tsx +4 -4
  123. package/src/page-chrome/PageHeader/block.meta.ts +1 -1
  124. package/src/page-chrome/PageHeader/examples/ContainerPanel.tsx +16 -0
  125. package/src/page-chrome/PageHeader/examples/EditableTitle.tsx +23 -0
  126. package/src/page-chrome/StickyActionBar/StickyActionBar.tsx +1 -1
  127. package/src/scheduling/AgendaList/AgendaList.tsx +39 -15
  128. package/src/scheduling/AgendaList/AgendaListZone.test.tsx +38 -0
  129. package/src/scheduling/AgendaList/block.meta.ts +1 -1
  130. package/src/scheduling/AgendaList/examples/TimeZone.tsx +28 -0
  131. package/src/scheduling/MonthCalendar/MonthCalendar.tsx +51 -40
  132. package/src/scheduling/MonthCalendar/MonthCalendarZone.test.tsx +44 -0
  133. package/src/scheduling/MonthCalendar/block.meta.ts +1 -1
  134. package/src/scheduling/MonthCalendar/examples/TimeZone.tsx +28 -0
  135. package/src/scheduling/WeekCalendar/WeekCalendar.tsx +37 -28
  136. package/src/scheduling/WeekCalendar/WeekCalendarZone.test.tsx +41 -0
  137. package/src/scheduling/WeekCalendar/block.meta.ts +1 -1
  138. package/src/scheduling/WeekCalendar/examples/TimeZone.tsx +28 -0
  139. package/src/scheduling/shared/CalendarHeader.tsx +26 -1
  140. package/src/scheduling/shared/dates.ts +102 -58
  141. package/src/scheduling/shared/events.ts +2 -2
  142. package/src/shell/AppSidebar/AppSidebar.context.test.tsx +175 -0
  143. package/src/shell/AppSidebar/AppSidebar.doc.ts +29 -0
  144. package/src/shell/AppSidebar/AppSidebar.tsx +97 -25
  145. package/src/shell/AppSidebar/block.meta.ts +1 -1
  146. package/src/shell/GlobalSearch/GlobalSearch.test.tsx +1 -0
  147. package/src/shell/GlobalSearch/GlobalSearch.tsx +1 -1
  148. package/src/tables/DataTable/DataTable.cursor-example.test.tsx +67 -0
  149. package/src/tables/DataTable/DataTable.export.test.tsx +511 -0
  150. package/src/tables/DataTable/DataTable.inline-edit-focus.test.tsx +32 -0
  151. package/src/tables/DataTable/DataTable.layout.test.tsx +6 -5
  152. package/src/tables/DataTable/DataTable.link-actions.test.tsx +18 -0
  153. package/src/tables/DataTable/DataTable.server-pagination.test.tsx +328 -14
  154. package/src/tables/DataTable/DataTable.test.tsx +85 -1
  155. package/src/tables/DataTable/DataTable.tsx +108 -14
  156. package/src/tables/DataTable/block.meta.ts +11 -1
  157. package/src/tables/DataTable/column-sizing.ts +2 -2
  158. package/src/tables/DataTable/data-table-props.ts +29 -1
  159. package/src/tables/DataTable/data-table-row.tsx +2 -2
  160. package/src/tables/DataTable/data-table-utils.ts +4 -0
  161. package/src/tables/DataTable/editable-cell.tsx +20 -79
  162. package/src/tables/DataTable/examples/csv-export.tsx +74 -0
  163. package/src/tables/DataTable/examples/cursor-load-more.tsx +87 -0
  164. package/src/tables/DataTable/examples/server-pagination.tsx +47 -40
  165. package/src/tables/DataTable/export-menu.tsx +58 -0
  166. package/src/tables/DataTable/header-cell.tsx +1 -1
  167. package/src/tables/DataTable/labels.ts +7 -0
  168. package/src/tables/DataTable/resize-handle.tsx +2 -2
  169. package/src/tables/DataTable/use-table-export.ts +117 -0
  170. package/src/tables/FilterBar/FilterBar.test.tsx +12 -0
  171. package/src/tables/FilterBar/FilterBar.tsx +5 -7
  172. package/src/team/ProfileHeader/ProfileHeader.picker.test.tsx +34 -0
  173. package/src/team/ProfileHeader/ProfileHeader.test.tsx +2 -2
  174. package/src/team/ProfileHeader/ProfileHeader.tsx +17 -24
  175. package/src/team/ProfileHeader/block.meta.ts +1 -1
  176. package/src/test/OptInDefaults.test.tsx +10 -1
  177. package/src/test/clipboard-fallback.test.tsx +49 -0
  178. package/src/test/copy-examples.test.tsx +29 -0
  179. package/src/test/copy-feedback.test.tsx +166 -0
  180. package/src/test/fixtures/opt-in-defaults.json +5 -5
  181. package/src/test/without-forced-colors.test.ts +44 -0
  182. package/src/test/without-forced-colors.ts +14 -0
@@ -1,7 +1,15 @@
1
1
  import { render, screen } from '@testing-library/react';
2
2
  import userEvent from '@testing-library/user-event';
3
+ import { I18nProvider } from '@gntik-ai/ui';
3
4
  import { expectNoAxeViolations } from '../../test/a11y';
4
- import { CommentThread } from './CommentThread';
5
+ import { CommentThread, type ThreadComment } from './CommentThread';
6
+
7
+ const comment: ThreadComment = {
8
+ id: 'review',
9
+ author: { name: 'Reviewer' },
10
+ body: '**retry**\n<img src=x onerror=alert(1)>',
11
+ at: '2026-10-01T12:00:00Z',
12
+ };
5
13
 
6
14
  describe('CommentThread', () => {
7
15
  it('renders the comments and an empty composer', async () => {
@@ -26,4 +34,65 @@ describe('CommentThread', () => {
26
34
  expect(onSubmit).toHaveBeenLastCalledWith('Follow-up');
27
35
  expect(screen.getByRole('list', { name: '5 comments' })).toBeInTheDocument();
28
36
  });
37
+
38
+ it('keeps plain bodies as text in a paragraph with line breaks', () => {
39
+ const { container } = render(<CommentThread comments={[comment]} />);
40
+ const body = screen.getByText(/\*\*retry\*\*/);
41
+ expect(body.tagName).toBe('P');
42
+ expect(body).toHaveClass('whitespace-pre-line');
43
+ expect(body.textContent).toBe('**retry**\n<img src=x onerror=alert(1)>');
44
+ expect(container.querySelector('img')).toBeNull();
45
+ });
46
+
47
+ it('renders full supplied and appended comments through a block container', async () => {
48
+ const user = userEvent.setup();
49
+ const currentUser = { name: 'Writer' };
50
+ const renderBody = vi.fn((c: ThreadComment) => <blockquote>{c.body}</blockquote>);
51
+ render(<CommentThread comments={[comment]} currentUser={currentUser} renderBody={renderBody} />);
52
+ expect(renderBody).toHaveBeenCalledExactlyOnceWith(comment);
53
+ const body = screen.getByText(/\*\*retry\*\*/);
54
+ expect(body.parentElement?.tagName).toBe('DIV');
55
+ expect(body.closest('p')).toBeNull();
56
+ await user.type(screen.getByRole('textbox'), 'See **docs**');
57
+ renderBody.mockClear();
58
+ await user.keyboard('{Control>}{Enter}{/Control}');
59
+ expect(renderBody).toHaveBeenCalledTimes(2);
60
+ expect(renderBody).toHaveBeenCalledWith(comment);
61
+ expect(renderBody).toHaveBeenCalledWith({
62
+ id: 'local-1',
63
+ author: currentUser,
64
+ body: 'See **docs**',
65
+ at: expect.any(Number),
66
+ });
67
+ const posted = screen.getByText('See **docs**');
68
+ expect(posted.parentElement?.tagName).toBe('DIV');
69
+ expect(posted.closest('p')).toBeNull();
70
+ });
71
+
72
+ it.each([
73
+ ['en', false, 'Plain text · ⌘/Ctrl + Enter to post'],
74
+ ['en', true, 'Markdown supported · ⌘/Ctrl + Enter to post'],
75
+ ['es', false, 'Texto sin formato · ⌘/Ctrl + Intro para publicar'],
76
+ ['es', true, 'Admite Markdown · ⌘/Ctrl + Intro para publicar'],
77
+ ])('describes the composer in %s with renderBody=%s', (locale, rich, hint) => {
78
+ render(
79
+ <I18nProvider locale={locale}>
80
+ <CommentThread renderBody={rich ? (c) => <blockquote>{c.body}</blockquote> : undefined} />
81
+ </I18nProvider>,
82
+ );
83
+ expect(screen.getByText(hint)).toBeInTheDocument();
84
+ expect(screen.getByRole('textbox')).toHaveAccessibleDescription(hint);
85
+ });
86
+
87
+ it.each([false, true])('uses the custom hint with renderBody=%s', (rich) => {
88
+ render(
89
+ <CommentThread
90
+ renderBody={rich ? (c) => <blockquote>{c.body}</blockquote> : undefined}
91
+ composerHint={<em>Notes are visible to the workspace</em>}
92
+ />,
93
+ );
94
+ expect(screen.getByText('Notes are visible to the workspace').tagName).toBe('EM');
95
+ expect(screen.getByRole('textbox')).toHaveAccessibleDescription('Notes are visible to the workspace');
96
+ expect(screen.queryByText(/⌘\/Ctrl/)).not.toBeInTheDocument();
97
+ });
29
98
  });
@@ -1,5 +1,5 @@
1
1
  import { Avatar, Button, cn, Textarea, Timestamp, type DateInput, useI18n } from '@gntik-ai/ui';
2
- import { useId, useState, type FormEvent, type KeyboardEvent } from 'react';
2
+ import { useId, useState, type FormEvent, type KeyboardEvent, type ReactNode } from 'react';
3
3
  import { COMMENT_AUTHOR, REVIEW_COMMENTS } from './fixtures';
4
4
 
5
5
  export interface CommentAuthor {
@@ -10,13 +10,19 @@ export interface CommentAuthor {
10
10
  export interface ThreadComment {
11
11
  id: string;
12
12
  author: CommentAuthor;
13
- /** Plain text (no markdown); line breaks are kept. */
13
+ /** Plain text by default, with line breaks kept; pass renderBody to render Markdown. */
14
14
  body: string;
15
15
  at: DateInput;
16
16
  }
17
17
 
18
18
  export interface CommentThreadProps {
19
19
  comments?: readonly ThreadComment[];
20
+ /**
21
+ * Render the raw comment in a block container. Bodies are untrusted: use a safe
22
+ * renderer such as Markdown from @gntik-ai/chat (without allowHtml), never raw HTML.
23
+ * Defaults to plain text with line breaks kept.
24
+ */
25
+ renderBody?: (comment: ThreadComment) => ReactNode;
20
26
  /** Author of new comments (the signed-in user). */
21
27
  currentUser?: CommentAuthor;
22
28
  /** Called with the trimmed text when a comment is posted. */
@@ -27,18 +33,22 @@ export interface CommentThreadProps {
27
33
  label?: string;
28
34
  placeholder?: string;
29
35
  submitLabel?: string;
36
+ /** Overrides the plain-text or Markdown hint; stays the composer's accessible description. */
37
+ composerHint?: ReactNode;
30
38
  className?: string;
31
39
  }
32
40
 
33
- /** Comment thread: avatar, author, plain-text body and Timestamp, with a reply composer (⌘/Ctrl+Enter posts). */
41
+ /** Comment thread: avatar, author, plain text (or Markdown via renderBody) and Timestamp, with a reply composer (⌘/Ctrl+Enter posts). */
34
42
  export function CommentThread({
35
43
  comments = REVIEW_COMMENTS,
44
+ renderBody,
36
45
  currentUser = COMMENT_AUTHOR,
37
46
  onSubmit,
38
47
  appendOnSubmit = true,
39
48
  label: labelProp,
40
49
  placeholder: placeholderProp,
41
50
  submitLabel: submitLabelProp,
51
+ composerHint,
42
52
  className,
43
53
  }: CommentThreadProps) {
44
54
  const { t } = useI18n();
@@ -80,13 +90,19 @@ export function CommentThread({
80
90
  {i < all.length - 1 && (
81
91
  <span aria-hidden className="absolute top-9 -bottom-5 start-[15.5px] w-px bg-border" />
82
92
  )}
83
- <Avatar name={comment.author.name} src={comment.author.src} size="sm" className="relative z-10" />
93
+ <Avatar name={comment.author.name} src={comment.author.src} size="sm" className="relative z-raised" />
84
94
  <article className="min-w-0 flex-1 rounded-lg border border-border bg-background/50 p-3">
85
95
  <header className="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-0.5">
86
96
  <span className="text-[12.5px] font-semibold text-foreground">{comment.author.name}</span>
87
97
  <Timestamp value={comment.at} className="font-mono text-[11px]" />
88
98
  </header>
89
- <p className="mt-1 text-[13px] leading-relaxed whitespace-pre-line text-foreground/85">{comment.body}</p>
99
+ {renderBody ? (
100
+ <div className="mt-1 text-[13px] leading-relaxed text-foreground/85">{renderBody(comment)}</div>
101
+ ) : (
102
+ <p className="mt-1 text-[13px] leading-relaxed whitespace-pre-line text-foreground/85">
103
+ {comment.body}
104
+ </p>
105
+ )}
90
106
  </article>
91
107
  </li>
92
108
  ))}
@@ -107,7 +123,7 @@ export function CommentThread({
107
123
  />
108
124
  <div className="flex items-center justify-between gap-2 border-t border-border/60 px-3 py-2">
109
125
  <span id={hintId} className="text-[11.5px] text-muted-foreground">
110
- Plain text · ⌘/Ctrl + Enter to post
126
+ {composerHint ?? t(renderBody ? 'comments.hintMarkdown' : 'comments.hintPlain')}
111
127
  </span>
112
128
  <Button type="submit" size="sm" disabled={!text}>
113
129
  {submitLabel}
@@ -5,6 +5,6 @@ export const meta: BlockMeta = {
5
5
  family: 'data-display',
6
6
  status: 'beta',
7
7
  description:
8
- 'Plain-text comments with avatar, author and Timestamp, plus a reply composer (Textarea + Button, ⌘/Ctrl+Enter posts).',
8
+ 'Plain-text comments by default, with optional renderBody for safe Markdown, avatar, author and Timestamp, plus a reply composer (Textarea + Button, ⌘/Ctrl+Enter posts). renderBody receives the raw comment; use a safe renderer such as @gntik-ai/chat Markdown (without allowHtml). Bodies are untrusted: never inject raw HTML. composerHint overrides the catalog hint and remains the textarea’s accessible description.',
9
9
  uses: ['Avatar', 'Timestamp', 'Textarea', 'Button'],
10
10
  };
@@ -0,0 +1,20 @@
1
+ import { useI18n } from '@gntik-ai/ui';
2
+ import { CommentThread } from '../CommentThread';
3
+
4
+ /**
5
+ * /preview.html?kind=block&id=comment-thread--rendered-body
6
+ * A text-only stub demonstrates renderBody and a ReactNode composerHint override.
7
+ * For safe Markdown, see the scorecard template's @gntik-ai/chat Markdown renderer
8
+ * (without allowHtml). Treat bodies as untrusted; never inject raw HTML.
9
+ */
10
+ export default function RenderedBody() {
11
+ const { t } = useI18n();
12
+ return (
13
+ <CommentThread
14
+ renderBody={(comment) => (
15
+ <blockquote className="border-s-2 border-border ps-3 whitespace-pre-line">{comment.body}</blockquote>
16
+ )}
17
+ composerHint={<span>{t('comments.hintPlain')}</span>}
18
+ />
19
+ );
20
+ }
@@ -1,9 +1,32 @@
1
- import { render, screen } from '@testing-library/react';
1
+ import { fireEvent, render, screen } from '@testing-library/react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
  import { expectNoAxeViolations } from '../../test/a11y';
4
4
  import { DescriptionListCard } from './DescriptionListCard';
5
5
 
6
6
  describe('DescriptionListCard', () => {
7
+ it.each(['rejected', 'missing'] as const)(
8
+ 'reports a %s clipboard write as failed without calling onCopy',
9
+ async (failure) => {
10
+ userEvent.setup();
11
+ const clipboard = navigator.clipboard;
12
+ if (failure === 'missing')
13
+ Object.defineProperty(navigator, 'clipboard', { configurable: true, value: undefined });
14
+ else vi.spyOn(navigator.clipboard, 'writeText').mockRejectedValue(new DOMException('Denied', 'NotAllowedError'));
15
+ const onCopy = vi.fn();
16
+ try {
17
+ const { container } = render(<DescriptionListCard onCopy={onCopy} />);
18
+ fireEvent.click(screen.getByRole('button', { name: 'Copy Deployment ID' }));
19
+ const button = await screen.findByRole('button', { name: 'Copy failed' });
20
+ expect(container.querySelector('[aria-live="polite"]')).toHaveTextContent('Copy failed');
21
+ expect(screen.queryByRole('button', { name: 'Deployment ID copied' })).toBeNull();
22
+ expect(button.querySelector('.lucide-check')).toBeNull();
23
+ expect(onCopy).not.toHaveBeenCalled();
24
+ } finally {
25
+ Object.defineProperty(navigator, 'clipboard', { configurable: true, value: clipboard });
26
+ vi.restoreAllMocks();
27
+ }
28
+ },
29
+ );
7
30
  it('renders labels and values', async () => {
8
31
  const { container } = render(<DescriptionListCard onEdit={() => {}} />);
9
32
  expect(screen.getByText('Deployment ID')).toBeInTheDocument();
@@ -1,4 +1,4 @@
1
- import { Check, Copy, Pencil } from '@gntik-ai/icons';
1
+ import { Check, Copy, Pencil, X } from '@gntik-ai/icons';
2
2
  import {
3
3
  Button,
4
4
  Card,
@@ -10,8 +10,9 @@ import {
10
10
  IconButton,
11
11
  StatusTag,
12
12
  useI18n,
13
+ useClipboard,
13
14
  } from '@gntik-ai/ui';
14
- import { useEffect, useRef, useState, type ReactNode } from 'react';
15
+ import { type ReactNode } from 'react';
15
16
  import { DEPLOYMENT_DETAILS } from './fixtures';
16
17
 
17
18
  export interface DescriptionItem {
@@ -37,6 +38,7 @@ export interface DescriptionListCardLabels {
37
38
  copy: (label: string) => string;
38
39
  copied: (label: string) => string;
39
40
  copiedToClipboard: string;
41
+ copyFailed?: string;
40
42
  }
41
43
 
42
44
  export interface DescriptionListCardProps {
@@ -69,27 +71,19 @@ function CopyButton({
69
71
  labels?: Partial<DescriptionListCardLabels>;
70
72
  }) {
71
73
  const { t } = useI18n();
72
- const [copied, setCopied] = useState(false);
73
- const timer = useRef<number | undefined>(undefined);
74
- useEffect(() => () => window.clearTimeout(timer.current), []);
75
- const copy = async () => {
76
- const text = item.copyValue ?? item.value ?? '';
77
- try {
78
- await navigator.clipboard?.writeText(text);
79
- } catch {}
80
- setCopied(true);
81
- onCopy?.(item);
82
- window.clearTimeout(timer.current);
83
- timer.current = window.setTimeout(() => setCopied(false), 1500);
84
- };
74
+ const { status, copied, copy: copyText } = useClipboard({ timeout: 1500, onCopy: () => onCopy?.(item) });
75
+ const failedText = labels?.copyFailed ?? t('common.copyFailed');
76
+ const copy = () => copyText(item.copyValue ?? item.value ?? '');
85
77
  return (
86
78
  <>
87
79
  <IconButton
88
- icon={copied ? Check : Copy}
80
+ icon={status === 'failed' ? X : copied ? Check : Copy}
89
81
  label={
90
- copied
91
- ? (labels?.copied?.(item.label) ?? t('descriptionList.copied', { label: item.label }))
92
- : (labels?.copy?.(item.label) ?? t('descriptionList.copy', { label: item.label }))
82
+ status === 'failed'
83
+ ? failedText
84
+ : copied
85
+ ? (labels?.copied?.(item.label) ?? t('descriptionList.copied', { label: item.label }))
86
+ : (labels?.copy?.(item.label) ?? t('descriptionList.copy', { label: item.label }))
93
87
  }
94
88
  size="sm"
95
89
  variant="ghost"
@@ -97,7 +91,7 @@ function CopyButton({
97
91
  onClick={copy}
98
92
  />
99
93
  <span className="sr-only" aria-live="polite">
100
- {copied ? (labels?.copiedToClipboard ?? t('common.copiedToClipboard')) : ''}
94
+ {status === 'failed' ? failedText : copied ? (labels?.copiedToClipboard ?? t('common.copiedToClipboard')) : ''}
101
95
  </span>
102
96
  </>
103
97
  );
@@ -6,13 +6,14 @@ export const meta: BlockMeta = {
6
6
  family: 'data-display',
7
7
  status: 'beta',
8
8
  description:
9
- 'Key–value detail card with mono, status and rich values, copy-to-clipboard buttons and an Edit action. Optional labels?: Partial<DescriptionListCardLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview. wrap?: boolean (default false) shows full values and breaks long unbroken strings. columns?: 1 | 2 | 3 (default 1) stacks terms above values in two or three columns from sm, with one column below sm; items fill contiguous top-to-bottom chunks of ceil(item count / columns), and dividers stay within each column. Defaults preserve the original single-column rows. See the Spanish live preview for wrapping and both column layouts.',
9
+ 'Key–value detail card with mono, status and rich values, copy-to-clipboard buttons and an Edit action. Optional labels?: Partial<DescriptionListCardLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview. wrap?: boolean (default false) shows full values and breaks long unbroken strings. columns?: 1 | 2 | 3 (default 1) stacks terms above values in two or three columns from sm, with one column below sm; items fill contiguous top-to-bottom chunks of ceil(item count / columns), and dividers stay within each column. Defaults preserve the original single-column rows. See the Spanish live preview for wrapping and both column layouts. Copy actions await the clipboard write; denied or unavailable access shows common.copyFailed (overridden by labels.copyFailed), and only a successful write calls onCopy. Both results reset after 1500ms. See the Catalog labels live preview.',
10
10
  labels: [
11
11
  { key: 'title', type: 'string', state: 'Card heading; title prop wins' },
12
12
  { key: 'description', type: 'string', state: 'Card description; description prop wins' },
13
13
  { key: 'edit', type: 'string', state: 'Edit button; editLabel prop wins' },
14
14
  { key: 'copy', type: '(label: string) => string', state: 'Copy button name; original item label' },
15
15
  { key: 'copied', type: '(label: string) => string', state: 'Copy button name after copying; original item label' },
16
+ { key: 'copyFailed', type: 'string', state: 'Copy button name and polite announcement after a failed write' },
16
17
  { key: 'copiedToClipboard', type: 'string', state: 'Polite copy announcement' },
17
18
  ] satisfies Array<{ key: keyof DescriptionListCardLabels; type: string; state: string }>,
18
19
  uses: ['Card', 'Button', 'IconButton', 'StatusTag'],
@@ -1,4 +1,4 @@
1
- import { I18nProvider, Stack } from '@gntik-ai/ui';
1
+ import { I18nProvider, Stack, en } from '@gntik-ai/ui';
2
2
  import { DescriptionListCard } from '../DescriptionListCard';
3
3
  export default function Spanish() {
4
4
  return (
@@ -8,6 +8,7 @@ export default function Spanish() {
8
8
  <DescriptionListCard
9
9
  onEdit={() => {}}
10
10
  labels={{
11
+ copyFailed: en['common.copyFailed'],
11
12
  title: 'Resource details',
12
13
  description: 'Current settings',
13
14
  edit: 'Change',
@@ -0,0 +1,14 @@
1
+ import type { ComponentDoc } from '@gntik-ai/ui';
2
+ import { meta } from './block.meta';
3
+
4
+ export const doc: ComponentDoc = {
5
+ name: 'KpiRow',
6
+ group: 'Display',
7
+ status: 'beta',
8
+ description: meta.description,
9
+ primitive: 'Named description list with optional sparklines',
10
+ pattern:
11
+ 'Metrics reflow by container width. className styles the list; containerClassName styles its wrapper for placement and visibility.',
12
+ keyboard: [],
13
+ tokens: ['card', 'border', 'foreground', 'muted-foreground'],
14
+ };
@@ -3,6 +3,17 @@ import { expectNoAxeViolations } from '../../test/a11y';
3
3
  import { KpiRow } from './KpiRow';
4
4
 
5
5
  describe('KpiRow', () => {
6
+ it('keeps the named description list and list styling inside a separately styled wrapper', () => {
7
+ const { container } = render(<KpiRow label="Usage" className="gap-6" containerClassName="col-span-2" />);
8
+ const list = screen.getByLabelText('Usage');
9
+ expect(list.tagName).toBe('DL');
10
+ expect(list).toHaveClass('gap-6');
11
+ expect(list).not.toHaveClass('col-span-2');
12
+ expect(list.parentElement).toBe(container.firstElementChild);
13
+ expect(list.parentElement).toHaveClass('col-span-2');
14
+ expect(list.parentElement).not.toHaveClass('gap-6');
15
+ });
16
+
6
17
  it('renders the default KPIs as a description list with sparklines', async () => {
7
18
  const { container } = render(<KpiRow />);
8
19
  expect(screen.getByText('Active projects')).toBeInTheDocument();
@@ -23,14 +23,25 @@ export interface KpiRowProps {
23
23
  /** Accessible name of the list. */
24
24
  label?: string;
25
25
  className?: string;
26
+ /** Styles the container wrapper, including placement in a parent grid. */
27
+ containerClassName?: string;
26
28
  }
27
29
 
28
30
  const COLS: Record<number, string> = {
29
- 1: 'lg:grid-cols-1',
30
- 2: 'lg:grid-cols-2',
31
- 3: 'lg:grid-cols-3',
32
- 4: 'lg:grid-cols-4',
33
- 5: 'lg:grid-cols-5',
31
+ 1: '@4xl:grid-cols-1',
32
+ 2: '@4xl:grid-cols-2',
33
+ 3: '@4xl:grid-cols-3',
34
+ 4: '@4xl:grid-cols-4',
35
+ 5: '@4xl:grid-cols-5',
36
+ };
37
+
38
+ // Only internal edges: no border on a row's last tile or on the list's last tile.
39
+ const STRIP_DIVIDERS: Record<number, string> = {
40
+ 1: '',
41
+ 2: '@4xl:[&>div:not(:nth-child(2n)):not(:last-child)]:border-e',
42
+ 3: '@4xl:[&>div:not(:nth-child(3n)):not(:last-child)]:border-e',
43
+ 4: '@4xl:[&>div:not(:nth-child(4n)):not(:last-child)]:border-e',
44
+ 5: '@4xl:[&>div:not(:nth-child(5n)):not(:last-child)]:border-e',
34
45
  };
35
46
 
36
47
  /**
@@ -43,59 +54,65 @@ export function KpiRow({
43
54
  showTrends = true,
44
55
  label = 'Key metrics',
45
56
  className,
57
+ containerClassName,
46
58
  }: KpiRowProps) {
47
59
  const strip = variant === 'strip';
48
- const cols = COLS[Math.min(items.length, 5)] ?? 'lg:grid-cols-4';
60
+ const cols = COLS[Math.min(items.length, 5)] ?? '@4xl:grid-cols-4';
49
61
  return (
50
- <dl
51
- aria-label={label}
52
- className={cn(
53
- 'grid grid-cols-1 sm:grid-cols-2',
54
- cols,
55
- strip
56
- ? 'divide-y divide-border overflow-hidden rounded-xl border border-border bg-card shadow-sm sm:divide-x lg:divide-y-0'
57
- : 'gap-4',
58
- className,
59
- )}
60
- >
61
- {items.map((item) => (
62
- <div
63
- key={item.id}
64
- className={cn(
65
- 'flex min-w-0 flex-col',
66
- strip ? 'px-5 py-4' : 'rounded-xl border border-border bg-card p-5 shadow-sm',
67
- )}
68
- >
69
- <dt className={cn('truncate font-medium text-muted-foreground', strip ? 'text-[12px]' : 'text-[13px]')}>
70
- {item.label}
71
- </dt>
72
- <dd className="mt-2 flex flex-wrap items-baseline gap-x-2 gap-y-1">
73
- <span
74
- className={cn(
75
- 'font-semibold tracking-tight text-foreground tabular-nums',
76
- strip ? 'text-[22px]' : 'text-[26px]',
77
- )}
78
- >
79
- {item.value}
80
- </span>
81
- {item.delta && <TrendDelta {...item.delta} />}
82
- </dd>
83
- {item.delta?.note && !strip && <dd className="mt-1 text-[12px] text-muted-foreground">{item.delta.note}</dd>}
84
- {showTrends && item.trend && item.trend.length > 1 && (
85
- <dd className="mt-3">
86
- <Sparkline
87
- data={item.trend}
88
- label={item.label}
89
- area
90
- tone={item.trendTone ?? 'primary'}
91
- width={240}
92
- height={40}
93
- className="block h-auto w-full"
94
- />
62
+ <div className={cn('@container w-full min-w-0', containerClassName)}>
63
+ <dl
64
+ aria-label={label}
65
+ className={cn(
66
+ 'grid grid-cols-1 @lg:grid-cols-2',
67
+ cols,
68
+ strip
69
+ ? 'overflow-hidden rounded-xl border border-border bg-card shadow-sm [&>div]:border-border @max-lg:[&>div:not(:last-child)]:border-b @lg:@max-4xl:[&>div:nth-child(odd):not(:last-child)]:border-e'
70
+ : 'gap-4',
71
+ strip && (STRIP_DIVIDERS[Math.min(items.length, 5)] ?? STRIP_DIVIDERS[4]),
72
+ className,
73
+ )}
74
+ >
75
+ {items.map((item) => (
76
+ <div
77
+ key={item.id}
78
+ className={cn(
79
+ 'flex min-w-0 flex-col',
80
+ strip ? 'px-5 py-4' : 'rounded-xl border border-border bg-card p-5 shadow-sm',
81
+ )}
82
+ >
83
+ <dt className={cn('truncate font-medium text-muted-foreground', strip ? 'text-[12px]' : 'text-[13px]')}>
84
+ {item.label}
85
+ </dt>
86
+ <dd className="mt-2 flex flex-wrap items-baseline gap-x-2 gap-y-1">
87
+ <span
88
+ className={cn(
89
+ 'font-semibold tracking-tight text-foreground tabular-nums',
90
+ strip ? 'text-[22px]' : 'text-[26px]',
91
+ )}
92
+ >
93
+ {item.value}
94
+ </span>
95
+ {item.delta && <TrendDelta {...item.delta} />}
95
96
  </dd>
96
- )}
97
- </div>
98
- ))}
99
- </dl>
97
+ {item.delta?.note && !strip && (
98
+ <dd className="mt-1 text-[12px] text-muted-foreground">{item.delta.note}</dd>
99
+ )}
100
+ {showTrends && item.trend && item.trend.length > 1 && (
101
+ <dd className="mt-3">
102
+ <Sparkline
103
+ data={item.trend}
104
+ label={item.label}
105
+ area
106
+ tone={item.trendTone ?? 'primary'}
107
+ width={240}
108
+ height={40}
109
+ className="block h-auto w-full"
110
+ />
111
+ </dd>
112
+ )}
113
+ </div>
114
+ ))}
115
+ </dl>
116
+ </div>
100
117
  );
101
118
  }
@@ -0,0 +1,47 @@
1
+ import { InspectorLayout, Page, SidebarLayout } from '@gntik-ai/ui';
2
+ import { ResourceCardGrid } from '../../ResourceCardGrid/ResourceCardGrid';
3
+ import { ChartCard } from '../../ChartCard/ChartCard';
4
+ import { FormSection } from '../../../forms/FormSection/FormSection';
5
+ import { PageHeader } from '../../../page-chrome/PageHeader/PageHeader';
6
+ import { KpiRow } from '../KpiRow';
7
+
8
+ export default function ContainerPanel() {
9
+ return (
10
+ <div data-container-example className="h-[640px] overflow-hidden rounded-lg border border-border">
11
+ <InspectorLayout
12
+ panelTitle="Properties"
13
+ dockedQuery="(min-width: 0px)"
14
+ panel={<KpiRow variant="strip" showTrends={false} />}
15
+ >
16
+ <div className="grid gap-6 overflow-auto p-4">
17
+ <div data-container-slot="cards" className="flex min-w-0">
18
+ <KpiRow className="gap-6" containerClassName="col-span-2" />
19
+ </div>
20
+ <div data-container-slot="strip" className="flex min-w-0">
21
+ <KpiRow variant="strip" showTrends={false} />
22
+ </div>
23
+ </div>
24
+ </InspectorLayout>
25
+ </div>
26
+ );
27
+ }
28
+
29
+ // The default page frame also demonstrates the thresholds without a narrow panel.
30
+ export function StandardFrame() {
31
+ return (
32
+ <div className="h-[900px]">
33
+ <SidebarLayout sidebar={null}>
34
+ <Page>
35
+ <div data-standard-frame className="grid min-w-0 gap-6">
36
+ <PageHeader />
37
+ <KpiRow />
38
+ <ResourceCardGrid />
39
+ <ResourceCardGrid columns={4} />
40
+ <FormSection />
41
+ <ChartCard />
42
+ </div>
43
+ </Page>
44
+ </SidebarLayout>
45
+ </div>
46
+ );
47
+ }
@@ -0,0 +1,19 @@
1
+ import type { ComponentDoc } from '@gntik-ai/ui';
2
+ import { meta } from './block.meta';
3
+
4
+ export const doc: ComponentDoc = {
5
+ name: 'ResourceCardGrid',
6
+ group: 'Display',
7
+ status: 'beta',
8
+ description: meta.description,
9
+ primitive: 'Named list of cards with Base UI action menus',
10
+ pattern:
11
+ 'Cards reflow by container width up to the columns cap. className styles the list; containerClassName styles its wrapper for placement and visibility.',
12
+ keyboard: [
13
+ ['Tab', 'Move between card action menu triggers.'],
14
+ ['Enter / Space', 'Open the focused action menu.'],
15
+ ['Arrow keys', 'Move between actions in the open menu.'],
16
+ ['Escape', 'Close the menu and return focus to its trigger.'],
17
+ ],
18
+ tokens: ['card', 'border', 'foreground', 'muted-foreground', 'secondary'],
19
+ };
@@ -4,6 +4,19 @@ import { expectNoAxeViolations } from '../../test/a11y';
4
4
  import { ResourceCardGrid } from './ResourceCardGrid';
5
5
 
6
6
  describe('ResourceCardGrid', () => {
7
+ it('keeps list semantics and styling separate from wrapper placement', () => {
8
+ const { container } = render(
9
+ <ResourceCardGrid label="Services" className="gap-6" containerClassName="col-span-2" />,
10
+ );
11
+ const list = screen.getByRole('list', { name: 'Services' });
12
+ expect(list.tagName).toBe('UL');
13
+ expect(list).toHaveClass('gap-6');
14
+ expect(list).not.toHaveClass('col-span-2');
15
+ expect(list.parentElement).toBe(container.firstElementChild);
16
+ expect(list.parentElement).toHaveClass('col-span-2');
17
+ expect(list.parentElement).not.toHaveClass('gap-6');
18
+ });
19
+
7
20
  it('renders one card per resource', async () => {
8
21
  const { container } = render(<ResourceCardGrid />);
9
22
  expect(screen.getByRole('list', { name: 'Resources' })).toBeInTheDocument();