@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
@@ -0,0 +1,116 @@
1
+ import {_ResizeObserver} from './resizeObserver'
2
+
3
+ /**
4
+ * @beta
5
+ */
6
+ export interface ElementRectValue {
7
+ width: number
8
+ height: number
9
+ }
10
+
11
+ /**
12
+ * @beta
13
+ */
14
+ export interface ElementSize {
15
+ content: ElementRectValue
16
+ border: ElementRectValue
17
+
18
+ /** @deprecated INTERNAL ONLY */
19
+ _contentRect: DOMRectReadOnly
20
+ }
21
+
22
+ /**
23
+ * @internal
24
+ */
25
+ export type _ElementSizeSubscriber = (elementRect: ElementSize) => void
26
+
27
+ /**
28
+ * @internal
29
+ */
30
+ export interface _ElementSizeObserver {
31
+ subscribe: (element: HTMLElement, subscriber: _ElementSizeSubscriber) => () => void
32
+ }
33
+
34
+ /**
35
+ * @internal
36
+ */
37
+ export interface _ElementSizeListener {
38
+ subscribe: (element: HTMLElement, subscriber: _ElementSizeSubscriber) => () => void
39
+ }
40
+
41
+ // Initialize element size observer
42
+ // NOTE: this should NOT have size effects
43
+ /**
44
+ * @internal
45
+ */
46
+ export const _elementSizeObserver = _createElementSizeObserver()
47
+
48
+ function _createElementRectValueListener(): _ElementSizeListener {
49
+ return {
50
+ subscribe(element, subscriber) {
51
+ const resizeObserver = new _ResizeObserver(([entry]) => {
52
+ subscriber({
53
+ _contentRect: entry.contentRect,
54
+ border: {
55
+ width: entry.borderBoxSize[0].inlineSize,
56
+ height: entry.borderBoxSize[0].blockSize,
57
+ },
58
+ content: {
59
+ width: entry.contentRect.width,
60
+ height: entry.contentRect.height,
61
+ },
62
+ })
63
+ })
64
+
65
+ resizeObserver.observe(element)
66
+
67
+ return () => {
68
+ resizeObserver.unobserve(element)
69
+ resizeObserver.disconnect()
70
+ }
71
+ },
72
+ }
73
+ }
74
+
75
+ function _createElementSizeObserver(): _ElementSizeObserver {
76
+ const disposeCache = new WeakMap<HTMLElement, () => void>()
77
+ const subscribersCache = new WeakMap<HTMLElement, _ElementSizeSubscriber[]>()
78
+
79
+ return {
80
+ subscribe(element, subscriber) {
81
+ const subscribers = subscribersCache.get(element) || []
82
+
83
+ let dispose = disposeCache.get(element)
84
+
85
+ if (!subscribersCache.has(element)) {
86
+ subscribersCache.set(element, subscribers)
87
+
88
+ const listener = _createElementRectValueListener()
89
+
90
+ // listen
91
+ dispose = listener.subscribe(element, (elementRect) => {
92
+ for (const sub of subscribers) {
93
+ sub(elementRect)
94
+ }
95
+ })
96
+ }
97
+
98
+ subscribers.push(subscriber)
99
+
100
+ return () => {
101
+ // dispose
102
+
103
+ const idx = subscribers.indexOf(subscriber)
104
+
105
+ if (idx > -1) {
106
+ subscribers.splice(idx, 1)
107
+ }
108
+
109
+ if (subscribers.length === 0) {
110
+ // unlisten
111
+ if (dispose) dispose()
112
+ }
113
+ }
114
+ },
115
+ }
116
+ }
@@ -0,0 +1,2 @@
1
+ export * from './elementSizeObserver'
2
+ export * from './resizeObserver'
@@ -3,9 +3,7 @@ import {ResizeObserver as ResizeObserverPolyfill} from '@juggle/resize-observer'
3
3
  /**
4
4
  * @internal
5
5
  */
6
- const RO: typeof ResizeObserver =
6
+ export const _ResizeObserver: typeof ResizeObserver =
7
7
  typeof window !== 'undefined' && window.ResizeObserver
8
8
  ? window.ResizeObserver
9
9
  : ResizeObserverPolyfill
10
-
11
- export {RO as ResizeObserver}
@@ -1,5 +1,4 @@
1
1
  import styled from 'styled-components'
2
- import {responsiveBorderStyle, ResponsiveBorderStyleProps} from '../../styles/border'
3
2
  import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/radius'
4
3
  import {Box} from '../box'
5
4
  import {selectableBaseStyle, selectableColorStyle, SelectableStyleProps} from './style'
