@sanity/ui 2.9.0-corel.0 → 3.0.0-static.0

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 (322) hide show
  1. package/bin/ui.js +6 -0
  2. package/dist/_chunks-cjs/buildCommand.js +2836 -0
  3. package/dist/_chunks-cjs/buildCommand.js.map +1 -0
  4. package/dist/_chunks-cjs/getTheme_v2.js +1 -27
  5. package/dist/_chunks-cjs/getTheme_v2.js.map +1 -1
  6. package/dist/_chunks-es/getTheme_v2.mjs +1 -27
  7. package/dist/_chunks-es/getTheme_v2.mjs.map +1 -1
  8. package/dist/_legacy/getTheme_v2.esm.js +1 -27
  9. package/dist/_legacy/getTheme_v2.esm.js.map +1 -1
  10. package/dist/cli.d.ts +1 -0
  11. package/dist/cli.js +23 -0
  12. package/dist/cli.js.map +1 -0
  13. package/dist/css.d.mts +943 -0
  14. package/dist/css.d.ts +943 -0
  15. package/dist/css.esm.js +3135 -0
  16. package/dist/css.esm.js.map +1 -0
  17. package/dist/css.js +3135 -0
  18. package/dist/css.js.map +1 -0
  19. package/dist/css.mjs +3135 -0
  20. package/dist/css.mjs.map +1 -0
  21. package/dist/index.d.mts +175 -164
  22. package/dist/index.d.ts +175 -164
  23. package/dist/index.esm.js +864 -1955
  24. package/dist/index.esm.js.map +1 -1
  25. package/dist/index.js +870 -1962
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +864 -1955
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/sanity-theme.css +25 -0
  30. package/dist/system.css +2953 -0
  31. package/dist/theme.d.mts +84 -22
  32. package/dist/theme.d.ts +84 -22
  33. package/dist/theme.esm.js +232 -283
  34. package/dist/theme.esm.js.map +1 -1
  35. package/dist/theme.js +232 -283
  36. package/dist/theme.js.map +1 -1
  37. package/dist/theme.mjs +232 -283
  38. package/dist/theme.mjs.map +1 -1
  39. package/exports/css.ts +1 -0
  40. package/package.json +25 -4
  41. package/src/core/__workshop__/constants.ts +15 -15
  42. package/src/core/__workshop__/fontsPlugin.tsx +1 -1
  43. package/src/core/components/autocomplete/autocomplete.styles.tsx +1 -1
  44. package/src/core/components/autocomplete/autocomplete.tsx +12 -4
  45. package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -3
  46. package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -5
  47. package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +14 -2
  48. package/src/core/components/breadcrumbs/breadcrumbs.tsx +14 -9
  49. package/src/core/components/dialog/__workshop__/panes.tsx +1 -1
  50. package/src/core/components/dialog/dialog.tsx +77 -92
  51. package/src/core/components/hotkeys/hotkeys.tsx +18 -29
  52. package/src/core/components/menu/menu.tsx +8 -5
  53. package/src/core/components/menu/menuDivider.ts +2 -1
  54. package/src/core/components/menu/menuGroup.tsx +16 -8
  55. package/src/core/components/menu/menuItem.tsx +23 -14
  56. package/src/core/components/skeleton/skeleton.tsx +1 -1
  57. package/src/core/components/skeleton/styles.ts +1 -1
  58. package/src/core/components/skeleton/textSkeleton.tsx +1 -1
  59. package/src/core/components/tab/tab.tsx +6 -7
  60. package/src/core/components/tab/tabList.tsx +3 -2
  61. package/src/core/components/toast/styles.ts +1 -1
  62. package/src/core/components/toast/toast.tsx +6 -4
  63. package/src/core/components/toast/toastProvider.tsx +31 -22
  64. package/src/core/components/tree/style.ts +1 -1
  65. package/src/core/components/tree/tree.tsx +8 -2
  66. package/src/core/components/tree/treeGroup.tsx +1 -1
  67. package/src/core/components/tree/treeItem.tsx +38 -25
  68. package/src/core/components/tree/types.ts +5 -1
  69. package/src/core/lib/styled/elements.ts +135 -0
  70. package/src/core/lib/styled/index.ts +2 -0
  71. package/src/core/lib/styled/members.ts +15 -0
  72. package/src/core/lib/styled/styled.ts +79 -0
  73. package/src/core/primitives/_selectable/selectable.tsx +27 -14
  74. package/src/core/primitives/avatar/avatar.tsx +52 -32
  75. package/src/core/primitives/avatar/avatarCounter.tsx +1 -1
  76. package/src/core/primitives/avatar/avatarStack.tsx +1 -1
  77. package/src/core/primitives/badge/__workshop__/tones.tsx +9 -16
  78. package/src/core/primitives/badge/badge.tsx +18 -20
  79. package/src/core/primitives/box/box.tsx +62 -74
  80. package/src/core/primitives/button/__workshop__/props.tsx +3 -1
  81. package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +1 -1
  82. package/src/core/primitives/button/__workshop__/styled1.tsx +1 -1
  83. package/src/core/primitives/button/__workshop__/styled2.tsx +1 -1
  84. package/src/core/primitives/button/button.tsx +38 -45
  85. package/src/core/primitives/button/styles.ts +2 -2
  86. package/src/core/primitives/card/RootCardContext.ts +3 -0
  87. package/src/core/primitives/card/__workshop__/selected.tsx +1 -1
  88. package/src/core/primitives/card/__workshop__/styled.tsx +1 -1
  89. package/src/core/primitives/card/card.tsx +44 -46
  90. package/src/core/primitives/card/styles.ts +1 -1
  91. package/src/core/primitives/checkbox/checkbox.tsx +6 -8
  92. package/src/core/primitives/code/code.tsx +23 -12
  93. package/src/core/primitives/code/styles.ts +1 -1
  94. package/src/core/primitives/container/container.tsx +7 -15
  95. package/src/core/primitives/flex/__workshop__/example.tsx +1 -1
  96. package/src/core/primitives/flex/flex.tsx +6 -19
  97. package/src/core/primitives/grid/grid.tsx +2 -1
  98. package/src/core/primitives/heading/heading.tsx +32 -19
  99. package/src/core/primitives/heading/styles.ts +1 -1
  100. package/src/core/primitives/inline/inline.tsx +22 -13
  101. package/src/core/primitives/kbd/kbd.tsx +30 -37
  102. package/src/core/primitives/label/label.tsx +15 -4
  103. package/src/core/primitives/label/styles.ts +1 -1
  104. package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -1
  105. package/src/core/primitives/popover/popover.tsx +21 -15
  106. package/src/core/primitives/popover/popoverCard.tsx +36 -38
  107. package/src/core/primitives/radio/radio.tsx +1 -1
  108. package/src/core/primitives/radio/styles.ts +1 -1
  109. package/src/core/primitives/select/select.tsx +1 -1
  110. package/src/core/primitives/select/styles.ts +1 -1
  111. package/src/core/primitives/spinner/spinner.tsx +6 -20
  112. package/src/core/primitives/stack/stack.tsx +12 -10
  113. package/src/core/primitives/switch/styles.ts +9 -9
  114. package/src/core/primitives/switch/switch.tsx +20 -21
  115. package/src/core/primitives/text/__workshop__/colored.tsx +1 -1
  116. package/src/core/primitives/text/styles.ts +1 -2
  117. package/src/core/primitives/text/text.tsx +17 -21
  118. package/src/core/primitives/textArea/textArea.tsx +1 -1
  119. package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -1
  120. package/src/core/primitives/textInput/textInput.tsx +176 -123
  121. package/src/core/primitives/tooltip/tooltip.test.tsx +1 -0
  122. package/src/core/primitives/tooltip/tooltip.tsx +13 -13
  123. package/src/core/primitives/tooltip/tooltipCard.tsx +15 -14
  124. package/src/core/primitives/types.ts +35 -16
  125. package/src/core/styles/border/borderStyle.ts +6 -0
  126. package/src/core/styles/border/types.ts +1 -0
  127. package/src/core/styles/box/boxStyle.ts +6 -0
  128. package/src/core/styles/card/_cardColorStyle.ts +0 -8
  129. package/src/core/styles/flex/flexStyle.ts +0 -18
  130. package/src/core/styles/flex/types.ts +1 -3
  131. package/src/core/styles/grid/gridStyle.ts +0 -10
  132. package/src/core/styles/helpers.ts +9 -0
  133. package/src/core/styles/input/textInputStyle.ts +1 -1
  134. package/src/core/theme/__workshop__/build/Root.tsx +1 -1
  135. package/src/core/theme/themeProvider.tsx +1 -1
  136. package/src/core/theme/useTheme.ts +1 -1
  137. package/src/core/types/avatar.ts +6 -1
  138. package/src/core/types/button.ts +1 -0
  139. package/src/core/types/flex.ts +27 -26
  140. package/src/core/types/gridItem.ts +32 -24
  141. package/src/core/types/radius.ts +7 -4
  142. package/src/core/utils/arrow/arrow.tsx +1 -1
  143. package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +1 -1
  144. package/src/core/utils/layer/layer.tsx +28 -11
  145. package/src/core/utils/srOnly/srOnly.tsx +1 -1
  146. package/src/core/utils/virtualList/virtualList.tsx +1 -1
  147. package/src/css/_resp.ts +28 -0
  148. package/src/css/cli/buildCommand.ts +36 -0
  149. package/src/css/cli/index.ts +38 -0
  150. package/src/css/compile/comileRules.ts +59 -0
  151. package/src/css/compile/compileRule.ts +58 -0
  152. package/src/css/compile/compileSystem.ts +7 -0
  153. package/src/css/compile/compileTheme.ts +509 -0
  154. package/src/css/components/breadcrumbs/breadcrumbs.ts +5 -0
  155. package/src/css/components/breadcrumbs/index.ts +1 -0
  156. package/src/css/components/breadcrumbs/rules.ts +7 -0
  157. package/src/css/components/dialog/classes.ts +29 -0
  158. package/src/css/components/dialog/index.ts +1 -0
  159. package/src/css/components/dialog/rules.ts +75 -0
  160. package/src/css/components/tree/index.ts +1 -0
  161. package/src/css/components/tree/rules.ts +52 -0
  162. package/src/css/components/tree/tree.ts +5 -0
  163. package/src/css/composeClassNames.ts +3 -0
  164. package/src/css/index.ts +47 -0
  165. package/src/css/primitives/avatar/avatar.ts +32 -0
  166. package/src/css/primitives/avatar/index.ts +2 -0
  167. package/src/css/primitives/avatar/rules.ts +190 -0
  168. package/src/css/primitives/avatar/types.ts +9 -0
  169. package/src/css/primitives/badge/badge.ts +8 -0
  170. package/src/css/primitives/badge/index.ts +2 -0
  171. package/src/css/primitives/badge/rules.ts +25 -0
  172. package/src/css/primitives/badge/types.ts +8 -0
  173. package/src/css/primitives/box/box.ts +34 -0
  174. package/src/css/primitives/box/index.ts +2 -0
  175. package/src/css/primitives/box/rules.ts +25 -0
  176. package/src/css/primitives/box/types.ts +49 -0
  177. package/src/css/primitives/button/button.ts +26 -0
  178. package/src/css/primitives/button/index.ts +1 -0
  179. package/src/css/primitives/button/rules.ts +58 -0
  180. package/src/css/primitives/card/card.ts +21 -0
  181. package/src/css/primitives/card/index.ts +1 -0
  182. package/src/css/primitives/card/rules.ts +93 -0
  183. package/src/{core/primitives/checkbox/styles.ts → css/primitives/checkbox/__styles.ts} +3 -3
  184. package/src/css/primitives/checkbox/checkbox.ts +9 -0
  185. package/src/css/primitives/checkbox/index.ts +1 -0
  186. package/src/css/primitives/checkbox/rules.ts +136 -0
  187. package/src/css/primitives/code/code.ts +9 -0
  188. package/src/css/primitives/code/index.ts +2 -0
  189. package/src/css/primitives/code/rules.ts +71 -0
  190. package/src/css/primitives/code/types.ts +10 -0
  191. package/src/css/primitives/container/container.ts +7 -0
  192. package/src/css/primitives/container/index.ts +2 -0
  193. package/src/css/primitives/container/rules.ts +8 -0
  194. package/src/css/primitives/container/types.ts +6 -0
  195. package/src/css/primitives/heading/heading.ts +16 -0
  196. package/src/css/primitives/heading/index.ts +2 -0
  197. package/src/css/primitives/heading/rules.ts +84 -0
  198. package/src/css/primitives/heading/types.ts +12 -0
  199. package/src/css/primitives/kbd/index.ts +2 -0
  200. package/src/css/primitives/kbd/kbd.ts +7 -0
  201. package/src/css/primitives/kbd/rules.ts +20 -0
  202. package/src/css/primitives/kbd/types.ts +5 -0
  203. package/src/css/primitives/label/index.ts +2 -0
  204. package/src/css/primitives/label/label.ts +16 -0
  205. package/src/css/primitives/label/rules.ts +85 -0
  206. package/src/css/primitives/label/types.ts +12 -0
  207. package/src/css/primitives/popover/index.ts +1 -0
  208. package/src/css/primitives/popover/popover.ts +5 -0
  209. package/src/css/primitives/popover/rules.ts +5 -0
  210. package/src/css/primitives/radio/index.ts +1 -0
  211. package/src/css/primitives/radio/radio.ts +5 -0
  212. package/src/css/primitives/radio/rules.ts +5 -0
  213. package/src/css/primitives/select/index.ts +1 -0
  214. package/src/css/primitives/select/rules.ts +5 -0
  215. package/src/css/primitives/select/select.ts +5 -0
  216. package/src/{core/primitives/_selectable/style.ts → css/primitives/selectable/__style.ts} +5 -4
  217. package/src/css/primitives/selectable/index.ts +2 -0
  218. package/src/css/primitives/selectable/rules.ts +27 -0
  219. package/src/css/primitives/selectable/selectable.ts +9 -0
  220. package/src/css/primitives/selectable/types.ts +6 -0
  221. package/src/css/primitives/spinner/index.ts +1 -0
  222. package/src/css/primitives/spinner/rules.ts +22 -0
  223. package/src/css/primitives/spinner/spinner.ts +5 -0
  224. package/src/css/primitives/switch/index.ts +1 -0
  225. package/src/css/primitives/switch/rules.ts +132 -0
  226. package/src/css/primitives/switch/switch.ts +5 -0
  227. package/src/css/primitives/text/index.ts +2 -0
  228. package/src/css/primitives/text/rules.ts +75 -0
  229. package/src/css/primitives/text/text.ts +16 -0
  230. package/src/css/primitives/text/types.ts +11 -0
  231. package/src/css/primitives/textArea/index.ts +1 -0
  232. package/src/css/primitives/textArea/rules.ts +5 -0
  233. package/src/css/primitives/textArea/textArea.ts +5 -0
  234. package/src/css/primitives/textInput/index.ts +1 -0
  235. package/src/css/primitives/textInput/rules.ts +226 -0
  236. package/src/css/primitives/textInput/textInput.ts +7 -0
  237. package/src/css/primitives/token/rules.ts +45 -0
  238. package/src/css/primitives/tooltip/index.ts +1 -0
  239. package/src/css/primitives/tooltip/rules.ts +17 -0
  240. package/src/css/primitives/tooltip/tooltip.ts +9 -0
  241. package/src/css/responsiveRules.ts +25 -0
  242. package/src/css/rules.ts +121 -0
  243. package/src/css/styles/border/border.ts +22 -0
  244. package/src/css/styles/border/index.ts +2 -0
  245. package/src/css/styles/border/rules.ts +24 -0
  246. package/src/css/styles/border/types.ts +10 -0
  247. package/src/css/styles/display/rules.ts +62 -0
  248. package/src/css/styles/flex/flex.ts +20 -0
  249. package/src/css/styles/flex/index.ts +2 -0
  250. package/src/css/styles/flex/rules.ts +28 -0
  251. package/src/css/styles/flex/types.ts +35 -0
  252. package/src/css/styles/flexItem/flexItem.ts +8 -0
  253. package/src/css/styles/flexItem/index.ts +2 -0
  254. package/src/css/styles/flexItem/rules.ts +11 -0
  255. package/src/css/styles/flexItem/types.ts +11 -0
  256. package/src/css/styles/font/font.ts +12 -0
  257. package/src/css/styles/font/index.ts +2 -0
  258. package/src/css/styles/font/rules.ts +125 -0
  259. package/src/css/styles/font/types.ts +6 -0
  260. package/src/css/styles/gap/gap.ts +8 -0
  261. package/src/css/styles/gap/index.ts +2 -0
  262. package/src/css/styles/gap/rules.ts +33 -0
  263. package/src/css/styles/gap/types.ts +9 -0
  264. package/src/css/styles/grid/rules.ts +35 -0
  265. package/src/css/styles/gridItem/gridItem.ts +15 -0
  266. package/src/css/styles/gridItem/index.ts +2 -0
  267. package/src/css/styles/gridItem/rules.ts +96 -0
  268. package/src/css/styles/gridItem/types.ts +41 -0
  269. package/src/css/styles/height/rules.ts +7 -0
  270. package/src/css/styles/margin/index.ts +2 -0
  271. package/src/css/styles/margin/margin.ts +15 -0
  272. package/src/css/styles/margin/rules.ts +59 -0
  273. package/src/css/styles/margin/types.ts +11 -0
  274. package/src/css/styles/maxWidth/index.ts +2 -0
  275. package/src/css/styles/maxWidth/maxWidth.ts +6 -0
  276. package/src/css/styles/maxWidth/rules.ts +36 -0
  277. package/src/css/styles/maxWidth/types.ts +6 -0
  278. package/src/css/styles/overflow/rules.ts +9 -0
  279. package/src/css/styles/padding/index.ts +2 -0
  280. package/src/css/styles/padding/padding.ts +15 -0
  281. package/src/css/styles/padding/rules.ts +59 -0
  282. package/src/css/styles/padding/types.ts +12 -0
  283. package/src/css/styles/pointerEvents/index.ts +2 -0
  284. package/src/css/styles/pointerEvents/pointerEvents.ts +6 -0
  285. package/src/css/styles/pointerEvents/rules.ts +11 -0
  286. package/src/css/styles/pointerEvents/types.ts +7 -0
  287. package/src/css/styles/position/index.ts +2 -0
  288. package/src/css/styles/position/position.ts +7 -0
  289. package/src/css/styles/position/rules.ts +31 -0
  290. package/src/css/styles/position/types.ts +13 -0
  291. package/src/css/styles/radius/index.ts +2 -0
  292. package/src/css/styles/radius/radius.ts +8 -0
  293. package/src/css/styles/radius/rules.ts +13 -0
  294. package/src/css/styles/radius/types.ts +7 -0
  295. package/src/css/styles/shadow/rules.ts +53 -0
  296. package/src/css/styles/width/index.ts +2 -0
  297. package/src/css/styles/width/rules.ts +7 -0
  298. package/src/css/styles/width/types.ts +8 -0
  299. package/src/css/styles/width/width.ts +6 -0
  300. package/src/css/types.ts +591 -0
  301. package/src/css/varNames.ts +381 -0
  302. package/src/css/vars.ts +313 -0
  303. package/src/theme/build/_deprecated/color/factory.ts +1 -1
  304. package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
  305. package/src/theme/build/buildColorTheme.ts +39 -45
  306. package/src/theme/build/renderColorTheme.ts +65 -239
  307. package/src/theme/build/resolveColorTokens.ts +115 -51
  308. package/src/theme/config/tokens/color/types.ts +18 -4
  309. package/src/theme/defaults/colorTokens.ts +10 -17
  310. package/src/theme/defaults/config.ts +1 -1
  311. package/src/theme/getScopedTheme.ts +2 -9
  312. package/src/theme/system/_constants.ts +25 -0
  313. package/src/theme/system/_types.ts +41 -0
  314. package/src/theme/system/color/_constants.ts +0 -8
  315. package/src/theme/system/color/badge.ts +7 -3
  316. package/src/theme/system/index.ts +2 -0
  317. package/src/theme/system/v0/color/_system.ts +4 -8
  318. package/src/theme/system/v0/color/color.ts +2 -3
  319. package/src/theme/versioning/themeColor_v0_v2.ts +0 -26
  320. package/src/theme/versioning/v0_v2.ts +0 -4
  321. package/src/core/components/breadcrumbs/__workshop__/buttons.tsx +0 -58
  322. package/src/core/components/dialog/styles.ts +0 -76
