@sanity/ui 3.0.0-static.31 → 3.0.0-static.32

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 (35) hide show
  1. package/dist/_chunks-cjs/_visual-editing.cjs +49 -47
  2. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  3. package/dist/_chunks-es/_visual-editing.js +49 -47
  4. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  5. package/dist/css/index.cjs +1 -3
  6. package/dist/css/index.cjs.map +1 -1
  7. package/dist/css/index.css +1 -1
  8. package/dist/css/index.d.cts +1 -1
  9. package/dist/css/index.d.ts +1 -1
  10. package/dist/css/index.js +1 -3
  11. package/dist/css/index.js.map +1 -1
  12. package/dist/index.cjs +80 -79
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +82 -81
  17. package/dist/index.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/core/{primitives/root/Root.tsx → Root.tsx} +5 -3
  20. package/src/core/{primitives/root/RootProvider.tsx → RootProvider.tsx} +5 -5
  21. package/src/core/__workshop__/boundary.tsx +28 -0
  22. package/src/core/__workshop__/index.ts +14 -0
  23. package/src/core/index.ts +4 -2
  24. package/src/core/primitives/card/card.tsx +4 -3
  25. package/src/core/primitives/card/useCard.ts +8 -2
  26. package/src/core/primitives/grid/types.ts +1 -1
  27. package/src/core/primitives/popover/popover.tsx +1 -4
  28. package/src/core/primitives/tooltip/tooltip.tsx +1 -4
  29. package/src/core/utils/portal/portal.tsx +1 -5
  30. package/src/css/components/toast/toast.css.ts +2 -2
  31. package/src/css/primitives/root/root.css.ts +5 -1
  32. package/src/css/primitives/root/root.ts +1 -1
  33. package/src/css/props/gridColumnStart/types.ts +1 -1
  34. package/src/core/primitives/root/__workshop__/boundary.tsx +0 -5
  35. package/src/core/primitives/root/__workshop__/index.ts +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "3.0.0-static.31",
3
+ "version": "3.0.0-static.32",
4
4
  "keywords": [
5
5
  "react",
6
6
  "ui",
@@ -1,9 +1,9 @@
1
1
  import {box, root, type RootStyleProps} from '@sanity/ui/css'
2
2
  import {useCallback, useImperativeHandle, useRef, useState} from 'react'
3
3
 
4
- import type {Props} from '../../types/props'
5
- import {Box, type BoxOwnProps} from '../box/box'
4
+ import {Box, type BoxOwnProps} from './primitives/box/box'
6
5
  import {RootProvider} from './RootProvider'
6
+ import type {Props} from './types/props'
7
7
 
8
8
  /** @public */
9
9
  export const DEFAULT_ROOT_ELEMENT = 'html'
@@ -27,7 +27,8 @@ export function Root<E extends RootElementType = typeof DEFAULT_ROOT_ELEMENT>(pr
27
27
  as: as = DEFAULT_ROOT_ELEMENT,
28
28
  children,
29
29
  className,
30
- height = 'fill',
30
+ height, // = 'fill',
31
+ overflow = 'hidden',
31
32
  ref: forwardedRef,
32
33
  scheme = 'light',
33
34
  tone = 'transparent',
@@ -76,6 +77,7 @@ export function Root<E extends RootElementType = typeof DEFAULT_ROOT_ELEMENT>(pr
76
77
  scheme,
77
78
  tone,
78
79
  })}
80
+ overflow={overflow}
79
81
  ref={handleRef}
80
82
  >
81
83
  {node}
@@ -1,11 +1,11 @@
1
1
  import type {ThemeColorCardToneKey, ThemeColorSchemeKey} from '@sanity/ui/theme'
2
2
  import type {ReactNode} from 'react'
3
3
 
4
- import {ToastProvider} from '../../components/toast/toastProvider'
5
- import {BoundaryElementProvider} from '../../utils/boundaryElement/boundaryElementProvider'
6
- import {PortalProvider} from '../../utils/portal/portalProvider'
7
- import {CardProvider} from '../card/cardProvider'
8
- import {LayerProvider} from '../layer/layerProvider'
4
+ import {ToastProvider} from './components/toast/toastProvider'
5
+ import {CardProvider} from './primitives/card/cardProvider'
6
+ import {LayerProvider} from './primitives/layer/layerProvider'
7
+ import {BoundaryElementProvider} from './utils/boundaryElement/boundaryElementProvider'
8
+ import {PortalProvider} from './utils/portal/portalProvider'
9
9
 
10
10
  /** @public */
