@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,6 +1,7 @@
1
1
  import React, {createElement, forwardRef, isValidElement, useMemo} from 'react'
2
2
  import {isValidElementType} from 'react-is'
3
3
  import styled from 'styled-components'
4
+ import {useArrayProp} from '../../hooks'
4
5
  import {ThemeProps} from '../../styles'
5
6
  import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
6
7
  import {useTheme} from '../../theme'
@@ -66,19 +67,19 @@ export const Button = forwardRef(function Button(
66
67
  fontSize,
67
68
  icon,
68
69
  iconRight,
69
- justify = 'center',
70
+ justify: justifyProp = 'center',
70
71
  loading,
71
72
  mode = 'default',
72
- padding = 3,
73
- paddingX,
74
- paddingY,
75
- paddingTop,
76
- paddingBottom,
77
- paddingLeft,
78
- paddingRight,
79
- radius = 2,
73
+ padding: paddingProp = 3,
74
+ paddingX: paddingXProp,
75
+ paddingY: paddingYProp,
76
+ paddingTop: paddingTopProp,
77
+ paddingBottom: paddingBottomProp,
78
+ paddingLeft: paddingLeftProp,
79
+ paddingRight: paddingRightProp,
80
+ radius: radiusProp = 2,
80
81
  selected,
81
- space = 3,
82
+ space: spaceProp = 3,
82
83
  text,
83
84
  textAlign,
84
85
  tone = 'default',
@@ -86,6 +87,17 @@ export const Button = forwardRef(function Button(
86
87
  ...restProps
87
88
  } = props
88
89
 
90
+ const justify = useArrayProp(justifyProp)
91
+ const padding = useArrayProp(paddingProp)
92
+ const paddingX = useArrayProp(paddingXProp)
93
+ const paddingY = useArrayProp(paddingYProp)
94
+ const paddingTop = useArrayProp(paddingTopProp)
95
+ const paddingBottom = useArrayProp(paddingBottomProp)
96
+ const paddingLeft = useArrayProp(paddingLeftProp)
97
+ const paddingRight = useArrayProp(paddingRightProp)
98
+ const radius = useArrayProp(radiusProp)
99
+ const space = useArrayProp(spaceProp)
100
+
89
101
  const theme = useTheme()
90
102
 
91
103
  const boxProps = useMemo(
@@ -1,6 +1,7 @@
1
1
  import React, {forwardRef} from 'react'
2
2
  import {isValidElementType} from 'react-is'
3
3
  import styled from 'styled-components'
4
+ import {useArrayProp} from '../../hooks'
4
5
  import {
5
6
  responsiveBorderStyle,
6
7
  ResponsiveBorderStyleProps,
@@ -54,7 +55,6 @@ export const Card = forwardRef(function Card(
54
55
  ref: React.ForwardedRef<HTMLDivElement>
55
56
  ) {
56
57
  const {
57
- pressed = false,
58
58
  __unstable_checkered: checkered = false,
59
59
  __unstable_focusRing: focusRing = false,
60
60
  as: asProp,
@@ -63,6 +63,7 @@ export const Card = forwardRef(function Card(
63
63
  borderRight,
64
64
  borderBottom,
65
65
  borderLeft,
66
+ pressed,
66
67
  radius = 0,
67
68
  scheme,
68
69
  selected,
@@ -70,6 +71,7 @@ export const Card = forwardRef(function Card(
70
71
  tone: toneProp = 'default',
71
72
  ...restProps
72
73
  } = props
74
+
73
75
  const as = isValidElementType(asProp) ? asProp : 'div'
74
76
  const rootTheme = useRootTheme()
75
77
  const tone = toneProp === 'inherit' ? rootTheme.tone : toneProp
@@ -78,23 +80,23 @@ export const Card = forwardRef(function Card(
78
80
  <ThemeColorProvider scheme={scheme} tone={tone}>
79
81
  <Root
80
82
  data-as={typeof as === 'string' ? as : undefined}
81
- data-checkered={checkered ? '' : undefined}
82
- data-pressed={pressed ? '' : undefined}
83
83
  data-scheme={rootTheme.scheme}
84
- data-selected={selected ? '' : undefined}
85
84
  data-ui="Card"
86
85
  data-tone={tone}
87
86
  {...restProps}
88
- $border={border}
89
- $borderTop={borderTop}
90
- $borderRight={borderRight}
91
- $borderBottom={borderBottom}
92
- $borderLeft={borderLeft}
87
+ $border={useArrayProp(border)}
88
+ $borderTop={useArrayProp(borderTop)}
89
+ $borderRight={useArrayProp(borderRight)}
90
+ $borderBottom={useArrayProp(borderBottom)}
91
+ $borderLeft={useArrayProp(borderLeft)}
93
92
  $checkered={checkered}
94
93
  $focusRing={focusRing}
95
- $radius={radius}
96
- $shadow={shadow}
94
+ $radius={useArrayProp(radius)}
95
+ $shadow={useArrayProp(shadow)}
97
96
  $tone={tone}
97
+ data-checkered={checkered ? '' : undefined}
98
+ data-pressed={pressed ? '' : undefined}
99
+ data-selected={selected ? '' : undefined}
98
100
  forwardedAs={as}
99
101
  ref={ref}
100
102
  selected={selected}
@@ -14,8 +14,10 @@ export default function ExampleStory() {
14
14
  indeterminate={indeterminate}
15
15
  onChange={handleChange}
16
16
  />
17
- <Box marginLeft={3}>
18
- <Text>Label</Text>
17
+ <Box marginLeft={2}>
18
+ <Text size={1} weight="semibold">
19
+ Toggle
20
+ </Text>
19
21
  </Box>
20
22
  </Flex>
21
23
  </Flex>
@@ -23,8 +23,10 @@ export default function PropsStory() {
23
23
  onBlur={onBlur}
24
24
  readOnly={readOnly}
25
25
  />
26
- <Box marginLeft={3}>
27
- <Text>Label</Text>
26
+ <Box marginLeft={2}>
27
+ <Text size={1} weight="semibold">
28
+ Toggle
29
+ </Text>
28
30
  </Box>
29
31
  </Flex>
30
32
  </Flex>
@@ -6,8 +6,10 @@ export default function ReadOnlyStory() {
6
6
  <Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
7
7
  <Flex align="center" as="label">
8
8
  <Checkbox id="checkbox-example" readOnly />
9
- <Box marginLeft={3}>
10
- <Text>Label</Text>
9
+ <Box marginLeft={2}>
10
+ <Text size={1} weight="semibold">
11
+ Toggle
12
+ </Text>
11
13
  </Box>
12
14
  </Flex>
13
15
  </Flex>
@@ -9,7 +9,7 @@ import {
9
9
  export default function PropsStory() {
10
10
  const code = useText('Code', `console.log('Hello, world')`, 'Props')
11
11
  const language = useSelect('Language', WORKSHOP_CODE_LANGUAGE_OPTIONS, 'typescript', 'Props')
12
- const size = useSelect('Size', WORKSHOP_TEXT_FONT_SIZE_OPTIONS, undefined, 'Props')
12
+ const size = useSelect('Size', WORKSHOP_TEXT_FONT_SIZE_OPTIONS, 2, 'Props')
13
13
 
14
14
  return (
15
15
  <Box padding={[4, 5, 6]}>
@@ -1,6 +1,7 @@
1
1
  import React, {forwardRef} from 'react'
2
2
  import Refractor from 'react-refractor'
3
3
  import styled from 'styled-components'
4
+ import {useArrayProp} from '../../hooks'
4
5
  import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
5
6
  import {codeBaseStyle} from './styles'
6
7
 
@@ -28,7 +29,7 @@ export const Code = forwardRef(function Code(
28
29
  const registered = language ? Refractor.hasLanguage(language as any) : false
29
30
 
30
31
  return (
31
- <Root data-ui="Code" {...restProps} $size={size} $weight={weight} ref={ref}>
32
+ <Root data-ui="Code" {...restProps} $size={useArrayProp(size)} $weight={weight} ref={ref}>
32
33
  {!(language && registered) && <code>{children}</code>}
33
34
  {language && registered && <Refractor inline language={language} value={String(children)} />}
34
35
  </Root>
@@ -1,5 +1,6 @@
1
1
  import React, {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
+ import {useArrayProp} from '../../hooks'
3
4
  import {Box, BoxProps} from '../box'
4
5
  import {ResponsiveWidthProps} from '../types'
5
6
  import {containerBaseStyle, responsiveContainerWidthStyle} from './styles'
@@ -24,5 +25,13 @@ export const Container = forwardRef(function Container(
24
25
  ) {
25
26
  const {as, width = 2, ...restProps} = props
26
27
 
27
- return <Root data-ui="Container" {...restProps} $width={width} forwardedAs={as} ref={ref} />
28
+ return (
29
+ <Root
30
+ data-ui="Container"
31
+ {...restProps}
32
+ $width={useArrayProp(width)}
33
+ forwardedAs={as}
34
+ ref={ref}
35
+ />
36
+ )
28
37
  })
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {getResponsiveProp, rem, responsive, ThemeProps} from '../../styles'
2
+ import {rem, _responsive, ThemeProps} from '../../styles'
3
3
  import {ResponsiveWidthStyleProps} from './types'
4
4
 
5
5
  const BASE_STYLE: CSSObject = {
@@ -17,7 +17,7 @@ export function responsiveContainerWidthStyle(
17
17
  const {theme} = props
18
18
  const {container, media} = theme.sanity
19
19
 
20
- return responsive(media, getResponsiveProp(props.$width), (val) => ({
20
+ return _responsive(media, props.$width, (val) => ({
21
21
  maxWidth: val === 'auto' ? 'none' : rem(container[val]),
22
22
  }))
23
23
  }
@@ -2,5 +2,5 @@
2
2
  * @internal
3
3
  */
4
4
  export interface ResponsiveWidthStyleProps {
5
- $width?: number | number[] | 'auto'
5
+ $width: (number | 'auto')[]
6
6
  }
@@ -1,5 +1,6 @@
1
1
  import React, {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
+ import {useArrayProp} from '../../hooks'
3
4
  import {
4
5
  flexItemStyle,
5
6
  FlexItemStyleProps,
@@ -37,11 +38,11 @@ export const Flex = forwardRef(function Flex(
37
38
  <Root
38
39
  data-ui="Flex"
39
40
  {...restProps}
40
- $align={align}
41
- $direction={direction}
42
- $gap={gap}
43
- $justify={justify}
44
- $wrap={wrap}
41
+ $align={useArrayProp(align)}
42
+ $direction={useArrayProp(direction)}
43
+ $gap={useArrayProp(gap)}
44
+ $justify={useArrayProp(justify)}
45
+ $wrap={useArrayProp(wrap)}
45
46
  forwardedAs={as}
46
47
  ref={ref}
47
48
  />
@@ -10,41 +10,42 @@ export default function ResponsiveStory() {
10
10
  columns={[1, 2, 3, 4, 5, 6, 7]}
11
11
  gap={[0, 1, 2, 3, 4, 5, 6]}
12
12
  rows={[1, 2, 3, 4, 5, 6, 7]}
13
+ style={{textAlign: 'center'}}
13
14
  >
14
- <Card tone="transparent">
15
+ <Card padding={[1, 2, 3]} tone="transparent">
15
16
  <Code>1</Code>
16
17
  </Card>
17
- <Card tone="transparent">
18
+ <Card padding={[1, 2, 3]} tone="transparent">
18
19
  <Code>2</Code>
19
20
  </Card>
20
- <Card tone="transparent">
21
+ <Card padding={[1, 2, 3]} tone="transparent">
21
22
  <Code>3</Code>
22
23
  </Card>
23
- <Card tone="transparent">
24
+ <Card padding={[1, 2, 3]} tone="transparent">
24
25
  <Code>4</Code>
25
26
  </Card>
26
- <Card tone="transparent">
27
+ <Card padding={[1, 2, 3]} tone="transparent">
27
28
  <Code>5</Code>
28
29
  </Card>
29
- <Card tone="transparent">
30
+ <Card padding={[1, 2, 3]} tone="transparent">
30
31
  <Code>6</Code>
31
32
  </Card>
32
- <Card tone="transparent">
33
+ <Card padding={[1, 2, 3]} tone="transparent">
33
34
  <Code>7</Code>
34
35
  </Card>
35
- <Card tone="transparent">
36
+ <Card padding={[1, 2, 3]} tone="transparent">
36
37
  <Code>8</Code>
37
38
  </Card>
38
- <Card tone="transparent">
39
+ <Card padding={[1, 2, 3]} tone="transparent">
39
40
  <Code>9</Code>
40
41
  </Card>
41
- <Card tone="transparent">
42
+ <Card padding={[1, 2, 3]} tone="transparent">
42
43
  <Code>10</Code>
43
44
  </Card>
44
- <Card tone="transparent">
45
+ <Card padding={[1, 2, 3]} tone="transparent">
45
46
  <Code>11</Code>
46
47
  </Card>
47
- <Card tone="transparent">
48
+ <Card padding={[1, 2, 3]} tone="transparent">
48
49
  <Code>12</Code>
49
50
  </Card>
50
51
  </Grid>
@@ -1,5 +1,6 @@
1
1
  import React, {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
+ import {useArrayProp} from '../../hooks'
3
4
  import {responsiveGridStyle, ResponsiveGridStyleProps} from '../../styles/internal'
4
5
  import {Box, BoxProps} from '../box'
5
6
  import {ResponsiveGridProps} from '../types'
@@ -26,14 +27,14 @@ export const Grid = forwardRef(function Grid(
26
27
  data-as={typeof as === 'string' ? as : undefined}
27
28
  data-ui="Grid"
28
29
  {...restProps}
29
- $autoRows={autoRows}
30
- $autoCols={autoCols}
31
- $autoFlow={autoFlow}
32
- $columns={columns}
33
- $gap={gap}
34
- $gapX={gapX}
35
- $gapY={gapY}
36
- $rows={rows}
30
+ $autoRows={useArrayProp(autoRows)}
31
+ $autoCols={useArrayProp(autoCols)}
32
+ $autoFlow={useArrayProp(autoFlow)}
33
+ $columns={useArrayProp(columns)}
34
+ $gap={useArrayProp(gap)}
35
+ $gapX={useArrayProp(gapX)}
36
+ $gapY={useArrayProp(gapY)}
37
+ $rows={useArrayProp(rows)}
37
38
  forwardedAs={as}
38
39
  ref={ref}
39
40
  >
@@ -8,43 +8,55 @@ export default function OpticalAlignment() {
8
8
  <Stack space={1}>
9
9
  <Flex>
10
10
  <Card padding={0} scheme="dark">
11
- <Heading size={5}>Hamburgefonstiv M</Heading>
11
+ <Heading accent size={5}>
12
+ Hamburgefonstiv M
13
+ </Heading>
12
14
  </Card>
13
15
  </Flex>
14
16
 
15
17
  <Flex>
16
18
  <Card padding={0} scheme="dark">
17
- <Heading size={4}>Hamburgefonstiv M</Heading>
19
+ <Heading accent size={4}>
20
+ Hamburgefonstiv M
21
+ </Heading>
18
22
  </Card>
19
23
  </Flex>
20
24
 
21
25
  <Flex>
22
26
  <Card padding={0} scheme="dark">
23
- <Heading size={3}>Hamburgefonstiv M</Heading>
27
+ <Heading accent size={3}>
28
+ Hamburgefonstiv M
29
+ </Heading>
24
30
  </Card>
25
31
  </Flex>
26
32
 
27
33
  <Flex>
28
34
  <Card padding={0} scheme="dark">
29
- <Heading size={2}>Hamburgefonstiv M</Heading>
35
+ <Heading accent size={2}>
36
+ Hamburgefonstiv M
37
+ </Heading>
30
38
  </Card>
31
39
  </Flex>
32
40
 
33
41
  <Flex>
34
42
  <Card padding={0} scheme="dark">
35
- <Heading size={1}>Hamburgefonstiv M</Heading>
43
+ <Heading accent size={1}>
44
+ Hamburgefonstiv M
45
+ </Heading>
36
46
  </Card>
37
47
  </Flex>
38
48
 
39
49
  <Flex>
40
50
  <Card padding={0} scheme="dark">
41
- <Heading size={0}>Hamburgefonstiv M</Heading>
51
+ <Heading accent size={0}>
52
+ Hamburgefonstiv M
53
+ </Heading>
42
54
  </Card>
43
55
  </Flex>
44
56
 
45
57
  <Flex>
46
58
  <Card padding={2} scheme="dark">
47
- <Heading>
59
+ <Heading accent>
48
60
  <AddCircleIcon />
49
61
  </Heading>
50
62
  </Card>
@@ -1,5 +1,6 @@
1
1
  import React, {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
+ import {useArrayProp} from '../../hooks'
3
4
  import {
4
5
  ResponsiveFontStyleProps,
5
6
  responsiveHeadingFont,
@@ -69,9 +70,9 @@ export const Heading = forwardRef(function Heading(
69
70
  data-ui="Heading"
70
71
  {...restProps}
71
72
  $accent={accent}
72
- $align={align}
73
+ $align={useArrayProp(align)}
73
74
  $muted={muted}
74
- $size={size}
75
+ $size={useArrayProp(size)}
75
76
  $weight={weight}
76
77
  ref={ref}
77
78
  >
@@ -1,5 +1,6 @@
1
- import React, {forwardRef} from 'react'
1
+ import React, {forwardRef, useMemo} from 'react'
2
2
  import styled from 'styled-components'
3
+ import {useArrayProp} from '../../hooks'
3
4
  import {Box, BoxProps} from '../box'
4
5
  import {childrenToElementArray} from '../helpers'
5
6
  import {inlineBaseStyle, inlineSpaceStyle} from './styles'
@@ -22,13 +23,18 @@ export const Inline = forwardRef(function Inline(
22
23
  ref
23
24
  ) {
24
25
  const {as, children: childrenProp, space, ...restProps} = props
25
- const children = childrenToElementArray(childrenProp).filter(Boolean)
26
+
27
+ const children = useMemo(
28
+ () =>
29
+ childrenToElementArray(childrenProp)
30
+ .filter(Boolean)
31
+ .map((child, idx) => <div key={idx}>{child}</div>),
32
+ [childrenProp]
33
+ )
26
34
 
27
35
  return (
28
- <Root data-ui="Inline" {...restProps} $space={space} forwardedAs={as} ref={ref}>
29
- {children.map((child, idx) => (
30
- <div key={idx}>{child}</div>
31
- ))}
36
+ <Root data-ui="Inline" {...restProps} $space={useArrayProp(space)} forwardedAs={as} ref={ref}>
37
+ {children}
32
38
  </Root>
33
39
  )
34
40
  })
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {getResponsiveProp, rem, responsive, ThemeProps} from '../../styles'
2
+ import {rem, _responsive, ThemeProps} from '../../styles'
3
3
  import {ResponsiveInlineSpaceStyleProps} from './types'
4
4
 
5
5
  export function inlineBaseStyle(): CSSObject {
@@ -20,7 +20,7 @@ export function inlineBaseStyle(): CSSObject {
20
20
  export function inlineSpaceStyle(props: ResponsiveInlineSpaceStyleProps & ThemeProps): CSSObject[] {
21
21
  const {theme} = props
22
22
 
23
- return responsive(theme.sanity.media, getResponsiveProp(props.$space), (spaceIndex) => {
23
+ return _responsive(theme.sanity.media, props.$space, (spaceIndex) => {
24
24
  const space = rem(theme.sanity.space[spaceIndex])
25
25
 
26
26
  return {
@@ -2,5 +2,5 @@
2
2
  * @internal
3
3
  */
4
4
  export interface ResponsiveInlineSpaceStyleProps {
5
- $space?: number | number[]
5
+ $space: number[]
6
6
  }
@@ -1,5 +1,6 @@
1
1
  import React, {forwardRef} from 'react'
2
2
  import styled, {css} from 'styled-components'
3
+ import {useArrayProp} from '../../hooks'
3
4
  import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
4
5
  import {Box} from '../box'
5
6
  import {Code} from '../code'
@@ -38,7 +39,7 @@ export const KBD = forwardRef(function KBD(
38
39
  const {children, fontSize = 1, padding = 1, radius = 2, ...restProps} = props
39
40
 
40
41
  return (
41
- <Root data-ui="KBD" {...restProps} $radius={radius} ref={ref}>
42
+ <Root data-ui="KBD" {...restProps} $radius={useArrayProp(radius)} ref={ref}>
42
43
  <Box as="span" padding={padding}>
43
44
  <Code as="span" muted size={fontSize}>
44
45
  {children}
@@ -1,5 +1,6 @@
1
1
  import React, {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
+ import {useArrayProp} from '../../hooks'
3
4
  import {responsiveLabelFont, responsiveTextAlignStyle} from '../../styles/internal'
4
5
  import {ThemeFontWeightKey} from '../../theme'
5
6
  import {TextAlign} from '../../types'
@@ -25,7 +26,7 @@ export interface LabelProps {
25
26
 
26
27
  const Root = styled.div<{
27
28
  $accent?: boolean
28
- $align?: TextAlign | TextAlign[]
29
+ $align: TextAlign[]
29
30
  $muted: boolean
30
31
  $size: number[]
31
32
  }>(responsiveLabelFont, responsiveTextAlignStyle, labelBaseStyle)
@@ -68,9 +69,9 @@ export const Label = forwardRef(function Label(
68
69
  data-ui="Label"
69
70
  {...restProps}
70
71
  $accent={accent}
71
- $align={align}
72
+ $align={useArrayProp(align)}
72
73
  $muted={muted}
73
- $size={size}
74
+ $size={useArrayProp(size)}
74
75
  $weight={weight}
75
76
  ref={ref}
76
77
  >
@@ -5,7 +5,7 @@ export default function MarginsStory() {
5
5
  return (
6
6
  <Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
7
7
  <Popover
8
- __unstable_margins={[-5, -5, -5, -5]}
8
+ __unstable_margins={[-8, 8, -8, 8]}
9
9
  arrow={false}
10
10
  content={
11
11
  <Box padding={2}>
@@ -1,5 +1,5 @@
1
1
  import {Button, Card, Popover, PortalProvider, Text} from '@sanity/ui'
2
- import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
2
+ import {useBoolean, useSelect} from '@sanity/ui-workshop'
3
3
  import React, {useState} from 'react'
4
4
  import {
5
5
  WORKSHOP_CONTAINER_WIDTH_OPTIONS,
@@ -9,18 +9,17 @@ import {
9
9
  } from '../../../__workshop__/constants'
10
10
 
11
11
  export default function PlainStory() {
12
- const arrow = useBoolean('Arrow', true, 'Props')
13
- const boundaryElementFlag = useBoolean('Boundary element', true, 'Props')
14
- const content = useText('Content', 'Hello, world', 'Props')
15
- const constrainSize = useBoolean('Constrain size', true, 'Props')
16
- const matchReferenceWidth = useBoolean('Match reference width', false, 'Props')
17
- const open = useBoolean('Open', true, 'Props')
18
- const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
19
- const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS, 'bottom', 'Props')
20
- const portal = useBoolean('Portal', true, 'Props')
21
- const preventOverflow = useBoolean('Prevent overflow', true, 'Props')
22
- const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2, 'Props')
23
- const width = useSelect('Width', WORKSHOP_CONTAINER_WIDTH_OPTIONS, 'auto', 'Props')
12
+ const arrow = useBoolean('Arrow', true)
13
+ const boundaryElementFlag = useBoolean('Boundary element', true)
14
+ const constrainSize = useBoolean('Constrain size', true)
15
+ const matchReferenceWidth = useBoolean('Match reference width', false)
16
+ const open = useBoolean('Open', true)
17
+ const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3)
18
+ const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS, 'bottom')
19
+ const portal = useBoolean('Portal', true)
20
+ const preventOverflow = useBoolean('Prevent overflow', true)
21
+ const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2)
22
+ const width = useSelect('Width', WORKSHOP_CONTAINER_WIDTH_OPTIONS, 'auto')
24
23
  const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
25
24
  const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
26
25
 
@@ -46,7 +45,6 @@ export default function PlainStory() {
46
45
  __unstable_margins={[1, 1, 1, 1]}
47
46
  arrow={arrow}
48
47
  boundaryElement={boundaryElementFlag ? boundaryElement : undefined}
49
- content={<Text>{content}</Text>}
50
48
  constrainSize={constrainSize}
51
49
  fallbackPlacements={['top', 'bottom']}
52
50
  matchReferenceWidth={matchReferenceWidth}
@@ -39,7 +39,9 @@ function RecursiveExample({onClose}: {onClose?: () => void}) {
39
39
  }, [open])
40
40
 
41
41
  useEffect(() => {
42
- buttonRef.current?.focus()
42
+ setTimeout(() => {
43
+ buttonRef.current?.focus()
44
+ }, 0)
43
45
  }, [])
44
46
 
45
47
  const handleOpen = useCallback(() => setOpen(true), [])
@@ -58,6 +60,7 @@ function RecursiveExample({onClose}: {onClose?: () => void}) {
58
60
  fallbackPlacements={fallbackPlacements}
59
61
  content={<RecursiveExample onClose={handleClose} />}
60
62
  open={open}
63
+ padding={1}
61
64
  placement={fallbackPlacements[3]}
62
65
  portal
63
66
  tone={tones[seed]}