@@ -1,24 +1,24 @@
1
1
  import {CloseIcon} from '@sanity/icons'
2
- import {ThemeFontWeightKey} from '@sanity/ui/theme'
2
+ import {composeClassNames, RadiusStyleProps, ResponsiveProp, textInput} from '@sanity/ui/css'
3
+ import {FontTextSize, Space, ThemeFontWeightKey} from '@sanity/ui/theme'
3
4
  import {forwardRef, isValidElement, useCallback, useImperativeHandle, useMemo, useRef} from 'react'
4
5
  import {isValidElementType} from 'react-is'
5
- import {styled} from 'styled-components'
6
6
  import {EMPTY_RECORD} from '../../constants'
7
7
  import {useArrayProp, useCustomValidity} from '../../hooks'
8
- import {
9
- responsiveRadiusStyle,
10
- ResponsiveRadiusStyleProps,
11
- responsiveInputPaddingStyle,
12
- TextInputInputStyleProps,
13
- TextInputRepresentationStyleProps,
14
- TextInputResponsivePaddingStyleProps,
15
- textInputBaseStyle,
16
- textInputFontSizeStyle,
17
- textInputRepresentationStyle,
18
- textInputRootStyle,
19
- } from '../../styles/internal'
8
+ import {styled} from '../../lib/styled'
9
+ // import {
10
+ // // responsiveRadiusStyle,
11
+ // // ResponsiveRadiusStyleProps,
12
+ // responsiveInputPaddingStyle,
13
+ // TextInputInputStyleProps,
14
+ // // TextInputRepresentationStyleProps,
15
+ // TextInputResponsivePaddingStyleProps,
16
+ // textInputBaseStyle,
17
+ // textInputFontSizeStyle,
18
+ // // textInputRepresentationStyle,
19
+ // // textInputRootStyle,
20
+ // } from '../../styles/internal'
20
21
  import {useRootTheme} from '../../theme'
