@sanity/ui 3.0.0-static.10 → 3.0.0-static.12

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 (275) hide show
  1. package/dist/_chunks-cjs/_visual-editing.js +1300 -1269
  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 +1298 -1263
  6. package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
  7. package/dist/_visual-editing.d.mts +516 -360
  8. package/dist/_visual-editing.d.ts +516 -360
  9. package/dist/cli.js +1 -1
  10. package/dist/css.d.mts +258 -75
  11. package/dist/css.d.ts +258 -75
  12. package/dist/css.js +746 -752
  13. package/dist/css.js.map +1 -1
  14. package/dist/css.mjs +748 -754
  15. package/dist/css.mjs.map +1 -1
  16. package/dist/index.d.mts +1342 -871
  17. package/dist/index.d.ts +1342 -871
  18. package/dist/index.js +433 -325
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +429 -321
  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 -21710
  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 +19 -20
  31. package/dist/theme.js.map +1 -1
  32. package/dist/theme.mjs +19 -20
  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/_resp.ts +0 -1
  39. package/src/css/{system.style.ts → _system.style.ts} +3 -2
  40. package/src/css/aspects/display/display.ts +1 -0
  41. package/src/css/aspects/display/types.ts +2 -3
  42. package/src/css/aspects/flex/types.ts +4 -12
  43. package/src/css/aspects/flexItem/types.ts +1 -3
  44. package/src/css/aspects/font/font.style.ts +7 -66
  45. package/src/css/aspects/font/types.ts +1 -3
  46. package/src/css/aspects/grid/grid.ts +1 -0
  47. package/src/css/aspects/grid/types.ts +5 -9
  48. package/src/css/aspects/gridItem/gridItem.ts +1 -1
  49. package/src/css/aspects/gridItem/types.ts +7 -18
  50. package/src/css/aspects/height/height.ts +3 -4
  51. package/src/css/aspects/inset/inset.ts +1 -0
  52. package/src/css/aspects/margin/margin.ts +1 -0
  53. package/src/css/aspects/margin/types.ts +1 -0
  54. package/src/css/aspects/maxWidth/maxWidth.ts +1 -0
  55. package/src/css/aspects/maxWidth/types.ts +1 -0
  56. package/src/css/aspects/minWidth/minWidth.ts +1 -0
  57. package/src/css/aspects/minWidth/types.ts +2 -0
  58. package/src/css/aspects/overflow/overflow.ts +1 -0
  59. package/src/css/aspects/padding/padding.ts +1 -0
  60. package/src/css/aspects/pointerEvents/pointerEvents.ts +1 -0
  61. package/src/css/aspects/position/position.ts +1 -0
  62. package/src/css/aspects/shadow/shadow.style.ts +16 -41
  63. package/src/css/aspects/shadow/shadow.ts +1 -0
  64. package/src/css/aspects/textOverflow/textOverflow.ts +1 -0
  65. package/src/css/aspects/textOverflow/types.ts +1 -0
  66. package/src/css/aspects/width/types.ts +2 -0
  67. package/src/css/aspects/width/width.ts +1 -0
  68. package/src/css/compilePalette.ts +32 -0
  69. package/src/css/compileSystem.ts +7 -0
  70. package/src/css/{compile/compileTheme.ts → compileTheme.ts} +1 -0
  71. package/src/css/compileTheme_v3.ts +434 -0
  72. package/src/css/components/breadcrumbs/breadcrumbs.ts +1 -0
  73. package/src/css/components/dialog/dialog.ts +7 -0
  74. package/src/css/components/menu/menu.ts +2 -0
  75. package/src/css/components/skeleton/skeleton.style.ts +8 -4
  76. package/src/css/components/skeleton/skeleton.ts +4 -0
  77. package/src/css/components/skeleton/types.ts +4 -0
  78. package/src/css/components/toast/toast.ts +5 -0
  79. package/src/css/components/tree/tree.ts +1 -0
  80. package/src/css/composeClassNames.ts +4 -2
  81. package/src/css/constants.ts +11 -0
  82. package/src/css/index.ts +4 -3
  83. package/src/css/primitives/_arrow/_arrow.style.ts +6 -8
  84. package/src/css/primitives/_arrow/_arrow.ts +7 -0
  85. package/src/css/primitives/_input/input.ts +2 -0
  86. package/src/css/primitives/_selectable/_selectable.style.ts +24 -25
  87. package/src/css/primitives/_selectable/selectable.ts +1 -2
  88. package/src/css/primitives/avatar/avatar.style.ts +5 -8
  89. package/src/css/primitives/avatar/avatar.ts +6 -0
  90. package/src/css/primitives/avatar/types.ts +1 -0
  91. package/src/css/primitives/box/types.ts +1 -3
  92. package/src/css/primitives/button/button.style.ts +48 -15
  93. package/src/css/primitives/button/button.ts +4 -21
  94. package/src/css/primitives/button/index.ts +1 -0
  95. package/src/css/primitives/button/types.ts +18 -0
  96. package/src/css/primitives/card/card.style.ts +4 -7
  97. package/src/css/primitives/card/card.ts +2 -2
  98. package/src/css/primitives/card/types.ts +2 -2
  99. package/src/css/primitives/checkbox/checkbox.ts +2 -0
  100. package/src/css/primitives/container/container.ts +1 -0
  101. package/src/css/primitives/container/types.ts +1 -0
  102. package/src/css/primitives/kbd/kbd.ts +1 -0
  103. package/src/css/primitives/label/types.ts +7 -2
  104. package/src/css/primitives/popover/popover.ts +2 -0
  105. package/src/css/primitives/radio/radio.ts +1 -0
  106. package/src/css/primitives/select/select.ts +2 -0
  107. package/src/css/primitives/spinner/spinner.ts +2 -0
  108. package/src/css/primitives/switch/switch.ts +5 -0
  109. package/src/css/primitives/text/types.ts +4 -0
  110. package/src/css/primitives/textArea/textArea.ts +1 -0
  111. package/src/css/primitives/textInput/textInput.ts +1 -0
  112. package/src/css/primitives/token/token.style.ts +37 -36
  113. package/src/css/primitives/tooltip/tooltip.ts +2 -0
  114. package/src/css/responsiveRules.ts +12 -19
  115. package/src/css/scopeClassName.ts +1 -0
  116. package/src/css/types.ts +115 -15
  117. package/src/css/util.ts +5 -0
  118. package/src/css/utils/srOnly/srOnly.ts +1 -0
  119. package/src/css/varNames.ts +230 -143
  120. package/src/css/vars.ts +53 -22
  121. package/src/theme/palette/constants.ts +2 -0
  122. package/src/theme/palette/types.ts +3 -0
  123. package/src/theme/types.ts +2 -6
  124. package/src/theme/v0/focusRing.ts +1 -3
  125. package/src/theme/v0/font.ts +6 -18
  126. package/src/theme/v0/layer.ts +1 -3
  127. package/src/theme/v0/shadow.ts +2 -6
  128. package/src/theme/v2/avatar.ts +1 -3
  129. package/src/theme/v2/color/_system.ts +1 -3
  130. package/src/theme/v2/color/avatar.ts +2 -6
  131. package/src/theme/v2/color/badge.ts +2 -6
  132. package/src/theme/v2/color/button.ts +3 -9
  133. package/src/theme/v2/color/color.ts +3 -9
  134. package/src/theme/v2/color/input.ts +3 -9
  135. package/src/theme/v2/color/kbd.ts +1 -3
  136. package/src/theme/v2/color/selectable.ts +2 -6
  137. package/src/theme/v2/color/state.ts +1 -3
  138. package/src/theme/v2/color/syntax.ts +1 -3
  139. package/src/theme/v2/input.ts +1 -3
  140. package/src/theme/v2/theme.ts +2 -6
  141. package/src/theme/v3/buildTheme_v3.ts +2 -1
  142. package/src/theme/v3/color/color.ts +6 -4
  143. package/src/theme/v3/color/renderColor.ts +4 -1
  144. package/src/theme/v3/{defaults.ts → defaultTokens.ts} +2 -2
  145. package/src/theme/v3/index.ts +1 -1
  146. package/src/theme/v3/resolveTokens.ts +18 -18
  147. package/src/ui/RootClassNames.tsx +44 -0
  148. package/src/ui/StyleTags.tsx +3 -1
  149. package/src/ui/_compat/helpers.ts +72 -0
  150. package/src/ui/_compat/index.ts +2 -6
  151. package/src/ui/_compat/studioTheme.ts +7 -0
  152. package/src/ui/_compat/theme/themeColorProvider.tsx +2 -6
  153. package/src/ui/_compat/theme/themeProvider.tsx +2 -6
  154. package/src/ui/_compat/theme/types.ts +1 -3
  155. package/src/ui/_compat/theme/useRootTheme.ts +1 -3
  156. package/src/ui/_compat/theme/useTheme.ts +2 -6
  157. package/src/ui/_compat/types.ts +0 -83
  158. package/src/ui/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  159. package/src/ui/components/autocomplete/autocomplete.tsx +86 -114
  160. package/src/ui/components/autocomplete/autocompleteOption.tsx +2 -0
  161. package/src/ui/components/autocomplete/types.ts +3 -8
  162. package/src/ui/components/breadcrumbs/breadcrumbs.tsx +27 -21
  163. package/src/ui/components/dialog/dialog.tsx +89 -291
  164. package/src/ui/components/dialog/dialogCard.tsx +183 -0
  165. package/src/ui/components/dialog/isTargetWithinScope.ts +14 -0
  166. package/src/ui/components/hotkeys/hotkeys.tsx +33 -15
  167. package/src/ui/components/menu/__workshop__/asComponent.tsx +6 -6
  168. package/src/ui/components/menu/menu.tsx +27 -33
  169. package/src/ui/components/menu/menuButton.tsx +10 -14
  170. package/src/ui/components/menu/menuDivider.tsx +25 -13
  171. package/src/ui/components/menu/menuGroup.tsx +34 -26
  172. package/src/ui/components/menu/menuItem.tsx +51 -40
  173. package/src/ui/components/skeleton/codeSkeleton.tsx +53 -0
  174. package/src/ui/components/skeleton/headingSkeleton.tsx +52 -0
  175. package/src/ui/components/skeleton/index.ts +3 -0
  176. package/src/ui/components/skeleton/labelSkeleton.tsx +51 -0
  177. package/src/ui/components/skeleton/skeleton.tsx +39 -16
  178. package/src/ui/components/skeleton/textSkeleton.tsx +31 -110
  179. package/src/ui/components/tab/tab.tsx +23 -19
  180. package/src/ui/components/tab/tabList.tsx +34 -33
  181. package/src/ui/components/tab/tabPanel.tsx +25 -19
  182. package/src/ui/components/toast/toast.tsx +21 -16
  183. package/src/ui/components/toast/toastLayer.tsx +28 -10
  184. package/src/ui/components/toast/toastProvider.tsx +2 -6
  185. package/src/ui/components/toast/types.ts +2 -6
  186. package/src/ui/components/toast/useToast.ts +1 -3
  187. package/src/ui/components/tree/tree.tsx +194 -187
  188. package/src/ui/components/tree/treeGroup.tsx +25 -5
  189. package/src/ui/components/tree/treeItem.tsx +35 -23
  190. package/src/ui/hooks/useClickOutside.ts +2 -6
  191. package/src/ui/hooks/useClickOutsideEvent.ts +3 -9
  192. package/src/ui/index.ts +1 -0
  193. package/src/ui/primitives/_selectable/selectable.tsx +33 -20
  194. package/src/ui/primitives/avatar/avatar.tsx +28 -31
  195. package/src/ui/primitives/avatar/avatarCounter.tsx +33 -25
  196. package/src/ui/primitives/avatar/avatarStack.tsx +31 -24
  197. package/src/ui/primitives/avatar/types.ts +2 -0
  198. package/src/ui/primitives/badge/__workshop__/props.tsx +1 -9
  199. package/src/ui/primitives/badge/__workshop__/tones.tsx +1 -6
  200. package/src/ui/primitives/badge/badge.tsx +33 -32
  201. package/src/ui/primitives/badge/types.ts +2 -1
  202. package/src/ui/primitives/box/box.tsx +59 -29
  203. package/src/ui/primitives/button/__workshop__/sanityUploadButton.tsx +3 -3
  204. package/src/ui/primitives/button/__workshop__/uploadButton.tsx +2 -1
  205. package/src/ui/primitives/button/button.test.tsx +1 -15
  206. package/src/ui/primitives/button/button.tsx +63 -70
  207. package/src/ui/primitives/card/__workshop__/asComponent.tsx +3 -3
  208. package/src/ui/primitives/card/card.tsx +22 -22
  209. package/src/ui/primitives/card/cardProvider.tsx +2 -0
  210. package/src/ui/primitives/checkbox/checkbox.tsx +26 -15
  211. package/src/ui/primitives/code/code.tsx +24 -22
  212. package/src/ui/primitives/container/container.tsx +26 -15
  213. package/src/ui/primitives/flex/flex.tsx +21 -19
  214. package/src/ui/primitives/grid/grid.tsx +21 -16
  215. package/src/ui/primitives/heading/heading.tsx +42 -19
  216. package/src/ui/primitives/inline/inline.tsx +26 -23
  217. package/src/ui/primitives/kbd/kbd.tsx +25 -23
  218. package/src/ui/primitives/label/label.tsx +29 -26
  219. package/src/ui/primitives/popover/popover.tsx +293 -271
  220. package/src/ui/primitives/popover/popoverCard.tsx +122 -120
  221. package/src/ui/primitives/radio/radio.tsx +30 -14
  222. package/src/ui/primitives/select/select.tsx +24 -16
  223. package/src/ui/primitives/spinner/animatedSpinnerIcon.tsx +4 -2
  224. package/src/ui/primitives/spinner/spinner.tsx +24 -12
  225. package/src/ui/primitives/stack/stack.tsx +27 -18
  226. package/src/ui/primitives/switch/switch.tsx +31 -14
  227. package/src/ui/primitives/text/text.tsx +30 -24
  228. package/src/ui/primitives/textArea/textArea.tsx +33 -18
  229. package/src/ui/primitives/textInput/textInput.tsx +28 -40
  230. package/src/ui/primitives/tooltip/constants.ts +1 -1
  231. package/src/ui/primitives/tooltip/tooltip.tsx +85 -61
  232. package/src/ui/primitives/tooltip/tooltipCard.tsx +89 -82
  233. package/src/ui/primitives/types.ts +1 -3
  234. package/src/ui/types/avatar.ts +3 -6
  235. package/src/ui/types/badge.ts +1 -3
  236. package/src/ui/types/button.ts +1 -3
  237. package/src/ui/types/card.ts +1 -3
  238. package/src/ui/types/dialog.ts +1 -3
  239. package/src/ui/types/props.ts +20 -10
  240. package/src/ui/utils/arrow/arrow.tsx +43 -25
  241. package/src/ui/utils/boundaryElement/boundaryElementProvider.tsx +2 -6
  242. package/src/ui/utils/boundaryElement/types.ts +1 -3
  243. package/src/ui/utils/boundaryElement/useBoundaryElement.ts +1 -3
  244. package/src/ui/utils/elementQuery/elementQuery.tsx +43 -19
  245. package/src/ui/utils/errorBoundary.tsx +2 -0
  246. package/src/ui/utils/index.ts +0 -1
  247. package/src/ui/utils/layer/layer.tsx +23 -93
  248. package/src/ui/utils/layer/layerCard.tsx +92 -0
  249. package/src/ui/utils/layer/layerProvider.tsx +2 -6
  250. package/src/ui/utils/layer/useLayer.ts +1 -3
  251. package/src/ui/utils/portal/portal.ts +2 -6
  252. package/src/ui/utils/portal/portalProvider.tsx +2 -6
  253. package/src/ui/utils/portal/types.ts +1 -3
  254. package/src/ui/utils/portal/usePortal.ts +1 -3
  255. package/src/ui/utils/srOnly/srOnly.tsx +25 -20
  256. package/src/ui/utils/virtualList/virtualList.tsx +69 -50
  257. package/src/css/compile/compilePalette.ts +0 -27
  258. package/src/css/compile/compileRule.ts +0 -97
  259. package/src/css/compile/compileRules.test.ts +0 -36
  260. package/src/css/compile/compileRules.ts +0 -43
  261. package/src/css/compile/compileSystem.ts +0 -10
  262. package/src/css/compile/compileTheme_v3.ts +0 -401
  263. package/src/css/compile/types.ts +0 -6
  264. package/src/css/components/breadcrumbs/rules.ts +0 -25
  265. package/src/css/components/dialog/rules.ts +0 -78
  266. package/src/css/components/skeleton/rules.ts +0 -113
  267. package/src/css/components/toast/rules.ts +0 -18
  268. package/src/css/components/tree/rules.ts +0 -168
  269. package/src/css/primitives/_selectable/_contants.ts +0 -11
  270. package/src/css/primitives/card/_constants.ts +0 -13
  271. package/src/css/primitives/popover/rules.ts +0 -5
  272. package/src/css/primitives/spinner/rules.ts +0 -21
  273. package/src/css/primitives/token/rules.ts +0 -45
  274. package/src/ui/utils/conditionalWrapper/conditionalWrapper.tsx +0 -23
  275. package/src/ui/utils/conditionalWrapper/index.ts +0 -1
