@sanity/ui 0.37.21 → 0.38.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 (210) hide show
  1. package/lib/dts/src/components/breadcrumbs/breadcrumbs.d.ts.map +1 -1
  2. package/lib/dts/src/components/dialog/dialog.d.ts.map +1 -1
  3. package/lib/dts/src/components/dialog/styles.d.ts +1 -1
  4. package/lib/dts/src/components/dialog/styles.d.ts.map +1 -1
  5. package/lib/dts/src/components/hotkeys/hotkeys.d.ts.map +1 -1
  6. package/lib/dts/src/components/menu/menuGroup.d.ts.map +1 -1
  7. package/lib/dts/src/components/skeleton/skeleton.d.ts.map +1 -1
  8. package/lib/dts/src/hooks/index.d.ts +2 -1
  9. package/lib/dts/src/hooks/index.d.ts.map +1 -1
  10. package/lib/dts/src/hooks/useArrayProp.d.ts +7 -0
  11. package/lib/dts/src/hooks/useArrayProp.d.ts.map +1 -0
  12. package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts +1 -1
  13. package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts.map +1 -1
  14. package/lib/dts/src/hooks/useElementSize.d.ts +7 -0
  15. package/lib/dts/src/hooks/useElementSize.d.ts.map +1 -0
  16. package/lib/dts/src/index.d.ts +1 -0
  17. package/lib/dts/src/index.d.ts.map +1 -1
  18. package/lib/dts/src/observers/elementSizeObserver.d.ts +37 -0
  19. package/lib/dts/src/observers/elementSizeObserver.d.ts.map +1 -0
  20. package/lib/dts/src/observers/index.d.ts +3 -0
  21. package/lib/dts/src/observers/index.d.ts.map +1 -0
  22. package/lib/dts/src/observers/resizeObserver.d.ts +5 -0
  23. package/lib/dts/src/observers/resizeObserver.d.ts.map +1 -0
  24. package/lib/dts/src/primitives/_selectable/selectable.d.ts +1 -2
  25. package/lib/dts/src/primitives/_selectable/selectable.d.ts.map +1 -1
  26. package/lib/dts/src/primitives/avatar/avatar.d.ts.map +1 -1
  27. package/lib/dts/src/primitives/avatar/avatarCounter.d.ts.map +1 -1
  28. package/lib/dts/src/primitives/avatar/avatarStack.d.ts.map +1 -1
  29. package/lib/dts/src/primitives/avatar/styles.d.ts.map +1 -1
  30. package/lib/dts/src/primitives/badge/badge.d.ts.map +1 -1
  31. package/lib/dts/src/primitives/box/box.d.ts.map +1 -1
  32. package/lib/dts/src/primitives/button/button.d.ts.map +1 -1
  33. package/lib/dts/src/primitives/card/card.d.ts.map +1 -1
  34. package/lib/dts/src/primitives/code/code.d.ts.map +1 -1
  35. package/lib/dts/src/primitives/container/container.d.ts.map +1 -1
  36. package/lib/dts/src/primitives/container/styles.d.ts.map +1 -1
  37. package/lib/dts/src/primitives/container/types.d.ts +1 -1
  38. package/lib/dts/src/primitives/container/types.d.ts.map +1 -1
  39. package/lib/dts/src/primitives/flex/flex.d.ts.map +1 -1
  40. package/lib/dts/src/primitives/grid/grid.d.ts.map +1 -1
  41. package/lib/dts/src/primitives/heading/heading.d.ts.map +1 -1
  42. package/lib/dts/src/primitives/inline/inline.d.ts.map +1 -1
  43. package/lib/dts/src/primitives/inline/styles.d.ts.map +1 -1
  44. package/lib/dts/src/primitives/inline/types.d.ts +1 -1
  45. package/lib/dts/src/primitives/inline/types.d.ts.map +1 -1
  46. package/lib/dts/src/primitives/kbd/kbd.d.ts.map +1 -1
  47. package/lib/dts/src/primitives/label/label.d.ts.map +1 -1
  48. package/lib/dts/src/primitives/popover/popover.d.ts.map +1 -1
  49. package/lib/dts/src/primitives/select/styles.d.ts +5 -1
  50. package/lib/dts/src/primitives/select/styles.d.ts.map +1 -1
  51. package/lib/dts/src/primitives/stack/stack.d.ts.map +1 -1
  52. package/lib/dts/src/primitives/stack/styles.d.ts +1 -1
  53. package/lib/dts/src/primitives/stack/styles.d.ts.map +1 -1
  54. package/lib/dts/src/primitives/text/text.d.ts.map +1 -1
  55. package/lib/dts/src/primitives/textArea/textArea.d.ts.map +1 -1
  56. package/lib/dts/src/primitives/textInput/textInput.d.ts.map +1 -1
  57. package/lib/dts/src/primitives/tooltip/tooltip.d.ts.map +1 -1
  58. package/lib/dts/src/primitives/types.d.ts +1 -1
  59. package/lib/dts/src/primitives/types.d.ts.map +1 -1
  60. package/lib/dts/src/styles/border/types.d.ts +5 -5
  61. package/lib/dts/src/styles/border/types.d.ts.map +1 -1
  62. package/lib/dts/src/styles/box/types.d.ts +4 -4
  63. package/lib/dts/src/styles/box/types.d.ts.map +1 -1
  64. package/lib/dts/src/styles/flex/flexItemStyle.d.ts.map +1 -1
  65. package/lib/dts/src/styles/flex/types.d.ts +6 -6
  66. package/lib/dts/src/styles/flex/types.d.ts.map +1 -1
  67. package/lib/dts/src/styles/font/responsiveFont.d.ts.map +1 -1
  68. package/lib/dts/src/styles/font/types.d.ts +3 -3
  69. package/lib/dts/src/styles/font/types.d.ts.map +1 -1
  70. package/lib/dts/src/styles/grid/types.d.ts +14 -14
  71. package/lib/dts/src/styles/grid/types.d.ts.map +1 -1
  72. package/lib/dts/src/styles/helpers.d.ts +4 -4
  73. package/lib/dts/src/styles/helpers.d.ts.map +1 -1
  74. package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts +12 -12
  75. package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts.map +1 -1
  76. package/lib/dts/src/styles/input/textInputStyle.d.ts +7 -2
  77. package/lib/dts/src/styles/input/textInputStyle.d.ts.map +1 -1
  78. package/lib/dts/src/styles/margin/types.d.ts +7 -7
  79. package/lib/dts/src/styles/margin/types.d.ts.map +1 -1
  80. package/lib/dts/src/styles/padding/types.d.ts +7 -7
  81. package/lib/dts/src/styles/padding/types.d.ts.map +1 -1
  82. package/lib/dts/src/styles/radius/types.d.ts +1 -1
  83. package/lib/dts/src/styles/radius/types.d.ts.map +1 -1
  84. package/lib/dts/src/styles/shadow/shadowStyle.d.ts.map +1 -1
  85. package/lib/dts/src/styles/shadow/types.d.ts +1 -1
  86. package/lib/dts/src/styles/shadow/types.d.ts.map +1 -1
  87. package/lib/dts/src/theme/studioTheme/color.d.ts.map +1 -1
  88. package/lib/dts/src/utils/elementQuery/elementQuery.d.ts.map +1 -1
  89. package/lib/dts/src/utils/index.d.ts +0 -1
  90. package/lib/dts/src/utils/index.d.ts.map +1 -1
  91. package/lib/dts/src/utils/virtualList/virtualList.d.ts.map +1 -1
  92. package/lib/sanity-ui.js +734 -573
  93. package/lib/sanity-ui.js.map +1 -1
  94. package/lib/sanity-ui.modern.js +763 -592
  95. package/lib/sanity-ui.modern.js.map +1 -1
  96. package/lib/sanity-ui.module.js +728 -569
  97. package/lib/sanity-ui.module.js.map +1 -1
  98. package/package.json +11 -11
  99. package/src/__workshop__/color/overview.tsx +9 -11
  100. package/src/components/autocomplete/__workshop__/async.tsx +14 -12
  101. package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +36 -0
  102. package/src/components/autocomplete/autocomplete.tsx +2 -2
  103. package/src/components/breadcrumbs/breadcrumbs.tsx +3 -2
  104. package/src/components/dialog/dialog.tsx +17 -9
  105. package/src/components/dialog/styles.ts +4 -4
  106. package/src/components/hotkeys/hotkeys.tsx +3 -1
  107. package/src/components/menu/__workshop__/constrainedInBoundary.tsx +11 -14
  108. package/src/components/menu/__workshop__/groups.tsx +1 -1
  109. package/src/components/menu/menuGroup.tsx +3 -2
  110. package/src/components/menu/menuItem.tsx +3 -3
  111. package/src/components/skeleton/skeleton.tsx +10 -1
  112. package/src/components/skeleton/textSkeleton.tsx +7 -7
  113. package/src/hooks/index.ts +2 -1
  114. package/src/hooks/useArrayProp.ts +23 -0
  115. package/src/hooks/useElementRect/useElementRect.ts +4 -16
  116. package/src/hooks/useElementSize.ts +18 -0
  117. package/src/index.ts +1 -0
  118. package/src/observers/elementSizeObserver.ts +116 -0
  119. package/src/observers/index.ts +2 -0
  120. package/src/{utils → observers}/resizeObserver.ts +1 -3
  121. package/src/primitives/_selectable/selectable.tsx +5 -4
  122. package/src/primitives/avatar/avatar.tsx +7 -5
  123. package/src/primitives/avatar/avatarCounter.tsx +12 -11
  124. package/src/primitives/avatar/avatarStack.tsx +15 -10
  125. package/src/primitives/avatar/styles.ts +2 -2
  126. package/src/primitives/badge/badge.tsx +3 -2
  127. package/src/primitives/box/box.tsx +26 -25
  128. package/src/primitives/button/button.tsx +22 -10
  129. package/src/primitives/card/card.tsx +8 -7
  130. package/src/primitives/checkbox/__workshop__/example.tsx +4 -2
  131. package/src/primitives/checkbox/__workshop__/props.tsx +4 -2
  132. package/src/primitives/checkbox/__workshop__/readOnly.tsx +4 -2
  133. package/src/primitives/code/__workshop__/props.tsx +1 -1
  134. package/src/primitives/code/code.tsx +2 -1
  135. package/src/primitives/container/container.tsx +10 -1
  136. package/src/primitives/container/styles.ts +2 -2
  137. package/src/primitives/container/types.ts +1 -1
  138. package/src/primitives/flex/flex.tsx +6 -5
  139. package/src/primitives/grid/__workshop__/responsive.tsx +13 -12
  140. package/src/primitives/grid/grid.tsx +9 -8
  141. package/src/primitives/heading/__workshop__/opticalAlignment.tsx +19 -7
  142. package/src/primitives/heading/heading.tsx +3 -2
  143. package/src/primitives/inline/inline.tsx +12 -6
  144. package/src/primitives/inline/styles.ts +2 -2
  145. package/src/primitives/inline/types.ts +1 -1
  146. package/src/primitives/kbd/kbd.tsx +2 -1
  147. package/src/primitives/label/label.tsx +4 -3
  148. package/src/primitives/popover/__workshop__/{margins.tsx → MarginsStory.tsx} +1 -1
  149. package/src/primitives/popover/__workshop__/{matchReferenceWidth.tsx → MatchReferenceWidthStory.tsx} +0 -0
  150. package/src/primitives/popover/__workshop__/{plain.tsx → PlainStory.tsx} +12 -14
  151. package/src/primitives/popover/__workshop__/{recursive.tsx → RecursiveStory.tsx} +4 -1
  152. package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +60 -0
  153. package/src/primitives/popover/__workshop__/TestStory.tsx +79 -0
  154. package/src/primitives/popover/__workshop__/index.ts +10 -5
  155. package/src/primitives/popover/popover.tsx +29 -10
  156. package/src/primitives/select/select.tsx +9 -9
  157. package/src/primitives/select/styles.ts +10 -4
  158. package/src/primitives/stack/stack.tsx +2 -1
  159. package/src/primitives/stack/styles.ts +3 -3
  160. package/src/primitives/text/__workshop__/opticalAlignment.tsx +15 -5
  161. package/src/primitives/text/text.tsx +3 -2
  162. package/src/primitives/textArea/__workshop__/plain.tsx +23 -18
  163. package/src/primitives/textArea/textArea.tsx +21 -5
  164. package/src/primitives/textInput/__workshop__/clearButton.tsx +14 -8
  165. package/src/primitives/textInput/__workshop__/index.ts +2 -2
  166. package/src/primitives/textInput/__workshop__/plain.tsx +39 -32
  167. package/src/primitives/textInput/__workshop__/tones.tsx +234 -95
  168. package/src/primitives/textInput/__workshop__/typed.tsx +8 -2
  169. package/src/primitives/textInput/textInput.tsx +47 -12
  170. package/src/primitives/tooltip/__workshop__/props.tsx +7 -2
  171. package/src/primitives/tooltip/tooltip.tsx +19 -9
  172. package/src/primitives/types.ts +1 -1
  173. package/src/styles/border/borderStyle.ts +6 -6
  174. package/src/styles/border/types.ts +5 -5
  175. package/src/styles/box/boxStyle.ts +5 -5
  176. package/src/styles/box/types.ts +4 -4
  177. package/src/styles/flex/flexItemStyle.ts +5 -4
  178. package/src/styles/flex/flexStyle.ts +6 -6
  179. package/src/styles/flex/types.ts +6 -6
  180. package/src/styles/font/responsiveFont.ts +2 -4
  181. package/src/styles/font/textAlignStyle.ts +2 -2
  182. package/src/styles/font/types.ts +4 -3
  183. package/src/styles/grid/gridItemStyle.ts +7 -7
  184. package/src/styles/grid/gridStyle.ts +9 -9
  185. package/src/styles/grid/types.ts +14 -14
  186. package/src/styles/helpers.ts +9 -9
  187. package/src/styles/input/responsiveInputPaddingStyle.ts +24 -27
  188. package/src/styles/input/textInputStyle.ts +92 -80
  189. package/src/styles/margin/marginStyle.ts +8 -8
  190. package/src/styles/margin/marginsStyle.test.ts +1 -1
  191. package/src/styles/margin/types.ts +7 -7
  192. package/src/styles/padding/paddingStyle.test.ts +1 -1
  193. package/src/styles/padding/paddingStyle.ts +8 -8
  194. package/src/styles/padding/types.ts +7 -7
  195. package/src/styles/radius/radiusStyle.ts +2 -2
  196. package/src/styles/radius/types.ts +1 -1
  197. package/src/styles/shadow/shadowStyle.ts +2 -5
  198. package/src/styles/shadow/types.ts +1 -1
  199. package/src/theme/studioTheme/color.ts +15 -14
  200. package/src/theme/studioTheme/fonts.ts +4 -4
  201. package/src/utils/elementQuery/elementQuery.tsx +5 -18
  202. package/src/utils/index.ts +0 -1
  203. package/src/utils/layer/layerProvider.tsx +2 -2
  204. package/src/utils/virtualList/virtualList.tsx +3 -1
  205. package/lib/dts/src/hooks/useResponsiveProp.d.ts +0 -6
  206. package/lib/dts/src/hooks/useResponsiveProp.d.ts.map +0 -1
  207. package/lib/dts/src/utils/resizeObserver.d.ts +0 -6
  208. package/lib/dts/src/utils/resizeObserver.d.ts.map +0 -1
  209. package/src/hooks/useResponsiveProp.ts +0 -10
  210. package/src/primitives/popover/__workshop__/rightAligned.tsx +0 -57
