An open source design system that's fully customizable and agent ready
TypeScript
docs(lab): reconcile API contract props across lab components (#4163) (#4318)
Ojas Mutreja3ea72f19feba
diff --git a/packages/lab/src/ChatReasoning/ChatReasoning.doc.mjs b/packages/lab/src/ChatReasoning/ChatReasoning.doc.mjsindex df1c80478a..e21795095b 100644--- a/packages/lab/src/ChatReasoning/ChatReasoning.doc.mjs+++ b/packages/lab/src/ChatReasoning/ChatReasoning.doc.mjs@@ -7,10 +7,57 @@ export const docs = {displayName: 'Chat Reasoning',group: 'Chat',category: 'Chat',+ keywords: ['reasoning', 'thinking', 'thought', 'chain-of-thought', 'chat', 'llm', 'ai'],usage: {- description: '',+ description:+ 'Compact collapsible container for displaying model reasoning or chain-of-thought details. Shows a single-line summary when collapsed and expands to reveal full reasoning text.',},- props: [],+ props: [+ {+ name: 'children',+ type: 'ReactNode',+ description: 'Reasoning content string or custom ReactNode.',+ required: true,+ },+ {+ name: 'label',+ type: 'string',+ description: 'Header label displayed in the trigger line.',+ default: "'Thinking'",+ },+ {+ name: 'duration',+ type: 'string',+ description: 'Duration string shown next to the label (e.g. "12s").',+ },+ {+ name: 'isStreaming',+ type: 'boolean',+ description: 'Whether reasoning content is actively streaming. Displays animated shimmer effect.',+ default: 'false',+ },+ {+ name: 'isExpanded',+ type: 'boolean',+ description: 'Controlled expanded state.',+ },+ {+ name: 'defaultIsExpanded',+ type: 'boolean',+ description: 'Default expanded state for uncontrolled usage.',+ default: 'false',+ },+ {+ name: 'onExpandedChange',+ type: '(isExpanded: boolean) => void',+ description: 'Callback fired when the expanded state changes.',+ },+ {+ name: 'xstyle',+ type: 'StyleXStyles',+ description: 'StyleX styles for layout customization.',+ },+ ],};diff --git a/packages/lab/src/CodeEditor/CodeEditor.doc.mjs b/packages/lab/src/CodeEditor/CodeEditor.doc.mjsindex 41e2277a0f..1ba5d702a4 100644--- a/packages/lab/src/CodeEditor/CodeEditor.doc.mjs+++ b/packages/lab/src/CodeEditor/CodeEditor.doc.mjs@@ -7,10 +7,75 @@ export const docs = {displayName: 'Code Editor',group: 'CodeEditor',category: 'Data Input',+ keywords: ['code', 'editor', 'syntax', 'highlight', 'input', 'textarea'],usage: {- description: '',+ description:+ 'Editable code component with real-time syntax highlighting using the CSS Custom Highlight API. Supports line numbers, read-only state, placeholder text, and custom tokenizers.',},- props: [],+ props: [+ {+ name: 'value',+ type: 'string',+ description: 'Controlled string value for the editor.',+ required: true,+ },+ {+ name: 'onChange',+ type: '(value: string) => void',+ description: 'Callback fired when the code content changes.',+ required: true,+ },+ {+ name: 'label',+ type: 'string',+ description: 'Accessible label for the editable region (aria-label).',+ required: true,+ },+ {+ name: 'language',+ type: 'string',+ description: 'Programming language for syntax highlighting.',+ default: "'plaintext'",+ },+ {+ name: 'hasLineNumbers',+ type: 'boolean',+ description: 'Display line number gutter on the left.',+ default: 'false',+ },+ {+ name: 'isReadOnly',+ type: 'boolean',+ description: 'Renders the editor in a read-only state.',+ default: 'false',+ },+ {+ name: 'placeholder',+ type: 'string',+ description: 'Placeholder text displayed when value is empty.',+ },+ {+ name: 'maxHeight',+ type: 'number | string',+ description: 'Maximum container height before internal scrolling.',+ },+ {+ name: 'size',+ type: "'sm' | 'md'",+ description: 'Font size variant for the code text.',+ default: "'md'",+ },+ {+ name: 'tokenizer',+ type: '(code: string, language: string) => TokenLine[]',+ description: 'Custom tokenizer function override for language parsing.',+ },+ {+ name: 'xstyle',+ type: 'StyleXStyles',+ description: 'StyleX styles for layout customization.',+ },+ ],};diff --git a/packages/lab/src/LogStream/LogStream.doc.mjs b/packages/lab/src/LogStream/LogStream.doc.mjsindex 65e5aecb5a..3a99e08a27 100644--- a/packages/lab/src/LogStream/LogStream.doc.mjs+++ b/packages/lab/src/LogStream/LogStream.doc.mjs@@ -7,11 +7,62 @@ export const docs = {displayName: 'Log Stream',group: 'LogStream',category: 'Content',+ keywords: ['log', 'stream', 'terminal', 'console', 'output', 'logs', 'tail'],usage: {description:- 'Experimental streaming log viewer: mono grid rows (timestamp | level | source | message) with token-derived level accents, expandable per-row detail panels, follow-scroll live tailing with a "Jump to latest" affordance, and an always-dark terminal variant. Appended rows fade in via @starting-style (instant under prefers-reduced-motion). No virtualization; window streams beyond a few thousand rows in the caller.',+ 'Experimental streaming log viewer: mono grid rows (timestamp | level | source | message) with token-derived level accents, expandable per-row detail panels, follow-scroll live tailing with a "Jump to latest" affordance, and an always-dark terminal variant. Appended rows fade in via @starting-style.',},- props: [],+ props: [+ {+ name: 'entries',+ type: 'LogEntry[]',+ description: 'Array of log entry objects to render.',+ required: true,+ },+ {+ name: 'variant',+ type: "'default' | 'terminal'",+ description: "Visual variant style: 'default' uses theme surface background, 'terminal' uses fixed dark background.",+ default: "'default'",+ },+ {+ name: 'isFollowing',+ type: 'boolean',+ description: 'Controlled follow-pinning state to auto-scroll to the newest entry.',+ },+ {+ name: 'onFollowChange',+ type: '(following: boolean) => void',+ description: 'Callback fired when follow-pinning state changes.',+ },+ {+ name: 'maxHeight',+ type: 'number | string',+ description: 'Maximum container height before vertical scrolling.',+ },+ {+ name: 'hasTimestamps',+ type: 'boolean',+ description: 'Show or hide the timestamp column.',+ default: 'true',+ },+ {+ name: 'label',+ type: 'string',+ description: 'Accessible label for the log region.',+ default: "'Log stream'",+ },+ {+ name: 'renderEntry',+ type: '(entry: LogEntry) => ReactNode',+ description: 'Custom render function for replacing individual row layout.',+ },+ {+ name: 'xstyle',+ type: 'StyleXStyles',+ description: 'StyleX styles for layout customization.',+ },+ ],};diff --git a/packages/lab/src/Stepper/Stepper.doc.mjs b/packages/lab/src/Stepper/Stepper.doc.mjsindex ef9f1a64b9..39d0165880 100644--- a/packages/lab/src/Stepper/Stepper.doc.mjs+++ b/packages/lab/src/Stepper/Stepper.doc.mjs@@ -75,6 +75,12 @@ export const docs = {description: 'Controls the padding of all steps.',default: "'balanced'",},+ {+ name: 'indicatorPosition',+ type: "'separated' | 'on-track'",+ description: 'Position of step indicators relative to the connector track.',+ default: "'separated'",+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/lab/src/__tests__/labApiContractDrift.test.tsx b/packages/lab/src/__tests__/labApiContractDrift.test.tsxnew file mode 100644index 0000000000..be43cf9a65--- /dev/null+++ b/packages/lab/src/__tests__/labApiContractDrift.test.tsx@@ -0,0 +1,57 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, it, expect} from 'vitest';++import {docs as ChatReasoningDocs} from '../ChatReasoning/ChatReasoning.doc.mjs';+import {docs as CodeEditorDocs} from '../CodeEditor/CodeEditor.doc.mjs';+import {docs as LogStreamDocs} from '../LogStream/LogStream.doc.mjs';+import {docs as StepperDocs} from '../Stepper/Stepper.doc.mjs';++function getProps(docs: Record<string, unknown>): Array<{name: string}> {+ return (+ (docs.props as Array<{name: string}>) ||+ (+ docs.components as Array<{+ props: Array<{name: string}>;+ }>+ )?.[0]?.props ||+ []+ );+}++describe('Lab API Contract Drift (#4163)', () => {+ it('documents ChatReasoning props', () => {+ const props = getProps(ChatReasoningDocs).map(p => p.name);+ expect(props).toContain('duration');+ expect(props).toContain('isStreaming');+ expect(props).toContain('isExpanded');+ expect(props).toContain('defaultIsExpanded');+ expect(props).toContain('onExpandedChange');+ });++ it('documents CodeEditor props', () => {+ const props = getProps(CodeEditorDocs).map(p => p.name);+ expect(props).toContain('language');+ expect(props).toContain('hasLineNumbers');+ expect(props).toContain('isReadOnly');+ expect(props).toContain('placeholder');+ expect(props).toContain('maxHeight');+ expect(props).toContain('size');+ expect(props).toContain('tokenizer');+ });++ it('documents LogStream props', () => {+ const props = getProps(LogStreamDocs).map(p => p.name);+ expect(props).toContain('variant');+ expect(props).toContain('isFollowing');+ expect(props).toContain('onFollowChange');+ expect(props).toContain('maxHeight');+ expect(props).toContain('hasTimestamps');+ expect(props).toContain('renderEntry');+ });++ it('documents Stepper indicatorPosition prop', () => {+ const props = getProps(StepperDocs).map(p => p.name);+ expect(props).toContain('indicatorPosition');+ });+});