@sanity/ui 0.37.10 → 0.37.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 (242) hide show
  1. package/lib/dts/src/components/autocomplete/autocomplete.d.ts +2 -2
  2. package/lib/dts/src/components/autocomplete/autocomplete.d.ts.map +1 -1
  3. package/lib/dts/src/components/autocomplete/autocomplete.styles.d.ts.map +1 -1
  4. package/lib/dts/src/components/autocomplete/constants.d.ts +0 -4
  5. package/lib/dts/src/components/autocomplete/constants.d.ts.map +1 -1
  6. package/lib/dts/src/components/breadcrumbs/breadcrumbs.d.ts.map +1 -1
  7. package/lib/dts/src/components/dialog/dialog.d.ts.map +1 -1
  8. package/lib/dts/src/components/dialog/styles.d.ts +1 -1
  9. package/lib/dts/src/components/dialog/styles.d.ts.map +1 -1
  10. package/lib/dts/src/components/hotkeys/hotkeys.d.ts.map +1 -1
  11. package/lib/dts/src/components/menu/menuButton.d.ts.map +1 -1
  12. package/lib/dts/src/components/menu/menuGroup.d.ts.map +1 -1
  13. package/lib/dts/src/components/menu/menuItem.d.ts.map +1 -1
  14. package/lib/dts/src/components/skeleton/skeleton.d.ts.map +1 -1
  15. package/lib/dts/src/hooks/_internal/useUnique.d.ts +2 -3
  16. package/lib/dts/src/hooks/_internal/useUnique.d.ts.map +1 -1
  17. package/lib/dts/src/hooks/index.d.ts +2 -1
  18. package/lib/dts/src/hooks/index.d.ts.map +1 -1
  19. package/lib/dts/src/hooks/useArrayProp.d.ts +7 -0
  20. package/lib/dts/src/hooks/useArrayProp.d.ts.map +1 -0
  21. package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts +1 -1
  22. package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts.map +1 -1
  23. package/lib/dts/src/hooks/useElementSize.d.ts +7 -0
  24. package/lib/dts/src/hooks/useElementSize.d.ts.map +1 -0
  25. package/lib/dts/src/index.d.ts +1 -0
  26. package/lib/dts/src/index.d.ts.map +1 -1
  27. package/lib/dts/src/observers/elementSizeObserver.d.ts +37 -0
  28. package/lib/dts/src/observers/elementSizeObserver.d.ts.map +1 -0
  29. package/lib/dts/src/observers/index.d.ts +3 -0
  30. package/lib/dts/src/observers/index.d.ts.map +1 -0
  31. package/lib/dts/src/observers/resizeObserver.d.ts +5 -0
  32. package/lib/dts/src/observers/resizeObserver.d.ts.map +1 -0
  33. package/lib/dts/src/primitives/_selectable/selectable.d.ts +1 -2
  34. package/lib/dts/src/primitives/_selectable/selectable.d.ts.map +1 -1
  35. package/lib/dts/src/primitives/avatar/avatar.d.ts.map +1 -1
  36. package/lib/dts/src/primitives/avatar/avatarCounter.d.ts +1 -0
  37. package/lib/dts/src/primitives/avatar/avatarCounter.d.ts.map +1 -1
  38. package/lib/dts/src/primitives/avatar/avatarStack.d.ts +1 -0
  39. package/lib/dts/src/primitives/avatar/avatarStack.d.ts.map +1 -1
  40. package/lib/dts/src/primitives/avatar/styles.d.ts.map +1 -1
  41. package/lib/dts/src/primitives/badge/badge.d.ts.map +1 -1
  42. package/lib/dts/src/primitives/box/box.d.ts.map +1 -1
  43. package/lib/dts/src/primitives/button/button.d.ts.map +1 -1
  44. package/lib/dts/src/primitives/card/card.d.ts.map +1 -1
  45. package/lib/dts/src/primitives/code/code.d.ts.map +1 -1
  46. package/lib/dts/src/primitives/container/container.d.ts.map +1 -1
  47. package/lib/dts/src/primitives/container/styles.d.ts.map +1 -1
  48. package/lib/dts/src/primitives/container/types.d.ts +1 -1
  49. package/lib/dts/src/primitives/container/types.d.ts.map +1 -1
  50. package/lib/dts/src/primitives/flex/flex.d.ts.map +1 -1
  51. package/lib/dts/src/primitives/grid/grid.d.ts.map +1 -1
  52. package/lib/dts/src/primitives/heading/heading.d.ts.map +1 -1
  53. package/lib/dts/src/primitives/inline/inline.d.ts.map +1 -1
  54. package/lib/dts/src/primitives/inline/styles.d.ts.map +1 -1
  55. package/lib/dts/src/primitives/inline/types.d.ts +1 -1
  56. package/lib/dts/src/primitives/inline/types.d.ts.map +1 -1
  57. package/lib/dts/src/primitives/kbd/kbd.d.ts.map +1 -1
  58. package/lib/dts/src/primitives/label/label.d.ts.map +1 -1
  59. package/lib/dts/src/primitives/popover/popover.d.ts.map +1 -1
  60. package/lib/dts/src/primitives/select/styles.d.ts +5 -1
  61. package/lib/dts/src/primitives/select/styles.d.ts.map +1 -1
  62. package/lib/dts/src/primitives/stack/stack.d.ts.map +1 -1
  63. package/lib/dts/src/primitives/stack/styles.d.ts +1 -1
  64. package/lib/dts/src/primitives/stack/styles.d.ts.map +1 -1
  65. package/lib/dts/src/primitives/text/text.d.ts.map +1 -1
  66. package/lib/dts/src/primitives/textArea/textArea.d.ts.map +1 -1
  67. package/lib/dts/src/primitives/textInput/textInput.d.ts.map +1 -1
  68. package/lib/dts/src/primitives/tooltip/tooltip.d.ts.map +1 -1
  69. package/lib/dts/src/primitives/types.d.ts +1 -1
  70. package/lib/dts/src/primitives/types.d.ts.map +1 -1
  71. package/lib/dts/src/styles/border/types.d.ts +5 -5
  72. package/lib/dts/src/styles/border/types.d.ts.map +1 -1
  73. package/lib/dts/src/styles/box/types.d.ts +4 -4
  74. package/lib/dts/src/styles/box/types.d.ts.map +1 -1
  75. package/lib/dts/src/styles/flex/flexItemStyle.d.ts.map +1 -1
  76. package/lib/dts/src/styles/flex/types.d.ts +6 -6
  77. package/lib/dts/src/styles/flex/types.d.ts.map +1 -1
  78. package/lib/dts/src/styles/font/responsiveFont.d.ts +1 -1
  79. package/lib/dts/src/styles/font/responsiveFont.d.ts.map +1 -1
  80. package/lib/dts/src/styles/font/types.d.ts +3 -3
  81. package/lib/dts/src/styles/font/types.d.ts.map +1 -1
  82. package/lib/dts/src/styles/grid/types.d.ts +14 -14
  83. package/lib/dts/src/styles/grid/types.d.ts.map +1 -1
  84. package/lib/dts/src/styles/helpers.d.ts +4 -4
  85. package/lib/dts/src/styles/helpers.d.ts.map +1 -1
  86. package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts +12 -12
  87. package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts.map +1 -1
  88. package/lib/dts/src/styles/input/textInputStyle.d.ts +4 -1
  89. package/lib/dts/src/styles/input/textInputStyle.d.ts.map +1 -1
  90. package/lib/dts/src/styles/margin/types.d.ts +7 -7
  91. package/lib/dts/src/styles/margin/types.d.ts.map +1 -1
  92. package/lib/dts/src/styles/padding/types.d.ts +7 -7
  93. package/lib/dts/src/styles/padding/types.d.ts.map +1 -1
  94. package/lib/dts/src/styles/radius/types.d.ts +1 -1
  95. package/lib/dts/src/styles/radius/types.d.ts.map +1 -1
  96. package/lib/dts/src/styles/shadow/shadowStyle.d.ts.map +1 -1
  97. package/lib/dts/src/styles/shadow/types.d.ts +1 -1
  98. package/lib/dts/src/styles/shadow/types.d.ts.map +1 -1
  99. package/lib/dts/src/theme/lib/theme/fonts.d.ts +1 -3
  100. package/lib/dts/src/theme/lib/theme/fonts.d.ts.map +1 -1
  101. package/lib/dts/src/theme/studioTheme/fonts.d.ts.map +1 -1
  102. package/lib/dts/src/types/index.d.ts +2 -1
  103. package/lib/dts/src/types/index.d.ts.map +1 -1
  104. package/lib/dts/src/types/placement.d.ts +7 -0
  105. package/lib/dts/src/types/placement.d.ts.map +1 -0
  106. package/lib/dts/src/types/text.d.ts +5 -0
  107. package/lib/dts/src/types/text.d.ts.map +1 -0
  108. package/lib/dts/src/utils/elementQuery/elementQuery.d.ts.map +1 -1
  109. package/lib/dts/src/utils/index.d.ts +0 -1
  110. package/lib/dts/src/utils/index.d.ts.map +1 -1
  111. package/lib/dts/src/utils/virtualList/virtualList.d.ts.map +1 -1
  112. package/lib/sanity-ui.js +738 -627
  113. package/lib/sanity-ui.js.map +1 -1
  114. package/lib/{sanity-ui.modern.js → sanity-ui.modern.mjs} +736 -616
  115. package/lib/sanity-ui.modern.mjs.map +1 -0
  116. package/lib/sanity-ui.module.js +732 -623
  117. package/lib/sanity-ui.module.js.map +1 -1
  118. package/package.json +11 -11
  119. package/src/__workshop__/color/overview.tsx +9 -11
  120. package/src/components/autocomplete/__workshop__/async.tsx +14 -12
  121. package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +36 -0
  122. package/src/components/autocomplete/autocomplete.styles.tsx +0 -1
  123. package/src/components/autocomplete/autocomplete.tsx +14 -7
  124. package/src/components/autocomplete/constants.ts +0 -5
  125. package/src/components/breadcrumbs/breadcrumbs.tsx +3 -2
  126. package/src/components/dialog/dialog.tsx +17 -9
  127. package/src/components/dialog/styles.ts +3 -3
  128. package/src/components/hotkeys/hotkeys.tsx +3 -1
  129. package/src/components/menu/__workshop__/constrainedInBoundary.tsx +11 -14
  130. package/src/components/menu/__workshop__/groups.tsx +1 -1
  131. package/src/components/menu/menuButton.tsx +21 -13
  132. package/src/components/menu/menuGroup.tsx +3 -2
  133. package/src/components/menu/menuItem.tsx +4 -5
  134. package/src/components/skeleton/skeleton.tsx +10 -1
  135. package/src/components/skeleton/textSkeleton.tsx +7 -7
  136. package/src/hooks/_internal/useUnique.ts +4 -5
  137. package/src/hooks/index.ts +2 -1
  138. package/src/hooks/useArrayProp.ts +23 -0
  139. package/src/hooks/useElementRect/useElementRect.ts +4 -16
  140. package/src/hooks/useElementSize.ts +18 -0
  141. package/src/index.ts +1 -0
  142. package/src/observers/elementSizeObserver.ts +116 -0
  143. package/src/observers/index.ts +2 -0
  144. package/src/{utils → observers}/resizeObserver.ts +1 -4
  145. package/src/primitives/_selectable/selectable.tsx +5 -4
  146. package/src/primitives/avatar/avatar.tsx +7 -5
  147. package/src/primitives/avatar/avatarCounter.tsx +14 -12
  148. package/src/primitives/avatar/avatarStack.tsx +19 -13
  149. package/src/primitives/avatar/styles.ts +2 -2
  150. package/src/primitives/badge/badge.tsx +3 -2
  151. package/src/primitives/box/box.tsx +27 -26
  152. package/src/primitives/button/button.tsx +22 -10
  153. package/src/primitives/card/card.tsx +13 -11
  154. package/src/primitives/checkbox/__workshop__/example.tsx +4 -2
  155. package/src/primitives/checkbox/__workshop__/props.tsx +4 -2
  156. package/src/primitives/checkbox/__workshop__/readOnly.tsx +4 -2
  157. package/src/primitives/code/__workshop__/props.tsx +1 -1
  158. package/src/primitives/code/code.tsx +2 -1
  159. package/src/primitives/container/container.tsx +10 -1
  160. package/src/primitives/container/styles.ts +2 -2
  161. package/src/primitives/container/types.ts +1 -1
  162. package/src/primitives/flex/flex.tsx +6 -5
  163. package/src/primitives/grid/__workshop__/responsive.tsx +13 -12
  164. package/src/primitives/grid/grid.tsx +9 -8
  165. package/src/primitives/heading/__workshop__/opticalAlignment.tsx +19 -7
  166. package/src/primitives/heading/heading.tsx +3 -2
  167. package/src/primitives/inline/inline.tsx +12 -6
  168. package/src/primitives/inline/styles.ts +2 -2
  169. package/src/primitives/inline/types.ts +1 -1
  170. package/src/primitives/kbd/kbd.tsx +2 -1
  171. package/src/primitives/label/label.tsx +4 -3
  172. package/src/primitives/popover/__workshop__/{margins.tsx → MarginsStory.tsx} +1 -1
  173. package/src/primitives/popover/__workshop__/{matchReferenceWidth.tsx → MatchReferenceWidthStory.tsx} +0 -0
  174. package/src/primitives/popover/__workshop__/{plain.tsx → PlainStory.tsx} +12 -14
  175. package/src/primitives/popover/__workshop__/{recursive.tsx → RecursiveStory.tsx} +4 -1
  176. package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +60 -0
  177. package/src/primitives/popover/__workshop__/TestStory.tsx +79 -0
  178. package/src/primitives/popover/__workshop__/index.ts +10 -5
  179. package/src/primitives/popover/popover.tsx +5 -3
  180. package/src/primitives/select/select.tsx +9 -9
  181. package/src/primitives/select/styles.ts +10 -4
  182. package/src/primitives/stack/stack.tsx +2 -1
  183. package/src/primitives/stack/styles.ts +3 -3
  184. package/src/primitives/text/__workshop__/opticalAlignment.tsx +15 -5
  185. package/src/primitives/text/text.tsx +3 -2
  186. package/src/primitives/textArea/__workshop__/plain.tsx +23 -18
  187. package/src/primitives/textArea/textArea.tsx +17 -5
  188. package/src/primitives/textInput/__workshop__/clearButton.tsx +14 -8
  189. package/src/primitives/textInput/__workshop__/index.ts +2 -2
  190. package/src/primitives/textInput/__workshop__/plain.tsx +39 -32
  191. package/src/primitives/textInput/__workshop__/tones.tsx +97 -75
  192. package/src/primitives/textInput/__workshop__/typed.tsx +8 -2
  193. package/src/primitives/textInput/textInput.tsx +43 -12
  194. package/src/primitives/tooltip/__workshop__/props.tsx +5 -1
  195. package/src/primitives/tooltip/tooltip.tsx +3 -2
  196. package/src/primitives/types.ts +1 -1
  197. package/src/styles/border/borderStyle.ts +6 -6
  198. package/src/styles/border/types.ts +5 -5
  199. package/src/styles/box/boxStyle.ts +5 -5
  200. package/src/styles/box/types.ts +4 -4
  201. package/src/styles/flex/flexItemStyle.ts +5 -4
  202. package/src/styles/flex/flexStyle.ts +6 -6
  203. package/src/styles/flex/types.ts +6 -6
  204. package/src/styles/font/responsiveFont.ts +7 -27
  205. package/src/styles/font/textAlignStyle.ts +2 -2
  206. package/src/styles/font/types.ts +4 -3
  207. package/src/styles/grid/gridItemStyle.ts +7 -7
  208. package/src/styles/grid/gridStyle.ts +9 -9
  209. package/src/styles/grid/types.ts +14 -14
  210. package/src/styles/helpers.ts +9 -9
  211. package/src/styles/input/responsiveInputPaddingStyle.ts +24 -27
  212. package/src/styles/input/textInputStyle.ts +89 -79
  213. package/src/styles/margin/marginStyle.ts +8 -8
  214. package/src/styles/margin/marginsStyle.test.ts +1 -1
  215. package/src/styles/margin/types.ts +7 -7
  216. package/src/styles/padding/paddingStyle.test.ts +1 -1
  217. package/src/styles/padding/paddingStyle.ts +8 -8
  218. package/src/styles/padding/types.ts +7 -7
  219. package/src/styles/radius/radiusStyle.ts +2 -2
  220. package/src/styles/radius/types.ts +1 -1
  221. package/src/styles/shadow/shadowStyle.ts +2 -5
  222. package/src/styles/shadow/types.ts +1 -1
  223. package/src/theme/lib/theme/fonts.ts +1 -3
  224. package/src/theme/studioTheme/fonts.ts +5 -9
  225. package/src/types/index.ts +2 -2
  226. package/src/types/placement.ts +18 -0
  227. package/src/types/text.ts +4 -0
  228. package/src/utils/elementQuery/elementQuery.tsx +5 -18
  229. package/src/utils/index.ts +0 -1
  230. package/src/utils/layer/layer.tsx +1 -1
  231. package/src/utils/layer/layerProvider.tsx +2 -2
  232. package/src/utils/virtualList/virtualList.tsx +8 -7
  233. package/lib/dts/src/hooks/useResponsiveProp.d.ts +0 -6
  234. package/lib/dts/src/hooks/useResponsiveProp.d.ts.map +0 -1
  235. package/lib/dts/src/types/common.d.ts +0 -11
  236. package/lib/dts/src/types/common.d.ts.map +0 -1
  237. package/lib/dts/src/utils/resizeObserver.d.ts +0 -6
  238. package/lib/dts/src/utils/resizeObserver.d.ts.map +0 -1
  239. package/lib/sanity-ui.modern.js.map +0 -1
  240. package/src/hooks/useResponsiveProp.ts +0 -10
  241. package/src/primitives/popover/__workshop__/rightAligned.tsx +0 -57
  242. package/src/types/common.ts +0 -12
