@sanity/ui 3.0.0-static.27 → 3.0.0-static.29

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 (229) hide show
  1. package/README.md +5 -8
  2. package/dist/_chunks-cjs/_visual-editing.cjs +744 -874
  3. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  4. package/dist/_chunks-cjs/refractor.cjs +2 -2
  5. package/dist/_chunks-cjs/refractor.cjs.map +1 -1
  6. package/dist/_chunks-es/_visual-editing.js +788 -917
  7. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  8. package/dist/_chunks-es/refractor.js +1 -1
  9. package/dist/{css.cjs → css/index.cjs} +72 -53
  10. package/dist/css/index.cjs.map +1 -0
  11. package/dist/css/index.css +1 -0
  12. package/dist/{css.d.ts → css/index.d.cts} +26 -8
  13. package/dist/{css.d.cts → css/index.d.ts} +26 -8
  14. package/dist/{css.js → css/index.js} +72 -53
  15. package/dist/css/index.js.map +1 -0
  16. package/dist/css/layers.css +4 -0
  17. package/dist/css/primitives/popover/popover.css +4 -0
  18. package/dist/index.cjs +2049 -1811
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +62 -26
  21. package/dist/index.d.ts +62 -26
  22. package/dist/index.js +2056 -1819
  23. package/dist/index.js.map +1 -1
  24. package/dist/theme.cjs +7 -7
  25. package/dist/theme.cjs.map +1 -1
  26. package/dist/theme.js +7 -7
  27. package/dist/theme.js.map +1 -1
  28. package/exports/_visual-editing.ts +1 -1
  29. package/package.json +14 -19
  30. package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  31. package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
  32. package/src/core/components/autocomplete/autocomplete.tsx +15 -19
  33. package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
  34. package/src/core/components/autocomplete/constants.ts +3 -1
  35. package/src/core/components/autocomplete/types.ts +1 -1
  36. package/src/core/components/breadcrumbs/breadcrumbs.tsx +8 -3
  37. package/src/core/components/dialog/__workshop__/activate.tsx +11 -3
  38. package/src/core/components/dialog/__workshop__/panes.tsx +12 -5
  39. package/src/core/components/dialog/dialog.tsx +12 -6
  40. package/src/core/components/dialog/dialogCard.tsx +89 -54
  41. package/src/core/components/dialog/dialogContext.ts +1 -1
  42. package/src/core/components/dialog/dialogProvider.tsx +1 -1
  43. package/src/core/components/dialog/index.ts +1 -0
  44. package/src/core/components/dialog/isTargetWithinScope.ts +1 -1
  45. package/src/core/components/hotkeys/hotkeys.tsx +3 -2
  46. package/src/core/components/menu/__workshop__/avatarMenu.tsx +12 -6
  47. package/src/core/components/menu/__workshop__/customSelectedState.tsx +1 -5
  48. package/src/core/components/menu/__workshop__/shouldFocus.tsx +1 -2
  49. package/src/core/components/menu/helpers.ts +1 -1
  50. package/src/core/components/menu/menu.tsx +6 -3
  51. package/src/core/components/menu/menuButton.tsx +5 -3
  52. package/src/core/components/menu/menuDivider.tsx +1 -1
  53. package/src/core/components/menu/menuGroup.tsx +8 -4
  54. package/src/core/components/menu/menuItem.tsx +4 -2
  55. package/src/core/components/tab/tab.tsx +2 -2
  56. package/src/core/components/tab/tabList.tsx +2 -2
  57. package/src/core/components/tab/tabPanel.tsx +2 -2
  58. package/src/core/components/toast/toast.tsx +21 -17
  59. package/src/core/components/toast/toastLayer.tsx +3 -2
  60. package/src/core/components/toast/toastProvider.tsx +15 -11
  61. package/src/core/components/tree/tree.tsx +2 -2
  62. package/src/core/components/tree/treeGroup.tsx +2 -2
  63. package/src/core/components/tree/treeItem.tsx +13 -6
  64. package/src/core/components/tree/types.ts +0 -1
  65. package/src/core/components/virtualList/virtualList.tsx +10 -5
  66. package/src/core/helpers/focus.ts +0 -8
  67. package/src/core/hooks/useArrayProp.ts +1 -1
  68. package/src/core/hooks/useElementRect/__workshop__/example.tsx +1 -3
  69. package/src/core/hooks/useElementSize.ts +1 -1
  70. package/src/core/hooks/useResponsiveProp.ts +1 -1
  71. package/src/core/index.ts +84 -7
  72. package/src/core/observers/{elementSizeObserver.ts → elementSize.ts} +1 -1
  73. package/src/core/primitives/_selectable/index.ts +1 -0
  74. package/src/core/primitives/_selectable/selectable.tsx +13 -3
  75. package/src/core/{types/selectable.ts → primitives/_selectable/types.ts} +1 -1
  76. package/src/core/primitives/arrow/arrow.tsx +1 -1
  77. package/src/core/primitives/avatar/avatar.tsx +4 -3
  78. package/src/core/primitives/avatar/avatarCounter.tsx +3 -3
  79. package/src/core/primitives/avatar/avatarStack.tsx +4 -4
  80. package/src/core/primitives/avatar/types.ts +17 -0
  81. package/src/core/primitives/badge/badge.tsx +2 -1
  82. package/src/core/primitives/badge/types.ts +11 -2
  83. package/src/core/primitives/box/__workshop__/responsive.tsx +0 -1
  84. package/src/core/primitives/box/box.tsx +1 -1
  85. package/src/core/primitives/box/index.ts +1 -0
  86. package/src/core/primitives/button/__workshop__/disabled.tsx +37 -51
  87. package/src/core/primitives/button/__workshop__/index.ts +5 -0
  88. package/src/core/primitives/button/__workshop__/textOverflow.tsx +13 -0
  89. package/src/core/primitives/button/button.tsx +15 -14
  90. package/src/core/primitives/button/index.ts +1 -0
  91. package/src/core/primitives/card/__workshop__/listNavigation.tsx +2 -2
  92. package/src/core/primitives/card/card.tsx +1 -1
  93. package/src/core/primitives/card/types.ts +3 -0
  94. package/src/core/primitives/checkbox/__workshop__/tones.tsx +9 -1
  95. package/src/core/primitives/checkbox/checkbox.tsx +3 -4
  96. package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +17 -42
  97. package/src/core/primitives/code/code.tsx +1 -1
  98. package/src/core/primitives/container/container.tsx +1 -1
  99. package/src/core/primitives/flex/flex.tsx +1 -1
  100. package/src/core/primitives/flex/index.ts +1 -0
  101. package/src/core/primitives/grid/grid.tsx +1 -1
  102. package/src/core/primitives/grid/index.ts +1 -0
  103. package/src/core/primitives/heading/heading.tsx +1 -1
  104. package/src/core/primitives/inline/inline.tsx +1 -1
  105. package/src/core/primitives/kbd/kbd.tsx +1 -1
  106. package/src/core/primitives/label/label.tsx +1 -1
  107. package/src/core/primitives/layer/layer.test.tsx +1 -1
  108. package/src/core/primitives/layer/layer.tsx +2 -2
  109. package/src/core/primitives/layer/layerCard.tsx +3 -3
  110. package/src/core/primitives/layer/layerProvider.tsx +2 -1
  111. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +12 -10
  112. package/src/core/primitives/popover/__workshop__/TestStory.tsx +9 -8
  113. package/src/core/primitives/popover/constants.ts +1 -1
  114. package/src/core/primitives/popover/floating-ui/size.ts +1 -1
  115. package/src/core/primitives/popover/popover.tsx +7 -4
  116. package/src/core/primitives/popover/popoverLayer.tsx +2 -1
  117. package/src/core/primitives/popover/types.ts +5 -0
  118. package/src/core/primitives/radio/radio.tsx +2 -2
  119. package/src/core/primitives/root/Root.tsx +89 -0
  120. package/src/core/primitives/root/__workshop__/boundary.tsx +5 -0
  121. package/src/core/primitives/root/__workshop__/index.ts +8 -0
  122. package/src/core/primitives/root/index.ts +1 -0
  123. package/src/core/primitives/select/select.tsx +2 -2
  124. package/src/core/{components → primitives}/skeleton/__workshop__/index.ts +1 -1
  125. package/src/core/{components → primitives}/skeleton/codeSkeleton.tsx +1 -1
  126. package/src/core/{components → primitives}/skeleton/headingSkeleton.tsx +1 -1
  127. package/src/core/{components → primitives}/skeleton/labelSkeleton.tsx +1 -1
  128. package/src/core/{components → primitives}/skeleton/skeleton.tsx +7 -8
  129. package/src/core/{components → primitives}/skeleton/textSkeleton.tsx +1 -1
  130. package/src/core/primitives/spinner/spinner.tsx +1 -1
  131. package/src/core/primitives/srOnly/srOnly.tsx +1 -1
  132. package/src/core/primitives/stack/stack.tsx +1 -1
  133. package/src/core/primitives/switch/switch.tsx +1 -6
  134. package/src/core/primitives/text/__workshop__/colored.tsx +2 -2
  135. package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +17 -42
  136. package/src/core/primitives/text/text.tsx +3 -1
  137. package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
  138. package/src/core/primitives/textArea/textArea.tsx +2 -2
  139. package/src/core/primitives/textInput/textInput.tsx +3 -2
  140. package/src/core/primitives/tooltip/constants.ts +1 -1
  141. package/src/core/primitives/tooltip/tooltip.tsx +5 -3
  142. package/src/core/primitives/tooltip/tooltipLayer.tsx +1 -1
  143. package/src/core/primitives/types.ts +8 -10
  144. package/src/core/types/radius.ts +1 -1
  145. package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +9 -5
  146. package/src/core/utils/elementQuery/elementQuery.tsx +2 -2
  147. package/src/core/utils/portal/portal.tsx +1 -1
  148. package/src/css/components/dialog/dialog.css.ts +26 -1
  149. package/src/css/components/dialog/dialog.ts +27 -7
  150. package/src/css/components/skeleton/skeleton.ts +3 -1
  151. package/src/css/components/skeleton/types.ts +3 -1
  152. package/src/css/components/toast/toast.css.ts +1 -0
  153. package/src/css/defaultTheme.css.ts +55 -2
  154. package/src/css/index.ts +77 -5
  155. package/src/css/primitives/_input/input.ts +2 -1
  156. package/src/css/primitives/_input/types.ts +2 -1
  157. package/src/css/primitives/_selectable/_selectable.css.ts +32 -24
  158. package/src/css/primitives/_selectable/selectable.ts +1 -1
  159. package/src/css/primitives/_selectable/types.ts +1 -1
  160. package/src/css/primitives/avatar/avatar.css.ts +8 -4
  161. package/src/css/primitives/avatar/avatar.ts +1 -1
  162. package/src/css/primitives/badge/types.ts +0 -2
  163. package/src/css/primitives/box/box.ts +35 -37
  164. package/src/css/primitives/box/types.ts +34 -36
  165. package/src/css/primitives/button/button.css.ts +4 -0
  166. package/src/css/primitives/button/button.ts +5 -2
  167. package/src/css/primitives/button/types.ts +4 -11
  168. package/src/css/primitives/card/__workshop__/color.tsx +70 -0
  169. package/src/css/primitives/card/__workshop__/index.ts +14 -0
  170. package/src/css/primitives/card/card.css.ts +4 -0
  171. package/src/css/primitives/code/code.ts +3 -1
  172. package/src/css/primitives/code/types.ts +2 -1
  173. package/src/css/primitives/container/container.ts +3 -1
  174. package/src/css/primitives/heading/heading.ts +4 -1
  175. package/src/css/primitives/heading/types.ts +3 -1
  176. package/src/css/primitives/kbd/kbd.ts +1 -1
  177. package/src/css/primitives/kbd/types.ts +1 -1
  178. package/src/css/primitives/label/label.ts +4 -1
  179. package/src/css/primitives/label/types.ts +3 -1
  180. package/src/css/primitives/root/index.ts +2 -0
  181. package/src/css/primitives/root/root.css.ts +15 -0
  182. package/src/css/primitives/root/root.ts +17 -0
  183. package/src/css/primitives/root/types.ts +10 -0
  184. package/src/css/primitives/switch/switch.css.ts +1 -1
  185. package/src/css/primitives/text/text.ts +6 -1
  186. package/src/css/primitives/text/types.ts +5 -2
  187. package/src/theme/v3/defaultFonts.ts +6 -6
  188. package/src/theme/v3/defaultTokens.ts +1 -1
  189. package/bin/sanity-ui.cjs +0 -5
  190. package/dist/css.cjs.map +0 -1
  191. package/dist/css.js.map +0 -1
  192. package/dist/ui.css +0 -1
  193. package/src/cli/buildCommand.ts +0 -10
  194. package/src/cli/index.ts +0 -26
  195. package/src/core/components/autocomplete/index.ts +0 -2
  196. package/src/core/components/index.ts +0 -10
  197. package/src/core/helpers/index.ts +0 -5
  198. package/src/core/hooks/index.ts +0 -13
  199. package/src/core/observers/index.ts +0 -2
  200. package/src/core/primitives/index.ts +0 -30
  201. package/src/core/types/avatar.ts +0 -16
  202. package/src/core/types/card.ts +0 -4
  203. package/src/core/types/index.ts +0 -15
  204. package/src/core/types/popover.ts +0 -4
  205. package/src/core/utils/index.ts +0 -4
  206. package/src/css/__theme/index.ts +0 -16
  207. package/src/css/__theme/lib/contract/buildVarContract.ts +0 -78
  208. package/src/css/__theme/lib/contract/index.ts +0 -4
  209. package/src/css/__theme/lib/contract/types.ts +0 -17
  210. package/src/css/__theme/resolveTheme.ts +0 -865
  211. package/src/css/components/index.ts +0 -6
  212. package/src/css/primitives/index.ts +0 -24
  213. package/src/css/props/index.ts +0 -37
  214. package/src/css/utils/srOnly/index.ts +0 -1
  215. /package/src/core/{global.ts → __DEV__.ts} +0 -0
  216. /package/src/core/{types/dialog.ts → components/dialog/types.ts} +0 -0
  217. /package/src/core/observers/{resizeObserver.ts → resize.ts} +0 -0
  218. /package/src/core/{types/badge.ts → primitives/badge/types2.ts} +0 -0
  219. /package/src/core/{types/box.ts → primitives/box/types.ts} +0 -0
  220. /package/src/core/{types/button.ts → primitives/button/types.ts} +0 -0
  221. /package/src/core/{types/flex.ts → primitives/flex/types.ts} +0 -0
  222. /package/src/core/{types/grid.ts → primitives/grid/types.ts} +0 -0
  223. /package/src/core/{components → primitives}/skeleton/__workshop__/delay.tsx +0 -0
  224. /package/src/core/{components → primitives}/skeleton/__workshop__/skeleton.tsx +0 -0
  225. /package/src/core/{components → primitives}/skeleton/index.ts +0 -0
  226. /package/src/core/types/{text.ts → textAlign.ts} +0 -0
  227. /package/src/css/{utils → primitives/srOnly}/index.ts +0 -0
  228. /package/src/css/{utils → primitives}/srOnly/srOnly.css.ts +0 -0
  229. /package/src/css/{utils → primitives}/srOnly/srOnly.ts +0 -0
