@sanity/ui 5.0.0-alpha.24 → 5.0.0-alpha.25

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 (73) hide show
  1. package/dist/index.d.ts +136 -144
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +64 -99
  4. package/dist/index.js.map +1 -1
  5. package/dist/styles.css +1 -1
  6. package/package.json +1 -1
  7. package/src/components/avatar/avatar.props.ts +4 -2
  8. package/src/components/avatar-counter/avatarCounter.props.ts +4 -2
  9. package/src/components/avatar-stack/avatarStack.props.ts +4 -2
  10. package/src/components/badge/Badge.tsx +2 -5
  11. package/src/components/badge/badge.props.ts +15 -15
  12. package/src/components/box/Box.tsx +2 -5
  13. package/src/components/box/box.props.ts +18 -12
  14. package/src/components/button/Button.tsx +2 -2
  15. package/src/components/button/button.props.ts +49 -43
  16. package/src/components/card/Card.tsx +2 -2
  17. package/src/components/card/card.props.ts +19 -13
  18. package/src/components/checkbox/checkbox.props.ts +4 -2
  19. package/src/components/code/code.props.ts +5 -3
  20. package/src/components/container/Container.tsx +2 -2
  21. package/src/components/container/container.props.ts +17 -11
  22. package/src/components/dialog/Dialog.tsx +10 -5
  23. package/src/components/dialog/dialog.props.ts +11 -3
  24. package/src/components/divider/divider.props.ts +4 -2
  25. package/src/components/eyebrow/Eyebrow.tsx +2 -5
  26. package/src/components/eyebrow/eyebrow.props.ts +19 -12
  27. package/src/components/flex/Flex.tsx +2 -5
  28. package/src/components/flex/flex.props.ts +19 -12
  29. package/src/components/grid/Grid.tsx +2 -5
  30. package/src/components/grid/grid.props.ts +20 -16
  31. package/src/components/h-stack/HStack.tsx +2 -5
  32. package/src/components/h-stack/hStack.props.ts +7 -4
  33. package/src/components/heading/Heading.tsx +2 -5
  34. package/src/components/heading/heading.props.ts +18 -13
  35. package/src/components/hotkeys/hotkeys.props.ts +4 -2
  36. package/src/components/icon/icon.props.ts +3 -3
  37. package/src/components/icon-button/IconButton.tsx +2 -4
  38. package/src/components/icon-button/iconButton.props.ts +17 -17
  39. package/src/components/indicator/Indicator.tsx +2 -2
  40. package/src/components/indicator/indicator.props.ts +17 -11
  41. package/src/components/indicator-stack/IndicatorStack.tsx +2 -4
  42. package/src/components/indicator-stack/indicatorStack.props.ts +13 -7
  43. package/src/components/inline/Inline.tsx +2 -2
  44. package/src/components/inline/inline.props.ts +17 -11
  45. package/src/components/kbd/kbd.props.ts +4 -2
  46. package/src/components/link/link.props.ts +4 -2
  47. package/src/components/list/List.tsx +47 -97
  48. package/src/components/list/list.css +28 -9
  49. package/src/components/list/list.props.ts +59 -68
  50. package/src/components/popover/popover.props.ts +7 -5
  51. package/src/components/press-area/PressArea.tsx +2 -4
  52. package/src/components/press-area/press-area.css +9 -3
  53. package/src/components/press-area/pressArea.props.ts +13 -7
  54. package/src/components/radio/radio.props.ts +2 -1
  55. package/src/components/select/select.props.ts +4 -2
  56. package/src/components/skip-to-content/skipToContent.props.ts +4 -2
  57. package/src/components/spinner/spinner.props.ts +4 -2
  58. package/src/components/switch/switch.props.ts +4 -2
  59. package/src/components/tabs/tabs.props.ts +8 -9
  60. package/src/components/text/Text.tsx +2 -5
  61. package/src/components/text/text.props.ts +19 -12
  62. package/src/components/text-area/textArea.props.ts +4 -5
  63. package/src/components/text-input/textInput.props.ts +5 -3
  64. package/src/components/tooltip/tooltip.props.ts +7 -5
  65. package/src/components/tooltip-group/TooltipGroup.tsx +2 -4
  66. package/src/components/tooltip-group/tooltipGroup.props.ts +13 -7
  67. package/src/components/v-stack/VStack.tsx +2 -5
  68. package/src/components/v-stack/vStack.props.ts +7 -4
  69. package/src/components/visually-hidden/VisuallyHidden.tsx +2 -4
  70. package/src/components/visually-hidden/visuallyHidden.props.ts +17 -11
  71. package/src/types/Interactive.ts +3 -1
  72. package/src/types/Polymorphic.ts +9 -0
  73. package/src/version.ts +2 -2