@@ -1,7 +1,14 @@
1
1
  import {Box, Card, Container, Stack, Text, TextInput} from '@sanity/ui'
2
+ import {useBoolean} from '@sanity/ui-workshop'
2
3
  import React from 'react'
3
4
 
4
5
  export default function TonesStory() {
6
+ const transparentTone = useBoolean('Transparent', true)
7
+ const primaryTone = useBoolean('Primary', true)
8
+ const positiveTone = useBoolean('Positive', true)
9
+ const cautionTone = useBoolean('Caution', true)
10
+ const criticalTone = useBoolean('Critical', true)
11
+
5
12
  return (
6
13
  <Container width={1}>
7
14
  <Stack padding={[3, 4, 5]} space={4}>
@@ -20,81 +27,96 @@ export default function TonesStory() {
20
27
  }
21
28
  />
22
29
  </Card>
23
- <Card padding={3} tone="transparent">
24
- <TextInput
25
- placeholder="transparent"
26
- prefix={
27
- <Box padding={3}>
28
- <Text>prefix</Text>
29
- </Box>
30
- }
31
- suffix={
32
- <Box padding={3}>
33
- <Text>suffix</Text>
34
- </Box>
35
- }
36
- />
37
- </Card>
38
- <Card padding={3} tone="primary">
39
- <TextInput
40
- placeholder="primary"
41
- prefix={
42
- <Box padding={3}>
43
- <Text>prefix</Text>
44
- </Box>
45
- }
46
- suffix={
47
- <Box padding={3}>
48
- <Text>suffix</Text>
49
- </Box>
50
- }
51
- />
52
- </Card>
53
- <Card padding={3} tone="positive">
54
- <TextInput
55
- placeholder="positive"
56
- prefix={
57
- <Box padding={3}>
58
- <Text>prefix</Text>
59
- </Box>
60
- }
61
- suffix={
62
- <Box padding={3}>
63
- <Text>suffix</Text>
64
- </Box>
65
- }
66
- />
67
- </Card>
68
- <Card padding={3} tone="caution">
69
- <TextInput
70
- placeholder="caution"
71
- prefix={
72
- <Box padding={3}>
73
- <Text>prefix</Text>
74
- </Box>
75
- }
76
- suffix={
77
- <Box padding={3}>
78
- <Text>suffix</Text>
79
- </Box>
80
- }
81
- />
82
- </Card>
83
- <Card padding={3} tone="critical">
84
- <TextInput
85
- placeholder="critical"
86
- prefix={
87
- <Box padding={3}>
88
- <Text>prefix</Text>
89
- </Box>
90
- }
91
- suffix={
92
- <Box padding={3}>
93
- <Text>suffix</Text>
94
- </Box>
95
- }
96
- />
97
- </Card>
30
+
31
+ {transparentTone && (
32
+ <Card padding={3} tone="transparent">
33
+ <TextInput
34
+ placeholder="transparent"
35
+ prefix={
36
+ <Box padding={3}>
37
+ <Text>prefix</Text>
38
+ </Box>
39
+ }
40
+ suffix={
41
+ <Box padding={3}>
42
+ <Text>suffix</Text>
43
+ </Box>
44
+ }
45
+ />
46
+ </Card>
47
+ )}
48
+
49
+ {primaryTone && (
50
+ <Card padding={3} tone="primary">
51
+ <TextInput
52
+ placeholder="primary"
53
+ prefix={
54
+ <Box padding={3}>
55
+ <Text>prefix</Text>
56
+ </Box>
57
+ }
58
+ suffix={
59
+ <Box padding={3}>
60
+ <Text>suffix</Text>
61
+ </Box>
62
+ }
63
+ />
64
+ </Card>
65
+ )}
66
+
67
+ {positiveTone && (
68
+ <Card padding={3} tone="positive">
69
+ <TextInput
70
+ placeholder="positive"
71
+ prefix={
72
+ <Box padding={3}>
73
+ <Text>prefix</Text>
74
+ </Box>
75
+ }
76
+ suffix={
77
+ <Box padding={3}>
78
+ <Text>suffix</Text>
79
+ </Box>
80
+ }
81
+ />
82
+ </Card>
83
+ )}
84
+
85
+ {cautionTone && (
86
+ <Card padding={3} tone="caution">
87
+ <TextInput
88
+ placeholder="caution"
89
+ prefix={
90
+ <Box padding={3}>
91
+ <Text>prefix</Text>
92
+ </Box>
93
+ }
94
+ suffix={
95
+ <Box padding={3}>
96
+ <Text>suffix</Text>
97
+ </Box>
98
+ }
99
+ />
100
+ </Card>
101
+ )}
102
+
103
+ {criticalTone && (
104
+ <Card padding={3} tone="critical">
105
+ <TextInput
106
+ placeholder="critical"
107
+ prefix={
108
+ <Box padding={3}>
109
+ <Text>prefix</Text>
110
+ </Box>
111
+ }
112
+ suffix={
113
+ <Box padding={3}>
114
+ <Text>suffix</Text>
115
+ </Box>
116
+ }
117
+ />
118
+ </Card>
119
+ )}
98
120
  </Stack>
99
121
  </Container>
100
122
  )
@@ -1,4 +1,4 @@
1
- import {TextInput} from '@sanity/ui'
1
+ import {Box, Container, TextInput} from '@sanity/ui'
2
2
  import {useSelect} from '@sanity/ui-workshop'
3
3
  import React, {useCallback, useState} from 'react'
4
4
  import {WORKSHOP_TEXT_INPUT_TYPE_OPTIONS} from '../../../__workshop__/constants'
@@ -12,5 +12,11 @@ export default function TypedStory() {
12
12
  setValue(event.currentTarget.value)
13
13
  }, [])