@@ -0,0 +1,44 @@
1
+ import {card, scopeClassName as _} from '@sanity/ui/css'
2
+ import {useEffect} from 'react'
3
+
4
+ import {_raf2} from './helpers'
5
+ import {useCard} from './primitives'
6
+
7
+ /** @internal */
8
+ export function RootClassNames(props: {element: HTMLElement}) {
9
+ const {element} = props
10
+ const {scheme, tone} = useCard() ?? {}
11
+
12
+ useEffect(() => {
13
+ const els = document.querySelectorAll(
14
+ [_('button'), _('card'), _('font')].map((n) => `.${n}`).join(', '),
15
+ )
16
+
17
+ // temporarily disable all transitions when the theme changes
18
+ for (const el of els) {
19
+ if (el instanceof HTMLElement) {
20
+ el.style.transition = 'none'
21
+ }
22
+ }
23
+
24
+ _raf2(() => {
25
+ document.documentElement.className = card({scheme, tone}) ?? ''
26
+
27
+ _raf2(() => {
28
+ for (const el of els) {
29
+ if (el instanceof HTMLElement) {
30
+ el.style.transition = ''
31
+ }
32
+ }
33
+ })
34
+ })
35
+
36
+ return () => {
37
+ document.documentElement.className = ''
38
+ }
39
+ }, [element, scheme, tone])
40
+
41
+ return null
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'
@@ -0,0 +1,72 @@
1
+ import {
2
+ createColorTheme as _createColorTheme,
3
+ hexToRgb as _hexToRgb,
4
+ hslToRgb as _hslToRgb,
5
+ multiply as _multiply,
6
+ parseColor as _parseColor,
7
+ rgba as _rgba,
8
+ rgbToHex as _rgbToHex,
9
+ rgbToHsl as _rgbToHsl,
10
+ screen as _screen,
11
+ } from '@sanity/ui/theme'
12
+
13
+ export {
14
+ /** @deprecated use `px` from `@sanity/ui/css` */
15
+ px,
16
+ /** @deprecated use `rem` from `@sanity/ui/css` */
17
+ rem,
18
+ } from '@sanity/ui/css'
19
+
20
+ /**
21
+ * @public
22
+ * @deprecated Use `createColorTheme` from `@sanity/ui/theme` instead.
23
+ */
24
+ export const createColorTheme = _createColorTheme
25
+
26
+ /**
27
+ * @public
28
+ * @deprecated Use `hexToRgb` from `@sanity/ui/theme` instead.
29
+ */
30
+ export const hexToRgb = _hexToRgb
31
+
32
+ /**
33
+ * @public
34
+ * @deprecated Use `hslToRgb` from `@sanity/ui/theme` instead.
35
+ */
36
+ export const hslToRgb = _hslToRgb
37
+
38
+ /**
39
+ * @public
40
+ * @deprecated Use `multiply` from `@sanity/ui/theme` instead.
41
+ */
42
+ export const multiply = _multiply
43
+
44
+ /**
45
+ * @public
46
+ * @deprecated Use `parseColor` from `@sanity/ui/theme` instead.
47
+ */
48
+ export const parseColor = _parseColor
49
+
50
+ /**
51
+ * @public
52
+ * @deprecated Use `rgbToHex` from `@sanity/ui/theme` instead.
53
+ */
54
+ export const rgbToHex = _rgbToHex
55
+
56
+ /**
57
+ * @public
58
+ * @deprecated Use `rgbToHsl` from `@sanity/ui/theme` instead.
59
+ */
60
+ export const rgbToHsl = _rgbToHsl
61
+
62
+ /**
63
+ * @public
64
+ * @deprecated Use `rgba` from `@sanity/ui/theme` instead.
65
+ */
66
+ export const rgba = _rgba
67
+
68
+ /**
69
+ * @public
70
+ * @deprecated Use `screen` from `@sanity/ui/theme` instead.
71
+ */
72
+ export const screen = _screen
@@ -1,9 +1,5 @@
1
+ export * from './helpers'
2
+ export * from './studioTheme'
1
3
  export * from './styles'
2
4
  export * from './theme'
3
5
  export * from './types'
4
- export {
5
- /** @deprecated use `px` from `@sanity/ui/css` */
6
- px,
7
- /** @deprecated use `rem` from `@sanity/ui/css` */
8
- rem,
9
- } from '@sanity/ui/css'
@@ -0,0 +1,7 @@
1
+ import {buildTheme} from '@sanity/ui/theme'
2
+
3
+ /**
4
+ * @public
5
+ * @deprecated Use `buildTheme` from `@sanity/ui/theme` instead.
6
+ */
7
+ export const studioTheme = buildTheme()
@@ -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
  }
