Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sana Malik committed Jan 30, 2025
1 parent c01680d commit f57fc8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/@react-spectrum/labeledvalue/docs/LabeledValue.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ By default, the list is displayed as a conjunction (an "and"-based grouping of i
The value can be a component and will be rendered as provided. Components cannot be editable.

```tsx example
import {Link} from '@adobe/react-spectrum';

<LabeledValue label="Website" value={<Link href="https://www.adobe.com/">Adobe.com</Link>} />
```

Expand Down
3 changes: 2 additions & 1 deletion packages/@react-spectrum/labeledvalue/docs/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {DateTime, LabeledValueBaseProps} from '@react-spectrum/labeledvalue/src/LabeledValue';
import {RangeValue} from '@react-types/shared';
import { ReactNode } from 'react';

// The doc generator is not smart enough to handle the real types for LabeledValue so this is a simpler one.
export interface LabeledValueProps extends LabeledValueBaseProps {
/** The value to display. */
value: string | string[] | number | RangeValue<number> | DateTime | RangeValue<DateTime>,
value: string | string[] | number | RangeValue<number> | DateTime | RangeValue<DateTime> | ReactNode,
/** Formatting options for the value. The available options depend on the type passed to the `value` prop. */
formatOptions?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | Intl.ListFormatOptions
}
7 changes: 7 additions & 0 deletions packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,19 @@ interface StringListProps<T extends string[]> {
/** Formatting options for the value. */
formatOptions?: Intl.ListFormatOptions
}
interface ReactNodeProps<T extends ReactNode> {
/** The value to display. */
value: T
/** Formatting options for the value. */
formatOptions?: never
}

type LabeledValueProps<T> =
T extends NumberValue ? NumberProps<T> :
T extends DateTimeValue ? DateProps<T> :
T extends string[] ? StringListProps<T> :
T extends string ? StringProps<T> :
T extends ReactNode ? ReactNodeProps<T> :
never;

type SpectrumLabeledValueTypes = string[] | string | Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time | number | RangeValue<number> | RangeValue<DateTime> | ReactNode;
Expand Down

0 comments on commit f57fc8a

Please sign in to comment.