@sanity/ui 5.0.0-alpha.2 → 5.0.0-alpha.21

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 (140) hide show
  1. package/README.md +1 -1
  2. package/dist/LazyRefractor-CQ22IeXB.js +19 -0
  3. package/dist/LazyRefractor-CQ22IeXB.js.map +1 -0
  4. package/dist/cli/install.js +2 -1
  5. package/dist/index.d.ts +826 -855
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +2439 -1796
  8. package/dist/index.js.map +1 -1
  9. package/dist/polyfills.d.ts +1 -0
  10. package/dist/polyfills.js +5 -0
  11. package/dist/polyfills.js.map +1 -0
  12. package/dist/styles.css +1 -1
  13. package/package.json +16 -9
  14. package/src/cli/install.ts +2 -1
  15. package/src/components/avatar/Avatar.tsx +50 -0
  16. package/src/components/avatar/avatar.css +51 -0
  17. package/src/components/avatar/avatar.props.ts +57 -0
  18. package/src/components/avatar-counter/AvatarCounter.tsx +38 -0
  19. package/src/components/avatar-counter/avatar-counter.css +8 -0
  20. package/src/components/avatar-counter/avatarCounter.props.ts +44 -0
  21. package/src/components/avatar-stack/AvatarStack.tsx +60 -0
  22. package/src/components/avatar-stack/avatar-stack.css +16 -0
  23. package/src/components/avatar-stack/avatarStack.props.ts +20 -0
  24. package/src/components/badge/Badge.tsx +53 -0
  25. package/src/components/badge/badge.css +6 -0
  26. package/src/components/badge/badge.props.ts +31 -0
  27. package/src/components/box/box.css +5 -0
  28. package/src/components/box/box.props.ts +7 -2
  29. package/src/components/button/Button.tsx +7 -1
  30. package/src/components/button/button.css +51 -23
  31. package/src/components/button/button.props.ts +27 -9
  32. package/src/components/card/Card.tsx +1 -1
  33. package/src/components/card/card.props.ts +10 -5
  34. package/src/components/checkbox/Checkbox.tsx +15 -29
  35. package/src/components/checkbox/checkbox.css +19 -20
  36. package/src/components/checkbox/checkbox.props.ts +11 -12
  37. package/src/components/code/Code.tsx +18 -19
  38. package/src/components/code/code.props.ts +23 -14
  39. package/src/components/container/Container.tsx +5 -1
  40. package/src/components/container/container.css +4 -0
  41. package/src/components/container/container.props.ts +6 -2
  42. package/src/components/dialog/Dialog.tsx +139 -0
  43. package/src/components/dialog/dialog.css +49 -0
  44. package/src/components/dialog/dialog.props.ts +45 -0
  45. package/src/components/eyebrow/eyebrow.props.ts +6 -2
  46. package/src/components/flex/flex.css +5 -0
  47. package/src/components/flex/flex.props.ts +6 -2
  48. package/src/components/grid/grid.css +5 -0
  49. package/src/components/grid/grid.props.ts +14 -3
  50. package/src/components/h-stack/HStack.tsx +8 -14
  51. package/src/components/h-stack/hStack.props.ts +5 -13
  52. package/src/components/heading/Heading.tsx +8 -3
  53. package/src/components/heading/heading.css +0 -5
  54. package/src/components/heading/heading.props.ts +16 -5
  55. package/src/components/hotkeys/Hotkeys.tsx +29 -0
  56. package/src/components/hotkeys/hotkeys.css +3 -0
  57. package/src/components/hotkeys/hotkeys.props.ts +15 -0
  58. package/src/components/icon/Icon.tsx +22 -11
  59. package/src/components/icon/icon.props.ts +7 -3
  60. package/src/components/icon-button/iconButton.props.ts +7 -2
  61. package/src/components/index.css +12 -1
  62. package/src/components/indicator/indicator.css +1 -1
  63. package/src/components/indicator/indicator.props.ts +6 -2
  64. package/src/components/indicator-stack/indicatorStack.props.ts +3 -1
  65. package/src/components/inline/inline.props.ts +6 -2
  66. package/src/components/kbd/KBD.tsx +33 -0
  67. package/src/components/kbd/kbd.css +6 -0
  68. package/src/components/kbd/kbd.props.ts +20 -0
  69. package/src/components/link/link.props.ts +4 -4
  70. package/src/components/list/list.props.ts +27 -9
  71. package/src/components/popover/Popover.tsx +85 -0
  72. package/src/components/popover/popover.css +21 -0
  73. package/src/components/popover/popover.props.ts +38 -0
  74. package/src/components/press-area/pressArea.props.ts +3 -1
  75. package/src/components/radio/Radio.tsx +10 -28
  76. package/src/components/radio/radio.css +17 -32
  77. package/src/components/radio/radio.props.ts +1 -19
  78. package/src/components/select/Select.tsx +41 -0
  79. package/src/components/select/select.css +67 -0
  80. package/src/components/select/select.props.ts +18 -0
  81. package/src/components/skip-to-content/skipToContent.props.ts +9 -3
  82. package/src/components/spinner/Spinner.tsx +2 -1
  83. package/src/components/spinner/spinner.props.ts +3 -0
  84. package/src/components/switch/Switch.tsx +9 -21
  85. package/src/components/switch/switch.css +22 -23
  86. package/src/components/switch/switch.props.ts +7 -11
  87. package/src/components/tabs/Tabs.tsx +186 -0
  88. package/src/components/tabs/tabs.css +34 -0
  89. package/src/components/tabs/tabs.props.ts +66 -0
  90. package/src/components/text/text.props.ts +6 -2
  91. package/src/components/text-area/TextArea.tsx +32 -0
  92. package/src/components/text-area/text-area.css +56 -0
  93. package/src/components/text-area/textArea.props.ts +35 -0
  94. package/src/components/text-input/TextInput.tsx +32 -0
  95. package/src/components/text-input/text-input.css +55 -0
  96. package/src/components/text-input/textInput.props.ts +42 -0
  97. package/src/components/tooltip/Tooltip.tsx +59 -55
  98. package/src/components/tooltip/tooltip.css +21 -40
  99. package/src/components/tooltip/tooltip.props.ts +24 -8
  100. package/src/components/tooltip-group/TooltipGroup.tsx +2 -5
  101. package/src/components/tooltip-group/tooltipGroup.props.ts +3 -1
  102. package/src/components/v-stack/VStack.tsx +8 -14
  103. package/src/components/v-stack/vStack.props.ts +5 -13
  104. package/src/components/visually-hidden/visuallyHidden.props.ts +6 -2
  105. package/src/css/classes/dynamic/height.css +2 -0
  106. package/src/css/classes/generic/display.css +8 -8
  107. package/src/css/classes/generic/placement.css +105 -86
  108. package/src/css/classes/local/animation.css +4 -0
  109. package/src/css/classes/local/field-sizing.css +3 -0
  110. package/src/css/classes/local/index.css +3 -1
  111. package/src/css/classes/local/text-trim.css +11 -4
  112. package/src/css/classes/local/top-anchor.css +4 -0
  113. package/src/css/classes/system/shadow.css +6 -6
  114. package/src/css/classes/system/typography.css +0 -4
  115. package/src/css/global/reset.css +16 -1
  116. package/src/css/tokens/semantic.css +7 -6
  117. package/src/css/tokens/surface.css +80 -12
  118. package/src/hooks/useIsClient.ts +10 -0
  119. package/src/index.ts +17 -2
  120. package/src/polyfills.ts +17 -0
  121. package/src/props/formElement.ts +34 -0
  122. package/src/props/layout.ts +3 -3
  123. package/src/props/tone.ts +13 -2
  124. package/src/types/Avatar.ts +14 -0
  125. package/src/types/Code.ts +0 -3
  126. package/src/types/Eyebrow.ts +1 -1
  127. package/src/types/FormElement.ts +2 -0
  128. package/src/types/Heading.ts +1 -1
  129. package/src/types/TextAlign.ts +1 -1
  130. package/src/types/Tone.ts +2 -0
  131. package/src/utils/getProps.ts +1 -1
  132. package/src/utils/mergeTriggerProps.ts +66 -0
  133. package/src/utils/renderPortal.tsx +14 -0
  134. package/src/version.ts +2 -2
  135. package/dist/_chunks-es/LazyRefractor.js +0 -20
  136. package/dist/_chunks-es/LazyRefractor.js.map +0 -1
  137. package/src/components/label/Label.tsx +0 -34
  138. package/src/components/label/label.css +0 -3
  139. package/src/components/label/label.props.ts +0 -19
  140. package/src/css/classes/local/tone.css +0 -75