@@ -2,7 +2,6 @@
2
2
 
3
3
  import {
4
4
  type BaseTheme as _BaseTheme,
5
- buildTheme,
6
5
  type HSL as _HSL,
7
6
  type PartialThemeColorBuilderOpts,
8
7
  type RGB as _RGB,
@@ -190,85 +189,3 @@ export {
190
189
  type ThemeColorToneKey,
191
190
  type ThemeInput,
192
191
  }
193
-
194
- import {
195
- createColorTheme as _createColorTheme,
196
- hexToRgb as _hexToRgb,
197
- hslToRgb as _hslToRgb,
198
- multiply as _multiply,
199
- parseColor as _parseColor,
200
- rgba as _rgba,
201
- rgbToHex as _rgbToHex,
202
- rgbToHsl as _rgbToHsl,
203
- screen as _screen,
204
- } from '@sanity/ui/theme'
205
-
206
- /**
207
- * @public
208
- * @deprecated Use `createColorTheme` from `@sanity/ui/theme` instead.
209
- */
210
- export const createColorTheme = _createColorTheme
211
-
212
- /**
213
- * @public
214
- * @deprecated Use `hexToRgb` from `@sanity/ui/theme` instead.
215
- */
216
- export const hexToRgb = _hexToRgb
217
-
218
- /**
219
- * @public
220
- * @deprecated Use `hslToRgb` from `@sanity/ui/theme` instead.
221
- */
222
- export const hslToRgb = _hslToRgb
223
-
224
- /**
225
- * @public
226
- * @deprecated Use `multiply` from `@sanity/ui/theme` instead.
227
- */
228
- export const multiply = _multiply
229
-
230
- /**
231
- * @public
232
- * @deprecated Use `parseColor` from `@sanity/ui/theme` instead.
233
- */
234
- export const parseColor = _parseColor
235
-
236
- /**
237
- * @public
238
- * @deprecated Use `rgbToHex` from `@sanity/ui/theme` instead.
239
- */
240
- export const rgbToHex = _rgbToHex
241
-
242
- /**
243
- * @public
244
- * @deprecated Use `rgbToHsl` from `@sanity/ui/theme` instead.
245
- */
246
- export const rgbToHsl = _rgbToHsl
247
-
248
- /**
249
- * @public
250
- * @deprecated Use `rgba` from `@sanity/ui/theme` instead.
251
- */
252
- export const rgba = _rgba
253
-
254
- /**
255
- * @public
256
- * @deprecated Use `screen` from `@sanity/ui/theme` instead.
257
- */
258
- export const screen = _screen
259
-
260
- /**
261
- * @public
262
- * @deprecated Use `buildTheme` from `@sanity/ui/theme` instead.
263
- */
264
- export const studioTheme = (() => {
265
- let theme: ReturnType<typeof buildTheme> | undefined
266
- return {
267
- get value() {
268
- if (!theme) {
269
- theme = buildTheme()
270
- }
271
- return theme
272
- },
273
- }
274
- })()
@@ -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
  }