@sanity/ui 3.0.0-static.11 → 3.0.0-static.13

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 (251) hide show
  1. package/dist/_chunks-cjs/_visual-editing.js +1293 -1215
  2. package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
  3. package/dist/_chunks-cjs/buildCommand.js +28 -10
  4. package/dist/_chunks-cjs/buildCommand.js.map +1 -1
  5. package/dist/_chunks-es/_visual-editing.mjs +1284 -1202
  6. package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
  7. package/dist/_visual-editing.d.mts +528 -358
  8. package/dist/_visual-editing.d.ts +528 -358
  9. package/dist/cli.js +1 -1
  10. package/dist/css.d.mts +143 -73
  11. package/dist/css.d.ts +143 -73
  12. package/dist/css.js +329 -472
  13. package/dist/css.js.map +1 -1
  14. package/dist/css.mjs +330 -473
  15. package/dist/css.mjs.map +1 -1
  16. package/dist/index.d.mts +1362 -869
  17. package/dist/index.d.ts +1362 -869
  18. package/dist/index.js +383 -308
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +387 -312
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/sanity-palette.css +105 -1
  23. package/dist/sanity-palette.min.css +1 -0
  24. package/dist/sanity-theme.css +4571 -1
  25. package/dist/sanity-theme.min.css +1 -0
  26. package/dist/system.css +22053 -21946
  27. package/dist/system.min.css +1 -0
  28. package/dist/theme.d.mts +51 -106
  29. package/dist/theme.d.ts +51 -106
  30. package/dist/theme.js +9 -9
  31. package/dist/theme.js.map +1 -1
  32. package/dist/theme.mjs +9 -9
  33. package/dist/theme.mjs.map +1 -1
  34. package/package.json +10 -5
  35. package/src/cli/buildCommand.ts +46 -19
  36. package/src/css/_comp.ts +2 -2
  37. package/src/css/{compile/compileStyle.ts → _compileStyle.ts} +7 -7
  38. package/src/css/{system.style.ts → _system.style.ts} +3 -2
  39. package/src/css/aspects/display/display.ts +1 -0
  40. package/src/css/aspects/display/types.ts +2 -3
  41. package/src/css/aspects/flex/types.ts +4 -12
  42. package/src/css/aspects/flexItem/types.ts +1 -3
  43. package/src/css/aspects/font/types.ts +1 -3
  44. package/src/css/aspects/grid/grid.ts +1 -0
  45. package/src/css/aspects/grid/types.ts +5 -9
  46. package/src/css/aspects/gridItem/gridItem.ts +1 -1
  47. package/src/css/aspects/gridItem/types.ts +7 -18
  48. package/src/css/aspects/height/height.ts +3 -4
  49. package/src/css/aspects/inset/inset.ts +1 -0
  50. package/src/css/aspects/margin/margin.ts +1 -0
  51. package/src/css/aspects/margin/types.ts +1 -0
  52. package/src/css/aspects/maxWidth/maxWidth.ts +1 -0
  53. package/src/css/aspects/maxWidth/types.ts +1 -0
  54. package/src/css/aspects/minWidth/minWidth.ts +1 -0
  55. package/src/css/aspects/minWidth/types.ts +2 -0
  56. package/src/css/aspects/overflow/overflow.ts +1 -0
  57. package/src/css/aspects/padding/padding.ts +1 -0
  58. package/src/css/aspects/pointerEvents/pointerEvents.ts +1 -0
  59. package/src/css/aspects/position/position.ts +1 -0
  60. package/src/css/aspects/shadow/shadow.ts +1 -0
  61. package/src/css/aspects/textOverflow/textOverflow.ts +1 -0
  62. package/src/css/aspects/textOverflow/types.ts +1 -0
  63. package/src/css/aspects/width/types.ts +2 -0
  64. package/src/css/aspects/width/width.ts +1 -0
  65. package/src/css/{compile/compilePalette.ts → compilePalette.ts} +14 -10
  66. package/src/css/compileSystem.ts +7 -0
  67. package/src/css/{compile/compileTheme.ts → compileTheme.ts} +1 -0
  68. package/src/css/{compile/compileTheme_v3.ts → compileTheme_v3.ts} +123 -104
  69. package/src/css/components/breadcrumbs/breadcrumbs.ts +1 -0
  70. package/src/css/components/dialog/dialog.ts +7 -0
  71. package/src/css/components/menu/menu.ts +2 -0
  72. package/src/css/components/skeleton/skeleton.ts +4 -0
  73. package/src/css/components/skeleton/types.ts +4 -0
  74. package/src/css/components/toast/toast.ts +5 -0
  75. package/src/css/components/tree/tree.ts +1 -0
  76. package/src/css/composeClassNames.ts +4 -2
  77. package/src/css/constants.ts +2 -0
  78. package/src/css/index.ts +3 -3
  79. package/src/css/primitives/_arrow/_arrow.ts +3 -0
  80. package/src/css/primitives/_input/input.ts +2 -0
  81. package/src/css/primitives/_selectable/_selectable.style.ts +1 -2
  82. package/src/css/primitives/_selectable/selectable.ts +1 -2
  83. package/src/css/primitives/avatar/avatar.style.ts +5 -8
  84. package/src/css/primitives/avatar/avatar.ts +6 -0
  85. package/src/css/primitives/avatar/types.ts +1 -0
  86. package/src/css/primitives/box/types.ts +1 -3
  87. package/src/css/primitives/button/button.ts +4 -21
  88. package/src/css/primitives/button/index.ts +1 -0
  89. package/src/css/primitives/button/types.ts +18 -0
  90. package/src/css/primitives/card/card.style.ts +3 -6
  91. package/src/css/primitives/card/card.ts +2 -2
  92. package/src/css/primitives/card/types.ts +2 -2
  93. package/src/css/primitives/checkbox/checkbox.ts +2 -0
  94. package/src/css/primitives/container/container.ts +1 -0
  95. package/src/css/primitives/container/types.ts +1 -0
  96. package/src/css/primitives/kbd/kbd.ts +1 -0
  97. package/src/css/primitives/label/types.ts +7 -2
  98. package/src/css/primitives/popover/popover.ts +2 -0
  99. package/src/css/primitives/radio/radio.ts +1 -0
  100. package/src/css/primitives/select/select.ts +2 -0
  101. package/src/css/primitives/spinner/spinner.ts +2 -0
  102. package/src/css/primitives/switch/switch.ts +5 -0
  103. package/src/css/primitives/text/types.ts +4 -0
  104. package/src/css/primitives/textArea/textArea.ts +1 -0
  105. package/src/css/primitives/textInput/textInput.ts +1 -0
  106. package/src/css/primitives/tooltip/tooltip.ts +2 -0
  107. package/src/css/scopeClassName.ts +1 -0
  108. package/src/css/types.ts +9 -12
  109. package/src/css/util.ts +5 -0
  110. package/src/css/utils/srOnly/srOnly.ts +3 -1
  111. package/src/css/varNames.ts +131 -141
  112. package/src/css/vars.ts +1 -6
  113. package/src/theme/palette/constants.ts +2 -0
  114. package/src/theme/palette/types.ts +3 -0
  115. package/src/theme/types.ts +2 -6
  116. package/src/theme/v0/focusRing.ts +1 -3
  117. package/src/theme/v0/font.ts +6 -18
  118. package/src/theme/v0/layer.ts +1 -3
  119. package/src/theme/v0/shadow.ts +2 -6
  120. package/src/theme/v2/avatar.ts +1 -3
  121. package/src/theme/v2/color/_system.ts +1 -3
  122. package/src/theme/v2/color/avatar.ts +2 -6
  123. package/src/theme/v2/color/badge.ts +2 -6
  124. package/src/theme/v2/color/button.ts +3 -9
  125. package/src/theme/v2/color/color.ts +3 -9
  126. package/src/theme/v2/color/input.ts +3 -9
  127. package/src/theme/v2/color/kbd.ts +1 -3
  128. package/src/theme/v2/color/selectable.ts +2 -6
  129. package/src/theme/v2/color/state.ts +1 -3
  130. package/src/theme/v2/color/syntax.ts +1 -3
  131. package/src/theme/v2/input.ts +1 -3
  132. package/src/theme/v2/theme.ts +2 -6
  133. package/src/theme/v3/buildTheme_v3.ts +1 -0
  134. package/src/theme/v3/color/color.ts +6 -4
  135. package/src/theme/v3/color/renderColor.ts +4 -1
  136. package/src/theme/v3/defaultTokens.ts +1 -0
  137. package/src/theme/v3/resolveTokens.ts +9 -9
  138. package/src/ui/RootClassNames.tsx +3 -0
  139. package/src/ui/StyleTags.tsx +3 -1
  140. package/src/ui/_compat/theme/themeColorProvider.tsx +2 -6
  141. package/src/ui/_compat/theme/themeProvider.tsx +2 -6
  142. package/src/ui/_compat/theme/types.ts +1 -3
  143. package/src/ui/_compat/theme/useRootTheme.ts +1 -3
  144. package/src/ui/_compat/theme/useTheme.ts +2 -6
  145. package/src/ui/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  146. package/src/ui/components/autocomplete/autocomplete.tsx +86 -114
  147. package/src/ui/components/autocomplete/autocompleteOption.tsx +2 -0
  148. package/src/ui/components/autocomplete/types.ts +3 -8
  149. package/src/ui/components/breadcrumbs/breadcrumbs.tsx +27 -21
  150. package/src/ui/components/dialog/dialog.tsx +89 -291
  151. package/src/ui/components/dialog/dialogCard.tsx +183 -0
  152. package/src/ui/components/dialog/isTargetWithinScope.ts +14 -0
  153. package/src/ui/components/hotkeys/hotkeys.tsx +33 -15
  154. package/src/ui/components/menu/__workshop__/asComponent.tsx +6 -6
  155. package/src/ui/components/menu/menu.tsx +27 -33
  156. package/src/ui/components/menu/menuButton.tsx +10 -14
  157. package/src/ui/components/menu/menuDivider.tsx +25 -13
  158. package/src/ui/components/menu/menuGroup.tsx +34 -26
  159. package/src/ui/components/menu/menuItem.tsx +51 -40
  160. package/src/ui/components/skeleton/codeSkeleton.tsx +53 -0
  161. package/src/ui/components/skeleton/headingSkeleton.tsx +52 -0
  162. package/src/ui/components/skeleton/index.ts +3 -0
  163. package/src/ui/components/skeleton/labelSkeleton.tsx +51 -0
  164. package/src/ui/components/skeleton/skeleton.tsx +39 -16
  165. package/src/ui/components/skeleton/textSkeleton.tsx +31 -110
  166. package/src/ui/components/tab/tab.tsx +23 -19
  167. package/src/ui/components/tab/tabList.tsx +34 -33
  168. package/src/ui/components/tab/tabPanel.tsx +25 -19
  169. package/src/ui/components/toast/toast.tsx +21 -16
  170. package/src/ui/components/toast/toastLayer.tsx +28 -10
  171. package/src/ui/components/toast/toastProvider.tsx +2 -6
  172. package/src/ui/components/toast/types.ts +2 -6
  173. package/src/ui/components/toast/useToast.ts +1 -3
  174. package/src/ui/components/tree/tree.tsx +194 -187
  175. package/src/ui/components/tree/treeGroup.tsx +25 -5
  176. package/src/ui/components/tree/treeItem.tsx +35 -23
  177. package/src/ui/hooks/useClickOutside.ts +2 -6
  178. package/src/ui/hooks/useClickOutsideEvent.ts +3 -9
  179. package/src/ui/primitives/_selectable/selectable.tsx +33 -20
  180. package/src/ui/primitives/avatar/avatar.tsx +28 -31
  181. package/src/ui/primitives/avatar/avatarCounter.tsx +33 -25
  182. package/src/ui/primitives/avatar/avatarStack.tsx +31 -24
  183. package/src/ui/primitives/avatar/types.ts +2 -0
  184. package/src/ui/primitives/badge/__workshop__/props.tsx +1 -9
  185. package/src/ui/primitives/badge/__workshop__/tones.tsx +1 -6
  186. package/src/ui/primitives/badge/badge.tsx +33 -32
  187. package/src/ui/primitives/badge/types.ts +2 -1
  188. package/src/ui/primitives/box/box.tsx +59 -29
  189. package/src/ui/primitives/button/__workshop__/sanityUploadButton.tsx +3 -3
  190. package/src/ui/primitives/button/__workshop__/uploadButton.tsx +2 -1
  191. package/src/ui/primitives/button/button.test.tsx +1 -15
  192. package/src/ui/primitives/button/button.tsx +64 -70
  193. package/src/ui/primitives/card/__workshop__/asComponent.tsx +3 -3
  194. package/src/ui/primitives/card/card.tsx +22 -22
  195. package/src/ui/primitives/card/cardProvider.tsx +2 -0
  196. package/src/ui/primitives/checkbox/checkbox.tsx +26 -15
  197. package/src/ui/primitives/code/code.tsx +24 -22
  198. package/src/ui/primitives/container/container.tsx +26 -15
  199. package/src/ui/primitives/flex/flex.tsx +21 -19
  200. package/src/ui/primitives/grid/grid.tsx +21 -16
  201. package/src/ui/primitives/heading/heading.tsx +42 -19
  202. package/src/ui/primitives/inline/inline.tsx +26 -23
  203. package/src/ui/primitives/kbd/kbd.tsx +25 -23
  204. package/src/ui/primitives/label/label.tsx +41 -26
  205. package/src/ui/primitives/popover/popover.tsx +281 -277
  206. package/src/ui/primitives/popover/popoverCard.tsx +119 -118
  207. package/src/ui/primitives/radio/radio.tsx +30 -14
  208. package/src/ui/primitives/select/select.tsx +24 -16
  209. package/src/ui/primitives/spinner/animatedSpinnerIcon.tsx +4 -2
  210. package/src/ui/primitives/spinner/spinner.tsx +24 -12
  211. package/src/ui/primitives/stack/stack.tsx +27 -18
  212. package/src/ui/primitives/switch/switch.tsx +31 -14
  213. package/src/ui/primitives/text/text.tsx +42 -24
  214. package/src/ui/primitives/textArea/textArea.tsx +33 -18
  215. package/src/ui/primitives/textInput/textInput.tsx +28 -40
  216. package/src/ui/primitives/tooltip/constants.ts +1 -1
  217. package/src/ui/primitives/tooltip/tooltip.tsx +76 -59
  218. package/src/ui/primitives/tooltip/tooltipCard.tsx +89 -82
  219. package/src/ui/primitives/types.ts +1 -3
  220. package/src/ui/types/avatar.ts +3 -6
  221. package/src/ui/types/badge.ts +1 -3
  222. package/src/ui/types/button.ts +1 -3
  223. package/src/ui/types/card.ts +1 -3
  224. package/src/ui/types/dialog.ts +1 -3
  225. package/src/ui/types/props.ts +20 -10
  226. package/src/ui/utils/arrow/arrow.tsx +40 -14
  227. package/src/ui/utils/boundaryElement/boundaryElementProvider.tsx +2 -6
  228. package/src/ui/utils/boundaryElement/types.ts +1 -3
  229. package/src/ui/utils/boundaryElement/useBoundaryElement.ts +1 -3
  230. package/src/ui/utils/elementQuery/elementQuery.tsx +36 -14
  231. package/src/ui/utils/errorBoundary.tsx +2 -0
  232. package/src/ui/utils/index.ts +0 -1
  233. package/src/ui/utils/layer/layer.tsx +23 -93
  234. package/src/ui/utils/layer/layerCard.tsx +92 -0
  235. package/src/ui/utils/layer/layerProvider.tsx +2 -6
  236. package/src/ui/utils/layer/useLayer.ts +1 -3
  237. package/src/ui/utils/portal/portal.ts +2 -6
  238. package/src/ui/utils/portal/portalProvider.tsx +2 -6
  239. package/src/ui/utils/portal/types.ts +1 -3
  240. package/src/ui/utils/portal/usePortal.ts +1 -3
  241. package/src/ui/utils/srOnly/srOnly.tsx +25 -20
  242. package/src/ui/utils/virtualList/virtualList.tsx +36 -24
  243. package/src/css/compile/compileRule.ts +0 -97
  244. package/src/css/compile/compileRules.test.ts +0 -36
  245. package/src/css/compile/compileRules.ts +0 -43
  246. package/src/css/compile/compileSystem.ts +0 -7
  247. package/src/css/compile/types.ts +0 -6
  248. package/src/css/primitives/_selectable/_contants.ts +0 -11
  249. package/src/css/primitives/card/_constants.ts +0 -13
  250. package/src/ui/utils/conditionalWrapper/conditionalWrapper.tsx +0 -23
  251. package/src/ui/utils/conditionalWrapper/index.ts +0 -1
