@sanity/ui 0.37.19 → 0.37.21

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 +1 -2
  9. package/lib/dts/src/hooks/index.d.ts.map +1 -1
  10. package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts +1 -1
  11. package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts.map +1 -1
  12. package/lib/dts/src/hooks/useResponsiveProp.d.ts +6 -0
  13. package/lib/dts/src/hooks/useResponsiveProp.d.ts.map +1 -0
  14. package/lib/dts/src/index.d.ts +0 -1
  15. package/lib/dts/src/index.d.ts.map +1 -1
  16. package/lib/dts/src/primitives/_selectable/selectable.d.ts +2 -1
  17. package/lib/dts/src/primitives/_selectable/selectable.d.ts.map +1 -1
  18. package/lib/dts/src/primitives/avatar/avatar.d.ts.map +1 -1
  19. package/lib/dts/src/primitives/avatar/avatarCounter.d.ts.map +1 -1
  20. package/lib/dts/src/primitives/avatar/avatarStack.d.ts.map +1 -1
  21. package/lib/dts/src/primitives/avatar/styles.d.ts.map +1 -1
  22. package/lib/dts/src/primitives/badge/badge.d.ts.map +1 -1
  23. package/lib/dts/src/primitives/box/box.d.ts.map +1 -1
  24. package/lib/dts/src/primitives/button/button.d.ts.map +1 -1
  25. package/lib/dts/src/primitives/card/card.d.ts.map +1 -1
  26. package/lib/dts/src/primitives/code/code.d.ts.map +1 -1
  27. package/lib/dts/src/primitives/container/container.d.ts.map +1 -1
  28. package/lib/dts/src/primitives/container/styles.d.ts.map +1 -1
  29. package/lib/dts/src/primitives/container/types.d.ts +1 -1
  30. package/lib/dts/src/primitives/container/types.d.ts.map +1 -1
  31. package/lib/dts/src/primitives/flex/flex.d.ts.map +1 -1
  32. package/lib/dts/src/primitives/grid/grid.d.ts.map +1 -1
  33. package/lib/dts/src/primitives/heading/heading.d.ts.map +1 -1
  34. package/lib/dts/src/primitives/inline/inline.d.ts.map +1 -1
  35. package/lib/dts/src/primitives/inline/styles.d.ts.map +1 -1
  36. package/lib/dts/src/primitives/inline/types.d.ts +1 -1
  37. package/lib/dts/src/primitives/inline/types.d.ts.map +1 -1
  38. package/lib/dts/src/primitives/kbd/kbd.d.ts.map +1 -1
  39. package/lib/dts/src/primitives/label/label.d.ts.map +1 -1
  40. package/lib/dts/src/primitives/popover/popover.d.ts.map +1 -1
  41. package/lib/dts/src/primitives/select/styles.d.ts +1 -5
  42. package/lib/dts/src/primitives/select/styles.d.ts.map +1 -1
  43. package/lib/dts/src/primitives/stack/stack.d.ts.map +1 -1
  44. package/lib/dts/src/primitives/stack/styles.d.ts +1 -1
  45. package/lib/dts/src/primitives/stack/styles.d.ts.map +1 -1
  46. package/lib/dts/src/primitives/text/text.d.ts.map +1 -1
  47. package/lib/dts/src/primitives/textArea/textArea.d.ts.map +1 -1
  48. package/lib/dts/src/primitives/textInput/textInput.d.ts.map +1 -1
  49. package/lib/dts/src/primitives/tooltip/tooltip.d.ts.map +1 -1
  50. package/lib/dts/src/primitives/types.d.ts +1 -1
  51. package/lib/dts/src/primitives/types.d.ts.map +1 -1
  52. package/lib/dts/src/styles/border/types.d.ts +5 -5
  53. package/lib/dts/src/styles/border/types.d.ts.map +1 -1
  54. package/lib/dts/src/styles/box/types.d.ts +4 -4
  55. package/lib/dts/src/styles/box/types.d.ts.map +1 -1
  56. package/lib/dts/src/styles/flex/flexItemStyle.d.ts.map +1 -1
  57. package/lib/dts/src/styles/flex/types.d.ts +6 -6
  58. package/lib/dts/src/styles/flex/types.d.ts.map +1 -1
  59. package/lib/dts/src/styles/font/responsiveFont.d.ts.map +1 -1
  60. package/lib/dts/src/styles/font/types.d.ts +3 -3
  61. package/lib/dts/src/styles/font/types.d.ts.map +1 -1
  62. package/lib/dts/src/styles/grid/types.d.ts +14 -14
  63. package/lib/dts/src/styles/grid/types.d.ts.map +1 -1
  64. package/lib/dts/src/styles/helpers.d.ts +4 -4
  65. package/lib/dts/src/styles/helpers.d.ts.map +1 -1
  66. package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts +12 -12
  67. package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts.map +1 -1
  68. package/lib/dts/src/styles/input/textInputStyle.d.ts +2 -7
  69. package/lib/dts/src/styles/input/textInputStyle.d.ts.map +1 -1
  70. package/lib/dts/src/styles/margin/types.d.ts +7 -7
  71. package/lib/dts/src/styles/margin/types.d.ts.map +1 -1
  72. package/lib/dts/src/styles/padding/types.d.ts +7 -7
  73. package/lib/dts/src/styles/padding/types.d.ts.map +1 -1
  74. package/lib/dts/src/styles/radius/types.d.ts +1 -1
  75. package/lib/dts/src/styles/radius/types.d.ts.map +1 -1
  76. package/lib/dts/src/styles/shadow/shadowStyle.d.ts.map +1 -1
  77. package/lib/dts/src/styles/shadow/types.d.ts +1 -1
  78. package/lib/dts/src/styles/shadow/types.d.ts.map +1 -1
  79. package/lib/dts/src/theme/studioTheme/color.d.ts.map +1 -1
  80. package/lib/dts/src/utils/elementQuery/elementQuery.d.ts.map +1 -1
  81. package/lib/dts/src/utils/index.d.ts +1 -0
  82. package/lib/dts/src/utils/index.d.ts.map +1 -1
  83. package/lib/dts/src/utils/resizeObserver.d.ts +6 -0
  84. package/lib/dts/src/utils/resizeObserver.d.ts.map +1 -0
  85. package/lib/dts/src/utils/virtualList/virtualList.d.ts.map +1 -1
  86. package/lib/sanity-ui.js +574 -734
  87. package/lib/sanity-ui.js.map +1 -1
  88. package/lib/sanity-ui.modern.js +595 -765
  89. package/lib/sanity-ui.modern.js.map +1 -1
  90. package/lib/sanity-ui.module.js +570 -728
  91. package/lib/sanity-ui.module.js.map +1 -1
  92. package/package.json +11 -11
  93. package/src/__workshop__/color/overview.tsx +11 -9
  94. package/src/components/autocomplete/__workshop__/async.tsx +12 -14
  95. package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -36
  96. package/src/components/autocomplete/autocomplete.tsx +2 -2
  97. package/src/components/breadcrumbs/breadcrumbs.tsx +2 -3
  98. package/src/components/dialog/dialog.tsx +9 -17
  99. package/src/components/dialog/styles.ts +4 -4
  100. package/src/components/hotkeys/hotkeys.tsx +1 -3
  101. package/src/components/menu/__workshop__/constrainedInBoundary.tsx +14 -11
  102. package/src/components/menu/__workshop__/groups.tsx +1 -1
  103. package/src/components/menu/menuGroup.tsx +2 -3
  104. package/src/components/menu/menuItem.tsx +3 -3
  105. package/src/components/skeleton/skeleton.tsx +1 -10
  106. package/src/components/skeleton/textSkeleton.tsx +7 -7
  107. package/src/hooks/index.ts +1 -2
  108. package/src/hooks/useElementRect/useElementRect.ts +16 -4
  109. package/src/hooks/useResponsiveProp.ts +10 -0
  110. package/src/index.ts +0 -1
  111. package/src/primitives/_selectable/selectable.tsx +4 -5
  112. package/src/primitives/avatar/avatar.tsx +5 -7
  113. package/src/primitives/avatar/avatarCounter.tsx +11 -12
  114. package/src/primitives/avatar/avatarStack.tsx +10 -15
  115. package/src/primitives/avatar/styles.ts +2 -2
  116. package/src/primitives/badge/badge.tsx +2 -3
  117. package/src/primitives/box/box.tsx +25 -26
  118. package/src/primitives/button/button.tsx +10 -22
  119. package/src/primitives/card/card.tsx +7 -8
  120. package/src/primitives/checkbox/__workshop__/example.tsx +2 -4
  121. package/src/primitives/checkbox/__workshop__/props.tsx +2 -4
  122. package/src/primitives/checkbox/__workshop__/readOnly.tsx +2 -4
  123. package/src/primitives/code/__workshop__/props.tsx +1 -1
  124. package/src/primitives/code/code.tsx +1 -2
  125. package/src/primitives/container/container.tsx +1 -10
  126. package/src/primitives/container/styles.ts +2 -2
  127. package/src/primitives/container/types.ts +1 -1
  128. package/src/primitives/flex/flex.tsx +5 -6
  129. package/src/primitives/grid/__workshop__/responsive.tsx +12 -13
  130. package/src/primitives/grid/grid.tsx +8 -9
  131. package/src/primitives/heading/__workshop__/opticalAlignment.tsx +7 -19
  132. package/src/primitives/heading/heading.tsx +2 -3
  133. package/src/primitives/inline/inline.tsx +6 -12
  134. package/src/primitives/inline/styles.ts +2 -2
  135. package/src/primitives/inline/types.ts +1 -1
  136. package/src/primitives/kbd/kbd.tsx +1 -2
  137. package/src/primitives/label/label.tsx +3 -4
  138. package/src/primitives/popover/__workshop__/index.ts +5 -10
  139. package/src/primitives/popover/__workshop__/{MarginsStory.tsx → margins.tsx} +1 -1
  140. package/src/primitives/popover/__workshop__/{MatchReferenceWidthStory.tsx → matchReferenceWidth.tsx} +0 -0
  141. package/src/primitives/popover/__workshop__/{PlainStory.tsx → plain.tsx} +14 -12
  142. package/src/primitives/popover/__workshop__/{RecursiveStory.tsx → recursive.tsx} +1 -4
  143. package/src/primitives/popover/__workshop__/rightAligned.tsx +57 -0
  144. package/src/primitives/popover/popover.tsx +10 -29
  145. package/src/primitives/select/select.tsx +9 -9
  146. package/src/primitives/select/styles.ts +4 -10
  147. package/src/primitives/stack/stack.tsx +1 -2
  148. package/src/primitives/stack/styles.ts +3 -3
  149. package/src/primitives/text/__workshop__/opticalAlignment.tsx +5 -15
  150. package/src/primitives/text/text.tsx +2 -3
  151. package/src/primitives/textArea/__workshop__/plain.tsx +18 -23
  152. package/src/primitives/textArea/textArea.tsx +5 -21
  153. package/src/primitives/textInput/__workshop__/clearButton.tsx +8 -14
  154. package/src/primitives/textInput/__workshop__/index.ts +2 -2
  155. package/src/primitives/textInput/__workshop__/plain.tsx +32 -39
  156. package/src/primitives/textInput/__workshop__/tones.tsx +95 -234
  157. package/src/primitives/textInput/__workshop__/typed.tsx +2 -8
  158. package/src/primitives/textInput/textInput.tsx +12 -47
  159. package/src/primitives/tooltip/__workshop__/props.tsx +2 -7
  160. package/src/primitives/tooltip/tooltip.tsx +9 -19
  161. package/src/primitives/types.ts +1 -1
  162. package/src/styles/border/borderStyle.ts +6 -6
  163. package/src/styles/border/types.ts +5 -5
  164. package/src/styles/box/boxStyle.ts +5 -5
  165. package/src/styles/box/types.ts +4 -4
  166. package/src/styles/flex/flexItemStyle.ts +4 -5
  167. package/src/styles/flex/flexStyle.ts +6 -6
  168. package/src/styles/flex/types.ts +6 -6
  169. package/src/styles/font/responsiveFont.ts +4 -2
  170. package/src/styles/font/textAlignStyle.ts +2 -2
  171. package/src/styles/font/types.ts +3 -4
  172. package/src/styles/grid/gridItemStyle.ts +7 -7
  173. package/src/styles/grid/gridStyle.ts +9 -9
  174. package/src/styles/grid/types.ts +14 -14
  175. package/src/styles/helpers.ts +9 -9
  176. package/src/styles/input/responsiveInputPaddingStyle.ts +27 -24
  177. package/src/styles/input/textInputStyle.ts +80 -92
  178. package/src/styles/margin/marginStyle.ts +8 -8
  179. package/src/styles/margin/marginsStyle.test.ts +1 -1
  180. package/src/styles/margin/types.ts +7 -7
  181. package/src/styles/padding/paddingStyle.test.ts +1 -1
  182. package/src/styles/padding/paddingStyle.ts +8 -8
  183. package/src/styles/padding/types.ts +7 -7
  184. package/src/styles/radius/radiusStyle.ts +2 -2
  185. package/src/styles/radius/types.ts +1 -1
  186. package/src/styles/shadow/shadowStyle.ts +5 -2
  187. package/src/styles/shadow/types.ts +1 -1
  188. package/src/theme/studioTheme/color.ts +14 -15
  189. package/src/theme/studioTheme/fonts.ts +4 -4
  190. package/src/utils/elementQuery/elementQuery.tsx +18 -5
  191. package/src/utils/index.ts +1 -0
  192. package/src/utils/layer/layerProvider.tsx +2 -2
  193. package/src/{observers → utils}/resizeObserver.ts +3 -1
  194. package/src/utils/virtualList/virtualList.tsx +7 -8
  195. package/lib/dts/src/hooks/useArrayProp.d.ts +0 -7
  196. package/lib/dts/src/hooks/useArrayProp.d.ts.map +0 -1
  197. package/lib/dts/src/hooks/useElementSize.d.ts +0 -7
  198. package/lib/dts/src/hooks/useElementSize.d.ts.map +0 -1
  199. package/lib/dts/src/observers/elementSizeObserver.d.ts +0 -37
  200. package/lib/dts/src/observers/elementSizeObserver.d.ts.map +0 -1
  201. package/lib/dts/src/observers/index.d.ts +0 -3
  202. package/lib/dts/src/observers/index.d.ts.map +0 -1
  203. package/lib/dts/src/observers/resizeObserver.d.ts +0 -5
  204. package/lib/dts/src/observers/resizeObserver.d.ts.map +0 -1
  205. package/src/hooks/useArrayProp.ts +0 -23
  206. package/src/hooks/useElementSize.ts +0 -18
  207. package/src/observers/elementSizeObserver.ts +0 -116
  208. package/src/observers/index.ts +0 -2
  209. package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +0 -60
  210. package/src/primitives/popover/__workshop__/TestStory.tsx +0 -79
