@sanity/ui 3.0.0-static.5 → 3.0.0-static.7
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.js +60 -56
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +61 -57
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +10 -10
- package/dist/_visual-editing.d.ts +10 -10
- package/dist/cli.js +1 -1
- package/dist/css.d.mts +11 -1
- package/dist/css.d.ts +11 -1
- package/dist/css.js +324 -309
- package/dist/css.js.map +1 -1
- package/dist/css.mjs +324 -309
- package/dist/css.mjs.map +1 -1
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +5 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -19
- package/dist/index.mjs.map +1 -1
- package/dist/sanity-theme.css +1 -1
- package/dist/system.css +229 -10
- package/dist/theme.js +1 -1
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +1 -1
- package/dist/theme.mjs.map +1 -1
- package/package.json +2 -2
- package/src/css/aspects/index.ts +1 -0
- package/src/css/aspects/minWidth/index.ts +2 -0
- package/src/css/aspects/minWidth/minWidth.style.ts +13 -0
- package/src/css/aspects/minWidth/minWidth.ts +6 -0
- package/src/css/aspects/minWidth/types.ts +7 -0
- package/src/css/compile/compileRule.ts +1 -0
- package/src/css/compile/compileStyle.ts +1 -1
- package/src/css/primitives/_input/__workshop__/index.ts +1 -1
- package/src/css/primitives/box/box.style.ts +1 -1
- package/src/css/primitives/box/box.ts +2 -3
- package/src/css/primitives/box/types.ts +2 -0
- package/src/css/primitives/card/card.style.ts +69 -3
- package/src/css/primitives/card/types.ts +0 -1
- package/src/css/primitives/popover/popover.ts +4 -0
- package/src/css/primitives/switch/switch.style.ts +8 -83
- package/src/css/system.style.ts +2 -0
- package/src/theme/v3/defaults.ts +1 -1
- package/src/ui/components/autocomplete/__workshop__/index.ts +1 -1
- package/src/ui/components/autocomplete/autocomplete.tsx +2 -11
- package/src/ui/components/dialog/dialog.tsx +3 -4
- package/src/ui/constants.ts +6 -0
- package/src/ui/hooks/useMediaIndex/useMediaIndex.ts +0 -2
- package/src/ui/primitives/box/box.tsx +3 -2
- package/src/ui/primitives/card/card.tsx +2 -6
- package/src/ui/primitives/code/code.tsx +1 -1
- package/src/ui/primitives/kbd/kbd.tsx +2 -2
- package/src/ui/primitives/popover/popover.tsx +5 -75
- package/src/ui/primitives/popover/popoverCard.tsx +45 -39
- package/src/ui/primitives/textInput/textInput.tsx +1 -1
- package/src/ui/primitives/tooltip/tooltip.tsx +2 -3
- package/src/css/primitives/card/rules.ts +0 -473
|
@@ -26,13 +26,8 @@ import {
|
|
|
26
26
|
useRef,
|
|
27
27
|
} from 'react'
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
useArrayProp,
|
|
32
|
-
// useElementSize,
|
|
33
|
-
// useMediaIndex,
|
|
34
|
-
usePrefersReducedMotion,
|
|
35
|
-
} from '../../hooks'
|
|
29
|
+
import {Z_OFFSETS} from '../../constants'
|
|
30
|
+
import {useArrayProp, usePrefersReducedMotion} from '../../hooks'
|
|
36
31
|
import {origin} from '../../middleware/origin'
|
|
37
32
|
import {Placement, PopoverMargins, Props} from '../../types'
|
|
38
33
|
import {LayerProps, LayerProvider, Portal, useBoundaryElement, useLayer} from '../../utils'
|
|
@@ -44,7 +39,6 @@ import {
|
|
|
44
39
|
DEFAULT_POPOVER_PADDING,
|
|
45
40
|
} from './constants'
|
|
46
41
|
import {size} from './floating-ui/size'
|
|
47
|
-
// import {calcCurrentWidth, calcMaxWidth} from './helpers'
|
|
48
42
|
import {PopoverCard} from './popoverCard'
|
|
49
43
|
import {PopoverUpdateCallback} from './types'
|
|
50
44
|
|
|
@@ -67,7 +61,7 @@ export interface PopoverProps extends CardProps, LayerProps {
|
|
|
67
61
|
* When `true`, prevent overflow within the current boundary:
|
|
68
62
|
* - by flipping on its side axis
|
|
69
63
|
* - by resizing
|
|
70
|
-
|
|
64
|
+
*
|
|
71
65
|
* Note that:
|
|
72
66
|
* - setting `preventOverflow` to `true` also prevents overflow on its side axis
|
|
73
67
|
* - setting `matchReferenceWidth` to `true` also causes the popover to resize
|
|
@@ -128,13 +122,13 @@ export const Popover = memo(
|
|
|
128
122
|
props: Props<PopoverProps, 'div'>,
|
|
129
123
|
forwardedRef: ForwardedRef<HTMLDivElement>,
|
|
130
124
|
): ReactElement {
|
|
131
|
-
// const {container, layer} = useTheme_v2()
|
|
132
125
|
const boundaryElementContext = useBoundaryElement()
|
|
133
126
|
|
|
134
127
|
const {
|
|
135
128
|
__unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
|
|
136
129
|
animate: _animate = false,
|
|
137
130
|
arrow: arrowProp = false,
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
138
132
|
boundaryElement = boundaryElementContext.element,
|
|
139
133
|
children: childProp,
|
|
140
134
|
constrainSize = false,
|
|
@@ -161,17 +155,12 @@ export const Popover = memo(
|
|
|
161
155
|
tone = 'inherit',
|
|
162
156
|
width: widthProp = 'auto',
|
|
163
157
|
// zOffset: zOffsetProp = layer.popover.zOffset,
|
|
164
|
-
zOffset: zOffsetProp,
|
|
158
|
+
zOffset: zOffsetProp = Z_OFFSETS.popover,
|
|
165
159
|
updateRef,
|
|
166
160
|
...restProps
|
|
167
161
|
} = props
|
|
168
162
|
const prefersReducedMotion = usePrefersReducedMotion()
|
|
169
163
|
const animate = prefersReducedMotion ? false : _animate
|
|
170
|
-
// const boundarySize = useElementSize(boundaryElement)?.border
|
|
171
|
-
// const padding = useArrayProp(paddingProp)
|
|
172
|
-
// const radius = useArrayProp(radiusProp)
|
|
173
|
-
// const shadow = useArrayProp(shadowProp)
|
|
174
|
-
// const widthArrayProp = useArrayProp(widthProp)
|
|
175
164
|
const zOffset = useArrayProp(zOffsetProp)
|
|
176
165
|
const ref = useRef<HTMLDivElement | null>(null)
|
|
177
166
|
const arrowRef = useRef<HTMLDivElement | null>(null)
|
|
@@ -182,57 +171,9 @@ export const Popover = memo(
|
|
|
182
171
|
() => ref.current,
|
|
183
172
|
)
|
|
184
173
|
|
|
185
|
-
// const mediaIndex = useMediaIndex()
|
|
186
|
-
// const boundaryWidth = constrainSize || preventOverflow ? boundarySize?.width : undefined
|
|
187
|
-
|
|
188
|
-
// Update width when
|
|
189
|
-
// - media index changes
|
|
190
|
-
// - `width` property changes
|
|
191
|
-
// const width = calcCurrentWidth({
|
|
192
|
-
// container,
|
|
193
|
-
// mediaIndex,
|
|
194
|
-
// width: widthArrayProp,
|
|
195
|
-
// })
|
|
196
|
-
// const widthRef = useRef(width)
|
|
197
|
-
|
|
198
|
-
// useEffect(() => {
|
|
199
|
-
// widthRef.current = width
|
|
200
|
-
// }, [width])
|
|
201
|
-
|
|
202
|
-
// Update max width when
|
|
203
|
-
// - boundary width changes
|
|
204
|
-
// - `width` property changes
|
|
205
|
-
// const maxWidth = calcMaxWidth({boundaryWidth, currentWidth: width})
|
|
206
|
-
// const maxWidthRef = useRef(maxWidth)
|
|
207
|
-
|
|
208
|
-
// useEffect(() => {
|
|
209
|
-
// maxWidthRef.current = maxWidth
|
|
210
|
-
// }, [maxWidth])
|
|
211
|
-
|
|
212
174
|
// Keep track of reference element width (see `size` middleware below)
|
|
213
175
|
const referenceWidthRef = useRef<number>(undefined)
|
|
214
176
|
|
|
215
|
-
// // Force apply width & max width to floating element
|
|
216
|
-
// useEffect(() => {
|
|
217
|
-
// const floatingElement = ref.current
|
|
218
|
-
|
|
219
|
-
// if (!open || !floatingElement) return
|
|
220
|
-
|
|
221
|
-
// const referenceWidth = referenceWidthRef.current
|
|
222
|
-
|
|
223
|
-
// if (matchReferenceWidth) {
|
|
224
|
-
// if (referenceWidth !== undefined) {
|
|
225
|
-
// floatingElement.style.width = `${referenceWidth}px`
|
|
226
|
-
// }
|
|
227
|
-
// } else if (width !== undefined) {
|
|
228
|
-
// floatingElement.style.width = `${width}px`
|
|
229
|
-
// }
|
|
230
|
-
|
|
231
|
-
// if (typeof maxWidth === 'number') {
|
|
232
|
-
// floatingElement.style.maxWidth = `${maxWidth}px`
|
|
233
|
-
// }
|
|
234
|
-
// }, [width, matchReferenceWidth, maxWidth, open])
|
|
235
|
-
|
|
236
177
|
const middleware = useMemo(() => {
|
|
237
178
|
const ret: Middleware[] = []
|
|
238
179
|
|
|
@@ -260,22 +201,11 @@ export const Popover = memo(
|
|
|
260
201
|
|
|
261
202
|
referenceWidthRef.current = referenceWidth
|
|
262
203
|
|
|
263
|
-
// const _currentWidth = widthRef.current
|
|
264
|
-
// const _maxWidth = maxWidthRef.current
|
|
265
|
-
|
|
266
204
|
if (matchReferenceWidth) {
|
|
267
205
|
elements.floating.style.width = `${referenceWidth}px`
|
|
268
206
|
}
|
|
269
|
-
// else if (_currentWidth !== undefined) {
|
|
270
|
-
// elements.floating.style.width = `${_currentWidth}px`
|
|
271
|
-
// }
|
|
272
207
|
|
|
273
208
|
if (constrainSize) {
|
|
274
|
-
// elements.floating.style.maxWidth = `${Math.min(
|
|
275
|
-
// availableWidth,
|
|
276
|
-
// _maxWidth ?? Infinity,
|
|
277
|
-
// )}px`
|
|
278
|
-
|
|
279
209
|
elements.floating.style.maxWidth = `${availableWidth}px`
|
|
280
210
|
elements.floating.style.maxHeight = `${availableHeight}px`
|
|
281
211
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {Strategy} from '@floating-ui/react-dom'
|
|
2
|
+
import {popoverCard} from '@sanity/ui/css'
|
|
2
3
|
import {motion, MotionProps} from 'framer-motion'
|
|
3
4
|
import {CSSProperties, ForwardedRef, forwardRef, memo, useMemo} from 'react'
|
|
4
5
|
|
|
5
6
|
import {POPOVER_MOTION_PROPS} from '../../constants'
|
|
6
7
|
import {Placement, PopoverMargins, Props} from '../../types'
|
|
7
8
|
import {Arrow, useLayer} from '../../utils'
|
|
8
|
-
import {Card, CardProps} from '../card'
|
|
9
|
+
import {Card, CardProps, CardProvider, useCard} from '../card'
|
|
9
10
|
import {Flex} from '../flex'
|
|
10
11
|
import {
|
|
11
12
|
DEFAULT_POPOVER_ARROW_HEIGHT,
|
|
@@ -69,6 +70,8 @@ export const PopoverCard = memo(
|
|
|
69
70
|
...restProps
|
|
70
71
|
} = props
|
|
71
72
|
|
|
73
|
+
const card = useCard()
|
|
74
|
+
|
|
72
75
|
const layer = useLayer()
|
|
73
76
|
|
|
74
77
|
// Get margins: [top, right, bottom, left]
|
|
@@ -107,48 +110,51 @@ export const PopoverCard = memo(
|
|
|
107
110
|
)
|
|
108
111
|
|
|
109
112
|
return (
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
radius={radius}
|
|
118
|
-
ref={ref}
|
|
119
|
-
scheme={scheme}
|
|
120
|
-
shadow={shadow}
|
|
121
|
-
sizing="border"
|
|
122
|
-
style={rootStyle}
|
|
123
|
-
tone={tone}
|
|
124
|
-
variants={POPOVER_MOTION_PROPS.card}
|
|
125
|
-
transition={POPOVER_MOTION_PROPS.transition}
|
|
126
|
-
initial={animate ? ['hidden', 'initial'] : undefined}
|
|
127
|
-
animate={animate ? ['visible', 'scaleIn'] : undefined}
|
|
128
|
-
exit={animate ? ['hidden', 'scaleOut'] : undefined}
|
|
129
|
-
>
|
|
130
|
-
<Flex
|
|
131
|
-
data-ui="Popover__wrapper"
|
|
113
|
+
<CardProvider tone={card?.tone ?? 'transparent'} scheme={card?.scheme ?? 'light'}>
|
|
114
|
+
<MotionCard
|
|
115
|
+
className={popoverCard()}
|
|
116
|
+
data-ui="Popover"
|
|
117
|
+
{...(restProps as CardProps & MotionProps)}
|
|
118
|
+
data-context-tone={card?.tone ?? 'transparent'}
|
|
119
|
+
data-placement={placement}
|
|
132
120
|
direction="column"
|
|
133
|
-
flex
|
|
134
|
-
|
|
135
|
-
|
|
121
|
+
display="flex"
|
|
122
|
+
radius={radius}
|
|
123
|
+
ref={ref}
|
|
124
|
+
scheme={scheme}
|
|
125
|
+
shadow={shadow}
|
|
126
|
+
sizing="border"
|
|
127
|
+
style={rootStyle}
|
|
128
|
+
tone={tone}
|
|
129
|
+
variants={POPOVER_MOTION_PROPS.card}
|
|
130
|
+
transition={POPOVER_MOTION_PROPS.transition}
|
|
131
|
+
initial={animate ? ['hidden', 'initial'] : undefined}
|
|
132
|
+
animate={animate ? ['visible', 'scaleIn'] : undefined}
|
|
133
|
+
exit={animate ? ['hidden', 'scaleOut'] : undefined}
|
|
136
134
|
>
|
|
137
|
-
<Flex
|
|
138
|
-
|
|
135
|
+
<Flex
|
|
136
|
+
data-ui="Popover__wrapper"
|
|
137
|
+
direction="column"
|
|
138
|
+
flex={1}
|
|
139
|
+
maxWidth={maxWidth}
|
|
140
|
+
overflow={overflow}
|
|
141
|
+
>
|
|
142
|
+
<Flex direction="column" flex={1} padding={padding}>
|
|
143
|
+
{children}
|
|
144
|
+
</Flex>
|
|
139
145
|
</Flex>
|
|
140
|
-
</Flex>
|
|
141
146
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
{arrow && (
|
|
148
|
+
<Arrow
|
|
149
|
+
ref={arrowRef}
|
|
150
|
+
style={arrowStyle}
|
|
151
|
+
width={DEFAULT_POPOVER_ARROW_WIDTH}
|
|
152
|
+
height={DEFAULT_POPOVER_ARROW_HEIGHT}
|
|
153
|
+
radius={DEFAULT_POPOVER_ARROW_RADIUS}
|
|
154
|
+
/>
|
|
155
|
+
)}
|
|
156
|
+
</MotionCard>
|
|
157
|
+
</CardProvider>
|
|
152
158
|
)
|
|
153
159
|
}),
|
|
154
160
|
)
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from 'react'
|
|
29
29
|
import {useEffectEvent} from 'use-effect-event'
|
|
30
30
|
|
|
31
|
-
import {
|
|
31
|
+
import {Z_OFFSETS} from '../../constants'
|
|
32
32
|
import {useArrayProp, usePrefersReducedMotion} from '../../hooks'
|
|
33
33
|
import {useDelayedState} from '../../hooks/useDelayedState'
|
|
34
34
|
import {origin} from '../../middleware/origin'
|
|
@@ -91,7 +91,6 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
91
91
|
forwardedRef: ForwardedRef<HTMLDivElement>,
|
|
92
92
|
) {
|
|
93
93
|
const boundaryElementContext = useBoundaryElement()
|
|
94
|
-
const {layer} = useTheme_v2()
|
|
95
94
|
const {
|
|
96
95
|
animate: _animate = false,
|
|
97
96
|
arrow: arrowProp = false,
|
|
@@ -109,7 +108,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
109
108
|
radius = 3,
|
|
110
109
|
scheme,
|
|
111
110
|
shadow = 2,
|
|
112
|
-
zOffset =
|
|
111
|
+
zOffset = Z_OFFSETS.tooltip,
|
|
113
112
|
tone,
|
|
114
113
|
...restProps
|
|
115
114
|
} = props
|