@@ -2,7 +2,9 @@ import {type PropDef} from '../../types/PropDef'
2
2
 
3
3
  /** @public */
4
4
  export interface IndicatorStackProps<T extends React.ElementType = 'div'> {
5
- /** Element to render */
5
+ /**
6
+ * HTML element to render.
7
+ */
6
8
  as?: T
7
9
  }
8
10
 
@@ -7,9 +7,13 @@ import {SPACE, type SpaceInherit} from '../../types/Space'
7
7
  /** @deprecated Use HStack component instead */
8
8
  /** @public */
9
9
  export interface InlineProps<T extends React.ElementType = 'div'> extends PaddingProps {
10
- /** Element to render */
10
+ /**
11
+ * HTML element or component to render.
12
+ */
11
13
  as?: T
12
- /** CSS **gap** property */
14
+ /**
15
+ * Space between children.
16
+ */
13
17
  gap?: Responsive<SpaceInherit>
14
18
  }
15
19
 
@@ -0,0 +1,33 @@
1
+ import clsx from 'clsx'
2
+
3
+ import {getProps} from '../../utils/getProps'
4
+ import {suffixClassName} from '../../utils/suffixClassName'
5
+ import {Text} from '../text/Text'
6
+ import {type KBDProps, kbdProps} from './kbd.props'
7
+
8
+ const kbdClassName = suffixClassName('sui-KBD')
9
+
10
+ /** @alpha */
11
+ export function KBD(props: KBDProps) {
12
+ const {className, style, text, ...rest} = getProps(props, kbdProps)
13
+
14
+ const kbdClasses = clsx(kbdClassName, 'sui-p1 sui-radius2 sui-display-inline-block')
15
+
16
+ return (
17
+ <Text
18
+ as="kbd"
19
+ className={clsx(kbdClasses, className)}
20
+ style={style}
21
+ data-ui="KBD"
22
+ size={0}
23
+ weight="semibold"
24
+ muted
25
+ trim
26
+ {...rest}
27
+ >
28
+ {text}
29
+ </Text>
30
+ )
31
+ }
32
+
33
+ export type {KBDProps}
@@ -0,0 +1,6 @@
1
+ .sui-KBD {
2
+ --kbd-background: var(--backdrop);
3
+ --kbd-border-color: var(--separator-low);
4
+ background-color: var(--kbd-background);
5
+ box-shadow: inset 0 0 0 1px var(--kbd-border-color);
6
+ }
@@ -0,0 +1,20 @@
1
+ import {type PropDef} from '../../types/PropDef'
2
+
3
+ /** @public */
4
+ export interface KBDProps extends React.ComponentProps<'kbd'> {
5
+ /**
6
+ * Sets KBD's key label.
7
+ */
8
+ text?: string
9
+ /**
10
+ * Not accepted.
11
+ * @remarks Pass the key label via `text`.
12
+ */
13
+ children?: never
14
+ }
15
+
16
+ export const kbdProps: Record<string, PropDef> = {
17
+ text: {
18
+ type: 'string',
19
+ },
20
+ }
@@ -2,12 +2,12 @@ import {type PropDef} from '../../types/PropDef'
2
2
 