@@ -1,101 +1,240 @@
1
- import {Box, Card, Container, Stack, Text, TextInput} from '@sanity/ui'
1
+ import {Box, Card, Container, Flex, 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
- <Container width={1}>
7
- <Stack padding={[3, 4, 5]} space={4}>
8
- <Card padding={3}>
9
- <TextInput
10
- placeholder="default"
11
- prefix={
12
- <Box padding={3}>
13
- <Text>prefix</Text>
14
- </Box>
15
- }
16
- suffix={
17
- <Box padding={3}>
18
- <Text>suffix</Text>
19
- </Box>
20
- }
21
- />
22
- </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>
98
- </Stack>
99
- </Container>
13
+ <Card height="fill" tone="transparent">
14
+ <Flex align="center" height="fill" justify="center">
15
+ <Container width={1}>
16
+ <Flex>
17
+ <Card flex={1} scheme="light">
18
+ <Stack padding={[3, 4, 5]} space={4}>
19
+ <Card padding={3}>
20
+ <TextInput
21
+ placeholder="default"
22
+ prefix={
23
+ <Box padding={3}>
24
+ <Text>prefix</Text>
25
+ </Box>
26
+ }
27
+ suffix={
28
+ <Box padding={3}>
29
+ <Text>suffix</Text>
30
+ </Box>
31
+ }
32
+ />
33
+ </Card>
34
+
35
+ {transparentTone && (
36
+ <Card padding={3} tone="transparent">
37
+ <TextInput
38
+ placeholder="transparent"
39
+ prefix={
40
+ <Box padding={3}>
41
+ <Text>prefix</Text>
42
+ </Box>
43
+ }
44
+ suffix={
45
+ <Box padding={3}>
46
+ <Text>suffix</Text>
47
+ </Box>
48
+ }
49
+ />
50
+ </Card>
51
+ )}
52
+
53
+ {primaryTone && (
54
+ <Card padding={3} tone="primary">
55
+ <TextInput
56
+ placeholder="primary"
57
+ prefix={
58
+ <Box padding={3}>
59
+ <Text>prefix</Text>
60
+ </Box>
61
+ }
62
+ suffix={
63
+ <Box padding={3}>
64
+ <Text>suffix</Text>
65
+ </Box>
66
+ }
67
+ />
68
+ </Card>
69
+ )}
70
+
71
+ {positiveTone && (
72
+ <Card padding={3} tone="positive">
73
+ <TextInput
74
+ placeholder="positive"
75
+ prefix={
76
+ <Box padding={3}>
77
+ <Text>prefix</Text>
78
+ </Box>
79
+ }
80
+ suffix={
81
+ <Box padding={3}>
82
+ <Text>suffix</Text>
83
+ </Box>
84
+ }
85
+ />
86
+ </Card>
87
+ )}
88
+
89
+ {cautionTone && (
90
+ <Card padding={3} tone="caution">
91
+ <TextInput
92
+ placeholder="caution"
93
+ prefix={
94
+ <Box padding={3}>
95
+ <Text>prefix</Text>
96
+ </Box>
97
+ }
98
+ suffix={
99
+ <Box padding={3}>
100
+ <Text>suffix</Text>
101
+ </Box>
102
+ }
103
+ />
104
+ </Card>
105
+ )}
106
+
107
+ {criticalTone && (
108
+ <Card padding={3} tone="critical">
109
+ <TextInput
110
+ placeholder="critical"
111
+ prefix={
112
+ <Box padding={3}>
113
+ <Text>prefix</Text>
114
+ </Box>
115
+ }
116
+ suffix={
117
+ <Box padding={3}>
118
+ <Text>suffix</Text>
119
+ </Box>
120
+ }
121
+ />
122
+ </Card>
123
+ )}
124
+ </Stack>
125
+ </Card>
126
+ <Card flex={1} scheme="dark">
127
+ <Stack padding={[3, 4, 5]} space={4}>
128
+ <Card padding={3}>
129
+ <TextInput
130
+ placeholder="default"
131
+ prefix={
132
+ <Box padding={3}>
133
+ <Text>prefix</Text>
134
+ </Box>
135
+ }
136
+ suffix={
137
+ <Box padding={3}>
138
+ <Text>suffix</Text>
139
+ </Box>
140
+ }
141
+ />
142
+ </Card>
143
+
144
+ {transparentTone && (
145
+ <Card padding={3} tone="transparent">
146
+ <TextInput
147
+ placeholder="transparent"
148
+ prefix={
149
+ <Box padding={3}>
150
+ <Text>prefix</Text>
151
+ </Box>
152
+ }
153
+ suffix={
154
+ <Box padding={3}>
155
+ <Text>suffix</Text>
156
+ </Box>
157
+ }
158
+ />
159
+ </Card>
160
+ )}
161
+
162
+ {primaryTone && (
163
+ <Card padding={3} tone="primary">
164
+ <TextInput
165
+ placeholder="primary"
166
+ prefix={
167
+ <Box padding={3}>
168
+ <Text>prefix</Text>
169
+ </Box>
170
+ }
171
+ suffix={
172
+ <Box padding={3}>
173
+ <Text>suffix</Text>
174
+ </Box>
175
+ }
176
+ />
177
+ </Card>
178
+ )}
179
+
180
+ {positiveTone && (
181
+ <Card padding={3} tone="positive">
182
+ <TextInput
183
+ placeholder="positive"
184
+ prefix={
185
+ <Box padding={3}>
186
+ <Text>prefix</Text>
187
+ </Box>
188
+ }
189
+ suffix={
190
+ <Box padding={3}>
191
+ <Text>suffix</Text>
192
+ </Box>
193
+ }
194
+ />
195
+ </Card>
196
+ )}
197
+
198
+ {cautionTone && (
199
+ <Card padding={3} tone="caution">
200
+ <TextInput
201
+ placeholder="caution"
202
+ prefix={
203
+ <Box padding={3}>
204
+ <Text>prefix</Text>
205
+ </Box>
206
+ }
207
+ suffix={
208
+ <Box padding={3}>
209
+ <Text>suffix</Text>
210
+ </Box>
211
+ }
212
+ />
213
+ </Card>
214
+ )}
215
+
216
+ {criticalTone && (
217
+ <Card padding={3} tone="critical">
218
+ <TextInput
219
+ placeholder="critical"
220
+ prefix={
221
+ <Box padding={3}>
222
+ <Text>prefix</Text>
223
+ </Box>
224
+ }
225
+ suffix={
226
+ <Box padding={3}>
227
+ <Text>suffix</Text>
228
+ </Box>
229
+ }
230
+ />
231
+ </Card>
232
+ )}
233
+ </Stack>
234
+ </Card>
235
+ </Flex>
236
+ </Container>
237
+ </Flex>
238
+ </Card>
100
239
  )
