Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

docs(input fields): align statusVariant documentation and test coverage (#6428)

Manohar Paturi7d79b59c5a71
diff --git a/.changeset/input-fields-status-variant-tooltip.md b/.changeset/input-fields-status-variant-tooltip.md
new file mode 100644
index 0000000000..fc0f935dd1
--- /dev/null
+++ b/.changeset/input-fields-status-variant-tooltip.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[docs] align statusVariant documentation and test coverage across ComplexSelector, Tokenizer, and Typeahead
+
+@ManoharPaturi
diff --git a/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs b/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs
index 2e47e12c13..894a1e1aa9 100644
--- a/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs
+++ b/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs
@@ -142,6 +142,13 @@ export const docs = {
type: "{type: 'warning' | 'error' | 'success', message?: string}",
description: 'Validation status.',
},
+ {
+ name: 'statusVariant',
+ type: "'attached' | 'detached' | 'tooltip'",
+ description:
+ 'How the status message is placed relative to the input. attached overlaps directly below the input (bordered treatment; detached when variant is ghost); detached floats below as a separate element with spacing; tooltip reveals the message in an info-tip button.',
+ default: "'attached'",
+ },
{
name: 'size',
type: "'sm' | 'md' | 'lg'",
@@ -331,6 +338,8 @@ export const docsDense = {
'Caller-rendered opener replacing the field+button; spread the given props; popup anchored to it, labelled by label.',
handleRef: 'Imperative open/close/toggle handle.',
onOpenChange: 'Notified on every open and close, whatever caused it.',
+ statusVariant:
+ 'How status message is placed: attached overlaps below input (detached for ghost); detached floats below w/ spacing; tooltip shows on status icon.',
accessibility:
'Custom content must provide its own accessible structure. Use focus hooks and evaluate against WCAG 2.2.',
},
diff --git a/packages/core/src/ComplexSelector/ComplexSelector.test.tsx b/packages/core/src/ComplexSelector/ComplexSelector.test.tsx
index 4013b265d6..8ef223dc53 100644
--- a/packages/core/src/ComplexSelector/ComplexSelector.test.tsx
+++ b/packages/core/src/ComplexSelector/ComplexSelector.test.tsx
@@ -685,4 +685,69 @@ describe('ComplexSelector onOpenChange', () => {
act(() => handleRef.current?.open());
expect(onOpenChange.mock.calls).toEqual([[true]]);
});
+
+ describe('statusVariant forwarding', () => {
+ it('defaults to attached (status renders with data-variant="attached")', () => {
+ const {container} = render(
+ <ComplexSelector
+ label="Filter"
+ value={[]}
+ status={{type: 'error', message: 'Required'}}>
+ {() => <button type="button">Apply</button>}
+ </ComplexSelector>,
+ );
+ expect(container.querySelector('.astryx-field-status')).toHaveAttribute(
+ 'data-variant',
+ 'attached',
+ );
+ });
+
+ it('forwards statusVariant="detached" to the underlying Field status', () => {
+ const {container} = render(
+ <ComplexSelector
+ label="Filter"
+ value={[]}
+ status={{type: 'error', message: 'Required'}}
+ statusVariant="detached">
+ {() => <button type="button">Apply</button>}
+ </ComplexSelector>,
+ );
+ expect(container.querySelector('.astryx-field-status')).toHaveAttribute(
+ 'data-variant',
+ 'detached',
+ );
+ });
+
+ it('forces detached when variant="ghost" even if statusVariant="attached"', () => {
+ const {container} = render(
+ <ComplexSelector
+ label="Filter"
+ value={[]}
+ variant="ghost"
+ status={{type: 'error', message: 'Required'}}
+ statusVariant="attached">
+ {() => <button type="button">Apply</button>}
+ </ComplexSelector>,
+ );
+ expect(container.querySelector('.astryx-field-status')).toHaveAttribute(
+ 'data-variant',
+ 'detached',
+ );
+ });
+
+ it('renders no message box for statusVariant="tooltip"', () => {
+ const {container} = render(
+ <ComplexSelector
+ label="Filter"
+ value={[]}
+ status={{type: 'error', message: 'Required'}}
+ statusVariant="tooltip">
+ {() => <button type="button">Apply</button>}
+ </ComplexSelector>,
+ );
+ expect(
+ container.querySelector('.astryx-field-status'),
+ ).not.toBeInTheDocument();
+ });
+ });
});
diff --git a/packages/core/src/ComplexSelector/ComplexSelector.tsx b/packages/core/src/ComplexSelector/ComplexSelector.tsx
index ac61f47d36..b9b2eb3487 100644
--- a/packages/core/src/ComplexSelector/ComplexSelector.tsx
+++ b/packages/core/src/ComplexSelector/ComplexSelector.tsx
@@ -292,7 +292,13 @@ export interface ComplexSelectorProps<Value> extends Omit<
isLoading?: boolean;
/** Validation status. */
status?: ComplexSelectorStatus;
- /** Status placement. */
+ /**
+ * How the status message is placed relative to the input.
+ * - 'attached': message overlaps directly below the input (bordered treatment; detached when variant is ghost)
+ * - 'detached': message floats below as a separate element with spacing
+ * - 'tooltip': no message box; the status icon becomes a focusable info-tip button that reveals the message on hover, keyboard focus, or tap
+ * @default 'attached'
+ */
statusVariant?: FieldStatusVariant;
/** Tooltip text displayed next to the label. */
labelTooltip?: string;
diff --git a/packages/core/src/Tokenizer/Tokenizer.doc.mjs b/packages/core/src/Tokenizer/Tokenizer.doc.mjs
index d9efadd6ed..9199cf1673 100644
--- a/packages/core/src/Tokenizer/Tokenizer.doc.mjs
+++ b/packages/core/src/Tokenizer/Tokenizer.doc.mjs
@@ -114,9 +114,9 @@ export const docs = {
},
{
name: 'statusVariant',
- type: "'attached' | 'detached'",
+ type: "'attached' | 'detached' | 'tooltip'",
description:
- 'How the status message is placed relative to the input. attached overlaps directly below the input (bordered treatment); detached floats below as a separate element with spacing.',
+ 'How the status message is placed relative to the input. attached overlaps directly below the input (bordered treatment); detached floats below as a separate element with spacing; tooltip reveals the message in an info-tip button.',
default: "'attached'",
},
{
@@ -463,9 +463,9 @@ export const docsZh = {
},
{
name: 'statusVariant',
- type: "'attached' | 'detached'",
+ type: "'attached' | 'detached' | 'tooltip'",
description:
- '状态消息相对于输入框的放置方式。attached 直接叠加在输入框下方(带边框处理);detached 作为独立元素浮于下方并留有间距。',
+ '状态消息相对于输入框的放置方式。attached 直接叠加在输入框下方(带边框处理);detached 作为独立元素浮于下方并留有间距;tooltip 在状态图标的提示气泡中显示消息。',
default: "'attached'",
},
{
@@ -760,7 +760,7 @@ export const docsDense = {
htmlName: 'HTML name attr; one hidden input per selected item id.',
status: 'Validation status w/ type+message for error/warning/success.',
statusVariant:
- 'How status message is placed: attached overlaps below input; detached floats below w/ spacing.',
+ 'How status message is placed: attached overlaps below input; detached floats below w/ spacing; tooltip shows on status icon.',
isLabelHidden: 'Visually hides label; keeps a11y.',
description: 'Helper text below label.',
isRequired: 'Marks field required.',
diff --git a/packages/core/src/Tokenizer/Tokenizer.tsx b/packages/core/src/Tokenizer/Tokenizer.tsx
index 147df0dad8..e469dae359 100644
--- a/packages/core/src/Tokenizer/Tokenizer.tsx
+++ b/packages/core/src/Tokenizer/Tokenizer.tsx
@@ -125,6 +125,7 @@ export interface TokenizerProps<T extends SearchableItem> extends Omit<
* How the status message is placed relative to the input.
* - 'attached': message overlaps directly below the input (bordered treatment)
* - 'detached': message floats below as a separate element with spacing
+ * - 'tooltip': no message box; the status icon becomes a focusable info-tip button that reveals the message on hover, keyboard focus, or tap
* @default 'attached'
*/
statusVariant?: FieldStatusVariant;
diff --git a/packages/core/src/Typeahead/Typeahead.doc.mjs b/packages/core/src/Typeahead/Typeahead.doc.mjs
index 2488fe6dfa..fd08aaa2ae 100644
--- a/packages/core/src/Typeahead/Typeahead.doc.mjs
+++ b/packages/core/src/Typeahead/Typeahead.doc.mjs
@@ -184,9 +184,9 @@ export const docs = {
},
{
name: 'statusVariant',
- type: "'attached' | 'detached'",
+ type: "'attached' | 'detached' | 'tooltip'",
description:
- 'How the status message is placed relative to the input. attached overlaps directly below the input (bordered treatment); detached floats below as a separate element with spacing.',
+ 'How the status message is placed relative to the input. attached overlaps directly below the input (bordered treatment); detached floats below as a separate element with spacing; tooltip reveals the message in an info-tip button.',
default: "'attached'",
},
{
diff --git a/packages/core/src/Typeahead/Typeahead.tsx b/packages/core/src/Typeahead/Typeahead.tsx
index e73f9c8726..265a6b73a9 100644
--- a/packages/core/src/Typeahead/Typeahead.tsx
+++ b/packages/core/src/Typeahead/Typeahead.tsx
@@ -95,6 +95,7 @@ export interface TypeaheadProps<T extends SearchableItem> extends Omit<
* How the status message is placed relative to the input.
* - 'attached': message overlaps directly below the input (bordered treatment)
* - 'detached': message floats below as a separate element with spacing
+ * - 'tooltip': no message box; the status icon becomes a focusable info-tip button that reveals the message on hover, keyboard focus, or tap
* @default 'attached'
*/
statusVariant?: FieldStatusVariant;