@@ -1,5 +1,5 @@
1
1
  import clsx from 'clsx'
2
- import type {ComponentProps, ComponentPropsWithRef, ElementType} from 'react'
2
+ import type {ElementType} from 'react'
3
3
 
4
4
  import type {ListTag} from '../../types/List'
5
5
  import {getProps} from '../../utils/getProps'
@@ -9,25 +9,20 @@ import {PressArea} from '../press-area/PressArea'
9
9
  import {Text} from '../text/Text'
10
10
  import {VStack} from '../v-stack/VStack'
11
11
  import {
12
- listButtonItemProps,
13
- type ListButtonItemProps,
12
+ listButtonProps,
13
+ type ListItemButtonProps,
14
+ type ListImageProps,
14
15
  type ListItemProps,
15
- listItemProps,
16
- type ListItemTextProps,
17
- listItemTextProps,
18
16
  type ListProps,
19
17
  listProps,
20
18
  } from './list.props'
21
19
 
22
20
  const listClassName = suffixClassName('sui-List')
23
21
  const listItemClassName = suffixClassName('sui-ListItem')
24
- const listButtonItemClassName = suffixClassName('sui-ListButtonItem')
25
- const listItemTextClassName = suffixClassName('sui-ListItemText')
22
+ const listButtonClassName = suffixClassName('sui-ListItemButton')
26
23
  const listItemImageClassName = suffixClassName('sui-ListItemImage')
27
24
 