@@ -1,18 +1,20 @@
1
+ import {
2
+ BoundaryElementProvider,
3
+ Box,
4
+ Card,
5
+ type CardTone,
6
+ Flex,
7
+ Popover,
8
+ type PopoverProps,
9
+ type PopoverUpdateCallback,
10
+ Stack,
11
+ Text,
12
+ } from '@sanity/ui'
1
13
  import {useSelect} from '@sanity/ui-workshop'
2
14
  import {useCallback, useEffect, useRef, useState} from 'react'
3
15
 
4
16
  import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
5
17
 
6
- import type {CardTone} from '../../../types'
7
- import {BoundaryElementProvider} from '../../../utils'
8
- import {Box} from '../../box'
9
- import {Card} from '../../card'
10
- import {Flex} from '../../flex'
11
- import {Stack} from '../../stack'
12
- import {Text} from '../../text'
13
- import {Popover, type PopoverProps} from '../popover'
14
- import type {PopoverUpdateCallback} from '../types'
15
-
16
18
  const SIDE_PANEL_WIDTH = {
17
19
  sm: 300,
18
20
  md: 400,
@@ -1,20 +1,21 @@
1
+ import {
2
+ BoundaryElementProvider,
3
+ Button,
4
+ Card,
5
+ Popover,
6
+ type PopoverUpdateCallback,
7
+ PortalProvider,
8
+ Text,
9
+ } from '@sanity/ui'
1
10
  import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
2
11
  import {useRef, useState} from 'react'
3
12
 
4
13
  import {
5
14
  WORKSHOP_CONTAINER_WIDTH_OPTIONS,
6
- // WORKSHOP_CONTAINER_WIDTH_OPTIONS,
7
15
  WORKSHOP_PLACEMENT_OPTIONS,
8
16
  WORKSHOP_RADIUS_OPTIONS,
9
17
  } from '$workshop'
10
18
 
11
- import {BoundaryElementProvider, PortalProvider} from '../../../utils'
12
- import {Button} from '../../button'
13
- import {Card} from '../../card'
14
- import {Text} from '../../text'
15
- import {Popover} from '../popover'
16
- import type {PopoverUpdateCallback} from '../types'
17
-
18
19
  export default function TestStory(): React.JSX.Element {
19
20
  const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
20
21
  const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
@@ -1,4 +1,4 @@
1
- import type {Placement, PopoverMargins} from '../../types'
1
+ import type {Placement, PopoverMargins} from '@sanity/ui'
2
2
 
3
3
  export const DEFAULT_POPOVER_DISTANCE = 4
4
4
  export const DEFAULT_POPOVER_PADDING = 4
@@ -1,6 +1,6 @@
1
1
  import {detectOverflow, type Elements, type Middleware} from '@floating-ui/react-dom'
2
2
 
3
- import type {PopoverMargins} from '../../../types'
3
+ import type {PopoverMargins} from '../types'
4
4
 
5
5
  export interface SizeMiddlewareApplyOptions {
6
6
  availableWidth: number
@@ -25,10 +25,13 @@ import {
25
25
  } from 'react'
26
26
 
27
27
  import {Z_OFFSETS} from '../../constants'
28
- import {usePrefersReducedMotion, useResponsiveProp} from '../../hooks'
28
+ import {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'
29
+ import {useResponsiveProp} from '../../hooks/useResponsiveProp'
29
30
  import {origin} from '../../middleware/origin'
30
- import type {ComponentType, Placement, PopoverMargins, Props} from '../../types'
31
- import {Portal, useBoundaryElement} from '../../utils'
31
+ import type {Placement} from '../../types/placement'
32
+ import type {ComponentType, Props} from '../../types/props'
33
+ import {useBoundaryElement} from '../../utils/boundaryElement'
34
+ import {Portal} from '../../utils/portal'
32
35
  import {CardProvider, useCard} from '../card'
33
36
  import {type LayerOwnProps, useLayer} from '../layer'
34
37
  import {
@@ -39,7 +42,7 @@ import {
39
42
  } from './constants'
40
43
  import {size} from './floating-ui/size'
41
44
  import {PopoverLayer} from './popoverLayer'
42
- import type {PopoverUpdateCallback} from './types'
45
+ import type {PopoverMargins, PopoverUpdateCallback} from './types'
43
46
 
44
47
  /** @public */
45
48
  export const DEFAULT_POPOVER_ELEMENT = 'div'
@@ -4,7 +4,7 @@ import {motion} from 'framer-motion'
4
4
  import {type CSSProperties, type ForwardedRef, useMemo} from 'react'
5
5
 
6
6
  import {POPOVER_MOTION_PROPS} from '../../constants'
7
- import type {Placement, PopoverMargins} from '../../types'
7
+ import type {Placement} from '../../types/placement'
8
8
  import {Arrow} from '../arrow'
9
9
  import {Flex} from '../flex'
10
10
  import {Layer, type LayerOwnProps, type LayerProps} from '../layer'
@@ -14,6 +14,7 @@ import {
14
14
  DEFAULT_POPOVER_ARROW_WIDTH,
15
15
  DEFAULT_POPOVER_MARGINS,
16
16
  } from './constants'
17
+ import type {PopoverMargins} from './types'
17
18
 
18
19
  /** @internal */
19
20
  export const DEFAULT_POPOVER_LAYER_ELEMENT = 'div'
@@ -1,5 +1,10 @@
1
1
  import type {ContainerWidth} from '@sanity/ui/theme'
2
2
 
3
+ /**
4
+ * @beta
5
+ */
6
+ export type PopoverMargins = [number, number, number, number]
7
+
3
8
  /** @beta */
4
9
  export type PopoverUpdateCallback = () => void
5
10
 
@@ -1,8 +1,8 @@
1
1
  import {radio, radioInput, radioPresentation} from '@sanity/ui/css'
2
2
  import {useImperativeHandle, useRef} from 'react'
3
3
 
4
- import {useCustomValidity} from '../../hooks'
5
- import type {ComponentType, Props} from '../../types'
4
+ import {useCustomValidity} from '../../hooks/useCustomValidity'
5
+ import type {ComponentType, Props} from '../../types/props'
6
6
 
7
7
  /** @public */
8
8
  export const DEFAULT_RADIO_ELEMENT = 'input'
@@ -0,0 +1,89 @@
1
+ import {box, root, type RootStyleProps} from '@sanity/ui/css'
2
+ import {useCallback, useImperativeHandle, useRef, useState} from 'react'
3
+
4
+ import {ToastProvider} from '../../components/toast'
5
+ import type {Props} from '../../types/props'
6
+ import {BoundaryElementProvider} from '../../utils/boundaryElement'
7
+ import {PortalProvider} from '../../utils/portal'
8
+ import {Box, type BoxOwnProps} from '../box'
9
+ import {CardProvider} from '../card'
10
+ import {LayerProvider} from '../layer'
11
+
12
+ /** @public */
13
+ export const DEFAULT_ROOT_ELEMENT = 'html'
14
+
15
+ /** @public */
16
+ export interface RootOwnProps extends BoxOwnProps, RootStyleProps {}
17
+
18
+ /** @public */
19
+ export type RootElementType = 'html' | 'body' | 'div'
20
+
21
+ /** @public */
22
+ export type RootProps<E extends RootElementType = RootElementType> = Props<RootOwnProps, E>
23
+
24
+ /**
25
+ * The `Root` component.
26
+ *
27
+ * @public
28
+ */
29
+ export function Root<E extends RootElementType = typeof DEFAULT_ROOT_ELEMENT>(props: RootProps<E>) {
30
+ const {
31
+ as: as = DEFAULT_ROOT_ELEMENT,
32
+ children,
33
+ className,
34
+ height = 'fill',
35
+ ref: forwardedRef,
36
+ scheme = 'light',
37
+ tone = 'transparent',
38
+ ...rest
39
+ } = props as RootProps<typeof DEFAULT_ROOT_ELEMENT>
40
+
41
+ const ref = useRef<HTMLHtmlElement | null>(null)
42
+
43
+ useImperativeHandle<HTMLHtmlElement | null, HTMLHtmlElement | null>(
44
+ forwardedRef,
45
+ () => ref.current,
46
+ )
47
+
48
+ const [portalElement, setPortalElement] = useState<HTMLElement | null>(null)
49
+ const [boundaryElement, setBoundaryElement] = useState<HTMLElement | null>(null)
50
+
51
+ const handleRef = useCallback((el: HTMLHtmlElement | null) => {
52
+ setBoundaryElement(el)
53
+ ref.current = el
54
+ }, [])
55
+
56
+ let node = (
57
+ <LayerProvider>
58
+ <CardProvider scheme={scheme} tone={tone}>
59
+ <ToastProvider>
60
+ <BoundaryElementProvider element={boundaryElement}>
61
+ <PortalProvider element={portalElement}>{children}</PortalProvider>
62
+ </BoundaryElementProvider>
63
+ <div data-portal="" ref={setPortalElement} />
64
+ </ToastProvider>
65
+ </CardProvider>
66
+ </LayerProvider>
67
+ )
68
+
69
+ if (as === 'html') {
70
+ node = <body className={box({height, margin: 0})}>{node}</body>
71
+ }
72
+
73
+ return (
74
+ <Box
75
+ as={as}
76
+ data-ui="Root"
77
+ {...rest}
78
+ className={root({
79
+ className,
80
+ height,
81
+ scheme,
82
+ tone,
83
+ })}
84
+ ref={handleRef}
85
+ >
86
+ {node}
87
+ </Box>
88
+ )
89
+ }
@@ -0,0 +1,5 @@
1
+ import {Root} from '@sanity/ui'
2
+
3
+ export default function BoundaryStory() {
4
+ return <Root>Hello!</Root>
5
+ }
@@ -0,0 +1,8 @@
1
+ import {defineScope} from '@sanity/ui-workshop'
2
+ import {lazy} from 'react'
3
+
4
+ export default defineScope({
5
+ name: 'primitives/radio',
6
+ title: 'Radio',
7
+ stories: [{name: 'boundary', title: 'Boundary', component: lazy(() => import('./boundary'))}],
8
+ })
@@ -0,0 +1 @@
1
+ export * from './Root'
@@ -9,8 +9,8 @@ import {
9
9
  import type {Space} from '@sanity/ui/theme'
10
10
  import {useImperativeHandle, useRef} from 'react'
11
11
 
12
- import {useCustomValidity} from '../../hooks'
13
- import type {ComponentType, Props} from '../../types'
12
+ import {useCustomValidity} from '../../hooks/useCustomValidity'
13
+ import type {ComponentType, Props} from '../../types/props'
14
14
  import {Box} from '../box'
15
15
  import {Text} from '../text'
16
16
 
@@ -2,7 +2,7 @@ import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
4
  export default defineScope({
5
- name: 'components/skeleton',
5
+ name: 'primitives/skeleton',
6
6
  title: 'Skeleton',
7
7
  stories: [
8
8
  {name: 'skeleton', title: 'Skeleton', component: lazy(() => import('./skeleton'))},
@@ -1,7 +1,7 @@
1
1
  import {codeSkeleton, type ResponsiveProp} from '@sanity/ui/css'
2
2
  import type {FontCodeSize} from '@sanity/ui/theme'
3
3
 
4
- import type {Props} from '../../types'
4
+ import type {Props} from '../../types/props'
5
5
  import {Skeleton, type SkeletonElementType, type SkeletonOwnProps} from './skeleton'
6
6
 
7
7
  /** @beta */
@@ -1,7 +1,7 @@
1
1
  import {headingSkeleton, type ResponsiveProp} from '@sanity/ui/css'
2
2
  import type {FontHeadingSize} from '@sanity/ui/theme'
3
3
 
4
- import type {Props} from '../../types'
4
+ import type {Props} from '../../types/props'
5
5
  import {Skeleton, type SkeletonElementType, type SkeletonOwnProps} from './skeleton'
6
6
 
7
7
  /** @beta */
@@ -1,7 +1,7 @@
1
1
  import {labelSkeleton, type ResponsiveProp} from '@sanity/ui/css'
2
2
  import type {FontLabelSize} from '@sanity/ui/theme'
3
3
 
4
- import type {Props} from '../../types'
4
+ import type {Props} from '../../types/props'
5
5
  import {Skeleton, type SkeletonElementType, type SkeletonOwnProps} from './skeleton'
6
6
 
7
7
  /** @beta */
@@ -1,8 +1,7 @@
1
1
  import {skeleton, type SkeletonStyleProps} from '@sanity/ui/css'
2
2
  import {useEffect, useState} from 'react'
3
3
 
4
- import {Box, type BoxOwnProps} from '../../primitives'
5
- import type {ComponentType, Props} from '../../types'
4
+ import type {ComponentType, Props} from '../../types/props'
6
5
 
7
6
  /** @beta */
8
7
  export const DEFAULT_SKELETON_ELEMENT = 'div'
@@ -11,11 +10,10 @@ export const DEFAULT_SKELETON_ELEMENT = 'div'
11
10
  * This API might change. DO NOT USE IN PRODUCTION.
12
11
  * @beta
13
12
  */
14
- export type SkeletonOwnProps = BoxOwnProps &
15
- SkeletonStyleProps & {
16
- animated?: boolean
17
- delay?: number
18
- }
13
+ export type SkeletonOwnProps = SkeletonStyleProps & {
14
+ animated?: boolean
15
+ delay?: number
16
+ }
19
17
 
20
18
  /** @beta */
21
19
  export type SkeletonElementType = 'div' | 'span' | ComponentType
@@ -34,6 +32,7 @@ export function Skeleton<E extends SkeletonElementType = typeof DEFAULT_SKELETON
34
32
  props: SkeletonProps<E>,
35
33
  ) {
36
34
  const {
35
+ as: As = DEFAULT_SKELETON_ELEMENT,
37
36
  animated = false,
38
37
  className,
39
38
  delay,
@@ -58,7 +57,7 @@ export function Skeleton<E extends SkeletonElementType = typeof DEFAULT_SKELETON
58
57
  }, [delay])
59
58
 
60
59
  return (
61
- <Box
60
+ <As
62
61
  data-ui="Skeleton"
63
62
  {...rest}
64
63
  className={skeleton({
@@ -1,7 +1,7 @@
1
1
  import {type ResponsiveProp, textSkeleton} from '@sanity/ui/css'
2
2
  import type {FontTextSize} from '@sanity/ui/theme'
3
3
 
4
- import type {Props} from '../../types'
4
+ import type {Props} from '../../types/props'
5
5
  import {Skeleton, type SkeletonElementType, type SkeletonOwnProps} from './skeleton'
6
6
 
7
7
  /** @beta */
@@ -1,7 +1,7 @@
1
1
  import {type ResponsiveProp, spinner} from '@sanity/ui/css'
2
2
  import type {FontTextSize} from '@sanity/ui/theme'
3
3
 
4
- import type {ComponentType, Props} from '../../types'
4
+ import type {ComponentType, Props} from '../../types/props'
5
5
  import {Text} from '../text'
6
6
  import {AnimatedSpinnerIcon} from './animatedSpinnerIcon'
7
7
 
@@ -1,6 +1,6 @@
1
1
  import {srOnly} from '@sanity/ui/css'
2
2
 
3
- import type {ComponentType, Props} from '../../types'
3
+ import type {ComponentType, Props} from '../../types/props'
4
4
 
5
5
  /** @public */
6
6
  export const DEFAULT_SR_ONLY_ELEMENT = 'span'
@@ -1,7 +1,7 @@
1
1
  import {type ResponsiveProp, stack} from '@sanity/ui/css'
2
2
  import type {Space} from '@sanity/ui/theme'
3
3
 
4
- import type {Props} from '../../types'
4
+ import type {Props} from '../../types/props'
5
5
  import {Box, type BoxElementType, type BoxOwnProps} from '../box'
6
6
 
7
7
  /** @public */
@@ -7,7 +7,7 @@ import {
7
7
  } from '@sanity/ui/css'
8
8
  import {useEffect, useImperativeHandle, useRef} from 'react'
9
9
 
10
- import type {ComponentType, Props} from '../../types'
10
+ import type {ComponentType, Props} from '../../types/props'
11
11
  import {Box} from '../box'
12
12
 
13
13
  /** @public */
@@ -36,7 +36,6 @@ export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEME
36
36
  ) {
37
37
  const {
38
38
  as: Element = DEFAULT_SWITCH_ELEMENT,
39
- checked,
40
39
  className,
41
40
  disabled,
42
41
  indeterminate,
@@ -63,8 +62,6 @@ export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEME
63
62
  return (
64
63
  <Box
65
64
  className={_switch({className})}
66
- data-checked={checked ? '' : undefined}
67
- data-indeterminate={indeterminate ? '' : undefined}
68
65
  data-ui="Switch"
69
66
  display="block"
70
67
  position="relative"
@@ -72,9 +69,7 @@ export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEME
72
69
  >
73
70
  <Element
74
71
  {...rest}
75
- checked={indeterminate !== true && checked}
76
72
  className={_switchElement()}
77
- data-disabled={disabled ? '' : undefined}
78
73
  data-read-only={!disabled && readOnly ? '' : undefined}
79
74
  disabled={disabled || readOnly}
80
75
  type="checkbox"
@@ -1,5 +1,5 @@
1
1
  import {Flex, Text} from '@sanity/ui'
2
- import {varNames, vars} from '@sanity/ui/css'
2
+ import {vars} from '@sanity/ui/css'
3
3
  import type {AvatarColor} from '@sanity/ui/theme'
4
4
  import {useSelect} from '@sanity/ui-workshop'
5
5
  import {styled} from 'styled-components'
@@ -7,7 +7,7 @@ import {styled} from 'styled-components'
7
7
  import {WORKSHOP_AVATAR_COLOR_OPTIONS} from '$workshop'
8
8
 
9
9
  const ColoredText = styled(Text)<{$color: AvatarColor}>`
10
- ${varNames.color.fg}: ${({$color}) => vars.color.avatar[$color].bg};
10
+ ${vars.color.fg.slice(4, -1)}: ${({$color}) => vars.color.avatar[$color].bg};
11
11
  `
12
12
 
13
13
  export default function ColoredTextStory() {
@@ -1,48 +1,23 @@
1
- import {AddCircleIcon} from '@sanity/icons'
2
- import {Box, Card, Flex, Stack, Text} from '@sanity/ui'
1
+ import {CropIcon} from '@sanity/icons'
2
+ import {Box, Stack, Text} from '@sanity/ui'
3
+ import {vars} from '@sanity/ui/css'
4
+ import {FONT_TEXT_SIZE} from '@sanity/ui/theme'
3
5
 
4
6
  export default function OpticalAlignment() {
5
7
  return (
6
- <Box padding={[4, 5, 6]}>
7
- <Stack gap={1}>
8
- <Flex>
9
- <Card padding={0} tone="neutral">
10
- <Text size={4}>Hamburgefonstiv M</Text>
11
- </Card>
12
- </Flex>
13
-
14
- <Flex>
15
- <Card padding={0} tone="neutral">
16
- <Text size={3}>Hamburgefonstiv M</Text>
17
- </Card>
18
- </Flex>
19
-
20
- <Flex>
21
- <Card padding={0} tone="neutral">
22
- <Text size={2}>Hamburgefonstiv M</Text>
23
- </Card>
24
- </Flex>
25
-
26
- <Flex>
27
- <Card padding={0} tone="neutral">
28
- <Text size={1}>Hamburgefonstiv M</Text>
29
- </Card>
30
- </Flex>
31
-
32
- <Flex>
33
- <Card padding={0} tone="neutral">
34
- <Text size={0}>Hamburgefonstiv M</Text>
35
- </Card>
36
- </Flex>
37
-
38
- <Flex>
39
- <Card padding={2} tone="neutral">
40
- <Text>
41
- <AddCircleIcon />
8
+ <Stack gap={4} padding={[4, 5, 6]}>
9
+ {FONT_TEXT_SIZE.map((size) => (
10
+ <Box display="flex" gap={2} key={size}>
11
+ <div style={{outline: `0.5px solid ${vars.color.tinted.suggest.border[4]}`}}>
12
+ <Text size={size}>
13
+ <CropIcon />
42
14
  </Text>
43
- </Card>
44
- </Flex>
45
- </Stack>
46
- </Box>
15
+ </div>
16
+ <div style={{outline: `0.5px solid ${vars.color.tinted.suggest.border[4]}`}}>
17
+ <Text size={size}>Hamburgefonstiv M</Text>
18
+ </div>
19
+ </Box>
20
+ ))}
21
+ </Stack>
47
22
  )
48
23
  }
@@ -1,6 +1,6 @@
1
1
  import {text, textOverflow, type TextOverflowStyleProps, type TextStyleProps} from '@sanity/ui/css'
2
2
 
3
- import type {ComponentType, Props} from '../../types'
3
+ import type {ComponentType, Props} from '../../types/props'
4
4
 
5
5
  /** @public */
6
6
  export const DEFAULT_TEXT_ELEMENT = 'div'
@@ -39,6 +39,7 @@ export function Text<E extends TextElementType = typeof DEFAULT_TEXT_ELEMENT>(pr
39
39
  children,
40
40
  className,
41
41
  flex,
42
+ maxWidth = 'fill',
42
43
  muted,
43
44
  size = 2,
44
45
  textOverflow: textOverflowProp,
@@ -55,6 +56,7 @@ export function Text<E extends TextElementType = typeof DEFAULT_TEXT_ELEMENT>(pr
55
56
  accent,
56
57
  align,
57
58
  flex,
59
+ maxWidth,
58
60
  muted,
59
61
  size,
60
62
  weight,
@@ -26,10 +26,10 @@ export default function PlainStory() {
26
26
 
27
27
  return (
28
28
  <Card
29
- align="center"
29
+ alignItems="center"
30
30
  display="flex"
31
31
  height="fill"
32
- justify="center"
32
+ justifyContent="center"
33
33
  padding={[4, 5, 6]}
34
34
  sizing="border"
35
35
  tone={tone}
@@ -8,8 +8,8 @@ import {
8
8
  import type {Space} from '@sanity/ui/theme'
9
9
  import {useImperativeHandle, useRef} from 'react'
10
10
 
11
- import {useCustomValidity} from '../../hooks'
12
- import type {ComponentType, Props} from '../../types'
11
+ import {useCustomValidity} from '../../hooks/useCustomValidity'
12
+ import type {ComponentType, Props} from '../../types/props'
13
13
 
14
14
  /** @public */
15
15
  export const DEFAULT_TEXT_AREA_ELEMENT = 'textarea'
@@ -23,9 +23,10 @@ import {
23
23
  import {isValidElementType} from 'react-is'
24
24
 
25
25
  import {EMPTY_RECORD} from '../../constants'
26
- import {useCustomValidity, useResponsiveProp} from '../../hooks'
26
+ import {useCustomValidity} from '../../hooks/useCustomValidity'
27
+ import {useResponsiveProp} from '../../hooks/useResponsiveProp'
27
28
  import {isRecord} from '../../lib/isRecord'
28
- import type {ComponentType, Props} from '../../types'
29
+ import type {ComponentType, Props} from '../../types/props'
29
30
  import {Box} from '../box'
30
31
  import {Button, type ButtonProps} from '../button'
31
32
  import {Text} from '../text'
@@ -1,4 +1,4 @@
1
- import type {Placement} from '../../types'
1
+ import type {Placement} from '../../types/placement'
2
2
 
3
3
  export const DEFAULT_TOOLTIP_ARROW_WIDTH = 15
4
4
  export const DEFAULT_TOOLTIP_ARROW_HEIGHT = 6
@@ -31,12 +31,14 @@ import {
31
31
  import {useEffectEvent} from 'use-effect-event'
32
32
 
33
33
  import {Z_OFFSETS} from '../../constants'
34
- import {usePrefersReducedMotion} from '../../hooks'
35
34
  import {useDelayedState} from '../../hooks/useDelayedState'
35
+ import {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'
36
36
  import {origin} from '../../middleware/origin'
37
- import type {ComponentType, Placement, Props} from '../../types'
38
- import {Portal, useBoundaryElement, usePortal} from '../../utils'
37
+ import type {Placement} from '../../types/placement'
38
+ import type {ComponentType, Props} from '../../types/props'
39
+ import {useBoundaryElement} from '../../utils/boundaryElement'
39
40
  import {getElementRef} from '../../utils/getElementRef'
41
+ import {Portal, usePortal} from '../../utils/portal'
40
42
  import {CardProvider, useCard} from '../card'
41
43
  import type {LayerOwnProps} from '../layer'
42
44
  import type {Delay} from '../types'
@@ -2,7 +2,7 @@ import {motion, type MotionStyle} from 'framer-motion'
2
2
  import {type CSSProperties, type ForwardedRef, useMemo} from 'react'
3
3
 
4
4
  import {POPOVER_MOTION_PROPS} from '../../constants'
5
- import type {Placement} from '../../types'
5
+ import type {Placement} from '../../types/placement'
6
6
  import {Arrow} from '../arrow'
7
7
  import {Layer, type LayerOwnProps, type LayerProps} from '../layer'
8
8
  import {
@@ -1,8 +1,14 @@
1
1
  import type {
2
2
  AlignItems,
3
+ BoxHeight,
4
+ BoxOverflow,
5
+ BoxSizing,
3
6
  Flex,
4
7
  FlexDirection,
5
8
  FlexWrap,
9
+ GridAutoCols,
10
+ GridAutoFlow,
11
+ GridAutoRows,
6
12
  GridItemColumn,
7
13
  GridItemColumnEnd,
8
14
  GridItemColumnStart,
@@ -11,17 +17,9 @@ import type {
11
17
  GridItemRowStart,
12
18
  JustifyContent,
13
19
  } from '@sanity/ui/css'
20
+ import type {Radius} from '@sanity/ui/theme'
14
21
 
15
- import type {
16
- BoxDisplay,
17
- BoxHeight,
18
- BoxOverflow,
19
- BoxSizing,
20
- GridAutoCols,
21
- GridAutoFlow,
22
- GridAutoRows,
23
- Radius,
24
- } from '../types'
22
+ import type {BoxDisplay} from './box/types'
25
23
 
26
24
  /**
27
25
  * @public
@@ -1,7 +1,7 @@
1
1
  export {
2
2
  /**
3
3
  * @public
4
- * @deprecated
4
+ * @deprecated Use `Radius` from `@sanity/ui/theme` instead.
5
5
  */
6
6
  type Radius,
7
7
  } from '@sanity/ui/theme'