101
240
  }
@@ -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,10 @@ export const TextInput = forwardRef(function TextInput(
202
214
  $hasPrefix={$hasPrefix}
203
215
  $hasSuffix={$hasSuffix}
204
216
  $radius={radius}
217
+ $scheme={rootTheme.scheme}
218
+ $tone={rootTheme.tone}
219
+ data-scheme={rootTheme.scheme}
220
+ data-tone={rootTheme.tone}
205
221
  >
206
222
  {icon && (
207
223
  <LeftBox padding={padding}>
@@ -213,16 +229,27 @@ export const TextInput = forwardRef(function TextInput(
213
229
  )}
214
230
 
215
231
  {!$hasClearButton && iconRight && (
216
- <RightCard padding={padding}>
232
+ <RightBox padding={padding}>
217
233
  <Text size={fontSize}>
218
234
  {isValidElement(iconRight) && iconRight}
219
235
  {isValidElementType(iconRight) && createElement(iconRight)}
220
236
  </Text>
221
- </RightCard>
237
+ </RightBox>
222
238
  )}
223
239
  </Presentation>
224
240
  ),
225
- [border, fontSize, icon, iconRight, padding, radius, $hasClearButton, $hasPrefix, $hasSuffix]
241
+ [
242
+ border,
243
+ fontSize,
244
+ icon,
245
+ iconRight,
246
+ padding,
247
+ radius,
248
+ rootTheme,
249
+ $hasClearButton,
250
+ $hasPrefix,
251
+ $hasSuffix,
252
+ ]
226
253
  )
227
254
 
228
255
  // Render clear button (memoized)
@@ -303,25 +330,33 @@ export const TextInput = forwardRef(function TextInput(
303
330
  )
304
331
 
305
332
  return (
306
- <Root data-ui="TextInput">
333
+ <Root data-ui="TextInput" tone={rootTheme.tone}>
307
334
  {prefixNode}
335
+
308
336
  <InputRoot>
309
337
  <Input
310
338
  data-as="input"
339
+ data-scheme={rootTheme.scheme}
340
+ data-tone={rootTheme.tone}
311
341
  {...restProps}
342
+ $fontSize={fontSize}
312
343
  $iconLeft={$hasIcon}
313
344
  $iconRight={$hasIconRight || $hasClearButton}
314
345
  $padding={padding}
346
+ $scheme={rootTheme.scheme}
315
347
  $space={space}
316
- $fontSize={fontSize}
348
+ $tone={rootTheme.tone}
349
+ $weight={weight}
317
350
  disabled={disabled}
318
351
  readOnly={readOnly}
319
352
  ref={ref}
320
353
  type={type}
321
354
  />
355
+
322
356
  {presentationNode}
323
357
  {clearButtonNode}
324
358
  </InputRoot>
359
+
325
360
  {suffixNode}
326
361
  </Root>
327
362
  )
@@ -1,17 +1,22 @@
1
1
  import {Box, Button, Card, Flex, Text, Tooltip} from '@sanity/ui'
2
+ import {useSelect, useText} 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 content = useText('Content', 'Tooltip content')
8
+ const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS, 'top')
9
+
5
10
  return (
6
11
  <Card height="fill">
7
12
  <Flex align="center" height="fill" justify="center" padding={4} sizing="border">
8
13
  <Tooltip
9
14
  content={
10
15
  <Box padding={2}>
11
- <Text size={1}>Tooltip content</Text>
16
+ <Text size={1}>{content}</Text>
12
17
  </Box>
13
18
  }
14
- placement="top"
19
+ placement={placement}
15
20
  portal
16
21
  >
17
22
  <Button mode="bleed" text="Hover me" />
@@ -1,7 +1,7 @@
1
- import React, {cloneElement, forwardRef, useCallback, useEffect, useState} from 'react'
1
+ import React, {cloneElement, forwardRef, useCallback, useEffect, useRef, 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)
@@ -117,14 +118,23 @@ export const Tooltip = forwardRef(function Tooltip(
117
118
  }
118
119
  }, [isOpen, referenceElement])
119
120
 
121
+ const updateTimeoutRef = useRef<NodeJS.Timeout | null>(null)
122
+
120
123
  useEffect(() => {
121
- if (forceUpdate) {
122
- try {
123
- forceUpdate()
124
- } catch (_) {
125
- // ignore caught error
126
- }
124
+ if (updateTimeoutRef.current) {
125
+ clearTimeout(updateTimeoutRef.current)
126
+ updateTimeoutRef.current = null
127
127
  }
128
+
129
+ updateTimeoutRef.current = setTimeout(() => {
130
+ if (forceUpdate) {
131
+ try {
132
+ forceUpdate()
133
+ } catch (_) {
134
+ // ignore caught error
135
+ }
136
+ }
137
+ }, 0)
128
138
  }, [forceUpdate, content])
129
139
 
130
140
  // Close when `disabled` changes to `true`
@@ -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
  }