11
11
  export interface RootProviderProps {
@@ -0,0 +1,28 @@
1
+ import {Box, Button, Root, Stack, Text, useCard, useToast} from '@sanity/ui'
2
+
3
+ export default function BoundaryStory() {
4
+ const {scheme} = useCard()
5
+
6
+ return (
7
+ <Box padding={5}>
8
+ <Root as="div" padding={5} radius={4} scheme={scheme}>
9
+ <Layout />
10
+ </Root>
11
+ </Box>
12
+ )
13
+ }
14
+
15
+ function Layout() {
16
+ const toast = useToast()
17
+
18
+ return (
19
+ <Stack gap={4}>
20
+ <Text size={1}>
21
+ Testing the root component. Toast messages will be rendered here, and should be contained
22
+ within the root element.
23
+ </Text>
24
+
25
+ <Button onClick={() => toast.push({title: 'Hello!'})} text="Push toast message" width="min" />
26
+ </Stack>
27
+ )
28
+ }
@@ -0,0 +1,14 @@
1
+ import {defineScope} from '@sanity/ui-workshop'
2
+ import {lazy} from 'react'
3
+
4
+ export default defineScope({
5
+ name: 'root',
6
+ title: 'Root',
7
+ stories: [
8
+ {
9
+ name: 'boundary',
10
+ title: 'Boundary',
11
+ component: lazy(() => import('./boundary')),
12
+ },
13
+ ],
14
+ })
package/src/core/index.ts CHANGED
@@ -96,8 +96,6 @@ export * from './primitives/layer/useLayer'
96
96
  export * from './primitives/popover/popover'
97
97
  export * from './primitives/popover/types'
98
98
  export * from './primitives/radio/radio'
99
- export * from './primitives/root/Root'
100
- export * from './primitives/root/RootProvider'
101
99
  export * from './primitives/select/select'
102
100
  export * from './primitives/selectable/selectable'
103
101
  export * from './primitives/selectable/types'
@@ -128,6 +126,10 @@ export * from './utils/portal/portalProvider'
128
126
  export * from './utils/portal/types'
129
127
  export * from './utils/portal/usePortal'
130
128
 
129
+ // root
130
+ export * from './Root'
131
+ export * from './RootProvider'
132
+
131
133
  // types
132
134
  export * from './types/gridItem'
133
135
  export * from './types/placement'
@@ -1,9 +1,10 @@
1
1
  import {card, type CardStyleProps} from '@sanity/ui/css'
2
+ import {useContext} from 'react'
2
3
 
3
4
  import type {Props} from '../../types/props'
4
5
  import {Box, type BoxElementType, type BoxOwnProps} from '../box/box'
6
+ import {CardContext} from './cardContext'
5
7
  import {CardProvider} from './cardProvider'
6
- import {useCard} from './useCard'
7
8
 
8
9
  /** @public */
9
10
  export const DEFAULT_CARD_ELEMENT = 'div'
@@ -54,7 +55,7 @@ export function Card<E extends CardElementType = typeof DEFAULT_CARD_ELEMENT>(pr
54
55
  ...rest
55
56
  } = props as CardProps<typeof DEFAULT_CARD_ELEMENT>
56
57
 
57
- const parent = useCard()
58
+ const parent = useContext(CardContext)
58
59
  const tone = toneProp === 'inherit' ? parent?.tone : toneProp
59
60
  const scheme = schemeProp === undefined ? parent?.scheme : schemeProp
60
61
 
@@ -96,7 +97,7 @@ export function Card<E extends CardElementType = typeof DEFAULT_CARD_ELEMENT>(pr
96
97
  const CompatProvider = parent.unstable_CompatProvider
97
98
 
98
99
  return (
99
- <CompatProvider scheme={scheme ?? 'light'} tone={tone ?? parent?.tone ?? 'default'}>
100
+ <CompatProvider scheme={scheme ?? 'light'} tone={tone ?? parent.tone}>
100
101
  {node}
101
102
  </CompatProvider>
102
103
  )
@@ -4,6 +4,12 @@ import {CardContext} from './cardContext'
4
4
  import type {CardContextValue} from './types'
5
5
 
6
6
  /** @public */
7
- export function useCard(): CardContextValue | null {
8
- return useContext(CardContext)
7
+ export function useCard(): CardContextValue {
8
+ const card = useContext(CardContext)
9
+
10
+ if (!card) {
11
+ throw new Error('useCard(): missing context value')
12
+ }
13
+
14
+ return card
9
15
  }
@@ -1,7 +1,7 @@
1
1
  export {
2
2
  /**
3
3
  * @public
4
- * @deprecated Use `GridAutoCols` from `@sanity/ui/css` instead.
4
+ * @deprecated Use `GridAutoColumns` from `@sanity/ui/css` instead.
5
5
  */
6
6
  type GridAutoCols,
7
7
  /**
@@ -405,10 +405,7 @@ export function Popover<E extends PopoverElementType = typeof DEFAULT_POPOVER_EL
405
405
  open &&
406
406
  (portal ? (
407
407
  <Portal __unstable_name={typeof portal === 'string' ? portal : undefined}>
408
- <CardProvider
409
- tone={tone === 'inherit' ? (card?.tone ?? 'default') : tone}
410
- scheme={scheme ?? 'light'}
411
- >
408
+ <CardProvider tone={tone === 'inherit' ? card.tone : tone} scheme={scheme ?? 'light'}>
412
409
  {node}
413
410
  </CardProvider>
414
411
  </Portal>
@@ -419,10 +419,7 @@ export function Tooltip<E extends TooltipElementType = typeof DEFAULT_TOOLTIP_EL
419
419
  showTooltip &&
420
420
  (portalProp ? (
421
421
  <Portal __unstable_name={typeof portalProp === 'string' ? portalProp : undefined}>
422
- <CardProvider
423
- tone={tone === 'inherit' ? (card?.tone ?? 'default') : tone}
424
- scheme={scheme ?? 'light'}
425
- >
422
+ <CardProvider tone={tone === 'inherit' ? card.tone : tone} scheme={scheme ?? 'light'}>
426
423
  {node}
427
424
  </CardProvider>
428
425
  </Portal>
@@ -28,11 +28,7 @@ export function Portal(props: PortalProps): ReactPortal | null {
28
28
  }
29
29
 
30
30
  return createPortal(
31
- <CardProvider
32
- // rendered={true}
33
- tone="transparent" // card?.tone || 'default',
34
- scheme={card?.scheme || 'light'}
35
- >
31
+ <CardProvider tone="transparent" scheme={card.scheme}>
36
32
  {children}
37
33
  </CardProvider>,
38
34
  portalElement,
@@ -2,11 +2,11 @@ import {_style} from '../../_style.css'
2
2
  import {layers} from '../../layers.css'
3
3
 
4
4
  export const layer = _style(layers.components, {
5
- position: 'fixed',
5
+ position: 'absolute',
6
6
  right: 0,
7
7
  bottom: 0,
8
8
  pointerEvents: 'none',
9
- minWidth: `${320 / 16}rem`, // 320px
9
+ // minWidth: `${320 / 16}rem`, // 320px
10
10
  maxWidth: `${420 / 16}rem`, // 420px
11
11
  width: '100%',
12
12
  })
@@ -2,7 +2,7 @@ import {_style} from '../../_style.css'
2
2
  import {layers} from '../../layers.css'
3
3
 
4
4
  export const _root = _style(layers.primitives, {
5
- minWidth: `${320 / 16}rem`, // 320px
5
+ // minWidth: `${320 / 16}rem`, // 320px
6
6
 
7
7
  selectors: {
8
8
  'html.&': {
@@ -11,5 +11,9 @@ export const _root = _style(layers.primitives, {
11
11
  textSizeAdjust: 'none',
12
12
  WebkitFontSmoothing: 'antialiased',
13
13
  },
14
+
15
+ 'div.&': {
16
+ position: 'relative',
17
+ },
14
18
  },
15
19
  })
@@ -12,6 +12,6 @@ export function root(props: RootStyleProps) {
12
12
  themeClassName,
13
13
  _root,
14
14
  card({scheme: props.scheme ?? 'light', tone: props.tone ?? 'transparent'}),
15
- height({height: props.height ?? 'fill'}),
15
+ height(props),
16
16
  )
17
17
  }
@@ -12,7 +12,7 @@ export type GridItemColumnStart = 'auto' | number
12
12
  /** @public */
13
13
  export interface GridColumnStartStyleProps {
14
14
  /**
15
- * @deprecated Use `gridColumn` instead
15
+ * @deprecated Use `gridColumnStart` instead
16
16
  */
17
17
  columnStart?: ResponsiveProp<GridItemColumnStart>
18
18
  gridColumnStart?: ResponsiveProp<GridColumnStart>
@@ -1,5 +0,0 @@
1
- import {Root} from '@sanity/ui'
2
-
3
- export default function BoundaryStory() {
4
- return <Root>Hello!</Root>
5
- }
@@ -1,8 +0,0 @@
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
- })