@@ -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 {useArrayProp, useForwardedRef, useCustomValidity} from '../../hooks'
6
+ import {useForwardedRef, useCustomValidity, useResponsiveProp} 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, useRootTheme} from '../../theme'
19
+ import {ThemeFontWeightKey} 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(Card).attrs({forwardedAs: 'span'})(textInputRootStyle)
75
+ const Root = styled.span(textInputRootStyle)
76
76
 
77
77
  const InputRoot = styled.span`
78
78
  flex: 1;
@@ -118,12 +118,6 @@ 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
-
127
121
  const RightCard = styled(Card)`
128
122
  background-color: transparent;
129
123
  position: absolute;
@@ -142,7 +136,7 @@ export const TextInput = forwardRef(function TextInput(
142
136
  border = true,
143
137
  clearButton,
144
138
  disabled = false,
145
- fontSize: fontSizeProp = 2,
139
+ fontSize = 2,
146
140
  icon,
147
141
  iconRight,
148
142
  onClear,
@@ -150,22 +144,16 @@ export const TextInput = forwardRef(function TextInput(
150
144
  prefix,
151
145
  radius: radiusProp = 1,
152
146
  readOnly,
153
- space: spaceProp = 3,
147
+ space = 3,
154
148
  suffix,
155
149
  customValidity,
156
150
  type = 'text',
157
- weight,
158
151
  ...restProps
159
152
  } = props
160
153
 
161
154
  const ref = useForwardedRef(forwardedRef)
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)
155
+ const padding = useResponsiveProp(paddingProp)
156
+ const radius = useResponsiveProp(radiusProp)
169
157
 
170
158
  // Transient properties
171
159
  const $hasClearButton = Boolean(clearButton)
@@ -214,10 +202,6 @@ export const TextInput = forwardRef(function TextInput(
214
202
  $hasPrefix={$hasPrefix}
215
203
  $hasSuffix={$hasSuffix}
216
204
  $radius={radius}
217
- $scheme={rootTheme.scheme}
218
- $tone={rootTheme.tone}
219
- data-scheme={rootTheme.scheme}
220
- data-tone={rootTheme.tone}
221
205
  >
222
206
  {icon && (
223
207
  <LeftBox padding={padding}>
@@ -229,27 +213,16 @@ export const TextInput = forwardRef(function TextInput(
229
213
  )}
230
214
 
231
215
  {!$hasClearButton && iconRight && (
232
- <RightBox padding={padding}>
216
+ <RightCard padding={padding}>
233
217
  <Text size={fontSize}>
234
218
  {isValidElement(iconRight) && iconRight}
235
219
  {isValidElementType(iconRight) && createElement(iconRight)}
236
220
  </Text>
237
- </RightBox>
221
+ </RightCard>
238
222
  )}
239
223
  </Presentation>
240
224
  ),
241
- [
242
- border,
243
- fontSize,
244
- icon,
245
- iconRight,
246
- padding,
247
- radius,
248
- rootTheme,
249
- $hasClearButton,
250
- $hasPrefix,
251
- $hasSuffix,
252
- ]
225
+ [border, fontSize, icon, iconRight, padding, radius, $hasClearButton, $hasPrefix, $hasSuffix]
253
226
  )
254
227
 
255
228
  // Render clear button (memoized)
@@ -330,33 +303,25 @@ export const TextInput = forwardRef(function TextInput(
330
303
  )
331
304
 
332
305
  return (
333
- <Root data-ui="TextInput" tone={rootTheme.tone}>
306
+ <Root data-ui="TextInput">
334
307
  {prefixNode}
335
-
336
308
  <InputRoot>
337
309
  <Input
338
310
  data-as="input"
339
- data-scheme={rootTheme.scheme}
340
- data-tone={rootTheme.tone}
341
311
  {...restProps}
342
- $fontSize={fontSize}
343
312
  $iconLeft={$hasIcon}
344
313
  $iconRight={$hasIconRight || $hasClearButton}
345
314
  $padding={padding}
346
- $scheme={rootTheme.scheme}
347
315
  $space={space}
348
- $tone={rootTheme.tone}
349
- $weight={weight}
316
+ $fontSize={fontSize}
350
317
  disabled={disabled}
351
318
  readOnly={readOnly}
352
319
  ref={ref}
353
320
  type={type}
354
321
  />
355
-
356
322
  {presentationNode}
357
323
  {clearButtonNode}
358
324
  </InputRoot>
359
-
360
325
  {suffixNode}
361
326
  </Root>
362
327
  )
@@ -1,22 +1,17 @@
1
1
  import {Box, Button, Card, Flex, Text, Tooltip} from '@sanity/ui'
2
- import {useSelect, useText} from '@sanity/ui-workshop'
3
2
  import React from 'react'
4
- import {WORKSHOP_PLACEMENT_OPTIONS} from '../../../__workshop__/constants'
5
3
 
6
4
  export default function PropsStory() {
7
- const content = useText('Content', 'Tooltip content')
8
- const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS, 'top')
9
-
10
5
  return (
11
6
  <Card height="fill">
12
7
  <Flex align="center" height="fill" justify="center" padding={4} sizing="border">
13
8
  <Tooltip
14
9
  content={
15
10
  <Box padding={2}>
16
- <Text size={1}>{content}</Text>
11
+ <Text size={1}>Tooltip content</Text>
17
12
  </Box>
18
13
  }
19
- placement={placement}
14
+ placement="top"
20
15
  portal
21
16
  >
22
17
  <Button mode="bleed" text="Hover me" />
@@ -1,7 +1,7 @@
1
- import React, {cloneElement, forwardRef, useCallback, useEffect, useRef, useState} from 'react'
1
+ import React, {cloneElement, forwardRef, useCallback, useEffect, useState} from 'react'
2
2
  import {usePopper} from 'react-popper'
3
3
  import styled from 'styled-components'
4
- import {useArrayProp, useForwardedRef} from '../../hooks'
4
+ import {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,14 +42,13 @@ export const Tooltip = forwardRef(function Tooltip(
42
42
  children,
43
43
  content,
44
44
  disabled,
45
- fallbackPlacements: fallbackPlacementsProp,
45
+ fallbackPlacements,
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)
53
52
  const forwardedRef = useForwardedRef(ref)
54
53
  const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)
55
54
  const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null)
@@ -118,23 +117,14 @@ export const Tooltip = forwardRef(function Tooltip(
118
117
  }
119
118
  }, [isOpen, referenceElement])
120
119
 
121
- const updateTimeoutRef = useRef<NodeJS.Timeout | null>(null)
122
-
123
120
  useEffect(() => {
124
- if (updateTimeoutRef.current) {
125
- clearTimeout(updateTimeoutRef.current)
126
- updateTimeoutRef.current = null
127
- }
128
-
129
- updateTimeoutRef.current = setTimeout(() => {
130
- if (forceUpdate) {
131
- try {
132
- forceUpdate()
133
- } catch (_) {
134
- // ignore caught error
135
- }
121
+ if (forceUpdate) {
122
+ try {
123
+ forceUpdate()
124
+ } catch (_) {
125
+ // ignore caught error
136
126
  }
137
- }, 0)
127
+ }
138
128
  }, [forceUpdate, content])
139
129
 
140
130
  // 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 | 'auto' | (number | 'auto')[]
130
+ width?: number | number[] | 'auto'
131
131
  }
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {_responsive} from '../helpers'
2
+ import {getResponsiveProp, 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, props.$border, (value) =>
18
+ return responsive(media, getResponsiveProp(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, props.$borderTop, (value) =>
27
+ return responsive(media, getResponsiveProp(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, props.$borderRight, (value) =>
36
+ return responsive(media, getResponsiveProp(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, props.$borderBottom, (value) =>
45
+ return responsive(media, getResponsiveProp(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, props.$borderLeft, (value) =>
54
+ return responsive(media, getResponsiveProp(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[]
6
- $borderTop: boolean[]
7
- $borderRight: boolean[]
8
- $borderBottom: boolean[]
9
- $borderLeft: boolean[]
5
+ $border?: boolean | boolean[]
6
+ $borderTop?: boolean | boolean[]
7
+ $borderRight?: boolean | boolean[]
8
+ $borderBottom?: boolean | boolean[]
9
+ $borderLeft?: boolean | boolean[]
10
10
  }
@@ -1,6 +1,6 @@
1
1
  import {Property} from 'csstype'
2
2
  import {CSSObject} from 'styled-components'
3
- import {_responsive} from '../helpers'
3
+ import {getResponsiveProp, responsive} from '../helpers'
4
4
  import {ThemeProps} from '../types'
5
5
  import {ResponsiveBoxStyleProps} from './types'
6
6
 
@@ -39,7 +39,7 @@ function responsiveBoxDisplayStyle(props: ResponsiveBoxStyleProps & ThemeProps)
39
39
  const {theme} = props
40
40
  const {media} = theme.sanity
41
41
 
42
- return _responsive(media, props.$display, (display) => ({
42
+ return responsive(media, getResponsiveProp(props.$display), (display) => ({
43
43
  '&:not([hidden])': {display},
44
44
  }))
45
45
  }
@@ -48,7 +48,7 @@ function responsiveBoxSizingStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
48
48
  const {theme} = props
49
49
  const {media} = theme.sanity
50
50
 
51
- return _responsive(media, props.$sizing, (sizing) => ({
51
+ return responsive(media, getResponsiveProp(props.$sizing), (sizing) => ({
52
52
  boxSizing: BOX_SIZING[sizing],
53
53
  }))
54
54
  }
@@ -57,7 +57,7 @@ function responsiveBoxHeightStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
57
57
  const {theme} = props
58
58
  const {media} = theme.sanity
59
59
 
60
- return _responsive(media, props.$height, (height) => ({
60
+ return responsive(media, getResponsiveProp(props.$height), (height) => ({
61
61
  height: BOX_HEIGHT[height],
62
62
  }))
63
63
  }
@@ -66,7 +66,7 @@ function responsiveBoxOverflowStyle(props: ResponsiveBoxStyleProps & ThemeProps)
66
66
  const {theme} = props
67
67
  const {media} = theme.sanity
68
68
 
69
- return _responsive(media, props.$overflow, (overflow) => ({
69
+ return responsive(media, getResponsiveProp(props.$overflow), (overflow) => ({
70
70
  overflow,
71
71
  }))
72
72
  }
@@ -4,8 +4,8 @@ import {BoxDisplay, BoxHeight, BoxOverflow, BoxSizing} from '../../types'
4
4
  * @internal
5
5
  */
6
6
  export interface ResponsiveBoxStyleProps {
7
- $display: BoxDisplay[]
8
- $height: BoxHeight[]
9
- $overflow: BoxOverflow[]
10
- $sizing: BoxSizing[]
7
+ $display?: BoxDisplay | BoxDisplay[]
8
+ $height?: BoxHeight | BoxHeight[]
9
+ $overflow?: BoxOverflow | BoxOverflow[]
10
+ $sizing?: BoxSizing | BoxSizing[]
11
11
  }
@@ -1,6 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {EMPTY_ARRAY} from '../../constants'
3
- import {_responsive} from '../helpers'
2
+ import {getResponsiveProp, responsive} from '../helpers'
4
3
  import {ThemeProps} from '../types'
5
4
  import {ResponsiveFlexItemStyleProps} from './types'
6
5
 
@@ -21,7 +20,7 @@ export function responsiveFlexItemStyle(
21
20
  const {theme} = props
22
21
  const {media} = theme.sanity
23
22
 
24
- if (!props.$flex) return EMPTY_ARRAY
25
-
26
- return _responsive(media, props.$flex, (flex) => ({flex}))
23
+ return responsive(media, getResponsiveProp(props.$flex), (flex) => {
24
+ return {flex}
25
+ })
27
26
  }
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {rem, _responsive} from '../helpers'
2
+ import {getResponsiveProp, rem, responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveFlexStyleProps} from './types'
5
5
 
@@ -28,7 +28,7 @@ export function responsiveFlexAlignStyle(
28
28
  const {theme} = props
29
29
  const {media} = theme.sanity
30
30
 
31
- return _responsive(media, props.$align, (align) => {
31
+ return responsive(media, getResponsiveProp(props.$align), (align) => {
32
32
  return {alignItems: align}
33
33
  })
34
34
  }
@@ -37,7 +37,7 @@ function responsiveFlexGapStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
37
37
  const {theme} = props
38
38
  const {media, space} = theme.sanity
39
39
 
40
- return _responsive(media, props.$gap, (gap) => ({
40
+ return responsive(media, getResponsiveProp(props.$gap), (gap) => ({
41
41
  gap: gap ? rem(space[gap]) : undefined,
42
42
  }))
43
43
  }
@@ -46,7 +46,7 @@ export function responsiveFlexWrapStyle(props: ResponsiveFlexStyleProps & ThemeP
46
46
  const {theme} = props
47
47
  const {media} = theme.sanity
48
48
 
49
- return _responsive(media, props.$wrap, (wrap) => {
49
+ return responsive(media, getResponsiveProp(props.$wrap), (wrap) => {
50
50
  return {flexWrap: wrap}
51
51
  })
52
52
  }
@@ -57,7 +57,7 @@ export function responsiveFlexJustifyStyle(
57
57
  const {theme} = props
58
58
  const {media} = theme.sanity
59
59
 
60
- return _responsive(media, props.$justify, (justify) => {
60
+ return responsive(media, getResponsiveProp(props.$justify), (justify) => {
61
61
  return {justifyContent: justify}
62
62
  })
63
63
  }
@@ -68,7 +68,7 @@ export function responsiveFlexDirectionStyle(
68
68
  const {theme} = props
69
69
  const {media} = theme.sanity
70
70
 
71
- return _responsive(media, props.$direction, (direction) => {
71
+ return responsive(media, getResponsiveProp(props.$direction), (direction) => {
72
72
  return {flexDirection: direction}
73
73
  })
74
74
  }
@@ -4,18 +4,18 @@ import {FlexAlign, FlexDirection, FlexJustify, FlexValue, FlexWrap} from '../../
4
4
  * @internal
5
5
  */
6
6
  export interface ResponsiveFlexStyleProps {
7
- $align: FlexAlign[]
8
- $direction: FlexDirection[]
9
- $gap: number[]
10
- $justify: FlexJustify[]
11
- $wrap: FlexWrap[]
7
+ $align?: FlexAlign | FlexAlign[]
8
+ $direction?: FlexDirection | FlexDirection[]
9
+ $gap?: number | number[]
10
+ $justify?: FlexJustify | FlexJustify[]
11
+ $wrap?: FlexWrap | FlexWrap[]
12
12
  }
13
13
 
14
14
  /**
15
15
  * @internal
16
16
  */
17
17
  export interface ResponsiveFlexItemStyleProps {
18
- $flex: FlexValue[]
18
+ $flex?: FlexValue | FlexValue[]
19
19
  }
20
20
 
21
21
  /**
@@ -1,6 +1,6 @@
1
1
  import {CSSObject} from 'styled-components'
2
2
  import {ThemeFontSize, ThemeFontKey} from '../../theme'
3
- import {rem, _responsive} from '../helpers'
3
+ import {getResponsiveProp, rem, responsive} from '../helpers'
4
4
  import {ThemeProps} from '../types'
5
5
  import {ResponsiveFontStyleProps} from './types'
6
6
 
@@ -48,7 +48,9 @@ export function responsiveFont(
48
48
  },
49
49
  }
50
50
 
51
- const resp = _responsive(media, $size, (sizeIndex) => fontSize(sizes[sizeIndex] || defaultSize))
51
+ const resp = responsive(media, getResponsiveProp($size), (sizeIndex) =>
52
+ fontSize(sizes[sizeIndex] || defaultSize)
53
+ )
52
54
 
53
55
  return [base, ...resp]
54
56
  }
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {_responsive} from '../helpers'
2
+ import {getResponsiveProp, responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveTextAlignStyleProps} from './types'
5
5
 
@@ -12,7 +12,7 @@ export function responsiveTextAlignStyle(
12
12
  ): CSSObject[] {
13
13
  const {theme} = props
14
14
 
15
- return _responsive(theme.sanity.media, props.$align, (textAlign) => {
15
+ return responsive(theme.sanity.media, getResponsiveProp(props.$align), (textAlign) => {
16
16
  return {textAlign}
17
17
  })
18
18
  }
@@ -5,7 +5,7 @@ import {TextAlign} from '../../types'
5
5
  * @internal
6
6
  */
7
7
  export interface ResponsiveFontSizeStyleProps {
8
- $size: number[]
8
+ $size?: number | number[]
9
9
  }
10
10
 
11
11
  /**
@@ -19,7 +19,7 @@ export interface FontWeightStyleProps {
19
19
  * @internal
20
20
  */
21
21
  export interface ResponsiveTextAlignStyleProps {
22
- $align: TextAlign[]
22
+ $align?: TextAlign | TextAlign[]
23
23
  }
24
24
 
25
25
  /**
@@ -27,8 +27,7 @@ export interface ResponsiveTextAlignStyleProps {
27
27
  */
28
28
  export interface ResponsiveFontStyleProps
29
29
  extends FontWeightStyleProps,
30
- ResponsiveFontSizeStyleProps,
31
- ResponsiveTextAlignStyleProps {
30
+ ResponsiveFontSizeStyleProps {
32
31
  $accent?: boolean
33
32
  $muted?: boolean
34
33
  }
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {_responsive} from '../helpers'
2
+ import {getResponsiveProp, responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveGridItemStyleProps} from './types'
5
5
 
@@ -30,7 +30,7 @@ function responsiveGridItemRowStyle(props: ResponsiveGridItemStyleProps & ThemeP
30
30
  const {theme} = props
31
31
  const {media} = theme.sanity
32
32
 
33
- return _responsive(media, props.$row, (row) => {
33
+ return responsive(media, getResponsiveProp(props.$row), (row) => {
34
34
  if (typeof row === 'number') {
35
35
  return {gridRow: `span ${row} / span ${row}`}
36
36
  }
@@ -43,7 +43,7 @@ function responsiveGridItemRowStartStyle(props: ResponsiveGridItemStyleProps & T
43
43
  const {theme} = props
44
44
  const {media} = theme.sanity
45
45
 
46
- return _responsive(media, props.$rowStart, (rowStart) => ({
46
+ return responsive(media, getResponsiveProp(props.$rowStart), (rowStart) => ({
47
47
  gridRowStart: rowStart,
48
48
  }))
49
49
  }
@@ -52,14 +52,14 @@ function responsiveGridItemRowEndStyle(props: ResponsiveGridItemStyleProps & The
52
52
  const {theme} = props
53
53
  const {media} = theme.sanity
54
54
 
55
- return _responsive(media, props.$rowEnd, (rowEnd) => ({gridRowEnd: rowEnd}))
55
+ return responsive(media, getResponsiveProp(props.$rowEnd), (rowEnd) => ({gridRowEnd: rowEnd}))
56
56
  }
57
57
 
58
58
  function responsiveGridItemColumnStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
59
59
  const {theme} = props
60
60
  const {media} = theme.sanity
61
61
 
62
- return _responsive(media, props.$column, (column) => {
62
+ return responsive(media, getResponsiveProp(props.$column), (column) => {
63
63
  if (typeof column === 'number') {
64
64
  return {gridColumn: `span ${column} / span ${column}`}
65
65
  }
@@ -72,7 +72,7 @@ function responsiveGridItemColumnStartStyle(props: ResponsiveGridItemStyleProps
72
72
  const {theme} = props
73
73
  const {media} = theme.sanity
74
74
 
75
- return _responsive(media, props.$columnStart, (columnStart) => ({
75
+ return responsive(media, getResponsiveProp(props.$columnStart), (columnStart) => ({
76
76
  gridColumnStart: columnStart,
77
77
  }))
78
78
  }
@@ -81,7 +81,7 @@ function responsiveGridItemColumnEndStyle(props: ResponsiveGridItemStyleProps &
81
81
  const {theme} = props
82
82
  const {media} = theme.sanity
83
83
 
84
- return _responsive(media, props.$columnEnd, (columnEnd) => ({
84
+ return responsive(media, getResponsiveProp(props.$columnEnd), (columnEnd) => ({
85
85
  gridColumnEnd: columnEnd,
86
86
  }))
87
87
  }
@@ -1,5 +1,5 @@
1
1
  import {CSSObject} from 'styled-components'
2
- import {rem, _responsive} from '../helpers'
2
+ import {getResponsiveProp, rem, responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveGridStyleProps} from './types'
5
5
 
@@ -46,7 +46,7 @@ function responsiveGridAutoFlowStyle(props: ResponsiveGridStyleProps & ThemeProp
46
46
  const {theme} = props
47
47
  const {media} = theme.sanity
48
48
 
49
- return _responsive(media, props.$autoFlow, (autoFlow) => ({
49
+ return responsive(media, getResponsiveProp(props.$autoFlow), (autoFlow) => ({
50
50
  gridAutoFlow: autoFlow,
51
51
  }))
52
52
  }
@@ -55,7 +55,7 @@ function responsiveGridAutoRowsStyle(props: ResponsiveGridStyleProps & ThemeProp
55
55
  const {theme} = props
56
56
  const {media} = theme.sanity
57
57
 
58
- return _responsive(media, props.$autoRows, (autoRows) => ({
58
+ return responsive(media, getResponsiveProp(props.$autoRows), (autoRows) => ({
59
59
  gridAutoRows: autoRows && GRID_AUTO_ROWS[autoRows],
60
60
  }))
61
61
  }
@@ -64,7 +64,7 @@ function responsiveGridAutoColsStyle(props: ResponsiveGridStyleProps & ThemeProp
64
64
  const {theme} = props
65
65
  const {media} = theme.sanity
66
66
 
67
- return _responsive(media, props.$autoCols, (autoCols) => ({
67
+ return responsive(media, getResponsiveProp(props.$autoCols), (autoCols) => ({
68
68
  gridAutoColumns: autoCols && GRID_AUTO_COLUMS[autoCols],
69
69
  }))
70
70
  }
@@ -73,7 +73,7 @@ function responsiveGridColumnsStyle(props: ResponsiveGridStyleProps & ThemeProps
73
73
  const {theme} = props
74
74
  const {media} = theme.sanity
75
75
 
76
- return _responsive(media, props.$columns, (columns) => ({
76
+ return responsive(media, getResponsiveProp(props.$columns), (columns) => ({
77
77
  gridTemplateColumns: columns && `repeat(${columns},minmax(0,1fr));`,
78
78
  }))
79
79
  }
@@ -82,7 +82,7 @@ function responsiveGridRowsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
82
82
  const {theme} = props
83
83
  const {media} = theme.sanity
84
84
 
85
- return _responsive(media, props.$rows, (rows) => ({
85
+ return responsive(media, getResponsiveProp(props.$rows), (rows) => ({
86
86
  gridTemplateRows: rows && `repeat(${rows},minmax(0,1fr));`,
87
87
  }))
88
88
  }
@@ -91,7 +91,7 @@ function responsiveGridGapStyle(props: ResponsiveGridStyleProps & ThemeProps) {
91
91
  const {theme} = props
92
92
  const {media, space} = theme.sanity
93
93
 
94
- return _responsive(media, props.$gap, (gap) => ({
94
+ return responsive(media, getResponsiveProp(props.$gap), (gap) => ({
95
95
  gridGap: gap ? rem(space[gap]) : undefined,
96
96
  }))
97
97
  }
@@ -100,7 +100,7 @@ function responsiveGridGapXStyle(props: ResponsiveGridStyleProps & ThemeProps) {
100
100
  const {theme} = props
101
101
  const {media, space} = theme.sanity
102
102
 
103
- return _responsive(media, props.$gapX, (gapX) => ({
103
+ return responsive(media, getResponsiveProp(props.$gapX), (gapX) => ({
104
104
  columnGap: gapX ? rem(space[gapX]) : undefined,
105
105
  }))
106
106
  }
@@ -109,7 +109,7 @@ function responsiveGridGapYStyle(props: ResponsiveGridStyleProps & ThemeProps) {
109
109
  const {theme} = props
110
110
  const {media, space} = theme.sanity
111
111
 
112
- return _responsive(media, props.$gapY, (gapY) => ({
112
+ return responsive(media, getResponsiveProp(props.$gapY), (gapY) => ({
113
113
  rowGap: gapY ? rem(space[gapY]) : undefined,
114
114
  }))
115
115
  }