@sanity/ui 3.0.0-static.31 → 3.0.0-static.33
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.
- package/dist/_chunks-cjs/_visual-editing.cjs +55 -50
- package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
- package/dist/_chunks-es/_visual-editing.js +56 -51
- package/dist/_chunks-es/_visual-editing.js.map +1 -1
- package/dist/_visual-editing.d.cts +10 -0
- package/dist/_visual-editing.d.ts +10 -0
- package/dist/css/index.cjs +2 -4
- package/dist/css/index.cjs.map +1 -1
- package/dist/css/index.css +1 -1
- package/dist/css/index.d.cts +1 -1
- package/dist/css/index.d.ts +1 -1
- package/dist/css/index.js +2 -4
- package/dist/css/index.js.map +1 -1
- package/dist/index.cjs +80 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +82 -81
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/core/{primitives/root/Root.tsx → Root.tsx} +6 -4
- package/src/core/{primitives/root/RootProvider.tsx → RootProvider.tsx} +5 -5
- package/src/core/__workshop__/boundary.tsx +28 -0
- package/src/core/__workshop__/index.ts +14 -0
- package/src/core/index.ts +4 -2
- package/src/core/primitives/card/card.tsx +4 -3
- package/src/core/primitives/card/useCard.ts +8 -2
- package/src/core/primitives/grid/types.ts +1 -1
- package/src/core/primitives/popover/popover.tsx +31 -12
- package/src/core/primitives/tooltip/tooltip.tsx +1 -4
- package/src/core/utils/portal/portal.tsx +1 -5
- package/src/css/components/toast/toast.css.ts +2 -2
- package/src/css/primitives/root/root.css.ts +6 -2
- package/src/css/primitives/root/root.ts +2 -2
- package/src/css/props/gridColumnStart/types.ts +1 -1
- package/dist/css/layers.css +0 -4
- package/dist/css/primitives/popover/popover.css +0 -4
- package/src/core/primitives/root/__workshop__/boundary.tsx +0 -5
- 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.
|
|
3
|
+
"version": "3.0.0-static.33",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"react",
|
|
6
6
|
"ui",
|
|
@@ -117,8 +117,8 @@
|
|
|
117
117
|
"@babel/preset-env": "^7.27.2",
|
|
118
118
|
"@babel/preset-react": "^7.27.1",
|
|
119
119
|
"@babel/preset-typescript": "^7.27.1",
|
|
120
|
-
"@commitlint/cli": "19.
|
|
121
|
-
"@commitlint/config-conventional": "19.
|
|
120
|
+
"@commitlint/cli": "^19.8.0",
|
|
121
|
+
"@commitlint/config-conventional": "^19.8.0",
|
|
122
122
|
"@eslint/js": "^9.29.0",
|
|
123
123
|
"@sanity/browserslist-config": "^1.0.5",
|
|
124
124
|
"@sanity/pkg-utils": "^7.2.6",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"eslint-plugin-import": "^2.31.0",
|
|
155
155
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
156
156
|
"eslint-plugin-react": "^7.37.5",
|
|
157
|
-
"eslint-plugin-react-hooks": "0.0.0-experimental-
|
|
157
|
+
"eslint-plugin-react-hooks": "0.0.0-experimental-12bc60f5-20250613",
|
|
158
158
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
159
159
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
160
160
|
"eslint-plugin-storybook": "^9.0.11",
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
"cypress:dev": "run-p dev cypress:open",
|
|
207
207
|
"cypress:open": "cypress open",
|
|
208
208
|
"cypress:run": "cypress run",
|
|
209
|
-
"dev": "run-p workshop:
|
|
209
|
+
"dev": "run-p workshop:dev storybook:dev",
|
|
210
210
|
"figma:build": "pnpm run --filter 'figma-plugin-sanity-ui' build",
|
|
211
211
|
"format": "prettier --write --cache --ignore-unknown .",
|
|
212
212
|
"lint": "eslint .",
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
"watch": "pkg watch --strict",
|
|
223
223
|
"workshop:build": "workshop build",
|
|
224
224
|
"workshop:clean": "rimraf .workshop",
|
|
225
|
-
"workshop:dev": "workshop dev",
|
|
225
|
+
"workshop:dev": "run-s workshop:clean && workshop dev",
|
|
226
226
|
"workshop:preview": "workshop preview"
|
|
227
227
|
}
|
|
228
228
|
}
|
|
@@ -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
|
|
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,10 +27,11 @@ 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
|
|
30
|
+
height,
|
|
31
|
+
overflow = 'hidden',
|
|
31
32
|
ref: forwardedRef,
|
|
32
33
|
scheme = 'light',
|
|
33
|
-
tone = '
|
|
34
|
+
tone = 'default',
|
|
34
35
|
...rest
|
|
35
36
|
} = props as RootProps<typeof DEFAULT_ROOT_ELEMENT>
|
|
36
37
|
|
|
@@ -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 '
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
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 =
|
|
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
|
|
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
|
|
8
|
-
|
|
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,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
arrow,
|
|
3
|
+
autoPlacement,
|
|
3
4
|
autoUpdate,
|
|
4
5
|
flip,
|
|
5
6
|
hide,
|
|
@@ -99,6 +100,16 @@ export type PopoverOwnProps = Omit<LayerOwnProps, 'maxWidth'> & {
|
|
|
99
100
|
modal?: boolean
|
|
100
101
|
open?: boolean
|
|
101
102
|
placement?: Placement
|
|
103
|
+
/**
|
|
104
|
+
* When 'flip' (default), the placement is determined from the initial placement and the
|
|
105
|
+
* fallback placements in order. Whichever fits in the viewport first.
|
|
106
|
+
*
|
|
107
|
+
* When 'autoPlacement', the initial placement and all fallback placements are evaluated
|
|
108
|
+
* and the placement with the most viewport space available.
|
|
109
|
+
*
|
|
110
|
+
* Option is only relevant if either `constrainSize` or `preventOverflow` is `true`
|
|
111
|
+
*/
|
|
112
|
+
placementStrategy?: 'flip' | 'autoPlacement'
|
|
102
113
|
/** Whether or not to render the popover in a portal element. */
|
|
103
114
|
portal?: boolean | string
|
|
104
115
|
preventOverflow?: boolean
|
|
@@ -171,6 +182,7 @@ export function Popover<E extends PopoverElementType = typeof DEFAULT_POPOVER_EL
|
|
|
171
182
|
overflow = 'hidden',
|
|
172
183
|
padding,
|
|
173
184
|
placement: placementProp = 'bottom',
|
|
185
|
+
placementStrategy = 'flip',
|
|
174
186
|
portal,
|
|
175
187
|
preventOverflow = true,
|
|
176
188
|
radius = 3,
|
|
@@ -205,14 +217,22 @@ export function Popover<E extends PopoverElementType = typeof DEFAULT_POPOVER_EL
|
|
|
205
217
|
|
|
206
218
|
// Flip the floating element when leaving the boundary box
|
|
207
219
|
if (constrainSize || preventOverflow) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
220
|
+
if (placementStrategy === 'autoPlacement') {
|
|
221
|
+
ret.push(
|
|
222
|
+
autoPlacement({
|
|
223
|
+
allowedPlacements: [placementProp].concat(fallbackPlacements),
|
|
224
|
+
}),
|
|
225
|
+
)
|
|
226
|
+
} else {
|
|
227
|
+
ret.push(
|
|
228
|
+
flip({
|
|
229
|
+
boundary: floatingBoundary || undefined,
|
|
230
|
+
fallbackPlacements,
|
|
231
|
+
padding: DEFAULT_POPOVER_PADDING,
|
|
232
|
+
rootBoundary,
|
|
233
|
+
}),
|
|
234
|
+
)
|
|
235
|
+
}
|
|
216
236
|
}
|
|
217
237
|
|
|
218
238
|
// Define distance between reference and floating element
|
|
@@ -287,6 +307,8 @@ export function Popover<E extends PopoverElementType = typeof DEFAULT_POPOVER_EL
|
|
|
287
307
|
constrainSize,
|
|
288
308
|
fallbackPlacements,
|
|
289
309
|
floatingBoundary,
|
|
310
|
+
placementProp,
|
|
311
|
+
placementStrategy,
|
|
290
312
|
margins,
|
|
291
313
|
matchReferenceWidth,
|
|
292
314
|
preventOverflow,
|
|
@@ -405,10 +427,7 @@ export function Popover<E extends PopoverElementType = typeof DEFAULT_POPOVER_EL
|
|
|
405
427
|
open &&
|
|
406
428
|
(portal ? (
|
|
407
429
|
<Portal __unstable_name={typeof portal === 'string' ? portal : undefined}>
|
|
408
|
-
<CardProvider
|
|
409
|
-
tone={tone === 'inherit' ? (card?.tone ?? 'default') : tone}
|
|
410
|
-
scheme={scheme ?? 'light'}
|
|
411
|
-
>
|
|
430
|
+
<CardProvider tone={tone === 'inherit' ? card.tone : tone} scheme={scheme ?? 'light'}>
|
|
412
431
|
{node}
|
|
413
432
|
</CardProvider>
|
|
414
433
|
</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: '
|
|
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,14 +2,18 @@ import {_style} from '../../_style.css'
|
|
|
2
2
|
import {layers} from '../../layers.css'
|
|
3
3
|
|
|
4
4
|
export const _root = _style(layers.primitives, {
|
|
5
|
-
|
|
5
|
+
WebkitFontSmoothing: 'antialiased',
|
|
6
|
+
// minWidth: `${320 / 16}rem`, // 320px
|
|
6
7
|
|
|
7
8
|
selectors: {
|
|
8
9
|
'html.&': {
|
|
9
10
|
MozTextSizeAdjust: 'none',
|
|
10
11
|
WebkitTextSizeAdjust: 'none',
|
|
11
12
|
textSizeAdjust: 'none',
|
|
12
|
-
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
'div.&': {
|
|
16
|
+
position: 'relative',
|
|
13
17
|
},
|
|
14
18
|
},
|
|
15
19
|
})
|
|
@@ -11,7 +11,7 @@ export function root(props: RootStyleProps) {
|
|
|
11
11
|
props.className,
|
|
12
12
|
themeClassName,
|
|
13
13
|
_root,
|
|
14
|
-
card({scheme: props.scheme ?? 'light', tone: props.tone ?? '
|
|
15
|
-
height(
|
|
14
|
+
card({scheme: props.scheme ?? 'light', tone: props.tone ?? 'default'}),
|
|
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 `
|
|
15
|
+
* @deprecated Use `gridColumnStart` instead
|
|
16
16
|
*/
|
|
17
17
|
columnStart?: ResponsiveProp<GridItemColumnStart>
|
|
18
18
|
gridColumnStart?: ResponsiveProp<GridColumnStart>
|
package/dist/css/layers.css
DELETED