21
- import {Radius} from '../../types'
22
22
  import {Box} from '../box'
23
23
  import {Button, ButtonProps} from '../button'
24
24
  import {Card} from '../card'
@@ -50,7 +50,7 @@ export type TextInputType =
50
50
  /**
51
51
  * @public
52
52
  */
53
- export interface TextInputProps {
53
+ export interface TextInputProps extends RadiusStyleProps {
54
54
  /**
55
55
  * @beta
56
56
  */
@@ -61,82 +61,89 @@ export interface TextInputProps {
61
61
  */
62
62
  clearButton?: boolean | TextInputClearButtonProps
63
63
  customValidity?: string
64
- fontSize?: number | number[]
64
+ fontSize?: ResponsiveProp<FontTextSize>
65
65
  icon?: React.ElementType | React.ReactNode
66
66
  iconRight?: React.ElementType | React.ReactNode
67
67
  /**
68
68
  * @beta
69
69
  */
70
70
  onClear?: () => void
71
- padding?: number | number[]
71
+ padding: ResponsiveProp<Space>
72
+ // padding?: number | number[]
72
73
  prefix?: React.ReactNode
73
- radius?: Radius | Radius[]
74
- space?: number | number[]
74
+ // radius?: Radius | Radius[]
75
+ // space?: number | number[]
76
+ space?: ResponsiveProp<Space>
75
77
  suffix?: React.ReactNode
76
78
  type?: TextInputType
77
79
  weight?: ThemeFontWeightKey
78
80
  }
79
81
 
80
- const CLEAR_BUTTON_BOX_STYLE: React.CSSProperties = {zIndex: 2}
81
-
82
- const Root = styled(Card).attrs({forwardedAs: 'span'})(textInputRootStyle)
83
-
84
- const InputRoot = styled.span`
85
- flex: 1;
86
- min-width: 0;
87
- display: block;
88
- position: relative;
89
- `
90
-
91
- const Prefix = styled(Card).attrs({forwardedAs: 'span'})`
92
- border-top-right-radius: 0;
93
- border-bottom-right-radius: 0;
94
-
95
- & > span {
96
- display: block;
97
- margin: -1px;
98
- }
99
- `
100
-
101
- const Suffix = styled(Card).attrs({forwardedAs: 'span'})`
102
- border-top-left-radius: 0;
103
- border-bottom-left-radius: 0;
104
-
105
- & > span {
106
- display: block;
107
- margin: -1px;
108
- }
109
- `
110
-
111
- const Input = styled.input<TextInputResponsivePaddingStyleProps & TextInputInputStyleProps>(
112
- responsiveInputPaddingStyle,
113
- textInputBaseStyle,
114
- textInputFontSizeStyle,
115
- )
116
-
117
- const Presentation = styled.span<ResponsiveRadiusStyleProps & TextInputRepresentationStyleProps>(
118
- responsiveRadiusStyle,
119
- textInputRepresentationStyle,
120
- )
121
-
122
- const LeftBox = styled(Box)`
123
- position: absolute;
124
- top: 0;
125
- left: 0;
126
- `
127
-
128
- const RightBox = styled(Box)`
129
- position: absolute;
130
- top: 0;
131
- right: 0;
132
- `
133
-
134
- const RightCard = styled(Card)`
135
- background-color: transparent;
136
- position: absolute;
137
- top: 0;
138
- right: 0;
139
- `
82
+ const CLEAR_BUTTON_BOX_STYLE: React.CSSProperties = {
83
+ backgroundColor: 'transparent',
84
+ top: 0,
85
+ right: 0,
86
+ zIndex: 2,
87
+ }
88
+
89
+ // const Root = styled(Card).attrs({forwardedAs: 'span'})(textInputRootStyle)
90
+
91
+ // const InputRoot = styled.span`
92
+ // flex: 1;
93
+ // min-width: 0;
94
+ // display: block;
95
+ // position: relative;
96
+ // `
97
+
98
+ // const Prefix = styled(Card).attrs({forwardedAs: 'span'})`
99
+ // border-top-right-radius: 0;
100
+ // border-bottom-right-radius: 0;
101
+
102
+ // & > span {
103
+ // display: block;
104
+ // margin: -1px;
105
+ // }
106
+ // `
107
+
108
+ // const Suffix = styled(Card).attrs({forwardedAs: 'span'})`
109
+ // border-top-left-radius: 0;
110
+ // border-bottom-left-radius: 0;
111
+
112
+ // & > span {
113
+ // display: block;
114
+ // margin: -1px;
115
+ // }
116
+ // `
117
+
118
+ // const Input = styled.input<TextInputResponsivePaddingStyleProps & TextInputInputStyleProps>(
119
+ // responsiveInputPaddingStyle,
120
+ // textInputBaseStyle,
121
+ // textInputFontSizeStyle,
122
+ // )
123
+
124
+ // const Presentation = styled.span<ResponsiveRadiusStyleProps & TextInputRepresentationStyleProps>(
125
+ // responsiveRadiusStyle,
126
+ // textInputRepresentationStyle,
127
+ // )
128
+
129
+ // const LeftBox = styled(Box)`
130
+ // position: absolute;
131
+ // top: 0;
132
+ // left: 0;
133
+ // `
134
+
135
+ // const RightBox = styled(Box)`
136
+ // position: absolute;
137
+ // top: 0;
138
+ // right: 0;
139
+ // `
140
+
141
+ // const RightCard = styled(Card)`
142
+ // background-color: transparent;
143
+ // position: absolute;
144
+ // top: 0;
145
+ // right: 0;
146
+ // `
140
147
 
141
148
  const TextInputClearButton = styled(Button)({
142
149
  '&:not([hidden])': {
@@ -156,6 +163,7 @@ export const TextInput = forwardRef(function TextInput(
156
163
  const {
157
164
  __unstable_disableFocusRing,
158
165
  border = true,
166
+ className,
159
167
  clearButton,
160
168
  disabled = false,
161
169
  fontSize: fontSizeProp = 2,
@@ -166,11 +174,11 @@ export const TextInput = forwardRef(function TextInput(
166
174
  prefix,
167
175
  radius: radiusProp = 2,
168
176
  readOnly,
169
- space: spaceProp = 3,
177
+ space: _space = 3,
170
178
  suffix,
171
179
  customValidity,
172
180
  type = 'text',
173
- weight,
181
+ weight: _width,
174
182
  ...restProps
175
183
  } = props
176
184
  const ref = useRef<HTMLInputElement | null>(null)
@@ -180,14 +188,14 @@ export const TextInput = forwardRef(function TextInput(
180
188
  const fontSize = useArrayProp(fontSizeProp)
181
189
  const padding = useArrayProp(paddingProp)
182
190
  const radius = useArrayProp(radiusProp)
183
- const space = useArrayProp(spaceProp)
191
+ // const space = useArrayProp(spaceProp)
184
192
 
185
193
  // Transient properties
186
194
  const $hasClearButton = Boolean(clearButton)
187
- const $hasIcon = Boolean(IconComponent)
188
- const $hasIconRight = Boolean(IconRightComponent)
189
- const $hasSuffix = Boolean(suffix)
190
- const $hasPrefix = Boolean(prefix)
195
+ // const $hasIcon = Boolean(IconComponent)
196
+ // const $hasIconRight = Boolean(IconRightComponent)
197
+ // const $hasSuffix = Boolean(suffix)
198
+ // const $hasPrefix = Boolean(prefix)
191
199
 
192
200
  useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(
193
201
  forwardedRef,
@@ -219,9 +227,18 @@ export const TextInput = forwardRef(function TextInput(
219
227
  const prefixNode = useMemo(
220
228
  () =>
221
229
  prefix && (
222
- <Prefix borderTop borderLeft borderBottom radius={radius} sizing="border" tone="inherit">
230
+ <Card
231
+ as="span"
232
+ borderTop
233
+ borderLeft
234
+ borderBottom
235
+ className="text-input-prefix"
236
+ radius={radius}
237
+ sizing="border"
238
+ tone="inherit"
239
+ >
223
240
  <span>{prefix}</span>
224
- </Prefix>
241
+ </Card>
225
242
  ),
226
243
  [prefix, radius],
227
244
  )
@@ -229,35 +246,41 @@ export const TextInput = forwardRef(function TextInput(
229
246
  // Render presentation (memoized)
230
247
  const presentationNode = useMemo(
231
248
  () => (
232
- <Presentation
233
- $hasPrefix={$hasPrefix}
234
- $unstableDisableFocusRing={__unstable_disableFocusRing}
235
- $hasSuffix={$hasSuffix}
236
- $radius={radius}
237
- $scheme={rootTheme.scheme}
238
- $tone={rootTheme.tone}
249
+ <Card
250
+ as="span"
251
+ // $hasPrefix={$hasPrefix}
252
+ // $unstableDisableFocusRing={__unstable_disableFocusRing}
253
+ // $hasSuffix={$hasSuffix}
254
+ // $radius={radius}
255
+ // $scheme={rootTheme.scheme}
256
+ // $tone={rootTheme.tone}
257
+ border={border}
258
+ className="text-input-presentation"
239
259
  data-border={border ? '' : undefined}
260
+ data-disable-focus-ring={__unstable_disableFocusRing ? '' : undefined}
240
261
  data-scheme={rootTheme.scheme}
241
262
  data-tone={rootTheme.tone}
263
+ position="absolute"
264
+ radius={radius}
242
265
  >
243
266
  {IconComponent && (
244
- <LeftBox padding={padding}>
267
+ <Box as="span" padding={padding} position="absolute" style={{top: 0, left: 0}}>
245
268
  <Text size={fontSize}>
246
269
  {isValidElement(IconComponent) && IconComponent}
247
270
  {isValidElementType(IconComponent) && <IconComponent />}
248
271
  </Text>
249
- </LeftBox>
272
+ </Box>
250
273
  )}
251
274
 
252
275
  {!$hasClearButton && IconRightComponent && (
253
- <RightBox padding={padding}>
276
+ <Box as="span" padding={padding} position="absolute" style={{top: 0, right: 0}}>
254
277
  <Text size={fontSize}>
255
278
  {isValidElement(IconRightComponent) && IconRightComponent}
256
279
  {isValidElementType(IconRightComponent) && <IconRightComponent />}
257
280
  </Text>
258
- </RightBox>
281
+ </Box>
259
282
  )}
260
- </Presentation>
283
+ </Card>
261
284
  ),
262
285
  [
263
286
  __unstable_disableFocusRing,
@@ -269,8 +292,8 @@ export const TextInput = forwardRef(function TextInput(
269
292
  radius,
270
293
  rootTheme,
271
294
  $hasClearButton,
272
- $hasPrefix,
273
- $hasSuffix,
295
+ // $hasPrefix,
296
+ // $hasSuffix,
274
297
  ],
275
298
  )
276
299
 
@@ -282,10 +305,11 @@ export const TextInput = forwardRef(function TextInput(
282
305
  if (v === 1) return 1
283
306
  if (v === 2) return 1
284
307
 
285
- return v - 2
308
+ return (v as Space) - 2
286
309
  }),
287
310
  [padding],
288
311
  )
312
+
289
313
  const clearButtonPadding = useMemo(
290
314
  () =>
291
315
  padding.map((v) => {
@@ -293,7 +317,7 @@ export const TextInput = forwardRef(function TextInput(
293
317
  if (v === 1) return 0
294
318
  if (v === 2) return 1
295
319
 
296
- return v - 1
320
+ return (v as Space) - 1
297
321
  }),
298
322
  [padding],
299
323
  )
@@ -306,11 +330,16 @@ export const TextInput = forwardRef(function TextInput(
306
330
  !disabled &&
307
331
  !readOnly &&
308
332
  clearButton && (
309
- <RightCard
310
- forwardedAs="span"
333
+ <Card
334
+ // forwardedAs="span"
311
335
  padding={clearButtonBoxPadding}
336
+ position="absolute"
312
337
  style={CLEAR_BUTTON_BOX_STYLE}
313
338
  tone={customValidity ? 'critical' : 'inherit'}
339
+
340
+ // position: absolute;
341
+ // top: 0;
342
+ // right: 0;
314
343
  >
315
344
  <TextInputClearButton
316
345
  aria-label="Clear"
@@ -324,7 +353,7 @@ export const TextInput = forwardRef(function TextInput(
324
353
  onClick={handleClearClick}
325
354
  onMouseDown={handleClearMouseDown}
326
355
  />
327
- </RightCard>
356
+ </Card>
328
357
  ),
329
358
  [
330
359
  clearButton,
@@ -345,31 +374,54 @@ export const TextInput = forwardRef(function TextInput(
345
374
  const suffixNode = useMemo(
346
375
  () =>
347
376
  suffix && (
348
- <Suffix borderTop borderRight borderBottom radius={radius} sizing="border" tone="inherit">
377
+ <Card
378
+ as="span"
379
+ borderTop
380
+ borderRight
381
+ borderBottom
382
+ className="text-input-suffix"
383
+ radius={radius}
384
+ sizing="border"
385
+ tone="inherit"
386
+ >
349
387
  <span>{suffix}</span>
350
- </Suffix>
388
+ </Card>
351
389
  ),
352
390
  [radius, suffix],
353
391
  )
354
392
 
355
393
  return (
356
- <Root data-ui="TextInput" tone={rootTheme.tone}>
394
+ <Card
395
+ align="center"
396
+ as="span"
397
+ className={composeClassNames(className, textInput({size: fontSizeProp}))}
398
+ data-ui="TextInput"
399
+ display="flex"
400
+ tone={rootTheme.tone}
401
+ >
357
402
  {prefixNode}
358
403
 
359
- <InputRoot>
360
- <Input
404
+ <Box
405
+ as="span"
406
+ className="text-input-wrapper"
407
+ flex={1}
408
+ // todo
409
+ // minWidth={0}
410
+ position="relative"
411
+ >
412
+ <input
361
413
  data-as="input"
362
414
  data-scheme={rootTheme.scheme}
363
415
  data-tone={rootTheme.tone}
364
416
  {...restProps}
365
- $fontSize={fontSize}
366
- $iconLeft={$hasIcon}
367
- $iconRight={$hasIconRight || $hasClearButton}
368
- $padding={padding}
369
- $scheme={rootTheme.scheme}
370
- $space={space}
371
- $tone={rootTheme.tone}
372
- $weight={weight}
417
+ // $fontSize={fontSize}
418
+ // $iconLeft={$hasIcon}
419
+ // $iconRight={$hasIconRight || $hasClearButton}
420
+ // $padding={padding}
421
+ // $scheme={rootTheme.scheme}
422
+ // $space={space}
423
+ // $tone={rootTheme.tone}
424
+ // $weight={weight}
373
425
  disabled={disabled}
374
426
  readOnly={readOnly}
375
427
  ref={ref}
@@ -378,10 +430,11 @@ export const TextInput = forwardRef(function TextInput(
378
430
 
379
431
  {presentationNode}
380
432
  {clearButtonNode}
381
- </InputRoot>
433
+ </Box>
382
434
 
383
435
  {suffixNode}
384
- </Root>
436
+ </Card>
385
437
  )
386
438
  })
439
+
387
440
  TextInput.displayName = 'ForwardRef(TextInput)'
@@ -1,4 +1,5 @@
1
1
  /** @jest-environment jsdom */
2
+
2
3
  import {screen, act, fireEvent} from '@testing-library/react'
3
4
  import '../../../../test/mocks/resizeObserver.mock'
4
5
  import '../../../../test/mocks/matchMedia.mock'
@@ -9,6 +9,7 @@ import {
9
9
  type Middleware,
10
10
  type RootBoundary,
11
11
  } from '@floating-ui/react-dom'
12
+ import {composeClassNames, RadiusStyleProps, tooltip} from '@sanity/ui/css'
12
13
  import type {ThemeColorSchemeKey} from '@sanity/ui/theme'
13
14
  import {AnimatePresence} from 'framer-motion'
14
15
  import {
@@ -23,7 +24,6 @@ import {
23
24
  useImperativeHandle,
24
25
  useLayoutEffect,
25
26
  } from 'react'
26
- import {styled} from 'styled-components'
27
27
  import {useEffectEvent} from 'use-effect-event'
28
28
  import {useArrayProp, usePrefersReducedMotion} from '../../hooks'
29
29
  import {useDelayedState} from '../../hooks/useDelayedState'
@@ -43,7 +43,7 @@ import {useTooltipDelayGroup} from './tooltipDelayGroup'
43
43
  /**
44
44
  * @public
45
45
  */
46
- export interface TooltipProps extends Omit<LayerProps, 'as'> {
46
+ export interface TooltipProps extends Omit<LayerProps, 'as'>, RadiusStyleProps {
47
47
  /** @deprecated Use `fallbackPlacements` instead. */
48
48
  allowedAutoPlacements?: Placement[]
49
49
  arrow?: boolean
@@ -56,7 +56,7 @@ export interface TooltipProps extends Omit<LayerProps, 'as'> {
56
56
  placement?: Placement
57
57
  /** Whether or not to render the tooltip in a portal element. */
58
58
  portal?: boolean | string
59
- radius?: number | number[]
59
+ // radius?: number | number[]
60
60
  scheme?: ThemeColorSchemeKey
61
61
  shadow?: number | number[]
62
62
  /**
@@ -79,17 +79,14 @@ export interface TooltipProps extends Omit<LayerProps, 'as'> {
79
79
  animate?: boolean
80
80
  }
81
81
 
82
- const Root = styled(Layer)`
83
- pointer-events: none;
84
- `
85
-
86
82
  /**
87
83
  * Tooltips display information when hovering, focusing or tapping.
88
84
  *
89
85
  * @public
90
86
  */
91
87
  export const Tooltip = forwardRef(function Tooltip(
92
- props: TooltipProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content'>,
88
+ props: TooltipProps &
89
+ Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'width' | 'wrap'>,
93
90
  forwardedRef: React.ForwardedRef<HTMLDivElement>,
94
91
  ) {
95
92
  const boundaryElementContext = useBoundaryElement()
@@ -99,6 +96,7 @@ export const Tooltip = forwardRef(function Tooltip(
99
96
  arrow: arrowProp = false,
100
97
  boundaryElement = boundaryElementContext?.element,
101
98
  children: childProp,
99
+ className,
102
100
  content,
103
101
  disabled,
104
102
  fallbackPlacements: fallbackPlacementsProp = props.fallbackPlacements ??
@@ -364,10 +362,11 @@ export const Tooltip = forwardRef(function Tooltip(
364
362
 
365
363
  if (disabled) return child
366
364
 
367
- const tooltip = (
368
- <Root
365
+ const node = (
366
+ <Layer
369
367
  data-ui="Tooltip"
370
368
  {...restProps}
369
+ className={composeClassNames(className, tooltip())}
371
370
  ref={setFloating}
372
371
  style={{
373
372
  ...floatingStyles,
@@ -393,17 +392,17 @@ export const Tooltip = forwardRef(function Tooltip(
393
392
  >
394
393
  {content}
395
394
  </TooltipCard>
396
- </Root>
395
+ </Layer>
397
396
  )
398
397
 
399
398
  const children =
400
399
  showTooltip &&
401
400
  (portalProp ? (
402
401
  <Portal __unstable_name={typeof portalProp === 'string' ? portalProp : undefined}>
403
- {tooltip}
402
+ {node}
404
403
  </Portal>
405
404
  ) : (
406
- tooltip
405
+ node
407
406
  ))
408
407
 
409
408
  return (
@@ -416,6 +415,7 @@ export const Tooltip = forwardRef(function Tooltip(
416
415
  </>
417
416
  )
418
417
  })
418
+
419
419
  Tooltip.displayName = 'ForwardRef(Tooltip)'
420
420
 
421
421
  /**
@@ -1,9 +1,12 @@
1
+ import {RadiusStyleProps, tooltipCard} from '@sanity/ui/css'
1
2
  import {ThemeColorSchemeKey} from '@sanity/ui/theme'
2
- import {MotionProps, motion} from 'framer-motion'
3
+ import {motion} from 'framer-motion'
3
4
  import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
4
- import {styled} from 'styled-components'
5
- import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY, POPOVER_MOTION_PROPS} from '../../constants'
6
- import {Placement, Radius} from '../../types'
5
+ import {
6
+ // POPOVER_MOTION_CONTENT_OPACITY_PROPERTY,
7
+ POPOVER_MOTION_PROPS,
8
+ } from '../../constants'
9
+ import {Placement} from '../../types'
7
10
  import {Arrow} from '../../utils'
8
11
  import {Card, CardProps} from '../card'
9
12
  import {
@@ -12,12 +15,7 @@ import {
12
15
  DEFAULT_TOOLTIP_ARROW_WIDTH,
13
16
  } from './constants'
14
17
 
15
- const MotionCard = styled(motion(Card))`
16
- & > * {
17
- opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
18
- will-change: opacity;
19
- }
20
- `
18
+ const MotionCard = motion(Card)
21
19
 
22
20
  /**
23
21
  * @internal
@@ -34,10 +32,10 @@ export const TooltipCard = memo(
34
32
  originY?: number
35
33
  padding?: number | number[]
36
34
  placement?: Placement
37
- radius?: Radius | Radius[]
38
35
  scheme?: ThemeColorSchemeKey
39
36
  shadow?: number | number[]
40
- } & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width'>,
37
+ } & RadiusStyleProps &
38
+ Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width' | 'wrap'>,
41
39
  ref: React.ForwardedRef<HTMLDivElement>,
42
40
  ) {
43
41
  const {
@@ -81,7 +79,9 @@ export const TooltipCard = memo(
81
79
  return (
82
80
  <MotionCard
83
81
  data-ui="Tooltip__card"
84
- {...(restProps as CardProps & MotionProps)}
82
+ {...(restProps as CardProps)}
83
+ data-animate={animate ? '' : undefined}
84
+ className={tooltipCard()}
85
85
  data-placement={placement}
86
86
  padding={padding}
87
87
  radius={radius}
@@ -89,7 +89,7 @@ export const TooltipCard = memo(
89
89
  scheme={scheme}
90
90
  shadow={shadow}
91
91
  style={rootStyle}
92
- {...(animate ? POPOVER_MOTION_PROPS : {})}
92
+ {...((animate ? POPOVER_MOTION_PROPS : {}) as CardProps)}
93
93
  >
94
94
  {children}
95
95
 
@@ -106,4 +106,5 @@ export const TooltipCard = memo(
106
106
  )
107
107
  }),
108
108
  )
109
+
109
110
  TooltipCard.displayName = 'Memo(ForwardRef(TooltipCard))'