3
3
  /** @beta */
4
4
  export interface LinkProps extends React.ComponentProps<'a'> {
5
- /** If true, sets `target="_blank"` and `rel="noopener noreferrer"` */
5
+ /**
6
+ * Sets the link to `target="_blank"` and `rel="noopener noreferrer"`.
7
+ */
6
8
  openInNewTab?: boolean
7
9
  /**
8
- * If true, sets `text-decoration: underline`
9
- *
10
- * @defaultValue true
10
+ * Underlines the link.
11
11
  */
12
12
  underlined?: boolean
13
13
  }
@@ -11,7 +11,9 @@ import type {Responsive} from '../../types/Responsive'
11
11
 
12
12
  /** @beta */
13
13
  export interface ListProps<T extends ListTag = 'ul'> extends Pick<GapProps, 'gap'> {
14
- /** Element to render */
14
+ /**
15
+ * HTML element to render.
16
+ */
15
17
  as?: T
16
18
  }
17
19
 
@@ -24,11 +26,17 @@ export const listProps: Record<string, PropDef> = {
24
26
 
25
27
  /** @beta */
26
28
  export interface ListItemProps extends React.ComponentProps<'li'> {
27
- /** Composite prop for setting padding and gap */
29
+ /**
30
+ * Sets horizontal padding, gap, and minimum row height together.
31
+ */
28
32
  density?: Responsive<Density>
29
- /** Starting slot */
33
+ /**
34
+ * Slot at the left edge of the row.
35
+ */
30
36
  start?: React.ReactNode
31
- /** Ending slot */
37
+ /**
38
+ * Slot at the right edge of the row.
39
+ */
32
40
  end?: React.ReactNode
33
41
  }
34
42
 
@@ -73,9 +81,13 @@ export const listItemProps: Record<string, PropDef> = {
73
81
 
74
82
  /** @beta */
75
83
  export interface ListButtonItemProps<T extends React.ElementType = 'button'> extends ListItemProps {
76
- /** Element to render */
84
+ /**
85
+ * Element or component to render for the press target.
86
+ */
77
87
  as?: InteractiveAs<T>
78
- /** Selected state */
88
+ /**
89
+ * Marks the row as the current selection.
90
+ */
79
91
  selected?: boolean
80
92
  }
81
93
 
@@ -91,11 +103,17 @@ export const listButtonItemProps: Record<string, PropDef> = {
91
103
 
92
104
  /** @beta */
93
105
  export interface ListItemTextProps<T extends React.ElementType = 'div'> {
94
- /** Element to render */
106
+ /**
107
+ * HTML element to render.
108
+ */
95
109
  as?: T
96
- /** Title text */
110
+ /**
111
+ * Main label.
112
+ */
97
113
  title?: React.ReactNode
98
- /** Subtitle text */
114
+ /**
115
+ * Text below the title.
116
+ */
99
117
  subtitle?: React.ReactNode
100
118
  }
101
119
 
@@ -0,0 +1,85 @@
1
+ import clsx from 'clsx'
2
+ import {Activity, cloneElement, useId, useState, type ToggleEvent} from 'react'
3
+
4
+ import {useIsClient} from '../../hooks/useIsClient'
5
+ import {getProps} from '../../utils/getProps'
6
+ import {mergeTriggerProps} from '../../utils/mergeTriggerProps'
7
+ import {renderPortal} from '../../utils/renderPortal'
8
+ import {suffixClassName} from '../../utils/suffixClassName'
9
+ import {type PopoverProps, popoverProps} from './popover.props'
10
+
11
+ const popoverClassName = suffixClassName('sui-PopoverContent')
12
+
13
+ function PopoverRoot({
14
+ placement = 'bottom',
15
+ ...props
16
+ }: PopoverProps & {
17
+ triggerProps?: Record<string, unknown>
18
+ }) {
19
+ const {
20
+ children,
21
+ className,
22
+ style,
23
+ id: idProp,
24
+ anchorName,
25
+ content,
26
+ portal,
27
+ triggerProps: forwardedTriggerProps,
28
+ ...rest
29
+ } = getProps({placement, ...props}, popoverProps)
30
+ const reactId = useId()
31
+ const id = idProp || reactId
32
+ const [open, setOpen] = useState(false)
33
+ const isClient = useIsClient()
34
+
35
+ const handleToggle = (e: ToggleEvent) => {
36
+ setOpen(e.newState === 'open')
37
+ }
38
+
39
+ const triggerProps = {
40
+ popoverTarget: id,
41
+ style: {anchorName: `--anchor-${anchorName || id}`},
42
+ }
43
+
44
+ const trigger = children.type.forwardsTriggerProps
45
+ ? cloneElement(children, {triggerProps})
46
+ : cloneElement(children, mergeTriggerProps(children.props, forwardedTriggerProps, triggerProps))
47
+
48
+ return (
49
+ <>
50
+ {trigger}
51
+
52
+ {renderPortal(
53
+ <Activity mode={open ? 'visible' : 'hidden'}>
54
+ <div
55
+ className={clsx(
56
+ popoverClassName,
57
+ 'sui-px2 sui-py1 sui-radius2 sui-position-fixed sui-shadow2',
58
+ className,
59
+ )}
60
+ style={{
61
+ ...style,
62
+ positionAnchor: `--anchor-${anchorName || id}`,
63
+ }}
64
+ data-ui="Popover"
65
+ popover="auto"
66
+ id={id}
67
+ onToggle={handleToggle}
68
+ {...rest}
69
+ >
70
+ {content}
71
+ </div>
72
+ </Activity>,
73
+ isClient,
74
+ portal,
75
+ )}
76
+ </>
77
+ )
78
+ }
79
+
80
+ /** @beta */
81
+ export const Popover = Object.assign(PopoverRoot, {
82
+ forwardsTriggerProps: true,
83
+ })
84
+
85
+ export type {PopoverProps}
@@ -0,0 +1,21 @@
1
+ .sui-PopoverContent {
2
+ visibility: hidden;
3
+ opacity: 0;
4
+ scale: 0.9;
5
+ transition: none;
6
+ }
7
+
8
+ .sui-PopoverContent:popover-open {
9
+ visibility: visible;
10
+ opacity: 1;
11
+ scale: 1;
12
+ transition: var(--fade-in-transition);
13
+ }
14
+
15
+ @starting-style {
16
+ .sui-PopoverContent:popover-open {
17
+ visibility: hidden;
18
+ opacity: 0;
19
+ scale: 0.9;
20
+ }
21
+ }
@@ -0,0 +1,38 @@
1
+ import {type PlacementProps, placementProps} from '../../props/placement'
2
+ import {type PropDef} from '../../types/PropDef'
3
+
4
+ /** @beta */
5
+ export interface PopoverProps
6
+ extends Omit<React.ComponentProps<'div'>, 'children' | 'content'>, PlacementProps {
7
+ /**
8
+ * Shared anchor identifier.
9
+ * @remarks Set the same value on a Tooltip and a Popover to point both at one trigger.
10
+ */
11
+ anchorName?: React.ReactNode
12
+ /**
13
+ * The trigger element.
14
+ * @remarks Popover clones it and attaches the `popovertarget` attribute that opens the floating layer.
15
+ */
16
+ children: React.ReactElement<Record<string, unknown>>
17
+ /**
18
+ * The floating content.
19
+ */
20
+ content?: React.ReactNode
21
+ /**
22
+ * Renders the content into `document.body` through a React portal instead of inline.
23
+ */
24
+ portal?: boolean
25
+ }
26
+
27
+ export const popoverProps: Record<string, PropDef> = {
28
+ anchorName: {
29
+ type: 'string',
30
+ },
31
+ content: {
32
+ type: 'string',
33
+ },
34
+ portal: {
35
+ type: 'boolean',
36
+ },
37
+ ...placementProps,
38
+ }
@@ -3,7 +3,9 @@ import {type PropDef} from '../../types/PropDef'
3
3
 
4
4
  /** @public */
5
5
  export interface PressAreaProps<T extends React.ElementType = 'button'> {
6
- /** Element to render */
6
+ /**
7
+ * Element or component to render.
8
+ */
7
9
  as?: InteractiveAs<T>
8
10
  }
9
11
 
@@ -1,47 +1,29 @@
1
1
  import clsx from 'clsx'
2
2
 
3
- import {getProps} from '../../utils/getProps'
4
3
  import {suffixClassName} from '../../utils/suffixClassName'
5
4
  import {Box} from '../box/Box'
6
- import {Label} from '../label/Label'
7
- import {VisuallyHidden} from '../visually-hidden/VisuallyHidden'
8
- import {type RadioProps, radioProps} from './radio.props'
5
+ import {type RadioProps} from './radio.props'
9
6
 
10
7
  const radioClassName = suffixClassName('sui-Radio')
11
8
  const radioInputClassName = suffixClassName('sui-RadioInput')
12
- const radioMarkClassName = suffixClassName('sui-RadioMark')
13
9
 
14
10
  /** @beta */
15
11
  export function Radio(props: RadioProps) {
16
- const {className, style, label, disabled, error, ...rest} = getProps(props, radioProps)
12
+ const {className, style, ...rest} = props
17
13
 
18
14
  return (
19
- <Label
15
+ <Box
16
+ as="span"
20
17
  className={clsx(radioClassName, className)}
21
18
  style={style}
22
19
  data-ui="Radio"
23
- disabled={disabled}
24
- error={error}
20
+ position="relative"
21
+ radius="full"
22
+ width="17px"
23
+ height="17px"
25
24
  >
26
- <VisuallyHidden
27
- as="input"
28
- type="radio"
29
- className={radioInputClassName}
30
- disabled={disabled}
31
- {...rest}
32
- />
33
-
34
- <Box
35
- as="span"
36
- className={clsx(radioMarkClassName, error && 'sui-error')}
37
- position="relative"
38
- radius="full"
39
- width="17px"
40
- height="17px"
41
- />
42
-
43
- {label}
44
- </Label>
25
+ <input type="radio" className={radioInputClassName} {...rest} />
26
+ </Box>
45
27
  )
46
28
  }
47
29
 
@@ -1,9 +1,4 @@
1
- /**
2
- * Custom radio control, base
3
- */
4
- .sui-RadioMark {
5
- /* Background and border colours are computed relatively in hover states;
6
- we use custom properties to make this easier */
1
+ .sui-Radio {
7
2
  --background-color: var(--backdrop);
8
3
  --border-color: var(--separator-high);
9
4
  background-color: var(--background-color);
@@ -11,10 +6,17 @@
11
6
  transition: var(--hover-transition);
12
7
  }
13
8
 
9
+ .sui-RadioInput {
10
+ opacity: 0;
11
+ position: absolute;
12
+ /* Use negative inset for 24x24 pixel hit area */
13
+ inset: var(--form-element-inset);
14
+ }
15
+
14
16
  /**
15
17
  * Custom radio marker
16
18
  */
17
- .sui-RadioMark:after {
19
+ .sui-Radio:before {
18
20
  content: '';
19
21
  background: var(--active-foreground-emphasized);
20
22
  border-radius: var(--radius-round);
@@ -28,16 +30,14 @@
28
30
  /**
29
31
  * Hover - uses relative border/background colours to darken/lighten in both normal & error state
30
32
  */
31
- /** Radio border (unchecked) */
32
- .sui-Radio:hover .sui-RadioMark {
33
+ .sui-Radio:has(.sui-RadioInput:hover) {
33
34
  border-color: light-dark(
34
35
  oklch(from var(--border-color) calc(l - var(--hover-lightness-delta)) c h),
35
36
  oklch(from var(--border-color) calc(l + var(--hover-lightness-delta)) c h)
36
37
  );
37
38
  }
38
39
 
39
- /* Radio background (checked) */
40
- .sui-Radio:hover .sui-RadioInput:is(:checked) + .sui-RadioMark {
40
+ .sui-Radio:has(.sui-RadioInput:is(:checked):hover) {
41
41
  background-color: light-dark(
42
42
  oklch(from var(--background-color) calc(l - var(--hover-lightness-delta)) c h),
43
43
  oklch(from var(--background-color) calc(l + var(--hover-lightness-delta)) c h)
@@ -47,7 +47,7 @@
47
47
  /**
48
48
  * Focus
49
49
  */
50
- .sui-RadioInput:focus-visible + .sui-RadioMark {
50
+ .sui-Radio:has(.sui-RadioInput:focus-visible) {
51
51
  outline: var(--focus-outline);
52
52
  outline-offset: var(--focus-offset);
53
53
  }
@@ -55,12 +55,12 @@
55
55
  /**
56
56
  * Checked
57
57
  */
58
- .sui-RadioInput:checked + .sui-RadioMark {
58
+ .sui-Radio:has(.sui-RadioInput:checked) {
59
59
  --background-color: var(--active-background-emphasized);
60
60
  --border-color: transparent;
61
61
  }
62
62
 
63
- .sui-RadioInput:checked + .sui-RadioMark:after {
63
+ .sui-Radio:has(.sui-RadioInput:checked):before {
64
64
  inset: 4px;
65
65
  opacity: 1;
66
66
  }
@@ -68,30 +68,15 @@
68
68
  /**
69
69
  * Disabled
70
70
  */
71
- .sui-RadioInput:disabled + .sui-RadioMark {
71
+ .sui-Radio:has(.sui-RadioInput:disabled) {
72
72
  --background-color: var(--inert-background);
73
73
  --border-color: var(--separator-low);
74
74
  }
75
75
 
76
- .sui-RadioInput:disabled + .sui-RadioMark:after {
76
+ .sui-Radio:has(.sui-RadioInput:disabled):before {
77
77
  background: light-dark(var(--gray-300), var(--gray-500));
78
78
  }
79
79
 
80
- /* Turn hover (and all pointer events) off for disabled radios */
81
- .sui-Radio:has(:disabled) {
80
+ .sui-RadioInput:disabled {
82
81
  pointer-events: none;
83
82
  }
84
-
85
- /**
86
- * Error
87
- */
88
- .sui-RadioMark.sui-error {
89
- --border-color: var(--error-separator);
90
- }
91
-
92
- /**
93
- * Error, checked
94
- */
95
- .sui-RadioInput:checked + .sui-RadioMark.sui-error {
96
- --background-color: var(--error-background-emphasized);
97
- }
@@ -1,20 +1,2 @@
1
- import {type MarginProps, marginProps} from '../../props/margin'
2
- import {type PropDef} from '../../types/PropDef'
3
-
4
1
  /** @beta */
5
- export interface RadioProps extends React.ComponentProps<'input'>, MarginProps {
6
- /** Error state */
7
- error?: boolean
8
- /** Input label */
9
- label: React.ReactNode
10
- }
11
-
12
- export const radioProps: Record<string, PropDef> = {
13
- error: {
14
- type: 'boolean',
15
- },
16
- label: {
17
- type: 'string',
18
- },
19
- ...marginProps,
20
- }
2
+ export interface RadioProps extends React.ComponentProps<'input'> {}
@@ -0,0 +1,41 @@
1
+ import SelectIcon from '@sanity/icons/Select'
2
+ import clsx from 'clsx'
3
+ import {useId} from 'react'
4
+
5
+ import {getProps} from '../../utils/getProps'
6
+ import {suffixClassName} from '../../utils/suffixClassName'
7
+ import {Icon} from '../icon/Icon'
8
+ import {type SelectProps, selectProps} from './select.props'
9
+
10
+ const selectClassName = suffixClassName('sui-Select')
11
+
12
+ /** @public */
13
+ export function Select({density = 'regular', hasError = false, ...props}: SelectProps) {
14
+ const {children, className, style, ...rest} = getProps({density, ...props}, selectProps)
15
+
16
+ const anchorId = useId()
17
+ const anchorName = `--anchor-${anchorId}`
18
+
19
+ const selectClasses = clsx(selectClassName, 'sui-radius2', 'sui-width-full', className)
20
+
21
+ const iconClasses = `sui-position-absolute sui-display-flex sui-align-items-center sui-px1`
22
+
23
+ return (
24
+ <>
25
+ <select
26
+ data-ui="Select"
27
+ className={selectClasses}
28
+ style={{...style, anchorName}}
29
+ {...rest}
30
+ aria-invalid={hasError || undefined}
31
+ >
32
+ {children}
33
+ </select>
34
+ <div className={iconClasses} data-ui="Select-icon" style={{positionAnchor: anchorName}}>
35
+ <Icon icon={SelectIcon} size={1} />
36
+ </div>
37
+ </>
38
+ )
39
+ }
40
+
41
+ export type {SelectProps}
@@ -0,0 +1,67 @@
1
+ .sui-Select {
2
+ --background-color: var(--backdrop);
3
+ --border-color: var(--separator-high);
4
+ --color: var(--foreground-high);
5
+ background-color: var(--background-color);
6
+ border: 1px solid var(--border-color);
7
+ font: var(--form-element-text);
8
+ color: var(--color);
9
+ }
10
+
11
+ [data-ui="Select-icon"] {
12
+ --background-color: var(--backdrop);
13
+ background-color: var(--background-color);
14
+ pointer-events: none;
15
+ /* reduce block size by 1px at each end and inset from right to not interrupt Select’s border */
16
+ top: calc(anchor(top) + 1px);
17
+ bottom: calc(anchor(bottom) + 1px);
18
+ right: calc(anchor(right) + 2px);
19
+ }
20
+
21
+ /**
22
+ * Error
23
+ */
24
+ .sui-Select[aria-invalid="true"] {
25
+ --border-color: var(--error-separator);
26
+ --color: var(--error-foreground);
27
+ }
28
+
29
+ .sui-Select[aria-invalid="true"] + [data-ui="Select-icon"] svg {
30
+ color: var(--error-foreground);
31
+ }
32
+
33
+ /**
34
+ * Hover - uses relative border/background colours to darken/lighten in both normal & error state
35
+ */
36
+ .sui-Select:hover {
37
+ border-color: light-dark(
38
+ oklch(from var(--border-color) calc(l - var(--hover-lightness-delta)) c h),
39
+ oklch(from var(--border-color) calc(l + var(--hover-lightness-delta)) c h)
40
+ );
41
+ }
42
+
43
+ /**
44
+ * Disabled
45
+ */
46
+ .sui-Select:disabled {
47
+ --background-color: var(--inert-background);
48
+ --border-color: var(--separator-low);
49
+ --color: var(--inert-foreground);
50
+ pointer-events: none;
51
+ }
52
+
53
+ .sui-Select:disabled + [data-ui="Select-icon"] {
54
+ --background-color: var(--inert-background);
55
+ }
56
+
57
+ .sui-Select:disabled + [data-ui="Select-icon"] svg {
58
+ color: var(--inert-foreground);
59
+ }
60
+
61
+ /**
62
+ * Focus
63
+ */
64
+ .sui-Select:focus-visible {
65
+ outline: var(--focus-outline);
66
+ outline-offset: var(--focus-offset);
67
+ }
@@ -0,0 +1,18 @@
1
+ import {formElementDensityProps, type FormElementDensityProps} from '../../props/formElement'
2
+ import {type PropDef} from '../../types/PropDef'
3
+
4
+ /** @public */
5
+ export interface SelectProps extends React.ComponentProps<'select'>, FormElementDensityProps {
6
+ /**
7
+ * Used to trigger styling for invalid states.
8
+ * @remarks Use when form validation fails. Pair with a visible error message.
9
+ */
10
+ hasError?: boolean
11
+ }
12
+
13
+ export const selectProps: Record<string, PropDef> = {
14
+ hasError: {
15
+ type: 'boolean',
16
+ },
17
+ ...formElementDensityProps,
18
+ }
@@ -3,12 +3,18 @@ import {type PropDef} from '../../types/PropDef'
3
3
  /** @beta */
4
4
  export interface SkipToContentProps extends React.ComponentProps<'a'> {
5
5
  /**
6
- * Anchor href. The target element should be focusable or have `tabindex="-1"`.
6
+ * Same-page fragment to jump to.
7
+ * @remarks Note: The hash character # is required for proper linking.
7
8
  */
8
9
  href: string
9
- /** Visible/announced label */
10
+ /**
11
+ * Visible and announced text.
12
+ */
10
13
  label: string
11
- /** Use label instead */
14
+ /**
15
+ * Not accepted.
16
+ * @remarks Pass text via `label`.
17
+ */
12
18
  children?: never
13
19
  }
14
20
 
@@ -1,4 +1,4 @@
1
- import {SpinnerIcon} from '@sanity/icons'
1
+ import {SpinnerIcon} from '@sanity/icons/Spinner'
2
2
  import clsx from 'clsx'
3
3
 
4
4
  import {getProps} from '../../utils/getProps'
@@ -15,6 +15,7 @@ export function Spinner({size = 2, ...props}: SpinnerProps) {
15
15
  return (
16
16
  <Icon
17
17
  icon={SpinnerIcon}
18
+ size={size}
18
19
  className={clsx(spinnerClassName, className)}
19
20
  style={style}
20
21
  data-ui="Spinner"