@@ -7,6 +6,8 @@ import {selectableBaseStyle, selectableColorStyle, SelectableStyleProps} from '.
7
6
  /**
8
7
  * @internal
9
8
  */
10
- export const Selectable = styled(Box)<
11
- SelectableStyleProps & ResponsiveRadiusStyleProps & ResponsiveBorderStyleProps
12
- >(responsiveBorderStyle, responsiveRadiusStyle, selectableBaseStyle, selectableColorStyle)
9
+ export const Selectable = styled(Box)<SelectableStyleProps & ResponsiveRadiusStyleProps>(
10
+ responsiveRadiusStyle,
11
+ selectableBaseStyle,
12
+ selectableColorStyle
13
+ )
@@ -1,8 +1,8 @@
1
1
  import {useId} from '@reach/auto-id'
2
- import React, {forwardRef, useCallback, useEffect, useState} from 'react'
2
+ import React, {forwardRef, useCallback, useEffect, useMemo, useState} from 'react'
3
3
  import ReactIs from 'react-is'
4
4
  import styled from 'styled-components'
5
- import {useResponsiveProp} from '../../hooks'
5
+ import {useArrayProp} from '../../hooks'
6
6
  import {ThemeColorSpotKey, useTheme} from '../../theme'
7
7
  import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
8
8
  import {Text} from '../text'
@@ -58,11 +58,11 @@ export const Avatar = forwardRef(function Avatar(
58
58
  arrowPosition: arrowPositionProp,
59
59
  animateArrowFrom,
60
60
  status = 'online',
61
- size: sizeProp,
61
+ size: sizeProp = 0,
62
62
  ...restProps
63
63
  } = props
64
64
  const as = ReactIs.isValidElementType(asProp) ? asProp : 'div'
65
- const size: AvatarSize[] = useResponsiveProp(sizeProp, [0])
65
+ const size = useArrayProp(sizeProp)
66
66
  const theme = useTheme()
67
67
  const color = theme.sanity.color.spot[colorKey] || theme.sanity.color.spot.gray
68
68
 
@@ -101,6 +101,8 @@ export const Avatar = forwardRef(function Avatar(
101
101
  }
102
102
  }, [onImageLoadError])
103
103
 