28
- function ListRoot<T extends ListTag = 'ul'>(
29
- props: ListProps<T> & Omit<ComponentPropsWithRef<T>, keyof ListProps<T>>,
30
- ) {
25
+ function ListRoot<T extends ListTag = 'ul'>(props: ListProps<T>) {
31
26
  const {as, children, className, style, ...rest} = getProps(props, listProps)
32
27
  const Component = as || 'ul'
33
28
 
@@ -44,110 +39,66 @@ function ListRoot<T extends ListTag = 'ul'>(
44
39
  )
45
40
  }
46
41
 
47
- function ListItem({density = 'regular', ...props}: ListItemProps) {
48
- const {children, className, style, end, start, ...rest} = getProps(
49
- {density, ...props},
50
- listItemProps,
51
- )
52
-
42
+ function ListItem({className, ...rest}: ListItemProps) {
53
43
  return (
54
44
  <li
55
- className={clsx(
56
- listItemClassName,
57
- 'sui-width-full sui-display-flex sui-align-items-center',
58
- className,
59
- )}
60
- style={style}
61
45
  data-ui="ListItem"
46
+ className={clsx(listItemClassName, 'sui-text-body1', className)}
62
47
  {...rest}
63
- >
64
- {start}
65
-
66
- <Flex flexGrow={1} gap="inherit">
67
- {children}
68
- </Flex>
69
-
70
- {end}
71
- </li>
48
+ />
72
49
  )
73
50
  }
74
51
 
75
- function ListButtonItem<T extends ElementType = 'button'>({
52
+ function ListItemButton<T extends ElementType = 'button'>({
76
53
  density = 'regular',
77
54
  ...props
78
- }: ListButtonItemProps<T> & Omit<ComponentPropsWithRef<T>, keyof ListButtonItemProps<T>>) {
79
- const {as, children, className, style, end, start, selected, ...rest} = getProps(
55
+ }: ListItemButtonProps<T>) {
56
+ const {as, children, className, style, text, subtext, end, start, current, ...rest} = getProps(
80
57
  {density, ...props},
81
- listButtonItemProps,
58
+ listButtonProps,
82
59
  )
83
60
  const Component = as || 'button'
84
61
 
85
62
  return (
86
- <li>
87
- <PressArea
88
- as={Component}
89
- className={clsx(
90
- listButtonItemClassName,
91
- 'sui-width-full sui-display-flex sui-align-items-center sui-radius2',
92
- className,
93
- )}
94
- style={style}
95
- data-ui="ListButtonItem"
96
- data-selected={selected}
97
- {...rest}
98
- >
99
- {start}
100
-
101
- <Flex flexGrow={1} gap="inherit">
102
- {children}
103
- </Flex>
104
-
105
- {end}
106
- </PressArea>
107
- </li>
108
- )
109
- }
110
-
111
- function ListItemText<T extends ElementType = 'div'>(
112
- props: ListItemTextProps<T> & Omit<ComponentPropsWithRef<T>, keyof ListItemTextProps<T>>,
113
- ) {
114
- const {as, className, style, title, subtitle, ...rest} = getProps(props, listItemTextProps)
115
- const Component = as || 'div'
116
-
117
- return (
118
- <Flex
63
+ <PressArea
119
64
  as={Component}
120
- className={clsx(listItemTextClassName, className)}
65
+ className={clsx(
66
+ listButtonClassName,
67
+ 'sui-width-full sui-display-flex sui-align-items-center sui-radius2',
68
+ className,
69
+ )}
121
70
  style={style}
122
- data-ui="ListItemText"
123
- flexDirection="column"
124
- justifyContent="center"
125
- gap={2}
126
- flexGrow={1}
71
+ data-ui="ListItemButton"
72
+ aria-current={current}
127
73
  {...rest}
128
74
  >
129
- {title && (
130
- <Text size={1} weight="medium" trim truncate={1}>
131
- {title}
132
- </Text>
133
- )}
75
+ {start}
134
76
 
135
- {subtitle && (
136
- <Text size={1} muted trim truncate={1}>
137
- {subtitle}
138
- </Text>
139
- )}
140
- </Flex>
77
+ <Flex flexDirection="column" justifyContent="center" gap={2} flexGrow={1}>
78
+ {text && (
79
+ <Text size={1} weight="medium" trim truncate={1}>
80
+ {text}
81
+ </Text>
82
+ )}
83
+
84
+ {subtext && (
85
+ <Text size={1} muted trim truncate={1}>
86
+ {subtext}
87
+ </Text>
88
+ )}
89
+
90
+ {children}
91
+ </Flex>
92
+
93
+ {end}
94
+ </PressArea>
141
95
  )
142
96
  }
143
97
 
144
- function ListItemImage(props: ComponentProps<'img'>) {
145
- const {className, style, ...rest} = getProps(props, {})
146
-
98
+ function ListItemImage({className, ...rest}: ListImageProps) {
147
99
  return (
148
100
  <img
149
101
  className={clsx(listItemImageClassName, 'sui-radius2', className)}
150
- style={style}
151
102
  data-ui="ListItemImage"
152
103
  {...rest}
153
104
  />
@@ -157,11 +108,10 @@ function ListItemImage(props: ComponentProps<'img'>) {
157
108
  ListRoot.displayName = 'List'
158
109
 
159
110
  /** @beta */
160
- export const List = ListRoot
161
-
162
- ListRoot.Item = ListItem
163
- ListRoot.ButtonItem = ListButtonItem
164
- ListRoot.ItemText = ListItemText
165
- ListRoot.ItemImage = ListItemImage
111
+ export const List = Object.assign(ListRoot, {
112
+ Item: ListItem,
113
+ ItemButton: ListItemButton,
114
+ ItemImage: ListItemImage,
115
+ })
166
116
 
167
- export type {ListProps, ListItemProps, ListButtonItemProps, ListItemTextProps}
117
+ export type {ListProps, ListItemProps, ListItemButtonProps, ListImageProps}
@@ -2,19 +2,38 @@
2
2
  list-style-type: none;
3
3
  }
4
4
 
5
- .sui-ListButtonItem:hover,
6
- .sui-ListButtonItem:focus-visible {
7
- background: var(--background-low);
5
+ .sui-ListItem,
6
+ .sui-ListItemButton {
7
+ --list-color: var(--foreground-high);
8
+ --list-color-muted: var(--foreground-low);
9
+ /*
10
+ * ListItemButton uses PressArea under the hood and can hook into
11
+ * its variables to set Text and Icon colors
12
+ */
13
+ --press-area-color: var(--list-color);
14
+ --press-area-color-muted: var(--list-color-muted);
15
+ color: var(--list-color);
8
16
  }
9
17
 
10
- .sui-ListButtonItem:focus-visible {
11
- outline: var(--focus-outline);
12
- outline-offset: var(--focus-offset);
18
+ .sui-ListItemButton {
19
+ --background-color: transparent;
20
+ background: var(--background-color);
13
21
  }
14
22
 
15
- .sui-ListButtonItem[data-selected] {
16
- background: var(--active-background-emphasized);
17
- color: var(--active-foreground-emphasized);
23
+ .sui-ListItemButton:hover,
24
+ .sui-ListItemButton:focus-visible {
25
+ --background-color: var(--background-low);
26
+ }
27
+
28
+ .sui-ListItemButton:disabled {
29
+ --list-color: var(--inert-foreground);
30
+ --list-color-muted: var(--inert-foreground);
31
+ }
32
+
33
+ .sui-ListItemButton[aria-current="true"] {
34
+ --background-color: var(--active-background-emphasized);
35
+ --list-color: var(--active-foreground-emphasized);
36
+ --list-color-muted: var(--active-background-normal);
18
37
  }
19
38
 
20
39
  .sui-ListItemImage {
@@ -1,4 +1,4 @@
1
- import type React from 'react'
1
+ import type {ComponentProps, ReactNode, ElementType} from 'react'
2
2
 
3
3
  import {type GapProps, gapProps} from '../../props/gap'
4
4
  import {heightProps} from '../../props/height'
@@ -6,16 +6,20 @@ import {paddingProps} from '../../props/padding'
6
6
  import {DENSITY, type Density} from '../../types/Density'
7
7
  import type {InteractiveAs} from '../../types/Interactive'
8
8
  import type {ListTag} from '../../types/List'
9
- import {type PropDef} from '../../types/PropDef'
9
+ import type {Polymorphic} from '../../types/Polymorphic'
10
+ import type {PropDef} from '../../types/PropDef'
10
11
  import type {Responsive} from '../../types/Responsive'
11
12
 
12
13
  /** @beta */
13
- export interface ListProps<T extends ListTag = 'ul'> extends Pick<GapProps, 'gap'> {
14
- /**
15
- * HTML element to render.
16
- */
17
- as?: T
18
- }
14
+ export type ListProps<T extends ListTag = 'ul'> = Polymorphic<
15
+ T,
16
+ Pick<GapProps, 'gap'> & {
17
+ /**
18
+ * HTML element to render.
19
+ */
20
+ as?: T
21
+ }
22
+ >
19
23
 
20
24
  export const listProps: Record<string, PropDef> = {
21
25
  as: {
@@ -25,22 +29,50 @@ export const listProps: Record<string, PropDef> = {
25
29
  }
26
30
 
27
31
  /** @beta */
28
- export interface ListItemProps extends React.ComponentProps<'li'> {
29
- /**
30
- * Sets horizontal padding, gap, and minimum row height together.
31
- */
32
- density?: Responsive<Density>
33
- /**
34
- * Slot at the left edge of the row.
35
- */
36
- start?: React.ReactNode
37
- /**
38
- * Slot at the right edge of the row.
39
- */
40
- end?: React.ReactNode
41
- }
32
+ export interface ListItemProps extends ComponentProps<'li'> {}
33
+
34
+ /** @beta */
35
+ export type ListItemButtonProps<T extends ElementType = 'button'> = Polymorphic<
36
+ T,
37
+ {
38
+ /**
39
+ * Element or component to render for the press target.
40
+ */
41
+ as?: InteractiveAs<T>
42
+ /**
43
+ * Marks the row as the current selection.
44
+ */
45
+ current?: boolean
46
+ /**
47
+ * Sets horizontal padding, gap, and minimum row height together.
48
+ */
49
+ density?: Responsive<Density>
50
+ /**
51
+ * Slot at the left edge of the row.
52
+ */
53
+ start?: ReactNode
54
+ /**
55
+ * Slot at the right edge of the row.
56
+ */
57
+ end?: ReactNode
58
+ /**
59
+ * Main label.
60
+ */
61
+ text?: ReactNode
62
+ /**
63
+ * Text below the title.
64
+ */
65
+ subtext?: ReactNode
66
+ }
67
+ >
42
68
 
43
- export const listItemProps: Record<string, PropDef> = {
69
+ export const listButtonProps: Record<string, PropDef> = {
70
+ as: {
71
+ type: 'string',
72
+ },
73
+ current: {
74
+ type: 'boolean',
75
+ },
44
76
  density: {
45
77
  type: 'composite',
46
78
  values: DENSITY,
@@ -77,54 +109,13 @@ export const listItemProps: Record<string, PropDef> = {
77
109
  start: {
78
110
  type: 'string',
79
111
  },
80
- }
81
-
82
- /** @beta */
83
- export interface ListButtonItemProps<T extends React.ElementType = 'button'> extends ListItemProps {
84
- /**
85
- * Element or component to render for the press target.
86
- */
87
- as?: InteractiveAs<T>
88
- /**
89
- * Marks the row as the current selection.
90
- */
91
- selected?: boolean
92
- }
93
-
94
- export const listButtonItemProps: Record<string, PropDef> = {
95
- as: {
112
+ text: {
96
113
  type: 'string',
97
114
  },
98
- selected: {
99
- type: 'boolean',
115
+ subtext: {
116
+ type: 'string',
100
117
  },
101
- ...listItemProps,
102
118
  }
103
119
 
104
120
  /** @beta */
105
- export interface ListItemTextProps<T extends React.ElementType = 'div'> {
106
- /**
107
- * HTML element to render.
108
- */
109
- as?: T
110
- /**
111
- * Main label.
112
- */
113
- title?: React.ReactNode
114
- /**
115
- * Text below the title.
116
- */
117
- subtitle?: React.ReactNode
118
- }
119
-
120
- export const listItemTextProps: Record<string, PropDef> = {
121
- as: {
122
- type: 'string',
123
- },
124
- title: {
125
- type: 'string',
126
- },
127
- subtitle: {
128
- type: 'string',
129
- },
130
- }
121
+ export interface ListImageProps extends ComponentProps<'img'> {}
@@ -1,23 +1,25 @@
1
+ import type {ComponentProps, ReactElement, ReactNode} from 'react'
2
+
1
3
  import {type PlacementProps, placementProps} from '../../props/placement'
2
- import {type PropDef} from '../../types/PropDef'
4
+ import type {PropDef} from '../../types/PropDef'
3
5
 
4
6
  /** @beta */
5
7
  export interface PopoverProps
6
- extends Omit<React.ComponentProps<'div'>, 'children' | 'content'>, PlacementProps {
8
+ extends Omit<ComponentProps<'div'>, 'children' | 'content'>, PlacementProps {
7
9
  /**
8
10
  * Shared anchor identifier.
9
11
  * @remarks Set the same value on a Tooltip and a Popover to point both at one trigger.
10
12
  */
11
- anchorName?: React.ReactNode
13
+ anchorName?: ReactNode
12
14
  /**
13
15
  * The trigger element.
14
16
  * @remarks Popover clones it and attaches the `popovertarget` attribute that opens the floating layer.
15
17
  */
16
- children: React.ReactElement<Record<string, unknown>>
18
+ children: ReactElement<Record<string, unknown>>
17
19
  /**
18
20
  * The floating content.
19
21
  */
20
- content?: React.ReactNode
22
+ content?: ReactNode
21
23
  /**
22
24
  * Removes popover padding.
23
25
  */
@@ -1,5 +1,5 @@
1
1
  import clsx from 'clsx'
2
- import type {ComponentPropsWithRef, ElementType} from 'react'
2
+ import type {ElementType} from 'react'
3
3
 
4
4
  import {getProps} from '../../utils/getProps'
5
5
  import {suffixClassName} from '../../utils/suffixClassName'
@@ -8,9 +8,7 @@ import {type PressAreaProps, pressAreaProps} from './pressArea.props'
8
8
  const pressAreaClassName = suffixClassName('sui-PressArea')
9
9
 
10
10
  /** @public */
11
- export function PressArea<T extends ElementType = 'button'>(
12
- props: PressAreaProps<T> & Omit<ComponentPropsWithRef<T>, keyof PressAreaProps<T>>,
13
- ) {
11
+ export function PressArea<T extends ElementType = 'button'>(props: PressAreaProps<T>) {
14
12
  const {as, children, className, style, ...rest} = getProps(props, pressAreaProps)
15
13
  const Component = as || 'button'
16
14
 
@@ -1,4 +1,4 @@
1
- .sui-PressArea {
1
+ :where(.sui-PressArea) {
2
2
  background: none;
3
3
  font: inherit;
4
4
  color: inherit;
@@ -16,7 +16,13 @@
16
16
  pointer-events: none;
17
17
  }
18
18
 
19
- .sui-PressArea .sui-Text,
19
+ .sui-PressArea .sui-Text {
20
+ --press-area-color: inherit;
21
+ color: var(--press-area-color);
22
+ }
23
+
24
+ .sui-PressArea .sui-Text:where(.sui-text-muted),
20
25
  .sui-PressArea [data-sanity-icon] {
21
- color: inherit;
26
+ --press-area-color-muted: inherit;
27
+ color: var(--press-area-color-muted);
22
28
  }
@@ -1,13 +1,19 @@
1
+ import type {ElementType} from 'react'
2
+
1
3
  import type {InteractiveAs} from '../../types/Interactive'
2
- import {type PropDef} from '../../types/PropDef'
4
+ import type {Polymorphic} from '../../types/Polymorphic'
5
+ import type {PropDef} from '../../types/PropDef'
3
6
 
4
7
  /** @public */
5
- export interface PressAreaProps<T extends React.ElementType = 'button'> {
6
- /**
7
- * Element or component to render.
8
- */
9
- as?: InteractiveAs<T>
10
- }
8
+ export type PressAreaProps<T extends ElementType = 'button'> = Polymorphic<
9
+ T,
10
+ {
11
+ /**
12
+ * Element or component to render.
13
+ */
14
+ as?: InteractiveAs<T>
15
+ }
16
+ >
11
17
 
12
18
  export const pressAreaProps: Record<string, PropDef> = {
13
19
  as: {
@@ -1,2 +1,3 @@
1
+ import type {ComponentProps} from 'react'
1
2
  /** @beta */
2
- export interface RadioProps extends React.ComponentProps<'input'> {}
3
+ export interface RadioProps extends ComponentProps<'input'> {}
@@ -1,8 +1,10 @@
1
+ import type {ComponentProps} from 'react'
2
+
1
3
  import {formElementDensityProps, type FormElementDensityProps} from '../../props/formElement'
2
- import {type PropDef} from '../../types/PropDef'
4
+ import type {PropDef} from '../../types/PropDef'
3
5
 
4
6
  /** @public */
5
- export interface SelectProps extends React.ComponentProps<'select'>, FormElementDensityProps {
7
+ export interface SelectProps extends ComponentProps<'select'>, FormElementDensityProps {
6
8
  /**
7
9
  * Used to trigger styling for invalid states.
8
10
  * @remarks Use when form validation fails. Pair with a visible error message.
@@ -1,7 +1,9 @@
1
- import {type PropDef} from '../../types/PropDef'
1
+ import type {ComponentProps} from 'react'
2
+
3
+ import type {PropDef} from '../../types/PropDef'
2
4
 
3
5
  /** @beta */
4
- export interface SkipToContentProps extends React.ComponentProps<'a'> {
6
+ export interface SkipToContentProps extends ComponentProps<'a'> {
5
7
  /**
6
8
  * Same-page fragment to jump to.
7
9
  * @remarks Note: The hash character # is required for proper linking.
@@ -1,9 +1,11 @@
1
+ import type {ComponentProps} from 'react'
2
+
1
3
  import {ICON_SIZE, type IconSize} from '../../types/Icon'
2
- import {type PropDef} from '../../types/PropDef'
4
+ import type {PropDef} from '../../types/PropDef'
3
5
  import type {Responsive} from '../../types/Responsive'
4
6
 
5
7
  /** @public */
6
- export interface SpinnerProps extends React.ComponentProps<'svg'> {
8
+ export interface SpinnerProps extends ComponentProps<'svg'> {
7
9
  /**
8
10
  * Size of the spinner icon.
9
11
  */
@@ -1,7 +1,9 @@
1
- import {type PropDef} from '../../types/PropDef'
1
+ import type {ComponentProps} from 'react'
2
+
3
+ import type {PropDef} from '../../types/PropDef'
2
4
 
3
5
  /** @beta */
4
- export interface SwitchProps extends React.ComponentProps<'input'> {
6
+ export interface SwitchProps extends ComponentProps<'input'> {
5
7
  /**
6
8
  * Applies error styling to the switch track for invalid states.
7
9
  * @remarks Use when form validation fails. Pair with a visible error message.
@@ -1,9 +1,11 @@
1
+ import type {ComponentProps, ReactNode, ElementType} from 'react'
2
+
1
3
  import type {LayoutProps} from '../../props/layout'
2
4
  import {toneProps, type ToneProps} from '../../props/tone'
3
- import {type PropDef} from '../../types/PropDef'
5
+ import type {PropDef} from '../../types/PropDef'
4
6
 
5
7
  /** @public */
6
- export interface TabsProps extends React.ComponentProps<'div'> {
8
+ export interface TabsProps extends ComponentProps<'div'> {
7
9
  /** The `value` of the active Tabs.Tab */
8
10
  value: string
9
11
  /** An updater function to set `value` - will be invoked with the `value` of the selected Tabs.Tab */
@@ -22,17 +24,15 @@ type TabsListLabelProps =
22
24
  | {'aria-label': string; 'aria-labelledby'?: never}
23
25
 
24
26
  /** @public */
25
- export type TabsListProps = Omit<React.ComponentProps<'div'>, 'id' | 'role'> & TabsListLabelProps
27
+ export type TabsListProps = Omit<ComponentProps<'div'>, 'id' | 'role'> & TabsListLabelProps
26
28
 
27
29
  export const tabsListProps: Record<string, PropDef> = {}
28
30
 
29
31
  /** @public */
30
32
  export interface TabProps
31
- extends
32
- Omit<React.ComponentProps<'button'>, 'aria-disabled' | 'disabled' | 'id' | 'role'>,
33
- ToneProps {
33
+ extends Omit<ComponentProps<'button'>, 'aria-disabled' | 'disabled' | 'id' | 'role'>, ToneProps {
34
34
  /** Optional icon for the tab */
35
- icon?: React.ElementType | React.ReactNode
35
+ icon?: ElementType | ReactNode
36
36
  /** Text label to display in the tab */
37
37
  label: string
38
38
  /** Unique string used to identify this tab and its matching Tabs.Panel */
@@ -53,8 +53,7 @@ export const tabProps: Record<string, PropDef> = {
53
53
  }
54
54
 
55
55
  /** @public */
56
- export interface TabsPanelProps
57
- extends Omit<React.ComponentProps<'div'>, 'id' | 'role'>, LayoutProps {
56
+ export interface TabsPanelProps extends Omit<ComponentProps<'div'>, 'id' | 'role'>, LayoutProps {
58
57
  /** Unique string used to identify this panel and its matching Tabs.Tab */
59
58
  value: string
60
59
  }
@@ -1,5 +1,5 @@
1
1
  import clsx from 'clsx'
2
- import type {ComponentPropsWithRef, ElementType} from 'react'
2
+ import type {ElementType} from 'react'
3
3
 
4
4
  import {getProps} from '../../utils/getProps'
5
5
  import {suffixClassName} from '../../utils/suffixClassName'
@@ -8,10 +8,7 @@ import {type TextProps, textProps} from './text.props'
8
8
  const textClassName = suffixClassName('sui-Text')
9
9
 
10
10
  /** @public */
11
- export function Text<T extends ElementType = 'span'>({
12
- size = 2,
13
- ...props
14
- }: TextProps<T> & Omit<ComponentPropsWithRef<T>, keyof TextProps<T>>) {
11
+ export function Text<T extends ElementType = 'span'>({size = 2, ...props}: TextProps<T>) {
15
12
  const {as, children, className, style, ...rest} = getProps({size, ...props}, textProps)
16
13
  const Component = as || 'span'
17
14
 
@@ -1,22 +1,29 @@
1
+ import type {ElementType} from 'react'
2
+
1
3
  import {marginProps, type MarginProps} from '../../props/margin'
2
4
  import {toneProps, type ToneProps} from '../../props/tone'
3
5
  import {type TypographyProps, typographyProps} from '../../props/typography'
4
- import {type PropDef} from '../../types/PropDef'
6
+ import type {Polymorphic} from '../../types/Polymorphic'
7
+ import type {PropDef} from '../../types/PropDef'
5
8
  import type {Responsive} from '../../types/Responsive'
6
9
  import {TEXT_SIZE, type TextSize} from '../../types/Text'
7
10
 
8
11
  /** @public */
9
- export interface TextProps<T extends React.ElementType = 'span'>
10
- extends MarginProps, ToneProps, TypographyProps {
11
- /**
12
- * HTML element to render.
13
- */
14
- as?: T
15
- /**
16
- * Sets font size.
17
- */
18
- size?: Responsive<TextSize>
19
- }
12
+ export type TextProps<T extends ElementType = 'span'> = Polymorphic<
13
+ T,
14
+ MarginProps &
15
+ ToneProps &
16
+ TypographyProps & {
17
+ /**
18
+ * HTML element to render.
19
+ */
20
+ as?: T
21
+ /**
22
+ * Sets font size.
23
+ */
24
+ size?: Responsive<TextSize>
25
+ }
26
+ >
20
27
 
21
28
  export const textProps: Record<string, PropDef> = {
22
29
  as: {