@sanity/ui 2.0.13-alpha.2 → 2.0.14
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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +84 -78
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +211 -205
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -78
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +1 -1
- package/dist/theme.d.ts +1 -1
- package/dist/theme.esm.js +587 -51
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +560 -22
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +587 -51
- package/dist/theme.mjs.map +1 -1
- package/package.json +27 -28
- package/src/core/components/autocomplete/autocomplete.styles.tsx +1 -1
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +1 -1
- package/src/core/components/dialog/__workshop__/panes.tsx +1 -1
- package/src/core/components/dialog/dialog.tsx +1 -1
- package/src/core/components/dialog/styles.ts +3 -3
- package/src/core/components/hotkeys/hotkeys.tsx +1 -1
- package/src/core/components/menu/menu.tsx +1 -1
- package/src/core/components/menu/menuDivider.ts +1 -1
- package/src/core/components/skeleton/skeleton.tsx +1 -1
- package/src/core/components/skeleton/textSkeleton.tsx +3 -3
- package/src/core/components/tab/tab.tsx +1 -1
- package/src/core/components/tab/tabList.tsx +1 -1
- package/src/core/components/toast/toast.tsx +1 -1
- package/src/core/components/toast/toastProvider.tsx +1 -1
- package/src/core/components/tree/style.ts +3 -2
- package/src/core/components/tree/treeItem.tsx +1 -1
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +1 -1
- package/src/core/primitives/_selectable/selectable.tsx +1 -1
- package/src/core/primitives/_selectable/style.ts +2 -1
- package/src/core/primitives/avatar/avatar.tsx +1 -1
- package/src/core/primitives/avatar/avatarCounter.tsx +4 -3
- package/src/core/primitives/avatar/avatarStack.tsx +3 -2
- package/src/core/primitives/avatar/styles.ts +3 -3
- package/src/core/primitives/badge/badge.tsx +1 -1
- package/src/core/primitives/box/box.tsx +1 -1
- package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +1 -1
- package/src/core/primitives/button/__workshop__/styled1.tsx +1 -1
- package/src/core/primitives/button/__workshop__/styled2.tsx +1 -1
- package/src/core/primitives/button/button.tsx +1 -1
- package/src/core/primitives/button/styles.ts +3 -3
- package/src/core/primitives/card/__workshop__/selected.tsx +3 -3
- package/src/core/primitives/card/__workshop__/styled.tsx +1 -1
- package/src/core/primitives/card/card.tsx +1 -1
- package/src/core/primitives/card/styles.ts +3 -2
- package/src/core/primitives/checkbox/checkbox.tsx +1 -1
- package/src/core/primitives/checkbox/styles.ts +2 -1
- package/src/core/primitives/code/code.tsx +1 -1
- package/src/core/primitives/code/styles.ts +4 -1
- package/src/core/primitives/container/container.tsx +1 -1
- package/src/core/primitives/container/styles.ts +2 -2
- package/src/core/primitives/flex/__workshop__/example.tsx +1 -1
- package/src/core/primitives/flex/flex.tsx +1 -1
- package/src/core/primitives/grid/grid.tsx +1 -1
- package/src/core/primitives/heading/heading.tsx +1 -1
- package/src/core/primitives/heading/styles.ts +2 -1
- package/src/core/primitives/inline/inline.tsx +1 -1
- package/src/core/primitives/inline/styles.ts +2 -2
- package/src/core/primitives/kbd/kbd.tsx +1 -1
- package/src/core/primitives/label/label.tsx +1 -1
- package/src/core/primitives/label/styles.ts +2 -1
- package/src/core/primitives/popover/popoverCard.tsx +1 -1
- package/src/core/primitives/radio/radio.tsx +1 -1
- package/src/core/primitives/radio/styles.ts +2 -1
- package/src/core/primitives/select/select.tsx +1 -1
- package/src/core/primitives/select/styles.ts +5 -5
- package/src/core/primitives/spinner/spinner.tsx +1 -1
- package/src/core/primitives/stack/stack.tsx +1 -1
- package/src/core/primitives/stack/styles.ts +2 -2
- package/src/core/primitives/switch/styles.ts +4 -3
- package/src/core/primitives/switch/switch.tsx +1 -1
- package/src/core/primitives/text/__workshop__/colored.tsx +3 -3
- package/src/core/primitives/text/styles.ts +2 -1
- package/src/core/primitives/text/text.tsx +1 -1
- package/src/core/primitives/textArea/textArea.tsx +1 -1
- package/src/core/primitives/textInput/textInput.tsx +1 -1
- package/src/core/primitives/tooltip/tooltip.tsx +21 -12
- package/src/core/primitives/tooltip/tooltipCard.tsx +1 -1
- package/src/core/styles/border/borderStyle.ts +6 -6
- package/src/core/styles/box/boxStyle.ts +5 -5
- package/src/core/styles/flex/flexItemStyle.ts +2 -2
- package/src/core/styles/flex/flexStyle.ts +6 -6
- package/src/core/styles/font/responsiveFont.ts +2 -2
- package/src/core/styles/font/textAlignStyle.ts +2 -2
- package/src/core/styles/grid/gridItemStyle.ts +7 -7
- package/src/core/styles/grid/gridStyle.ts +9 -9
- package/src/core/styles/helpers.ts +2 -2
- package/src/core/styles/input/responsiveInputPaddingStyle.ts +2 -2
- package/src/core/styles/input/textInputStyle.ts +4 -4
- package/src/core/styles/margin/marginsStyle.test.ts +1 -1
- package/src/core/styles/padding/paddingStyle.test.ts +1 -1
- package/src/core/styles/radius/radiusStyle.ts +2 -2
- package/src/core/styles/shadow/shadowStyle.ts +2 -2
- package/src/core/theme/__workshop__/build/Root.tsx +2 -1
- package/src/core/theme/theme.test.tsx +1 -1
- package/src/core/theme/themeProvider.tsx +7 -6
- package/src/core/theme/useTheme.ts +1 -2
- package/src/core/utils/arrow/arrow.tsx +1 -1
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +1 -1
- package/src/core/utils/layer/layer.tsx +1 -1
- package/src/core/utils/srOnly/srOnly.tsx +1 -1
- package/src/core/utils/virtualList/virtualList.tsx +1 -1
- package/src/theme/system/theme.ts +1 -1
- package/dist/_chunks-cjs/getScopedTheme.js +0 -547
- package/dist/_chunks-cjs/getScopedTheme.js.map +0 -1
- package/dist/_chunks-es/getScopedTheme.mjs +0 -548
- package/dist/_chunks-es/getScopedTheme.mjs.map +0 -1
- package/dist/_legacy/getScopedTheme.esm.js +0 -548
- package/dist/_legacy/getScopedTheme.esm.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
|
-
import styled from 'styled-components'
|
|
2
|
+
import {styled} from 'styled-components'
|
|
3
3
|
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {responsiveGridStyle, ResponsiveGridStyleProps} from '../../styles/internal'
|
|
5
5
|
import {Box, BoxProps} from '../box'
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css} from 'styled-components'
|
|
2
3
|
import {ThemeProps} from '../../styles'
|
|
3
4
|
import {HeadingStyleProps} from './types'
|
|
4
5
|
|
|
5
6
|
export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnType<typeof css> {
|
|
6
7
|
const {$accent, $muted} = props
|
|
7
|
-
const {font} = props.theme
|
|
8
|
+
const {font} = getTheme_v2(props.theme)
|
|
8
9
|
|
|
9
10
|
return css`
|
|
10
11
|
${$accent &&
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
3
3
|
import {ResponsiveInlineSpaceStyleProps} from './types'
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ export function inlineBaseStyle(): CSSObject {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function inlineSpaceStyle(props: ResponsiveInlineSpaceStyleProps & ThemeProps): CSSObject[] {
|
|
21
|
-
const {media, space} = props.theme
|
|
21
|
+
const {media, space} = getTheme_v2(props.theme)
|
|
22
22
|
|
|
23
23
|
return _responsive(media, props.$space, (spaceIndex) => {
|
|
24
24
|
const _space = rem(spaceIndex === 0.5 ? space[1] / 2 : space[spaceIndex])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
|
-
import styled,
|
|
2
|
+
import {styled, css} from 'styled-components'
|
|
3
3
|
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
5
5
|
import {Radius} from '../../types'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
2
2
|
import {forwardRef} from 'react'
|
|
3
|
-
import styled from 'styled-components'
|
|
3
|
+
import {styled} from 'styled-components'
|
|
4
4
|
import {useArrayProp} from '../../hooks'
|
|
5
5
|
import {responsiveLabelFont, responsiveTextAlignStyle} from '../../styles/internal'
|
|
6
6
|
import {TextAlign} from '../../types'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css} from 'styled-components'
|
|
2
3
|
import {ThemeProps} from '../../styles'
|
|
3
4
|
|
|
@@ -5,7 +6,7 @@ export function labelBaseStyle(
|
|
|
5
6
|
props: {$accent?: boolean; $muted: boolean} & ThemeProps,
|
|
6
7
|
): ReturnType<typeof css> {
|
|
7
8
|
const {$accent, $muted} = props
|
|
8
|
-
const {font} = props.theme
|
|
9
|
+
const {font} = getTheme_v2(props.theme)
|
|
9
10
|
|
|
10
11
|
return css`
|
|
11
12
|
text-transform: uppercase;
|
|
@@ -2,7 +2,7 @@ import {Strategy} from '@floating-ui/react-dom'
|
|
|
2
2
|
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
3
3
|
import {MotionProps, motion} from 'framer-motion'
|
|
4
4
|
import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
|
|
5
|
-
import styled from 'styled-components'
|
|
5
|
+
import {styled} from 'styled-components'
|
|
6
6
|
import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY, POPOVER_MOTION_PROPS} from '../../constants'
|
|
7
7
|
import {BoxOverflow, CardTone, Placement, PopoverMargins, Radius} from '../../types'
|
|
8
8
|
import {Arrow, useLayer} from '../../utils'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css} from 'styled-components'
|
|
2
3
|
import {rem, ThemeProps} from '../../styles'
|
|
3
4
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
@@ -17,7 +18,7 @@ export function radioBaseStyle(): ReturnType<typeof css> {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
20
|
-
const {color, input} = props.theme
|
|
21
|
+
const {color, input} = getTheme_v2(props.theme)
|
|
21
22
|
const dist = (input.radio.size - input.radio.markSize) / 2
|
|
22
23
|
|
|
23
24
|
return css`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ChevronDownIcon} from '@sanity/icons'
|
|
2
2
|
import {forwardRef} from 'react'
|
|
3
|
-
import styled from 'styled-components'
|
|
3
|
+
import {styled} from 'styled-components'
|
|
4
4
|
import {useForwardedRef, useCustomValidity, useArrayProp} from '../../hooks'
|
|
5
5
|
import {Radius} from '../../types'
|
|
6
6
|
import {Box} from '../box'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ThemeFontSize} from '@sanity/ui/theme'
|
|
1
|
+
import {ThemeFontSize, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {CSSObject} from '@sanity/ui/theme'
|
|
3
3
|
import {css} from 'styled-components'
|
|
4
4
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
@@ -24,7 +24,7 @@ function rootStyle(): ReturnType<typeof css> {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function inputBaseStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
27
|
-
const {font} = props.theme
|
|
27
|
+
const {font} = getTheme_v2(props.theme)
|
|
28
28
|
|
|
29
29
|
return css`
|
|
30
30
|
-webkit-font-smoothing: antialiased;
|
|
@@ -43,7 +43,7 @@ function inputBaseStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function inputColorStyle(props: ThemeProps) {
|
|
46
|
-
const {color, input} = props.theme
|
|
46
|
+
const {color, input} = getTheme_v2(props.theme)
|
|
47
47
|
|
|
48
48
|
return css`
|
|
49
49
|
/* enabled */
|
|
@@ -102,7 +102,7 @@ function textSize(size: ThemeFontSize) {
|
|
|
102
102
|
|
|
103
103
|
function inputTextSizeStyle(props: {$fontSize: number[]} & ThemeProps) {
|
|
104
104
|
const {$fontSize} = props
|
|
105
|
-
const {font, media} = props.theme
|
|
105
|
+
const {font, media} = getTheme_v2(props.theme)
|
|
106
106
|
|
|
107
107
|
return _responsive(media, $fontSize, (sizeIndex) =>
|
|
108
108
|
textSize(font.text.sizes[sizeIndex] || font.text.sizes[2]),
|
|
@@ -129,7 +129,7 @@ function inputStyle(): Array<
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
function iconBoxStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
132
|
-
const {color} = props.theme
|
|
132
|
+
const {color} = getTheme_v2(props.theme)
|
|
133
133
|
|
|
134
134
|
return css`
|
|
135
135
|
pointer-events: none;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
|
-
import styled from 'styled-components'
|
|
2
|
+
import {styled} from 'styled-components'
|
|
3
3
|
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {Box, BoxProps} from '../box'
|
|
5
5
|
import {stackBaseStyle, responsiveStackSpaceStyle, ResponsiveStackSpaceStyleProps} from './styles'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
3
3
|
|
|
4
4
|
export interface ResponsiveStackSpaceStyleProps {
|
|
@@ -23,7 +23,7 @@ export function stackBaseStyle(): CSSObject {
|
|
|
23
23
|
export function responsiveStackSpaceStyle(
|
|
24
24
|
props: ResponsiveStackSpaceStyleProps & ThemeProps,
|
|
25
25
|
): CSSObject[] {
|
|
26
|
-
const {media, space} = props.theme
|
|
26
|
+
const {media, space} = getTheme_v2(props.theme)
|
|
27
27
|
|
|
28
28
|
return _responsive(media, props.$space, (spaceIndex) => ({
|
|
29
29
|
gridGap: rem(space[spaceIndex]),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css} from 'styled-components'
|
|
2
3
|
import {rem, ThemeProps} from '../../styles'
|
|
3
4
|
import {focusRingStyle} from '../../styles/internal'
|
|
@@ -35,7 +36,7 @@ export function switchInputStyles(): ReturnType<typeof css> {
|
|
|
35
36
|
|
|
36
37
|
/* Representation */
|
|
37
38
|
export function switchRepresentationStyles(props: ThemeProps): ReturnType<typeof css> {
|
|
38
|
-
const {color, input} = props.theme
|
|
39
|
+
const {color, input} = getTheme_v2(props.theme)
|
|
39
40
|
|
|
40
41
|
return css`
|
|
41
42
|
--switch-bg-color: ${color.input.default.enabled.border};
|
|
@@ -111,7 +112,7 @@ export function switchRepresentationStyles(props: ThemeProps): ReturnType<typeof
|
|
|
111
112
|
|
|
112
113
|
/* Track */
|
|
113
114
|
export function switchTrackStyles(props: ThemeProps): ReturnType<typeof css> {
|
|
114
|
-
const {input} = props.theme
|
|
115
|
+
const {input} = getTheme_v2(props.theme)
|
|
115
116
|
|
|
116
117
|
return css`
|
|
117
118
|
&:not([hidden]) {
|
|
@@ -132,7 +133,7 @@ export function switchThumbStyles(
|
|
|
132
133
|
props: {$checked?: boolean; $indeterminate?: boolean} & ThemeProps,
|
|
133
134
|
): ReturnType<typeof css> {
|
|
134
135
|
const {$indeterminate} = props
|
|
135
|
-
const {input} = props.theme
|
|
136
|
+
const {input} = getTheme_v2(props.theme)
|
|
136
137
|
const trackWidth = input.switch.width
|
|
137
138
|
const trackHeight = input.switch.height
|
|
138
139
|
const trackPadding = input.switch.padding
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Flex, Text, ThemeProps} from '@sanity/ui'
|
|
2
|
-
import {ThemeColorAvatarColorKey, ThemeColorSpotKey} from '@sanity/ui/theme'
|
|
2
|
+
import {ThemeColorAvatarColorKey, ThemeColorSpotKey, getTheme_v2} from '@sanity/ui/theme'
|
|
3
3
|
import {useSelect} from '@sanity/ui-workshop'
|
|
4
|
-
import styled,
|
|
4
|
+
import {styled, css} from 'styled-components'
|
|
5
5
|
import {WORKSHOP_SPOT_COLOR_OPTIONS} from '../../../__workshop__/constants'
|
|
6
6
|
|
|
7
7
|
const ColoredText = styled(Text)<{$color?: ThemeColorSpotKey}>((
|
|
@@ -9,7 +9,7 @@ const ColoredText = styled(Text)<{$color?: ThemeColorSpotKey}>((
|
|
|
9
9
|
$color?: ThemeColorAvatarColorKey
|
|
10
10
|
} & ThemeProps,
|
|
11
11
|
) => {
|
|
12
|
-
const {color} = props.theme
|
|
12
|
+
const {color} = getTheme_v2(props.theme)
|
|
13
13
|
|
|
14
14
|
return css`
|
|
15
15
|
color: ${color.avatar[props.$color || 'gray'].bg};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css} from 'styled-components'
|
|
2
3
|
import {ThemeProps} from '../../styles'
|
|
3
4
|
|
|
@@ -5,7 +6,7 @@ export function textBaseStyle(
|
|
|
5
6
|
props: {$accent?: boolean; $muted?: boolean} & ThemeProps,
|
|
6
7
|
): ReturnType<typeof css> {
|
|
7
8
|
const {$accent, $muted} = props
|
|
8
|
-
const {font} = props.theme
|
|
9
|
+
const {font} = getTheme_v2(props.theme)
|
|
9
10
|
|
|
10
11
|
return css`
|
|
11
12
|
color: var(--card-fg-color);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
2
2
|
import {forwardRef} from 'react'
|
|
3
|
-
import styled from 'styled-components'
|
|
3
|
+
import {styled} from 'styled-components'
|
|
4
4
|
import {useForwardedRef, useCustomValidity, useArrayProp} from '../../hooks'
|
|
5
5
|
import {
|
|
6
6
|
responsiveInputPaddingStyle,
|
|
@@ -2,7 +2,7 @@ import {CloseIcon} from '@sanity/icons'
|
|
|
2
2
|
import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
3
3
|
import {createElement, forwardRef, isValidElement, useCallback, useMemo} from 'react'
|
|
4
4
|
import {isValidElementType} from 'react-is'
|
|
5
|
-
import styled from 'styled-components'
|
|
5
|
+
import {styled} from 'styled-components'
|
|
6
6
|
import {EMPTY_RECORD} from '../../constants'
|
|
7
7
|
import {useArrayProp, useForwardedRef, useCustomValidity} from '../../hooks'
|
|
8
8
|
import {
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
offset,
|
|
7
7
|
shift,
|
|
8
8
|
useFloating,
|
|
9
|
-
Middleware,
|
|
10
|
-
RootBoundary,
|
|
9
|
+
type Middleware,
|
|
10
|
+
type RootBoundary,
|
|
11
11
|
} from '@floating-ui/react-dom'
|
|
12
|
-
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
12
|
+
import type {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
13
13
|
import {AnimatePresence} from 'framer-motion'
|
|
14
14
|
import {
|
|
15
15
|
cloneElement,
|
|
@@ -19,24 +19,25 @@ import {
|
|
|
19
19
|
useMemo,
|
|
20
20
|
useRef,
|
|
21
21
|
useState,
|
|
22
|
-
ForwardedRef,
|
|
22
|
+
type ForwardedRef,
|
|
23
23
|
useId,
|
|
24
|
+
useSyncExternalStore,
|
|
24
25
|
} from 'react'
|
|
25
|
-
import styled from 'styled-components'
|
|
26
|
+
import {styled} from 'styled-components'
|
|
26
27
|
import {useArrayProp, useForwardedRef, usePrefersReducedMotion} from '../../hooks'
|
|
27
28
|
import {useDelayedState} from '../../hooks/useDelayedState'
|
|
28
29
|
import {origin} from '../../middleware/origin'
|
|
29
30
|
import {useTheme_v2} from '../../theme'
|
|
30
|
-
import {Placement} from '../../types'
|
|
31
|
+
import type {Placement} from '../../types'
|
|
31
32
|
import {
|
|
32
33
|
ConditionalWrapper,
|
|
33
34
|
Layer,
|
|
34
|
-
LayerProps,
|
|
35
|
+
type LayerProps,
|
|
35
36
|
Portal,
|
|
36
37
|
useBoundaryElement,
|
|
37
38
|
usePortal,
|
|
38
39
|
} from '../../utils'
|
|
39
|
-
import {Delay} from '../types'
|
|
40
|
+
import type {Delay} from '../types'
|
|
40
41
|
import {
|
|
41
42
|
DEFAULT_FALLBACK_PLACEMENTS,
|
|
42
43
|
DEFAULT_TOOLTIP_DISTANCE,
|
|
@@ -131,17 +132,23 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
131
132
|
const portalElement =
|
|
132
133
|
typeof portalProp === 'string' ? portal.elements?.[portalProp] || null : portal.element
|
|
133
134
|
|
|
135
|
+
const documentBodyOffsetWidth = useSyncExternalStore(
|
|
136
|
+
emptySubscribe,
|
|
137
|
+
() => document.body.offsetWidth,
|
|
138
|
+
// We don't actually know what the width of the body is during SSR, so we'll just assume it's 800px or larger
|
|
139
|
+
() => 800,
|
|
140
|
+
)
|
|
134
141
|
// Get the maximum tooltip width (sans tooltip padding)
|
|
135
142
|
// Tooltip width should never exceed the width of either any supplied boundary or portal element.
|
|
136
143
|
// If both portal and boundary elements are provided, use the smaller width of the two.
|
|
137
144
|
const tooltipWidth = useMemo(() => {
|
|
138
145
|
const availableWidths = [
|
|
139
146
|
...(boundaryElement ? [boundaryElement.offsetWidth] : []),
|
|
140
|
-
portalElement?.offsetWidth ||
|
|
147
|
+
portalElement?.offsetWidth || documentBodyOffsetWidth,
|
|
141
148
|
]
|
|
142
149
|
|
|
143
150
|
return Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2
|
|
144
|
-
}, [boundaryElement, portalElement?.offsetWidth])
|
|
151
|
+
}, [boundaryElement, documentBodyOffsetWidth, portalElement?.offsetWidth])
|
|
145
152
|
|
|
146
153
|
const middleware = useMemo(() => {
|
|
147
154
|
const ret: Middleware[] = []
|
|
@@ -242,14 +249,14 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
242
249
|
)
|
|
243
250
|
const handleClick = useCallback(
|
|
244
251
|
(e: MouseEvent) => {
|
|
245
|
-
handleIsOpenChange(false, true)
|
|
252
|
+
handleIsOpenChange(false, true)
|
|
246
253
|
childProp?.props.onClick?.(e)
|
|
247
254
|
},
|
|
248
255
|
[childProp?.props, handleIsOpenChange],
|
|
249
256
|
)
|
|
250
257
|
const handleContextMenu = useCallback(
|
|
251
258
|
(e: MouseEvent) => {
|
|
252
|
-
handleIsOpenChange(false, true)
|
|
259
|
+
handleIsOpenChange(false, true)
|
|
253
260
|
childProp?.props.onContextMenu?.(e)
|
|
254
261
|
},
|
|
255
262
|
[childProp?.props, handleIsOpenChange],
|
|
@@ -446,3 +453,5 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
446
453
|
</>
|
|
447
454
|
)
|
|
448
455
|
})
|
|
456
|
+
|
|
457
|
+
const emptySubscribe = () => () => {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
2
2
|
import {MotionProps, motion} from 'framer-motion'
|
|
3
3
|
import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
|
|
4
|
-
import styled from 'styled-components'
|
|
4
|
+
import {styled} from 'styled-components'
|
|
5
5
|
import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY, POPOVER_MOTION_PROPS} from '../../constants'
|
|
6
6
|
import {Placement, Radius} from '../../types'
|
|
7
7
|
import {Arrow} from '../../utils'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {_responsive} from '../helpers'
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveBorderStyleProps} from './types'
|
|
@@ -10,7 +10,7 @@ export function responsiveBorderStyle(): Array<
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function border(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
13
|
-
const {card, media} = props.theme
|
|
13
|
+
const {card, media} = getTheme_v2(props.theme)
|
|
14
14
|
const borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`
|
|
15
15
|
|
|
16
16
|
return _responsive(media, props.$border, (value) =>
|
|
@@ -19,7 +19,7 @@ function border(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function borderTop(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
22
|
-
const {card, media} = props.theme
|
|
22
|
+
const {card, media} = getTheme_v2(props.theme)
|
|
23
23
|
const borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`
|
|
24
24
|
|
|
25
25
|
return _responsive(media, props.$borderTop, (value) =>
|
|
@@ -28,7 +28,7 @@ function borderTop(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function borderRight(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
31
|
-
const {card, media} = props.theme
|
|
31
|
+
const {card, media} = getTheme_v2(props.theme)
|
|
32
32
|
const borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`
|
|
33
33
|
|
|
34
34
|
return _responsive(media, props.$borderRight, (value) =>
|
|
@@ -37,7 +37,7 @@ function borderRight(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function borderBottom(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
40
|
-
const {card, media} = props.theme
|
|
40
|
+
const {card, media} = getTheme_v2(props.theme)
|
|
41
41
|
const borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`
|
|
42
42
|
|
|
43
43
|
return _responsive(media, props.$borderBottom, (value) =>
|
|
@@ -46,7 +46,7 @@ function borderBottom(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function borderLeft(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
49
|
-
const {card, media} = props.theme
|
|
49
|
+
const {card, media} = getTheme_v2(props.theme)
|
|
50
50
|
const borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`
|
|
51
51
|
|
|
52
52
|
return _responsive(media, props.$borderLeft, (value) =>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {Property} from 'csstype'
|
|
3
3
|
import {_responsive} from '../helpers'
|
|
4
4
|
import {ThemeProps} from '../types'
|
|
@@ -36,7 +36,7 @@ export function responsiveBoxStyle(): Array<
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function responsiveBoxDisplayStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
39
|
-
const {media} = props.theme
|
|
39
|
+
const {media} = getTheme_v2(props.theme)
|
|
40
40
|
|
|
41
41
|
return _responsive(media, props.$display, (display) => ({
|
|
42
42
|
'&:not([hidden])': {display},
|
|
@@ -44,7 +44,7 @@ function responsiveBoxDisplayStyle(props: ResponsiveBoxStyleProps & ThemeProps)
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function responsiveBoxSizingStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
47
|
-
const {media} = props.theme
|
|
47
|
+
const {media} = getTheme_v2(props.theme)
|
|
48
48
|
|
|
49
49
|
return _responsive(media, props.$sizing, (sizing) => ({
|
|
50
50
|
boxSizing: BOX_SIZING[sizing],
|
|
@@ -52,7 +52,7 @@ function responsiveBoxSizingStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function responsiveBoxHeightStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
55
|
-
const {media} = props.theme
|
|
55
|
+
const {media} = getTheme_v2(props.theme)
|
|
56
56
|
|
|
57
57
|
return _responsive(media, props.$height, (height) => ({
|
|
58
58
|
height: BOX_HEIGHT[height],
|
|
@@ -60,7 +60,7 @@ function responsiveBoxHeightStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function responsiveBoxOverflowStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
63
|
-
const {media} = props.theme
|
|
63
|
+
const {media} = getTheme_v2(props.theme)
|
|
64
64
|
|
|
65
65
|
return _responsive(media, props.$overflow, (overflow) => ({
|
|
66
66
|
overflow,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {EMPTY_ARRAY} from '../../constants'
|
|
3
3
|
import {_responsive} from '../helpers'
|
|
4
4
|
import {ThemeProps} from '../types'
|
|
@@ -18,7 +18,7 @@ export function flexItemStyle(): Array<
|
|
|
18
18
|
export function responsiveFlexItemStyle(
|
|
19
19
|
props: ResponsiveFlexItemStyleProps & ThemeProps,
|
|
20
20
|
): CSSObject[] {
|
|
21
|
-
const {media} = props.theme
|
|
21
|
+
const {media} = getTheme_v2(props.theme)
|
|
22
22
|
|
|
23
23
|
if (!props.$flex) return EMPTY_ARRAY
|
|
24
24
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {rem, _responsive} from '../helpers'
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveFlexStyleProps} from './types'
|
|
@@ -25,7 +25,7 @@ export function responsiveFlexStyle(): Array<
|
|
|
25
25
|
export function responsiveFlexAlignStyle(
|
|
26
26
|
props: ResponsiveFlexStyleProps & ThemeProps,
|
|
27
27
|
): CSSObject[] {
|
|
28
|
-
const {media} = props.theme
|
|
28
|
+
const {media} = getTheme_v2(props.theme)
|
|
29
29
|
|
|
30
30
|
return _responsive(media, props.$align, (align) => {
|
|
31
31
|
return {alignItems: align}
|
|
@@ -33,7 +33,7 @@ export function responsiveFlexAlignStyle(
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function responsiveFlexGapStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
|
|
36
|
-
const {media, space} = props.theme
|
|
36
|
+
const {media, space} = getTheme_v2(props.theme)
|
|
37
37
|
|
|
38
38
|
return _responsive(media, props.$gap, (gap) => ({
|
|
39
39
|
gap: gap ? rem(space[gap]) : undefined,
|
|
@@ -41,7 +41,7 @@ function responsiveFlexGapStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export function responsiveFlexWrapStyle(props: ResponsiveFlexStyleProps & ThemeProps): CSSObject[] {
|
|
44
|
-
const {media} = props.theme
|
|
44
|
+
const {media} = getTheme_v2(props.theme)
|
|
45
45
|
|
|
46
46
|
return _responsive(media, props.$wrap, (wrap) => {
|
|
47
47
|
return {flexWrap: wrap}
|
|
@@ -51,7 +51,7 @@ export function responsiveFlexWrapStyle(props: ResponsiveFlexStyleProps & ThemeP
|
|
|
51
51
|
export function responsiveFlexJustifyStyle(
|
|
52
52
|
props: ResponsiveFlexStyleProps & ThemeProps,
|
|
53
53
|
): CSSObject[] {
|
|
54
|
-
const {media} = props.theme
|
|
54
|
+
const {media} = getTheme_v2(props.theme)
|
|
55
55
|
|
|
56
56
|
return _responsive(media, props.$justify, (justify) => {
|
|
57
57
|
return {justifyContent: justify}
|
|
@@ -61,7 +61,7 @@ export function responsiveFlexJustifyStyle(
|
|
|
61
61
|
export function responsiveFlexDirectionStyle(
|
|
62
62
|
props: ResponsiveFlexStyleProps & ThemeProps,
|
|
63
63
|
): CSSObject[] {
|
|
64
|
-
const {media} = props.theme
|
|
64
|
+
const {media} = getTheme_v2(props.theme)
|
|
65
65
|
|
|
66
66
|
return _responsive(media, props.$direction, (direction) => {
|
|
67
67
|
return {flexDirection: direction}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ThemeFontSize, ThemeFontKey} from '@sanity/ui/theme'
|
|
1
|
+
import {ThemeFontSize, ThemeFontKey, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {CSSObject} from '@sanity/ui/theme'
|
|
3
3
|
import {rem, _responsive} from '../helpers'
|
|
4
4
|
import {ThemeProps} from '../types'
|
|
@@ -13,7 +13,7 @@ export function responsiveFont(
|
|
|
13
13
|
props: ResponsiveFontStyleProps & ThemeProps,
|
|
14
14
|
): CSSObject[] {
|
|
15
15
|
const {$size, $weight} = props
|
|
16
|
-
const {font, media} = props.theme
|
|
16
|
+
const {font, media} = getTheme_v2(props.theme)
|
|
17
17
|
const {family, sizes, weights} = font[fontKey]
|
|
18
18
|
const fontWeight = ($weight && weights[$weight]) || weights.regular
|
|
19
19
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {_responsive} from '../helpers'
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveTextAlignStyleProps} from './types'
|
|
@@ -10,7 +10,7 @@ import {ResponsiveTextAlignStyleProps} from './types'
|
|
|
10
10
|
export function responsiveTextAlignStyle(
|
|
11
11
|
props: ResponsiveTextAlignStyleProps & ThemeProps,
|
|
12
12
|
): CSSObject[] {
|
|
13
|
-
const {media} = props.theme
|
|
13
|
+
const {media} = getTheme_v2(props.theme)
|
|
14
14
|
|
|
15
15
|
return _responsive(media, props.$align, (textAlign) => {
|
|
16
16
|
return {textAlign}
|