104
+ const initialsSize = useMemo(() => size.map((s) => (s === 0 ? 0 : s + 1)), [size])
105
+
104
106
  return (
105
107
  <Root
106
108
  as={as}
@@ -154,7 +156,7 @@ export const Avatar = forwardRef(function Avatar(
154
156
  {(imageFailed || !src) && initials && (
155
157
  <>
156
158
  <Initials>
157
- <Text as="span" size={size.map((s) => (s === 0 ? 0 : s + 1))}>
159
+ <Text as="span" size={initialsSize}>
158
160
  <strong>{initials}</strong>
159
161
  </Text>
160
162
  </Initials>
@@ -1,16 +1,16 @@
1
- import React, {forwardRef} from 'react'
1
+ import React, {forwardRef, useMemo} from 'react'
2
2
  import styled, {css} from 'styled-components'
3
3
  import {EMPTY_RECORD} from '../../constants'
4
- import {useResponsiveProp} from '../../hooks'
5
- import {rem, responsive, ThemeProps} from '../../styles'
4
+ import {useArrayProp} from '../../hooks'
5
+ import {rem, _responsive, ThemeProps} from '../../styles'
6
6
  import {AvatarSize} from '../../types'
7
7
  import {Text} from '../text'
8
8
 
9
- function responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemeProps) {
9
+ function _responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemeProps) {
10
10
  const {theme} = props
11
11
  const {avatar, media} = theme.sanity
12
12
 
13
- return responsive(media, props.$size, (size) => {
13
+ return _responsive(media, props.$size, (size) => {
14
14
  const avatarSize = avatar.sizes[size]
15
15
 
16
16
  if (!avatarSize) return EMPTY_RECORD
@@ -23,7 +23,7 @@ function responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemePr
23
23
  })
24
24
  }
25
25
 
26
- function avatarCounterBaseStyle(props: ThemeProps) {
26
+ function _avatarCounterBaseStyle(props: ThemeProps) {
27
27
  const {theme} = props
28
28
 
29
29
  return css`
@@ -44,8 +44,8 @@ function avatarCounterBaseStyle(props: ThemeProps) {
44
44
  }
45
45
 
46
46
  const Root = styled.div<{$size: AvatarSize[]}>(
47
- responsiveAvatarCounterSizeStyle,
48
- avatarCounterBaseStyle
47
+ _responsiveAvatarCounterSizeStyle,
48
+ _avatarCounterBaseStyle
49
49
  )
50
50
 
51
51
  /**
@@ -66,11 +66,12 @@ export const AvatarCounter = forwardRef(function AvatarCounter(
66
66
  ref: React.Ref<HTMLDivElement>
67
67
  ) {
68
68
  const {count, size: sizeProp = 0} = props
69
- const size: AvatarSize[] = useResponsiveProp(sizeProp, [0])
69
+ const size = useArrayProp(sizeProp)
70
+ const counterSize = useMemo(() => size.map((s) => (s === 0 ? 0 : s + 1)), [size])
70
71
 
71
72
  return (
72
- <Root $size={size} ref={ref}>
73
- <Text as="span" size={size.map((s) => (s === 0 ? 0 : s + 1))}>
73
+ <Root $size={size} data-ui="AvatarCounter" ref={ref}>
74
+ <Text as="span" size={counterSize}>
74
75
  <strong>{count}</strong>
75
76
  </Text>
76
77
  </Root>
@@ -1,7 +1,8 @@
1
1
  import React, {cloneElement, forwardRef} from 'react'
2
2
  import styled, {css} from 'styled-components'
3
3
  import {EMPTY_RECORD} from '../../constants'
4
- import {getResponsiveProp, rem, responsive, ThemeProps} from '../../styles'
4
+ import {useArrayProp} from '../../hooks'
5
+ import {rem, _responsive, ThemeProps} from '../../styles'
5
6
  import {AvatarSize} from '../../types'
6
7
  import {childrenToElementArray} from '../helpers'
7
8
  import {AvatarCounter} from './avatarCounter'
@@ -22,11 +23,11 @@ function avatarStackStyle() {
22
23
  return BASE_STYLES
23
24
  }
24
25
 
25
- function responsiveAvatarStackSizeStyle(props: {size: AvatarSize | AvatarSize[]} & ThemeProps) {
26
+ function responsiveAvatarStackSizeStyle(props: {$size: AvatarSize[]} & ThemeProps) {
26
27
  const {theme} = props
27
28
  const {avatar, media} = theme.sanity
28
29
 
29
- return responsive(media, getResponsiveProp(props.size), (size) => {
30
+ return _responsive(media, props.$size, (size) => {
30
31
  const avatarSize = avatar.sizes[size]
31
32
 
32
33
  if (!avatarSize) return EMPTY_RECORD
@@ -39,10 +40,7 @@ function responsiveAvatarStackSizeStyle(props: {size: AvatarSize | AvatarSize[]}
39
40
  })
40
41
  }
41
42
 
42
- const Root = styled.div<{size: AvatarSize | AvatarSize[]}>(
43
- responsiveAvatarStackSizeStyle,
44
- avatarStackStyle
45
- )
43
+ const Root = styled.div<{$size: AvatarSize[]}>(responsiveAvatarStackSizeStyle, avatarStackStyle)
46
44
 
47
45
  /**
48
46
  * @public
@@ -62,18 +60,25 @@ export const AvatarStack = forwardRef(function AvatarStack(
62
60
  props: AvatarStackProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'ref'>,
63
61
  ref: React.ForwardedRef<HTMLDivElement>
64
62
  ) {
65
- const {children: childrenProp, maxLength: maxLengthProp = 4, size = 0, tone, ...restProps} = props
66
- const maxLength = Math.max(maxLengthProp, 0)
63
+ const {
64
+ children: childrenProp,
65
+ maxLength: maxLengthProp = 4,
66
+ size: sizeProp = 0,
67
+ ...restProps
68
+ } = props
67
69
  const children = childrenToElementArray(childrenProp).filter(
68
70
  (child) => typeof child !== 'string'
69
71
  ) as React.ReactElement[]
72
+ const maxLength = Math.max(maxLengthProp, 0)
73
+ const size = useArrayProp(sizeProp)
74
+
70
75
  const len = children.length
71
76
  const visibleCount = maxLength - 1
72
77
  const extraCount = len - visibleCount
73
78
  const visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children
74
79
 
75
80
  return (
76
- <Root data-ui="AvatarStack" {...restProps} ref={ref} size={size}>
81
+ <Root data-ui="AvatarStack" {...restProps} ref={ref} $size={size}>
77
82
  {len === 0 && (
78
83
  <div>
79
84
  <AvatarCounter count={len} />
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {rem, responsive, ThemeProps} from '../../styles'
2
+ import {rem, _responsive, ThemeProps} from '../../styles'
3
3
  import {focusRingStyle} from '../../styles/internal'
4
4
  import {AvatarRootStyleProps, ResponsiveAvatarSizeStyleProps} from './types'
5
5
 
@@ -103,7 +103,7 @@ export function responsiveAvatarSizeStyle(
103
103
  const {theme} = props
104
104
  const {avatar, media} = theme.sanity
105
105
 
106
- return responsive(media, props.$size, (size) => {
106
+ return _responsive(media, props.$size, (size) => {
107
107
  const avatarSize = avatar.sizes[size] || avatar.sizes[0]
108
108
 
109
109
  return {
@@ -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 {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
4
5
  import {BadgeMode, BadgeTone} from '../../types'
5
6
  import {Box, BoxProps} from '../box'
@@ -46,8 +47,8 @@ export const Badge = forwardRef(function Badge(
46
47
  {...restProps}
47
48
  $mode={mode}
48
49
  $tone={tone}
49
- $radius={radius}
50
- padding={padding}
50
+ $radius={useArrayProp(radius)}
51
+ padding={useArrayProp(padding)}
51
52
  ref={ref}
52
53
  >
53
54
  <Label size={fontSize}>{children}</Label>
@@ -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
  boxStyle,
5
6
  flexItemStyle,
@@ -90,31 +91,31 @@ export const Box = forwardRef(function Box(
90
91
  data-as={typeof asProp === 'string' ? asProp : undefined}
91
92
  data-ui="Box"
92
93
  {...restProps}
93
- $column={column}
94
- $columnStart={columnStart}
95
- $columnEnd={columnEnd}
96
- $display={display}
97
- $flex={flex}
98
- $height={height}
99
- $margin={margin}
100
- $marginX={marginX}
101
- $marginY={marginY}
102
- $marginTop={marginTop}
103
- $marginRight={marginRight}
104
- $marginBottom={marginBottom}
105
- $marginLeft={marginLeft}
106
- $overflow={overflow}
107
- $padding={padding}
108
- $paddingX={paddingX}
109
- $paddingY={paddingY}
110
- $paddingTop={paddingTop}
111
- $paddingRight={paddingRight}
112
- $paddingBottom={paddingBottom}
113
- $paddingLeft={paddingLeft}
114
- $row={row}
115
- $rowStart={rowStart}
116
- $rowEnd={rowEnd}
117
- $sizing={sizing}
94
+ $column={useArrayProp(column)}
95
+ $columnStart={useArrayProp(columnStart)}
96
+ $columnEnd={useArrayProp(columnEnd)}
97
+ $display={useArrayProp(display)}
98
+ $flex={useArrayProp(flex)}
99
+ $height={useArrayProp(height)}
100
+ $margin={useArrayProp(margin)}
101
+ $marginX={useArrayProp(marginX)}
102
+ $marginY={useArrayProp(marginY)}
103
+ $marginTop={useArrayProp(marginTop)}
104
+ $marginRight={useArrayProp(marginRight)}
105
+ $marginBottom={useArrayProp(marginBottom)}
106
+ $marginLeft={useArrayProp(marginLeft)}
107
+ $overflow={useArrayProp(overflow)}
108
+ $padding={useArrayProp(padding)}
109
+ $paddingX={useArrayProp(paddingX)}
110
+ $paddingY={useArrayProp(paddingY)}
111
+ $paddingTop={useArrayProp(paddingTop)}
112
+ $paddingRight={useArrayProp(paddingRight)}
113
+ $paddingBottom={useArrayProp(paddingBottom)}
114
+ $paddingLeft={useArrayProp(paddingLeft)}
115
+ $row={useArrayProp(row)}
116
+ $rowStart={useArrayProp(rowStart)}
117
+ $rowEnd={useArrayProp(rowEnd)}
118
+ $sizing={useArrayProp(sizing)}
118
119
  as={asProp}
119
120
  ref={ref}
120
121
  >
@@ -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,
@@ -83,15 +84,15 @@ export const Card = forwardRef(function Card(
83
84
  data-ui="Card"
84
85
  data-tone={tone}
85
86
  {...restProps}
86
- $border={border}
87
- $borderTop={borderTop}
88
- $borderRight={borderRight}
89
- $borderBottom={borderBottom}
90
- $borderLeft={borderLeft}
87
+ $border={useArrayProp(border)}
88
+ $borderTop={useArrayProp(borderTop)}
89
+ $borderRight={useArrayProp(borderRight)}
90
+ $borderBottom={useArrayProp(borderBottom)}
91
+ $borderLeft={useArrayProp(borderLeft)}
91
92
  $checkered={checkered}
92
93
  $focusRing={focusRing}
93
- $radius={radius}
94
- $shadow={shadow}
94
+ $radius={useArrayProp(radius)}
95
+ $shadow={useArrayProp(shadow)}
95
96
  $tone={tone}
96
97
  data-checkered={checkered ? '' : undefined}
97
98
  data-pressed={pressed ? '' : undefined}
@@ -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
  />