@@ -1,6 +1,4 @@
1
- /**
2
- * @public
3
- */
1
+ /** @public */
4
2
  export interface ThemeColorKBD {
5
3
  bg: string
6
4
  fg: string
@@ -1,12 +1,8 @@
1
1
  import {ThemeColorStateKey, ThemeColorStateToneKey} from './_system'
2
2
  import {ThemeColorState_v2} from './state'
3
3
 
4
- /**
5
- * @public
6
- */
4
+ /** @public */
7
5
  export type ThemeColorSelectableTone_v2 = Record<ThemeColorStateKey, ThemeColorState_v2>
8
6
 
9
- /**
10
- * @public
11
- */
7
+ /** @public */
12
8
  export type ThemeColorSelectable_v2 = Record<ThemeColorStateToneKey, ThemeColorSelectableTone_v2>
@@ -3,9 +3,7 @@ import {ThemeColorAvatar_v2} from './avatar'
3
3
  import {ThemeColorBadge_v2} from './badge'
4
4
  import {ThemeColorKBD} from './kbd'
5
5
 
6
- /**
7
- * @public
8
- */
6
+ /** @public */
9
7
  export interface ThemeColorState_v2 {
10
8
  /** @internal */
11
9
  _blend?: ThemeColorBlendModeKey
@@ -1,6 +1,4 @@
1
- /**
2
- * @public
3
- */
1
+ /** @public */
4
2
  export interface ThemeColorSyntax {
5
3
  atrule: string
6
4
  attrName: string
@@ -1,8 +1,6 @@
1
1
  import {ThemeFocusRing} from '../v0/focusRing'
2
2
 
3
- /**
4
- * @public
5
- */
3
+ /** @public */
6
4
  export interface ThemeInput_v2 {
7
5
  checkbox: {
8
6
  size: number
@@ -7,9 +7,7 @@ import {ThemeAvatar_v2} from './avatar'
7
7
  import {ThemeColorCard_v2, ThemeColorSchemes_v2} from './color'
8
8
  import {ThemeInput_v2} from './input'
9
9
 
10
- /**
11
- * @public
12
- */
10
+ /** @public */
13
11
  export interface RootTheme_v2 {
14
12
  _version: 2
15
13
  avatar: ThemeAvatar_v2
@@ -35,9 +33,7 @@ export interface RootTheme_v2 {
35
33
  /** @internal */
36
34
  style?: ThemeStyles
37
35
  }
38
- /**
39
- * @public
40
- */
36
+ /** @public */
41
37
  export type Theme_v2 = Omit<RootTheme_v2, 'color'> & {
42
38
  color: ThemeColorCard_v2
43
39
  /**
@@ -5,6 +5,7 @@ import {defaultTokens} from './defaultTokens'
5
5
  import {resolveTokens} from './resolveTokens'
6
6
  import {Theme_v3, ThemeOptions} from './types'
7
7
 
8
+ /** @public */
8
9
  export function buildTheme_v3(options?: ThemeOptions): Theme_v3 {
9
10
  const {v2} = options ?? {}
10
11
 
@@ -6,8 +6,7 @@ import {
6
6
  ThemeColorStateToneKey,
7
7
  } from '../../v2'
8
8
 
9
- // export interface ThemeColorAvatarHue_v2 {}
10
-
9
+ /** @public */
11
10
  export interface ThemeColorElement {
12
11
  _hue: Hue
13
12
  bg: {
@@ -24,12 +23,13 @@ export interface ThemeColorElement {
24
23
  }
25
24
  }
26
25
 
26
+ /** @public */
27
27
  export type ThemeColorVariant = Record<ThemeColorStateToneKey, ThemeColorElement>
28
28
 
29
+ /** @public */
29
30
  export type ThemeColorVariantKey = 'tinted' | 'solid'
30
31
 
31
- // export type ThemeColorCard_v3 = Record<ThemeColorVariantKey, ThemeColorVariant>
32
-
32
+ /** @public */
33
33
  export interface ThemeColorCard_v3 {
34
34
  _hue: Hue
35
35
  avatar: ThemeColorAvatar_v2
@@ -90,9 +90,11 @@ export interface ThemeColorCard_v3 {
90
90
  variant: Record<ThemeColorVariantKey, ThemeColorVariant>
91
91
  }
92
92
 
93
+ /** @public */
93
94
  export interface ThemeColorScheme_v3 {
94
95
  card: Record<ThemeColorCardToneKey, ThemeColorCard_v3>
95
96
  }
96
97
 
98
+ /** @public */
97
99
  // color[scheme].card[cardTone][colorVariant][elementTone][property][level]
98
100
  export type ThemeColor_v3 = Record<ThemeColorSchemeKey, ThemeColorScheme_v3>
@@ -3,14 +3,17 @@ import {ThemeColorSchemeKey} from '../../v2'
3
3
  import {parseColor} from './parseColor'
4
4
  import {ColorToken} from './token'
5
5
 
6
- type CSSVariableKey = `--${string}`
6
+ /** @public */
7
+ export type CSSVariableKey = `--${string}`
7
8
 
9
+ /** @public */
8
10
  export interface RenderColorContext {
9
11
  bgVar: CSSVariableKey
10
12
  hue: Hue
11
13
  scheme: ThemeColorSchemeKey
12
14
  }
13
15
 
16
+ /** @public */
14
17
  export function renderColor(token: [ColorToken, ColorToken], context: RenderColorContext): string {
15
18
  const {bgVar, hue, scheme} = context
16
19
 
@@ -1,5 +1,6 @@
1
1
  import {PartialTokens, Tokens} from './tokens'
2
2
 
3
+ /** @internal */
3
4
  export const defaultTokens: PartialTokens<Tokens> = {
4
5
  color: {
5
6
  '*': {
@@ -53,47 +53,47 @@ function resolveCardColorTokens(
53
53
  gray: {
54
54
  _hue: tokens?.avatar?.gray?._hue ?? 'gray',
55
55
  bg: tokens?.avatar?.gray?.bg ?? ['400', '500'],
56
- fg: tokens?.avatar?.gray?.fg ?? ['900', '900'],
56
+ fg: tokens?.avatar?.gray?.fg ?? ['900', 'white'],
57
57
  },
58
58
  blue: {
59
59
  _hue: tokens?.avatar?.blue?._hue ?? 'blue',
60
60
  bg: tokens?.avatar?.blue?.bg ?? ['400', '500'],
61
- fg: tokens?.avatar?.blue?.fg ?? ['900', '900'],
61
+ fg: tokens?.avatar?.blue?.fg ?? ['900', 'white'],
62
62
  },
63
63
  purple: {
64
64
  _hue: tokens?.avatar?.purple?._hue ?? 'purple',
65
65
  bg: tokens?.avatar?.purple?.bg ?? ['400', '500'],
66
- fg: tokens?.avatar?.purple?.fg ?? ['900', '900'],
66
+ fg: tokens?.avatar?.purple?.fg ?? ['900', 'white'],
67
67
  },
68
68
  magenta: {
69
69
  _hue: tokens?.avatar?.magenta?._hue ?? 'magenta',
70
70
  bg: tokens?.avatar?.magenta?.bg ?? ['400', '500'],
71
- fg: tokens?.avatar?.magenta?.fg ?? ['900', '900'],
71
+ fg: tokens?.avatar?.magenta?.fg ?? ['900', 'white'],
72
72
  },
73
73
  red: {
74
74
  _hue: tokens?.avatar?.red?._hue ?? 'red',
75
75
  bg: tokens?.avatar?.red?.bg ?? ['400', '500'],
76
- fg: tokens?.avatar?.red?.fg ?? ['900', '900'],
76
+ fg: tokens?.avatar?.red?.fg ?? ['900', 'white'],
77
77
  },
78
78
  orange: {
79
79
  _hue: tokens?.avatar?.orange?._hue ?? 'orange',
80
80
  bg: tokens?.avatar?.orange?.bg ?? ['400', '500'],
81
- fg: tokens?.avatar?.orange?.fg ?? ['900', '900'],
81
+ fg: tokens?.avatar?.orange?.fg ?? ['900', 'white'],
82
82
  },
83
83
  yellow: {
84
84
  _hue: tokens?.avatar?.yellow?._hue ?? 'yellow',
85
85
  bg: tokens?.avatar?.yellow?.bg ?? ['400', '500'],
86
- fg: tokens?.avatar?.yellow?.fg ?? ['900', '900'],
86
+ fg: tokens?.avatar?.yellow?.fg ?? ['900', 'white'],
87
87
  },
88
88
  green: {
89
89
  _hue: tokens?.avatar?.green?._hue ?? 'green',
90
90
  bg: tokens?.avatar?.green?.bg ?? ['400', '500'],
91
- fg: tokens?.avatar?.green?.fg ?? ['900', '900'],
91
+ fg: tokens?.avatar?.green?.fg ?? ['900', 'white'],
92
92
  },
93
93
  cyan: {
94
94
  _hue: tokens?.avatar?.cyan?._hue ?? 'cyan',
95
95
  bg: tokens?.avatar?.cyan?.bg ?? ['400', '500'],
96
- fg: tokens?.avatar?.cyan?.fg ?? ['900', '900'],
96
+ fg: tokens?.avatar?.cyan?.fg ?? ['900', 'white'],
97
97
  },
98
98
  },
99
99
  backdrop: tokens?.backdrop ?? ['900', '100'],
@@ -4,6 +4,7 @@ import {useEffect} from 'react'
4
4
  import {_raf2} from './helpers'
5
5
  import {useCard} from './primitives'
6
6
 
7
+ /** @internal */
7
8
  export function RootClassNames(props: {element: HTMLElement}) {
8
9
  const {element} = props
9
10
  const {scheme, tone} = useCard() ?? {}
@@ -39,3 +40,5 @@ export function RootClassNames(props: {element: HTMLElement}) {
39
40
 
40
41
  return null
41
42
  }
43
+
44
+ RootClassNames.displayName = 'RootClassNames'
@@ -2,7 +2,7 @@ import {compilePalette, compileSystem, compileTheme} from '@sanity/ui/css'
2
2
  import {buildTheme_v3, RootTheme, Theme_v3} from '@sanity/ui/theme'
3
3
  import {ReactNode} from 'react'
4
4
 
5
- /* @beta */
5
+ /** @beta */
6
6
  export function StyleTags(props: {theme?: Theme_v3}): ReactNode {
7
7
  const {theme: themeProp} = props
8
8
 
@@ -22,3 +22,5 @@ export function StyleTags(props: {theme?: Theme_v3}): ReactNode {
22
22
  </>
23
23
  )
24
24
  }
25
+
26
+ StyleTags.displayName = 'StyleTags'
@@ -4,18 +4,14 @@ import {ReactElement, ReactNode} from 'react'
4
4
  import {ThemeProvider} from './themeProvider'
5
5
  import {useRootTheme} from './useRootTheme'
6
6
 
7
- /**
8
- * @public
9
- */
7
+ /** @public */
10
8
  export interface ThemeColorProviderProps {
11
9
  children?: ReactNode
12
10
  scheme?: ThemeColorSchemeKey
13
11
  tone?: ThemeColorCardToneKey
14
12
  }
15
13
 
16
- /**
17
- * @public
18
- */
14
+ /** @public */
19
15
  export function ThemeColorProvider(props: ThemeColorProviderProps): ReactElement {
20
16
  const {children, scheme, tone} = props
21
17
  const root = useRootTheme()
@@ -13,9 +13,7 @@ import {ThemeColorProvider} from './themeColorProvider'
13
13
  import {ThemeContext} from './themeContext'
14
14
  import {ThemeContextValue} from './types'
15
15
 
16
- /**
17
- * @public
18
- */
16
+ /** @public */
19
17
  export interface ThemeProviderProps {
20
18
  children?: ReactNode
21
19
  scheme?: ThemeColorSchemeKey
@@ -23,9 +21,7 @@ export interface ThemeProviderProps {
23
21
  tone?: ThemeColorCardToneKey
24
22
  }
25
23
 
26
- /**
27
- * @public
28
- */
24
+ /** @public */
29
25
  export function ThemeProvider(props: ThemeProviderProps): ReactElement {
30
26
  const parentTheme = useContext(ThemeContext)
31
27
  const {children} = props
@@ -1,8 +1,6 @@
1
1
  import {RootTheme, ThemeColorCardToneKey, ThemeColorSchemeKey} from '@sanity/ui/theme'
2
2
 
3
- /**
4
- * @public
5
- */
3
+ /** @public */
6
4
  export interface ThemeContextValue {
7
5
  /** @deprecated No longer used */
8
6
  version: 0.0
@@ -3,9 +3,7 @@ import {useContext} from 'react'
3
3
  import {ThemeContext} from './themeContext'
4
4
  import {ThemeContextValue} from './types'
5
5
 
6
- /**
7
- * @public
8
- */
6
+ /** @public */
9
7
  export function useRootTheme(): ThemeContextValue {
10
8
  const value = useContext(ThemeContext)
11
9
 
@@ -1,16 +1,12 @@
1
1
  import {getTheme_v2, Theme, Theme_v2} from '@sanity/ui/theme'
2
2
  import {useTheme as useStyledTheme} from 'styled-components'
3
3
 
4
- /**
5
- * @public
6
- */
4
+ /** @public */
7
5
  export function useTheme(): Theme {
8
6
  return useStyledTheme() as Theme
9
7
  }
10
8
 
11
- /**
12
- * @public
13
- */
9
+ /** @public */
14
10
  export function useTheme_v2(): Theme_v2 {
15
11
  return getTheme_v2(useStyledTheme() as Theme)
16
12
  }
@@ -83,13 +83,13 @@ function ConstrainedHeightExampleField({id, label}: {id: string; label: string})
83
83
  },
84
84
  popoverRef: React.Ref<HTMLDivElement>,
85
85
  ) => {
86
- const {hidden, inputElement, ...restProps} = popoverProps
86
+ const {hidden, inputElement, ...rest} = popoverProps
87
87
 
88
88
  if (hidden) return null
89
89
 
90
90
  return (
91
91
  <Popover
92
- {...restProps}
92
+ {...rest}
93
93
  arrow={false}
94
94
  constrainSize
95
95
  matchReferenceWidth
@@ -1,17 +1,15 @@
1
1
  import {ChevronDownIcon} from '@sanity/icons'
2
2
  import {ResponsiveProp} from '@sanity/ui/css'
3
- import {FontTextSize, Space} from '@sanity/ui/theme'
3
+ import {Space} from '@sanity/ui/theme'
4
4
  import {
5
- ChangeEvent,
5
+ type ChangeEvent,
6
6
  cloneElement,
7
- ElementType,
8
- FocusEvent,
9
- ForwardedRef,
10
- forwardRef,
11
- KeyboardEvent,
12
- MouseEvent,
13
- ReactElement,
14
- ReactNode,
7
+ type ElementType,
8
+ type FocusEvent,
9
+ type ForwardedRef,
10
+ type KeyboardEvent,
11
+ type MouseEvent,
12
+ type ReactNode,
15
13
  useCallback,
16
14
  useEffect,
17
15
  useImperativeHandle,
@@ -29,14 +27,14 @@ import {
29
27
  Button,
30
28
  Card,
31
29
  Popover,
32
- PopoverProps,
30
+ type PopoverProps,
33
31
  Stack,
34
32
  Text,
35
33
  TextInput,
34
+ TextInputOwnProps,
36
35
  } from '../../primitives'
37
- // import {Selectable} from '../../primitives/_selectable'
38
36
  import {AnimatedSpinnerIcon} from '../../primitives/spinner/animatedSpinnerIcon'
39
- import {Props, Radius} from '../../types'
37
+ import type {ComponentType, Props, Radius} from '../../types'
40
38
  import {AutocompleteOption} from './autocompleteOption'
41
39
  import {autocompleteReducer} from './autocompleteReducer'
42
40
  import {
@@ -44,58 +42,62 @@ import {
44
42
  AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS,
45
43
  AUTOCOMPLETE_POPOVER_PLACEMENT,
46
44
  } from './constants'
47
- import {AutocompleteOpenButtonProps, BaseAutocompleteOption} from './types'
48
-
49
- /**
50
- * @public
51
- */
52
- export interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseAutocompleteOption> {
53
- border?: boolean
54
- customValidity?: string
55
- disabled?: boolean
56
- filterOption?: (query: string, option: Option) => boolean
57
- fontSize?: ResponsiveProp<FontTextSize>
58
- icon?: ElementType | ReactNode
59
- id: string
60
- /** @beta */
61
- listBox?: BoxProps
62
- loading?: boolean
63
- onChange?: (value: string) => void
64
- onQueryChange?: (query: string | null) => void
65
- onSelect?: (value: string) => void
66
- /** @beta */
67
- openButton?: boolean | AutocompleteOpenButtonProps
68
- /** @beta */
69
- openOnFocus?: boolean
70
- /** The options to render. */
71
- options?: Option[]
72
- padding?: ResponsiveProp<Space>
73
- // padding?: number | number[]
74
- popover?: Omit<Props<PopoverProps, 'div'>, 'content' | 'onMouseEnter' | 'onMouseLeave' | 'open'>
75
- prefix?: ReactNode
76
- radius?: Radius | Radius[]
77
- readOnly?: boolean
78
- ref?: ForwardedRef<HTMLInputElement>
79
- /** @beta */
80
- relatedElements?: HTMLElement[]
81
- /** The callback function for rendering each option. */
82
- renderOption?: (option: Option) => React.JSX.Element
83
- /** @beta */
84
- renderPopover?: (
85
- props: {
86
- content: React.JSX.Element | null
87
- hidden: boolean
88
- inputElement: HTMLInputElement | null
89
- onMouseEnter: () => void
90
- onMouseLeave: () => void
91
- },
92
- ref: ForwardedRef<HTMLDivElement>,
93
- ) => ReactNode
94
- renderValue?: (value: string, option?: Option) => string
95
- suffix?: ReactNode
96
- /** The current value. */
97
- value?: string
98
- }
45
+ import type {AutocompleteOpenButtonProps, BaseAutocompleteOption} from './types'
46
+
47
+ /** @public */
48
+ export const DEFAULT_AUTOCOMPLETE_ELEMENT = 'input'
49
+
50
+ /** @public */
51
+ export type AutocompleteOwnProps<O extends BaseAutocompleteOption = BaseAutocompleteOption> =
52
+ TextInputOwnProps & {
53
+ border?: boolean
54
+ customValidity?: string
55
+ filterOption?: (query: string, option: O) => boolean
56
+ icon?: ElementType | ReactNode
57
+ /** @beta */
58
+ listBox?: BoxProps
59
+ loading?: boolean
60
+ onChange?: (value: string) => void
61
+ onQueryChange?: (query: string | null) => void
62
+ onSelect?: (value: string) => void
63
+ /** @beta */
64
+ openButton?: boolean | AutocompleteOpenButtonProps
65
+ /** @beta */
66
+ openOnFocus?: boolean
67
+ /** The options to render. */
68
+ options?: O[]
69
+ padding?: ResponsiveProp<Space>
70
+ popover?: Omit<Props<PopoverProps, 'div'>, 'content' | 'onMouseEnter' | 'onMouseLeave' | 'open'>
71
+ prefix?: ReactNode
72
+ radius?: Radius | Radius[]
73
+ /** @beta */
74
+ relatedElements?: HTMLElement[]
75
+ /** The callback function for rendering each option. */
76
+ renderOption?: (option: O) => React.JSX.Element
77
+ /** @beta */
78
+ renderPopover?: (
79
+ props: {
80
+ content: React.JSX.Element | null
81
+ hidden: boolean
82
+ inputElement: HTMLInputElement | null
83
+ onMouseEnter: () => void
84
+ onMouseLeave: () => void
85
+ },
86
+ ref: ForwardedRef<HTMLDivElement>,
87
+ ) => ReactNode
88
+ renderValue?: (value: string, option?: O) => string
89
+ suffix?: ReactNode
90
+ value?: string
91
+ }
92
+
93
+ /** @public */
94
+ export type AutocompleteElementType = 'input' | ComponentType
95
+
96
+ /** @public */
97
+ export type AutocompleteProps<
98
+ E extends AutocompleteElementType = AutocompleteElementType,
99
+ O extends BaseAutocompleteOption = BaseAutocompleteOption,
100
+ > = Props<AutocompleteOwnProps<O>, E>
99
101
 
100
102
  const DEFAULT_RENDER_VALUE = (value: string, option?: BaseAutocompleteOption) =>
101
103
  option ? option.value : value
@@ -103,27 +105,18 @@ const DEFAULT_RENDER_VALUE = (value: string, option?: BaseAutocompleteOption) =>
103
105
  const DEFAULT_FILTER_OPTION = (query: string, option: BaseAutocompleteOption) =>
104
106
  option.value.toLowerCase().indexOf(query.toLowerCase()) > -1
105
107
 
106
- const InnerAutocomplete = forwardRef(function InnerAutocomplete<
107
- Option extends BaseAutocompleteOption,
108
- >(
109
- props: Omit<
110
- Props<AutocompleteProps<Option>, 'div'>,
111
- | 'aria-activedescendant'
112
- | 'aria-autocomplete'
113
- | 'aria-expanded'
114
- | 'aria-owns'
115
- | 'as'
116
- | 'autoCapitalize'
117
- | 'autoComplete'
118
- | 'autoCorrect'
119
- | 'inputMode'
120
- | 'role'
121
- | 'spellCheck'
122
- | 'type'
123
- >,
124
- forwardedRef: ForwardedRef<HTMLInputElement>,
125
- ) {
108
+ /**
109
+ * The Autocomplete component is typically used for search components.
110
+ * It consists of a text input for writing a query, and properties for rendering suggestions.
111
+ *
112
+ * @public
113
+ */
114
+ export function Autocomplete<
115
+ E extends AutocompleteElementType = typeof DEFAULT_AUTOCOMPLETE_ELEMENT,
116
+ O extends BaseAutocompleteOption = BaseAutocompleteOption,
117
+ >(props: AutocompleteProps<E, O>) {
126
118
  const {
119
+ as = DEFAULT_AUTOCOMPLETE_ELEMENT,
127
120
  border = true,
128
121
  customValidity,
129
122
  disabled,
@@ -146,14 +139,15 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
146
139
  prefix,
147
140
  radius = 2,
148
141
  readOnly,
142
+ ref: forwardedRef,
149
143
  relatedElements,
150
144
  renderOption: renderOptionProp,
151
145
  renderPopover,
152
146
  renderValue = DEFAULT_RENDER_VALUE,
153
147
  suffix,
154
148
  value: valueProp,
155
- ...restProps
156
- } = props
149
+ ...rest
150
+ } = props as AutocompleteProps<typeof DEFAULT_AUTOCOMPLETE_ELEMENT, O>
157
151
 
158
152
  const [state, dispatch] = useReducer(autocompleteReducer, {
159
153
  activeValue: valueProp || null,
@@ -186,7 +180,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
186
180
  const rootElementRef = useRef<HTMLDivElement | null>(null)
187
181
  const resultsPopoverElementRef = useRef<HTMLDivElement | null>(null)
188
182
  const inputElementRef = useRef<HTMLInputElement | null>(null)
189
- const listBoxElementRef = useRef<HTMLDivElement | null>(null)
183
+ const listBoxElementRef = useRef<HTMLUListElement | null>(null)
190
184
 
191
185
  // Value refs
192
186
  const listFocusedRef = useRef(false)
@@ -535,7 +529,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
535
529
 
536
530
  const input = (
537
531
  <TextInput
538
- {...restProps}
532
+ {...rest}
539
533
  aria-activedescendant={activeItemId}
540
534
  aria-autocomplete="list"
541
535
  aria-expanded={expanded}
@@ -543,6 +537,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
543
537
  autoCapitalize="off"
544
538
  autoComplete="off"
545
539
  autoCorrect="off"
540
+ as={as}
546
541
  border={border}
547
542
  clearButton={clearButton}
548
543
  customValidity={customValidity}
@@ -694,29 +689,6 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
694
689
  {results}
695
690
  </div>
696
691
  )
697
- })
698
-
699
- InnerAutocomplete.displayName = 'ForwardRef(Autocomplete)'
692
+ }
700
693
 
701
- /**
702
- * The Autocomplete component is typically used for search components.
703
- * It consists of a text input for writing a query, and properties for rendering suggestions.
704
- *
705
- * @public
706
- */
707
- export const Autocomplete = InnerAutocomplete as <Option extends BaseAutocompleteOption>(
708
- props: Omit<
709
- Props<AutocompleteProps<Option>, 'input'>,
710
- | 'aria-activedescendant'
711
- | 'aria-autocomplete'
712
- | 'aria-expanded'
713
- | 'aria-owns'
714
- | 'autoCapitalize'
715
- | 'autoComplete'
716
- | 'autoCorrect'
717
- | 'inputMode'
718
- | 'role'
719
- | 'spellCheck'
720
- | 'type'
721
- >,
722
- ) => ReactElement
694
+ Autocomplete.displayName = 'Autocomplete'
@@ -43,3 +43,5 @@ export function AutocompleteOption(props: AutocompleteOptionProps): ReactElement
43
43
  </li>
44
44
  )
45
45
  }
46
+
47
+ AutocompleteOption.displayName = 'AutocompleteOption'
@@ -1,14 +1,9 @@
1
1
  import {ButtonProps} from '../../primitives'
2
- import {Props} from '../../types'
3
2
 
4
- /**
5
- * @public
6
- */
7
- export type AutocompleteOpenButtonProps = Omit<Props<ButtonProps, 'button'>, 'as'>
3
+ /** @public */
4
+ export type AutocompleteOpenButtonProps = Omit<ButtonProps<'button'>, 'as'>
8
5
 
9
- /**
10
- * @public
11
- */
6
+ /** @public */
12
7
  export interface BaseAutocompleteOption {
13
8
  value: string
14
9
  }