14
14
 
15
- return <TextInput onChange={handleChange} type={type} value={value} />
15
+ return (
16
+ <Box padding={4}>
17
+ <Container width={1}>
18
+ <TextInput onChange={handleChange} type={type} value={value} />
19
+ </Container>
20
+ </Box>
21
+ )
16
22
  }
@@ -3,7 +3,7 @@ import React, {createElement, forwardRef, isValidElement, useCallback, useMemo}
3
3
  import {isValidElementType} from 'react-is'
4
4
  import styled from 'styled-components'
5
5
  import {EMPTY_RECORD} from '../../constants'
6
- import {useForwardedRef, useCustomValidity, useResponsiveProp} from '../../hooks'
6
+ import {useArrayProp, useForwardedRef, useCustomValidity} from '../../hooks'
7
7
  import {
8
8
  responsiveRadiusStyle,
9
9
  ResponsiveRadiusStyleProps,
@@ -16,7 +16,7 @@ import {
16
16
  textInputRepresentationStyle,
17
17
  textInputRootStyle,
18
18
  } from '../../styles/internal'
19
- import {ThemeFontWeightKey} from '../../theme'
19
+ import {ThemeFontWeightKey, useRootTheme} from '../../theme'
20
20
  import {Box} from '../box'
21
21
  import {Button, ButtonProps} from '../button'
22
22
  import {Card} from '../card'
@@ -72,7 +72,7 @@ export interface TextInputProps {
72
72
 
73
73
  const CLEAR_BUTTON_BOX_STYLE: React.CSSProperties = {zIndex: 2}
74
74
 
75
- const Root = styled.span(textInputRootStyle)
75
+ const Root = styled(Card).attrs({forwardedAs: 'span'})(textInputRootStyle)
76
76
 
77
77
  const InputRoot = styled.span`
78
78
  flex: 1;
@@ -118,6 +118,12 @@ const LeftBox = styled(Box)`
118
118
  left: 0;
119
119
  `
120
120
 
121
+ const RightBox = styled(Box)`
122
+ position: absolute;
123
+ top: 0;
124
+ right: 0;
125
+ `
126
+
121
127
  const RightCard = styled(Card)`
122
128
  background-color: transparent;
123
129
  position: absolute;
@@ -136,7 +142,7 @@ export const TextInput = forwardRef(function TextInput(
136
142
  border = true,
137
143
  clearButton,
138
144
  disabled = false,
139
- fontSize = 2,
145
+ fontSize: fontSizeProp = 2,
140
146
  icon,
141
147
  iconRight,
142
148
  onClear,
@@ -144,16 +150,22 @@ export const TextInput = forwardRef(function TextInput(
144
150
  prefix,
145
151
  radius: radiusProp = 1,
146
152
  readOnly,
147
- space = 3,
153
+ space: spaceProp = 3,
148
154
  suffix,
149
155
  customValidity,
150
156
  type = 'text',
157
+ weight,
151
158
  ...restProps
152
159
  } = props
153
160
 
154
161
  const ref = useForwardedRef(forwardedRef)
155
- const padding = useResponsiveProp(paddingProp)
156
- const radius = useResponsiveProp(radiusProp)
162
+
163
+ const rootTheme = useRootTheme()
164
+
165
+ const fontSize = useArrayProp(fontSizeProp)
166
+ const padding = useArrayProp(paddingProp)
167
+ const radius = useArrayProp(radiusProp)
168
+ const space = useArrayProp(spaceProp)
157
169
 
158
170
  // Transient properties
159
171
  const $hasClearButton = Boolean(clearButton)
@@ -202,6 +214,8 @@ export const TextInput = forwardRef(function TextInput(
202
214
  $hasPrefix={$hasPrefix}
203
215
  $hasSuffix={$hasSuffix}
204
216
  $radius={radius}
217
+ $tone={rootTheme.tone}
218
+ data-tone={rootTheme.tone}
205
219
  >
206
220
  {icon && (
207
221
  <LeftBox padding={padding}>
@@ -213,16 +227,27 @@ export const TextInput = forwardRef(function TextInput(
213
227
  )}
214
228
 
215
229
  {!$hasClearButton && iconRight && (
216
- <RightCard padding={padding}>
230
+ <RightBox padding={padding}>
217
231
  <Text size={fontSize}>
218
232
  {isValidElement(iconRight) && iconRight}
219
233
  {isValidElementType(iconRight) && createElement(iconRight)}
220
234
  </Text>
221
- </RightCard>
235
+ </RightBox>
222
236
  )}
223
237
  </Presentation>
224
238
  ),
225
- [border, fontSize, icon, iconRight, padding, radius, $hasClearButton, $hasPrefix, $hasSuffix]
239
+ [
240
+ border,
241
+ fontSize,
242
+ icon,
243
+ iconRight,
244
+ padding,
245
+ radius,
246
+ rootTheme.tone,
247
+ $hasClearButton,
248
+ $hasPrefix,
249
+ $hasSuffix,
250
+ ]
226
251
  )
227
252
 
228
253
  // Render clear button (memoized)
@@ -303,25 +328,31 @@ export const TextInput = forwardRef(function TextInput(
303
328
  )
304
329
 
305
330
  return (
306
- <Root data-ui="TextInput">
331
+ <Root data-ui="TextInput" tone={rootTheme.tone}>
307
332
  {prefixNode}
333
+
308
334
  <InputRoot>
309
335
  <Input
310
336
  data-as="input"
337
+ data-tone={rootTheme.tone}
311
338
  {...restProps}
339
+ $fontSize={fontSize}
312
340
  $iconLeft={$hasIcon}
313
341
  $iconRight={$hasIconRight || $hasClearButton}
314
342
  $padding={padding}
315
343
  $space={space}
316
- $fontSize={fontSize}
344
+ $tone={rootTheme.tone}
345
+ $weight={weight}
317
346
  disabled={disabled}
318
347
  readOnly={readOnly}
319
348
  ref={ref}
320
349
  type={type}
321
350
  />
351
+
322
352
  {presentationNode}
323
353
  {clearButtonNode}
324
354
  </InputRoot>
355
+
325
356
  {suffixNode}
326
357
  </Root>
327
358
  )
@@ -1,7 +1,11 @@
1
1
  import {Box, Button, Card, Flex, Text, Tooltip} from '@sanity/ui'
2
+ import {useSelect} from '@sanity/ui-workshop'
2
3
  import React from 'react'
4
+ import {WORKSHOP_PLACEMENT_OPTIONS} from '../../../__workshop__/constants'
3
5
 
4
6
  export default function PropsStory() {
7
+ const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS, 'top')
8
+
5
9
  return (
6
10
  <Card height="fill">
7
11
  <Flex align="center" height="fill" justify="center" padding={4} sizing="border">
@@ -11,7 +15,7 @@ export default function PropsStory() {
11
15
  <Text size={1}>Tooltip content</Text>
12
16
  </Box>
13
17
  }
14
- placement="top"
18
+ placement={placement}
15
19
  portal
16
20
  >
17
21
  <Button mode="bleed" text="Hover me" />
@@ -1,7 +1,7 @@
1
1
  import React, {cloneElement, forwardRef, useCallback, useEffect, useState} from 'react'
2
2
  import {usePopper} from 'react-popper'
3
3
  import styled from 'styled-components'
4
- import {useForwardedRef} from '../../hooks'
4
+ import {useArrayProp, useForwardedRef} from '../../hooks'
5
5
  import {ThemeColorSchemeKey, useTheme} from '../../theme'
6
6
  import {Placement} from '../../types'
7
7
  import {Layer, LayerProps, Portal, useBoundaryElement} from '../../utils'
@@ -42,13 +42,14 @@ export const Tooltip = forwardRef(function Tooltip(
42
42
  children,
43
43
  content,
44
44
  disabled,
45
- fallbackPlacements,
45
+ fallbackPlacements: fallbackPlacementsProp,
46
46
  placement = 'bottom',
47
47
  portal,
48
48
  scheme,
49
49
  zOffset = theme.sanity.layer?.tooltip.zOffset,
50
50
  ...restProps
51
51
  } = props
52
+ const fallbackPlacements = useArrayProp(fallbackPlacementsProp)
52
53
  const forwardedRef = useForwardedRef(ref)
53
54
  const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)
54
55
  const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null)
@@ -127,5 +127,5 @@ export interface ResponsiveShadowProps {
127
127
  * @public
128
128
  */
129
129
  export interface ResponsiveWidthProps {
130
- width?: number | number[] | 'auto'
130
+ width?: number | 'auto' | (number | 'auto')[]
131
131
  }
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {getResponsiveProp, responsive} from '../helpers'
2
+ import {_responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveBorderStyleProps} from './types'
5
5
 
@@ -15,7 +15,7 @@ function border(props: ResponsiveBorderStyleProps & ThemeProps) {
15
15
  const {theme} = props
16
16
  const {media} = theme.sanity
17
17
 
18
- return responsive(media, getResponsiveProp(props.$border), (value) =>
18
+ return _responsive(media, props.$border, (value) =>
19
19
  value ? {'&&': {border: BORDER_VALUE}} : {'&&': {border: 0}}
20
20
  )
21
21
  }
@@ -24,7 +24,7 @@ function borderTop(props: ResponsiveBorderStyleProps & ThemeProps) {
24
24
  const {theme} = props
25
25
  const {media} = theme.sanity
26
26
 
27
- return responsive(media, getResponsiveProp(props.$borderTop), (value) =>
27
+ return _responsive(media, props.$borderTop, (value) =>
28
28
  value ? {'&&': {borderTop: BORDER_VALUE}} : {'&&': {borderTop: 0}}
29
29
  )
30
30
  }
@@ -33,7 +33,7 @@ function borderRight(props: ResponsiveBorderStyleProps & ThemeProps) {
33
33
  const {theme} = props
34
34
  const {media} = theme.sanity
35
35
 
36
- return responsive(media, getResponsiveProp(props.$borderRight), (value) =>
36
+ return _responsive(media, props.$borderRight, (value) =>
37
37
  value ? {'&&': {borderRight: BORDER_VALUE}} : {'&&': {borderRight: 0}}
38
38
  )
39
39
  }
@@ -42,7 +42,7 @@ function borderBottom(props: ResponsiveBorderStyleProps & ThemeProps) {
42
42
  const {theme} = props
43
43
  const {media} = theme.sanity
44
44
 
45
- return responsive(media, getResponsiveProp(props.$borderBottom), (value) =>
45
+ return _responsive(media, props.$borderBottom, (value) =>
46
46
  value ? {'&&': {borderBottom: BORDER_VALUE}} : {'&&': {borderBottom: 0}}
47
47
  )
48
48
  }
@@ -51,7 +51,7 @@ function borderLeft(props: ResponsiveBorderStyleProps & ThemeProps) {
51
51
  const {theme} = props
52
52
  const {media} = theme.sanity
53
53
 
54
- return responsive(media, getResponsiveProp(props.$borderLeft), (value) =>
54
+ return _responsive(media, props.$borderLeft, (value) =>
55
55
  value ? {'&&': {borderLeft: BORDER_VALUE}} : {'&&': {borderLeft: 0}}
56
56
  )
57
57
  }
@@ -2,9 +2,9 @@
2
2
  * @internal
3
3
  */
4
4
  export interface ResponsiveBorderStyleProps {
5
- $border?: boolean | boolean[]
6
- $borderTop?: boolean | boolean[]
7
- $borderRight?: boolean | boolean[]
8
- $borderBottom?: boolean | boolean[]
9
- $borderLeft?: boolean | boolean[]
5
+ $border: boolean[]
6
+ $borderTop: boolean[]
7
+ $borderRight: boolean[]
8
+ $borderBottom: boolean[]
9
+ $borderLeft: boolean[]
10
10
  }
@@ -1,6 +1,6 @@
1
1
  import {Property} from 'csstype'
2
2
  import {CSSObject} from 'styled-components'
3
- import {getResponsiveProp, responsive} from '../helpers'
3
+ import {_responsive} from '../helpers'
4
4
  import {ThemeProps} from '../types'
5
5
  import {ResponsiveBoxStyleProps} from './types'
6
6
 
@@ -39,7 +39,7 @@ function responsiveBoxDisplayStyle(props: ResponsiveBoxStyleProps & ThemeProps)
39
39
  const {theme} = props
40
40
  const {media} = theme.sanity
41
41
 
42
- return responsive(media, getResponsiveProp(props.$display), (display) => ({
42
+ return _responsive(media, props.$display, (display) => ({
43
43
  '&:not([hidden])': {display},
44
44
  }))
45
45
  }
@@ -48,7 +48,7 @@ function responsiveBoxSizingStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
48
48
  const {theme} = props
49
49
  const {media} = theme.sanity
50
50
 
51
- return responsive(media, getResponsiveProp(props.$sizing), (sizing) => ({
51
+ return _responsive(media, props.$sizing, (sizing) => ({
52
52
  boxSizing: BOX_SIZING[sizing],
53
53
  }))
54
54
  }
@@ -57,7 +57,7 @@ function responsiveBoxHeightStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
57
57
  const {theme} = props
58
58
  const {media} = theme.sanity
59
59
 
60
- return responsive(media, getResponsiveProp(props.$height), (height) => ({
60
+ return _responsive(media, props.$height, (height) => ({
61
61
  height: BOX_HEIGHT[height],
62
62
  }))
63
63
  }
@@ -66,7 +66,7 @@ function responsiveBoxOverflowStyle(props: ResponsiveBoxStyleProps & ThemeProps)
66
66
  const {theme} = props
67
67
  const {media} = theme.sanity
68
68
 
69
- return responsive(media, getResponsiveProp(props.$overflow), (overflow) => ({
69
+ return _responsive(media, props.$overflow, (overflow) => ({
70
70
  overflow,
71
71
  }))
72
72
  }
@@ -4,8 +4,8 @@ import {BoxDisplay, BoxHeight, BoxOverflow, BoxSizing} from '../../types'
4
4
  * @internal
5
5
  */
6
6
  export interface ResponsiveBoxStyleProps {
7
- $display?: BoxDisplay | BoxDisplay[]
8
- $height?: BoxHeight | BoxHeight[]
9
- $overflow?: BoxOverflow | BoxOverflow[]
10
- $sizing?: BoxSizing | BoxSizing[]
7
+ $display: BoxDisplay[]
8
+ $height: BoxHeight[]
9
+ $overflow: BoxOverflow[]
10
+ $sizing: BoxSizing[]
11
11
  }
@@ -1,5 +1,6 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {getResponsiveProp, responsive} from '../helpers'
2
+ import {EMPTY_ARRAY} from '../../constants'
3
+ import {_responsive} from '../helpers'
3
4
  import {ThemeProps} from '../types'
4
5
  import {ResponsiveFlexItemStyleProps} from './types'
5
6
 
@@ -20,7 +21,7 @@ export function responsiveFlexItemStyle(
20
21
  const {theme} = props
21
22
  const {media} = theme.sanity
22
23
 
23
- return responsive(media, getResponsiveProp(props.$flex), (flex) => {
24
- return {flex}
25
- })
24
+ if (!props.$flex) return EMPTY_ARRAY
25
+
26
+ return _responsive(media, props.$flex, (flex) => ({flex}))
26
27
  }
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {getResponsiveProp, rem, responsive} from '../helpers'
2
+ import {rem, _responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveFlexStyleProps} from './types'
5
5
 
@@ -28,7 +28,7 @@ export function responsiveFlexAlignStyle(
28
28
  const {theme} = props
29
29
  const {media} = theme.sanity
30
30
 
31
- return responsive(media, getResponsiveProp(props.$align), (align) => {
31
+ return _responsive(media, props.$align, (align) => {
32
32
  return {alignItems: align}
33
33
  })
34
34
  }
@@ -37,7 +37,7 @@ function responsiveFlexGapStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
37
37
  const {theme} = props
38
38
  const {media, space} = theme.sanity
39
39
 
40
- return responsive(media, getResponsiveProp(props.$gap), (gap) => ({
40
+ return _responsive(media, props.$gap, (gap) => ({
41
41
  gap: gap ? rem(space[gap]) : undefined,
42
42
  }))
43
43
  }
@@ -46,7 +46,7 @@ export function responsiveFlexWrapStyle(props: ResponsiveFlexStyleProps & ThemeP
46
46
  const {theme} = props
47
47
  const {media} = theme.sanity
48
48
 
49
- return responsive(media, getResponsiveProp(props.$wrap), (wrap) => {
49
+ return _responsive(media, props.$wrap, (wrap) => {
50
50
  return {flexWrap: wrap}
51
51
  })
52
52
  }
@@ -57,7 +57,7 @@ export function responsiveFlexJustifyStyle(
57
57
  const {theme} = props
58
58
  const {media} = theme.sanity
59
59
 
60
- return responsive(media, getResponsiveProp(props.$justify), (justify) => {
60
+ return _responsive(media, props.$justify, (justify) => {
61
61
  return {justifyContent: justify}
62
62
  })
63
63
  }
@@ -68,7 +68,7 @@ export function responsiveFlexDirectionStyle(
68
68
  const {theme} = props
69
69
  const {media} = theme.sanity
70
70
 
71
- return responsive(media, getResponsiveProp(props.$direction), (direction) => {
71
+ return _responsive(media, props.$direction, (direction) => {
72
72
  return {flexDirection: direction}
73
73
  })
74
74
  }
@@ -4,18 +4,18 @@ import {FlexAlign, FlexDirection, FlexJustify, FlexValue, FlexWrap} from '../../
4
4
  * @internal
5
5
  */
6
6
  export interface ResponsiveFlexStyleProps {
7
- $align?: FlexAlign | FlexAlign[]
8
- $direction?: FlexDirection | FlexDirection[]
9
- $gap?: number | number[]
10
- $justify?: FlexJustify | FlexJustify[]
11
- $wrap?: FlexWrap | FlexWrap[]
7
+ $align: FlexAlign[]
8
+ $direction: FlexDirection[]
9
+ $gap: number[]
10
+ $justify: FlexJustify[]
11
+ $wrap: FlexWrap[]
12
12
  }
13
13
 
14
14
  /**
15
15
  * @internal
16
16
  */
17
17
  export interface ResponsiveFlexItemStyleProps {
18
- $flex?: FlexValue | FlexValue[]
18
+ $flex: FlexValue[]
19
19
  }
20
20
 
21
21
  /**