An open source design system that's fully customizable and agent ready
TypeScript
docs: add Markdown docs, hasClear prop docs, fix @example gaps (#1174)
Joey05c9cc27654a
diff --git a/packages/core/src/CommandPalette/XDSCommandPaletteEmpty.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteEmpty.tsxindex 15a19c0fb4..4247b6f785 100644--- a/packages/core/src/CommandPalette/XDSCommandPaletteEmpty.tsx+++ b/packages/core/src/CommandPalette/XDSCommandPaletteEmpty.tsx@@ -47,6 +47,15 @@ export interface XDSCommandPaletteEmptyProps {* - `emptySearchText`: a search query returned no results** Can also be composed manually inside a custom render function.+ *+ * @example+ * ```+ * <XDSCommandPalette+ * emptyBootstrapText={<XDSCommandPaletteEmpty>Start typing to search</XDSCommandPaletteEmpty>}+ * emptySearchText={<XDSCommandPaletteEmpty>No results found</XDSCommandPaletteEmpty>}+ * searchSource={source}+ * />+ * ```*/export function XDSCommandPaletteEmpty({children,diff --git a/packages/core/src/DateInput/DateInput.doc.mjs b/packages/core/src/DateInput/DateInput.doc.mjsindex 6922831b17..e5e0217de7 100644--- a/packages/core/src/DateInput/DateInput.doc.mjs+++ b/packages/core/src/DateInput/DateInput.doc.mjs@@ -161,6 +161,19 @@ export const docs = {type: 'string',description: 'Tooltip text displayed via an info icon at the end of the label.',},+ {+ name: 'hasClear',+ type: 'boolean',+ description:+ 'Shows a clear (\u00d7) button when a date value is set. Clicking it clears the value and returns focus to the input.',+ default: 'false',+ },+ {+ name: 'hasClear',+ type: 'boolean',+ description: '设置日期值时显示清除 (×) 按鈕。点击后清空值并将焦点返回输入框。',+ default: 'false',+ },{name: 'numberOfMonths',type: '1 | 2',@@ -410,6 +423,7 @@ export const docsDense = {size: 'input control size',status: 'error/warning/success status w/ message',labelTooltip: 'tooltip text via info icon at label end',+ hasClear: 'Shows clear button when date is set. Clears value on click.',numberOfMonths: 'months shown simultaneously in calendar popover',xstyle: 'StyleX styles for layout; must be stylex.create() value',},diff --git a/packages/core/src/Markdown/Markdown.doc.mjs b/packages/core/src/Markdown/Markdown.doc.mjsnew file mode 100644index 0000000000..ddacd3e1d0--- /dev/null+++ b/packages/core/src/Markdown/Markdown.doc.mjs@@ -0,0 +1,241 @@+/** @type {import('../docs-types').ComponentDoc} */++export const docs = {+ name: 'Markdown',+ description:+ 'Renders a markdown string as XDS components. Supports headings, paragraphs, bold, italic, code, lists, tables, links, images, blockquotes, horizontal rules, and task lists. Handles streaming text with a smooth fade-in animation.',+ keywords: [+ 'markdown',+ 'rich text',+ 'prose',+ 'renderer',+ 'streaming',+ 'markup',+ 'formatted text',+ 'md',+ 'markdown renderer',+ ],+ features: [+ 'Zero dependencies — built-in markdown parser, no external library',+ 'Streaming mode — smooth fade-in animation for chunk-by-chunk text delivery',+ 'XDS integration — uses XDSList, XDSCodeBlock, XDSCode, and XDSCheckboxList for semantic output',+ 'Heading level shift — headingLevelStart maps # to any h1-h6 level for page hierarchy',+ 'Link interception — onLinkClick handler can intercept or prevent link navigation',+ "Density — default and compact spacing modes",+ "Task lists — GitHub Flavored Markdown checkboxes rendered via XDSCheckboxList in isReadOnly mode",+ 'Tables — rendered as accessible HTML tables with XDS typography',+ ],+ props: [+ {+ name: 'children',+ type: 'string',+ description: 'The markdown string to render.',+ required: true,+ },+ {+ name: 'density',+ type: "\'default\' | \'compact\'",+ description: 'Controls spacing between block-level elements.',+ default: "\'default\'",+ },+ {+ name: 'headingLevelStart',+ type: '1 | 2 | 3 | 4 | 5 | 6',+ description:+ 'The HTML heading level that markdown # maps to. Shifts all heading levels down to fit the surrounding page hierarchy. Levels exceeding h6 are clamped to h6.',+ default: '1',+ },+ {+ name: 'isStreaming',+ type: 'boolean',+ description:+ 'Enables streaming mode — uses incremental parsing and a smooth fade-in animation for chunk-by-chunk text delivery.',+ default: 'false',+ },+ {+ name: 'onLinkClick',+ type: '(href: string, event: MouseEvent) => void | false',+ description:+ 'Handler for link clicks. Return false to prevent the default navigation behavior.',+ },+ {+ name: 'xstyle',+ type: 'StyleXStyles',+ description:+ 'StyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value — not an inline style object like style={{}}.',+ },+ {+ name: 'className',+ type: 'string',+ description:+ 'CSS class name for the root element. Prefer xstyle for styling — className is provided for integration with non-StyleX systems.',+ },+ {+ name: 'style',+ type: 'CSSProperties',+ description:+ 'Inline styles for the root element. Prefer xstyle for styling — inline styles bypass StyleX optimization.',+ },+ {+ name: 'data-testid',+ type: 'string',+ description: 'Test selector for automated testing frameworks.',+ },+ ],+ examples: [+ {+ label: 'Basic usage',+ code: `<XDSMarkdown>+ {'# Hello\\n\\nThis is **bold** and _italic_ text.\\n\\n- Item one\\n- Item two'}+</XDSMarkdown>`,+ },+ {+ label: 'Streaming mode',+ code: `<XDSMarkdown isStreaming={isStreaming}>+ {streamedText}+</XDSMarkdown>`,+ },+ {+ label: 'Nested under a heading',+ code: `<XDSMarkdown headingLevelStart={3}>+ {'# Section\\n\\nThis renders as an h3.'}+</XDSMarkdown>`,+ },+ ],+ theming: {+ targets: [+ {className: 'xds-markdown', visualProps: ['density']},+ ],+ },+ accessibility: [+ 'Root element uses role="document" to establish a document landmark for screen readers.',+ 'Lists are rendered as semantic <ul>/<ol> elements.',+ 'Tables include proper <thead>/<tbody> with alignment attributes.',+ 'Task list checkboxes are rendered via XDSCheckboxList with isReadOnly.',+ 'Code blocks use XDSCodeBlock with appropriate ARIA attributes.',+ ],+};++export const docsZh = {+ name: 'Markdown',+ description:+ '将 Markdown 字符串渲染为 XDS 组件。支持标题、段落、粗体、斜体、代码、列表、表格、链接、图片、引用块、水平线和任务列表。支持流式文本的逐字符淡入动画。',+ features: [+ '零依赖 — 内置 Markdown 解析器,无需外部库',+ '流式模式 — 逐块文本渲染时平滑淡入动画',+ 'XDS 集成 — 使用 XDSList、XDSCodeBlock、XDSCode 和 XDSCheckboxList 输出语义内容',+ '标题级别偏移 — headingLevelStart 将 # 映射到任意 h1-h6 级别',+ '链接拦截 — onLinkClick 可拦截或阻止链接导航',+ '密度 — 默认和紧凑间距模式',+ '任务列表 — GitHub 风格 Markdown 复选框通过 XDSCheckboxList 以只读模式渲染',+ '表格 — 渲染为带 XDS 排版的语义 HTML 表格',+ ],+ props: [+ {+ name: 'children',+ type: 'string',+ description: '要渲染的 Markdown 字符串。',+ required: true,+ },+ {+ name: 'density',+ type: "'default' | 'compact'",+ description: '控制块级元素之间的间距。',+ default: "'default'",+ },+ {+ name: 'headingLevelStart',+ type: '1 | 2 | 3 | 4 | 5 | 6',+ description:+ 'Markdown # 映射到的 HTML 标题级别。将所有标题级别向下偏移以适应页面层次结构。超过 h6 的级别将被限制为 h6。',+ default: '1',+ },+ {+ name: 'isStreaming',+ type: 'boolean',+ description:+ '启用流式模式 — 使用增量解析和淡入动画处理分块文本。',+ default: 'false',+ },+ {+ name: 'onLinkClick',+ type: '(href: string, event: MouseEvent) => void | false',+ description: '链接点击处理器。返回 false 可阻止默认导航行为。',+ },+ {+ name: 'xstyle',+ type: 'StyleXStyles',+ description:+ '用于布局自定义的 StyleX 样式。必须是 stylex.create() 的值,而非内联样式对象。',+ },+ {+ name: 'className',+ type: 'string',+ description: '根元素的 CSS 类名。建议使用 xstyle — className 适用于非 StyleX 系统集成。',+ },+ {+ name: 'style',+ type: 'CSSProperties',+ description: '根元素的内联样式。建议使用 xstyle — 内联样式会绕过 StyleX 优化。',+ },+ {+ name: 'data-testid',+ type: 'string',+ description: '用于自动化测试框架的测试选择器。',+ },+ ],+ examples: [+ {+ label: '基本用法',+ code: `<XDSMarkdown>+ {'# Hello\\n\\nThis is **bold** text.'}+</XDSMarkdown>`,+ },+ {+ label: '流式模式',+ code: `<XDSMarkdown isStreaming={isStreaming}>+ {streamedText}+</XDSMarkdown>`,+ },+ ],+ theming: {+ targets: [+ {className: 'xds-markdown', visualProps: ['density']},+ ],+ },+ accessibility: [+ '根元素使用 role="document" 为屏幕阅读器建立文档地标。',+ '列表渲染为语义化 <ul>/<ol> 元素。',+ '表格包含带对齐属性的 <thead>/<tbody>。',+ '任务列表复选框通过 XDSCheckboxList 以 isReadOnly 模式渲染。',+ '代码块使用 XDSCodeBlock 并附带适当的 ARIA 属性。',+ ],+};++export const docsDense = {+ n: 'Markdown',+ d: 'Renders markdown string as XDS components. Headings, bold, italic, code, lists, tables, links, blockquotes, task lists. Streaming with fade-in animation.',+ kw: ['markdown', 'rich text', 'prose', 'renderer', 'streaming', 'markup', 'md'],+ f: [+ 'Zero-dep parser. Streaming fade-in. XDSList/XDSCodeBlock/XDSCheckboxList integration.',+ 'headingLevelStart: maps # to any h1-h6. Clamped at h6.',+ 'onLinkClick: intercept/prevent link nav. Return false to cancel.',+ 'density: default/compact block spacing.',+ 'Task lists via XDSCheckboxList isReadOnly. Tables as semantic HTML.',+ ],+ p: {+ children: 'Markdown string. Required.',+ density: "Block spacing. 'default'|'compact'. Default: 'default'.",+ headingLevelStart: 'Maps # to this heading level (1-6). Clamped to h6. Default: 1.',+ isStreaming: 'Incremental parse + fade-in for streamed chunks. Default: false.',+ onLinkClick: '(href, event) => void|false. Return false prevents navigation.',+ xstyle: 'stylex.create() for layout (margins, sizing).',+ className: 'CSS class. Prefer xstyle.',+ style: 'Inline styles. Prefer xstyle.',+ 'data-testid': 'Test selector.',+ },+ ex: [+ '<XDSMarkdown>{\'# Hello\\\\n\\\\nThis is **bold** text.\'}</XDSMarkdown>',+ '<XDSMarkdown isStreaming={isStreaming}>{streamedText}</XDSMarkdown>',+ ],+};diff --git a/packages/core/src/Markdown/XDSMarkdown.tsx b/packages/core/src/Markdown/XDSMarkdown.tsxindex 54db46a953..706b53f79c 100644--- a/packages/core/src/Markdown/XDSMarkdown.tsx+++ b/packages/core/src/Markdown/XDSMarkdown.tsx@@ -890,6 +890,17 @@ function renderBlock(// Component// ---------------------------------------------------------------------------+/**+ * Renders a markdown string as XDS components. Supports streaming with+ * smooth fade-in animation via isStreaming.+ *+ * @example+ * ```+ * <XDSMarkdown>+ * {'# Hello\n\nThis is **bold** and _italic_ text.\n\n- Item one\n- Item two'}+ * </XDSMarkdown>+ * ```+ */export function XDSMarkdown({ref,children,diff --git a/packages/core/src/NumberInput/NumberInput.doc.mjs b/packages/core/src/NumberInput/NumberInput.doc.mjsindex 304ddfd4e6..c9b5e1bda4 100644--- a/packages/core/src/NumberInput/NumberInput.doc.mjs+++ b/packages/core/src/NumberInput/NumberInput.doc.mjs@@ -188,6 +188,13 @@ export const docs = {type: 'boolean',description: 'Only allow integer values (no floating point).',},+ {+ name: 'hasClear',+ type: 'boolean',+ description:+ 'Shows a clear (\u00d7) button when the input has a value. When true, the onChange callback also accepts null to signal the user cleared the input.',+ default: 'false',+ },{name: 'htmlName',type: 'string',@@ -426,6 +433,12 @@ export const docsZh = {type: 'boolean',description: '仅允许整数值(不允许浮点数)。',},+ {+ name: 'hasClear',+ type: 'boolean',+ description: '输入有值时显示清除 (×) 按鈕。启用后, onChange 回调还接受 null 表示用户已清空输入。',+ default: 'false',+ },{name: 'htmlName',type: 'string',@@ -528,6 +541,7 @@ export const docsDense = {step: 'Step increment.',units: 'Units suffix (e.g. "%" or "GB").',isIntegerOnly: 'Only allow integer values.',+ hasClear: 'Shows clear button when input has value. onChange also accepts null on clear.',htmlName: 'HTML name for form submissions.',autoComplete: 'HTML autocomplete attribute.',hasAutoFocus: 'Focus input on mount.',diff --git a/packages/core/src/Selector/Selector.doc.mjs b/packages/core/src/Selector/Selector.doc.mjsindex 89cfe99246..421ca8db13 100644--- a/packages/core/src/Selector/Selector.doc.mjs+++ b/packages/core/src/Selector/Selector.doc.mjs@@ -115,6 +115,13 @@ export const docs = {type: '(value: string) => void',description: 'Callback fired when the selection changes.',},+ {+ name: 'hasClear',+ type: 'boolean',+ description:+ 'Shows a clear (\u00d7) button when a value is selected. When true, onChange also accepts null to signal the user cleared the selection.',+ default: 'false',+ },{name: 'placeholder',type: 'string',@@ -348,6 +355,12 @@ export const docsZh = {type: '(value: string) => void',description: '选择变更时触发的回调函数。',},+ {+ name: 'hasClear',+ type: 'boolean',+ description: '选中值时显示清除 (×) 按鈕。启用后,onChange 还接受 null 表示用户已清除选择。',+ default: 'false',+ },{name: 'placeholder',type: 'string',@@ -495,6 +508,7 @@ export const docsDense = {options: 'Array of items; strings, objects w/ value/label/icon/disabled, dividers ({type: "divider"}), sections ({type: "section", title, items}).',value: 'Currently selected value.',onChange: 'Callback fired when selection changes.',+ hasClear: 'Shows clear button when value selected. onChange also accepts null on clear.',placeholder: 'Placeholder text when no value selected.',size: 'Size variant for selector.',isDisabled: 'Disables selector.',diff --git a/packages/core/src/TextInput/TextInput.doc.mjs b/packages/core/src/TextInput/TextInput.doc.mjsindex 93eaa95d54..baba7d90fd 100644--- a/packages/core/src/TextInput/TextInput.doc.mjs+++ b/packages/core/src/TextInput/TextInput.doc.mjs@@ -180,6 +180,13 @@ export const docs = {description:'Validation status — applies a colored border and status icon. If message is provided, displays a floating message below the input. Error type also sets aria-invalid.',},+ {+ name: 'hasClear',+ type: 'boolean',+ description:+ 'Shows a clear (\u00d7) button when the input has a value. Clicking it clears the value and returns focus to the input.',+ default: 'false',+ },{name: 'hasAutoFocus',type: 'boolean',@@ -388,6 +395,12 @@ export const docsZh = {description:'验证状态 — 应用彩色边框和状态图标。如果提供了 message,在输入框下方显示浮动消息。错误类型还会设置 aria-invalid。',},+ {+ name: 'hasClear',+ type: 'boolean',+ description: '输入有值时显示清除 (×) 按鈕。点击后清空值并将焦点返回输入框。',+ default: 'false',+ },{name: 'hasAutoFocus',type: 'boolean',@@ -466,6 +479,7 @@ export const docsDense = {labelTooltip: 'Tooltip in info icon at label end.',startIcon: 'SVG icon at input start (e.g. heroicons or lucide).',status: 'Validation status; colored border+icon. Message floats below. Error sets aria-invalid.',+ hasClear: 'Shows clear button when input has value. Clears value on click.',hasAutoFocus: 'Auto-focus input on mount.',htmlName: 'HTML name attr for form submissions.',},