@sanity/ui 2.10.0-corel.0 → 2.10.0
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/getTheme_v2.js +110 -54
- package/dist/_chunks-cjs/getTheme_v2.js.map +1 -1
- package/dist/_chunks-es/getTheme_v2.mjs +110 -54
- package/dist/_chunks-es/getTheme_v2.mjs.map +1 -1
- package/dist/_legacy/getTheme_v2.esm.js +110 -54
- package/dist/_legacy/getTheme_v2.esm.js.map +1 -1
- package/dist/index.d.mts +43 -54
- package/dist/index.d.ts +43 -54
- package/dist/index.esm.js +3323 -3046
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3322 -3046
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3323 -3046
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +9 -9
- package/dist/theme.d.ts +9 -9
- package/dist/theme.esm.js +1144 -592
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +1144 -592
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +1144 -592
- package/dist/theme.mjs.map +1 -1
- package/package.json +73 -59
- package/src/core/__workshop__/constants.ts +15 -19
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +1 -1
- package/src/core/components/autocomplete/autocomplete.tsx +4 -3
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -3
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -5
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +13 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +31 -39
- package/src/core/components/dialog/dialog.tsx +5 -3
- package/src/core/components/dialog/dialogProvider.tsx +1 -1
- package/src/core/components/menu/__workshop__/asComponent.tsx +1 -1
- package/src/core/components/menu/__workshop__/tones.tsx +5 -6
- package/src/core/components/menu/menu.test.tsx +0 -2
- package/src/core/components/menu/menu.tsx +15 -11
- package/src/core/components/menu/menuButton.tsx +16 -38
- package/src/core/components/menu/menuGroup.tsx +4 -3
- package/src/core/components/menu/menuItem.tsx +5 -2
- package/src/core/components/tab/tabList.tsx +4 -12
- package/src/core/components/toast/__workshop__/hook.tsx +1 -1
- package/src/core/components/toast/toast.test.tsx +0 -1
- package/src/core/components/toast/toast.tsx +3 -3
- package/src/core/components/toast/toastProvider.tsx +8 -8
- package/src/core/components/toast/toastState.ts +6 -0
- package/src/core/components/tree/tree.tsx +1 -1
- package/src/core/components/tree/treeGroup.tsx +1 -1
- package/src/core/components/tree/treeItem.tsx +1 -1
- package/src/core/constants.ts +1 -1
- package/src/core/hooks/useArrayProp.ts +14 -9
- package/src/core/hooks/useDelayedState.ts +1 -1
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +2 -2
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +0 -1
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +0 -1
- package/src/core/lib/globalScope.ts +0 -1
- package/src/core/primitives/avatar/avatar.tsx +1 -1
- package/src/core/primitives/avatar/avatarStack.tsx +2 -5
- package/src/core/primitives/badge/__workshop__/tones.tsx +6 -13
- package/src/core/primitives/badge/badge.tsx +1 -1
- package/src/core/primitives/box/box.tsx +1 -1
- package/src/core/primitives/button/__workshop__/custom.tsx +4 -3
- package/src/core/primitives/button/__workshop__/props.tsx +1 -1
- package/src/core/primitives/button/button.tsx +7 -12
- package/src/core/primitives/button/styles.ts +1 -1
- package/src/core/primitives/card/__workshop__/allTones.tsx +6 -8
- package/src/core/primitives/card/__workshop__/asButton.tsx +42 -24
- package/src/core/primitives/card/__workshop__/asComponent.tsx +2 -2
- package/src/core/primitives/card/__workshop__/checkered.tsx +17 -7
- package/src/core/primitives/card/__workshop__/interactive.tsx +10 -3
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +5 -3
- package/src/core/primitives/card/__workshop__/props.tsx +7 -5
- package/src/core/primitives/card/__workshop__/selected.tsx +4 -1
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +6 -0
- package/src/core/primitives/code/__workshop__/props.tsx +1 -1
- package/src/core/primitives/code/code.tsx +1 -2
- package/src/core/primitives/container/__workshop__/example.tsx +1 -1
- package/src/core/primitives/flex/__workshop__/example.tsx +3 -3
- package/src/core/primitives/flex/flex.tsx +1 -5
- package/src/core/primitives/grid/__workshop__/responsive.tsx +12 -12
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +13 -25
- package/src/core/primitives/heading/heading.tsx +2 -2
- package/src/core/primitives/inline/__workshop__/plain.tsx +3 -3
- package/src/core/primitives/inline/inline.tsx +0 -1
- package/src/core/primitives/kbd/kbd.tsx +1 -1
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +6 -6
- package/src/core/primitives/label/label.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +3 -3
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +2 -2
- package/src/core/primitives/popover/popover.tsx +10 -10
- package/src/core/primitives/radio/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/select/__workshop__/readOnly.tsx +1 -1
- package/src/core/primitives/stack/stack.tsx +1 -1
- package/src/core/primitives/text/__workshop__/example.tsx +6 -6
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +11 -21
- package/src/core/primitives/text/styles.ts +0 -1
- package/src/core/primitives/text/text.tsx +3 -5
- package/src/core/primitives/textArea/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -5
- package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -2
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +6 -2
- package/src/core/primitives/textInput/__workshop__/tones.tsx +38 -0
- package/src/core/primitives/tooltip/tooltip.tsx +1 -2
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +1 -1
- package/src/core/styles/card/_cardColorStyle.ts +8 -8
- package/src/core/styles/flex/flexStyle.ts +0 -18
- package/src/core/styles/flex/types.ts +0 -2
- package/src/core/theme/__workshop__/build/story.tsx +1 -3
- package/src/core/theme/__workshop__/debug/story.tsx +18 -13
- package/src/core/theme/theme.test.tsx +0 -1
- package/src/core/theme/themeColorProvider.tsx +1 -1
- package/src/core/theme/themeProvider.tsx +5 -7
- package/src/core/utils/arrow/arrow.tsx +1 -1
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +0 -1
- package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +3 -1
- package/src/core/utils/elementQuery/elementQuery.tsx +16 -17
- package/src/core/utils/layer/layer.test.tsx +0 -1
- package/src/core/utils/layer/layer.tsx +9 -1
- package/src/core/utils/layer/layerProvider.tsx +2 -2
- package/src/core/utils/portal/portal.test.tsx +0 -1
- package/src/core/utils/portal/portalProvider.tsx +1 -1
- package/src/core/utils/srOnly/srOnly.tsx +1 -1
- package/src/core/utils/virtualList/virtualList.tsx +10 -3
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.ts +12 -8
- package/src/theme/build/merge.ts +0 -2
- package/src/theme/build/renderColorTheme.ts +54 -232
- package/src/theme/defaults/colorTokens.ts +13 -18
- package/src/theme/system/color/_constants.ts +6 -10
- package/src/theme/system/css.ts +1 -2
- package/src/theme/versioning/themeColor_v0_v2.ts +26 -26
- package/src/theme/versioning/v0_v2.ts +4 -4
- package/src/core/components/autocomplete/__workshop__/.eslintrc +0 -5
- package/src/core/components/breadcrumbs/__workshop__/.eslintrc +0 -5
- package/src/core/components/breadcrumbs/__workshop__/buttons.tsx +0 -58
- package/src/core/components/dialog/__workshop__/.eslintrc +0 -5
- package/src/core/components/hotkeys/__workshop__/.eslintrc +0 -5
- package/src/core/components/menu/__workshop__/.eslintrc +0 -5
- package/src/core/components/skeleton/__workshop__/.eslintrc +0 -5
- package/src/core/components/tab/__workshop__/.eslintrc +0 -5
- package/src/core/components/toast/__workshop__/.eslintrc +0 -5
- package/src/core/components/tree/__workshop__/.eslintrc +0 -5
- package/src/core/hooks/useElementRect/__workshop__/.eslintrc +0 -5
- package/src/core/hooks/useMediaIndex/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/avatar/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/badge/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/box/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/button/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/card/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/checkbox/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/code/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/container/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/flex/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/grid/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/heading/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/inline/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/kbd/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/label/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/popover/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/radio/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/select/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/spinner/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/stack/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/switch/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/text/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/textArea/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/textInput/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/textInput/__workshop__/multipleTones.tsx +0 -20
- package/src/core/primitives/tooltip/__workshop__/.eslintrc +0 -5
- package/src/core/theme/__workshop__/.eslintrc +0 -5
- package/src/core/utils/boundaryElement/__workshop__/.eslintrc +0 -5
- package/src/core/utils/elementQuery/__workshop__/.eslintrc +0 -5
- package/src/core/utils/layer/__workshop__/.eslintrc +0 -5
- package/src/core/utils/portal/__workshop__/.eslintrc +0 -5
- package/src/core/utils/virtualList/__workshop__/.eslintrc +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {forwardRef,
|
|
1
|
+
import {forwardRef, useImperativeHandle, useMemo, useState, type JSX} from 'react'
|
|
2
2
|
import {useElementSize} from '../../hooks'
|
|
3
3
|
import {useTheme_v2} from '../../theme'
|
|
4
4
|
import {findMaxBreakpoints, findMinBreakpoints} from './helpers'
|
|
@@ -21,31 +21,30 @@ export const ElementQuery = forwardRef(function ElementQuery(
|
|
|
21
21
|
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
22
22
|
) {
|
|
23
23
|
const theme = useTheme_v2()
|
|
24
|
-
const {children, media
|
|
24
|
+
const {children, media: _media, ...restProps} = props
|
|
25
|
+
const media = _media ?? theme.media
|
|
25
26
|
|
|
26
|
-
const ref = useRef<HTMLDivElement | null>(null)
|
|
27
27
|
const [element, setElement] = useState<HTMLDivElement | null>(null)
|
|
28
28
|
const elementSize = useElementSize(element)
|
|
29
29
|
const width = useMemo(() => elementSize?.border.width ?? window.innerWidth, [elementSize])
|
|
30
30
|
|
|
31
|
-
const max = useMemo(() =>
|
|
32
|
-
|
|
31
|
+
const max = useMemo(() => {
|
|
32
|
+
const eq = findMaxBreakpoints(media, width)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
return eq.length ? eq.join(' ') : undefined
|
|
35
|
+
}, [media, width])
|
|
36
|
+
const min = useMemo(() => {
|
|
37
|
+
const eq = findMinBreakpoints(media, width)
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
return eq.length ? eq.join(' ') : undefined
|
|
40
|
+
}, [media, width])
|
|
41
|
+
|
|
42
|
+
useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => element, [
|
|
43
|
+
element,
|
|
44
|
+
])
|
|
40
45
|
|
|
41
46
|
return (
|
|
42
|
-
<div
|
|
43
|
-
data-ui="ElementQuery"
|
|
44
|
-
{...restProps}
|
|
45
|
-
data-eq-max={max.length ? max.join(' ') : undefined}
|
|
46
|
-
data-eq-min={min.length ? min.join(' ') : undefined}
|
|
47
|
-
ref={setRef}
|
|
48
|
-
>
|
|
47
|
+
<div data-ui="ElementQuery" {...restProps} data-eq-max={max} data-eq-min={min} ref={setElement}>
|
|
49
48
|
{children}
|
|
50
49
|
</div>
|
|
51
50
|
)
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FocusEvent,
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useRef,
|
|
8
|
+
type JSX,
|
|
9
|
+
} from 'react'
|
|
2
10
|
import {styled} from 'styled-components'
|
|
3
11
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
12
|
import {containsOrEqualsElement, isHTMLElement} from '../../helpers'
|
|
@@ -15,7 +15,7 @@ export interface LayerProviderProps {
|
|
|
15
15
|
/**
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
|
-
export function LayerProvider(props: LayerProviderProps): React.ReactElement {
|
|
18
|
+
export function LayerProvider(props: LayerProviderProps): React.ReactElement<any> {
|
|
19
19
|
const {children, zOffset: zOffsetProp = 0} = props
|
|
20
20
|
|
|
21
21
|
// Get parent context values
|
|
@@ -85,7 +85,7 @@ export function LayerProvider(props: LayerProviderProps): React.ReactElement {
|
|
|
85
85
|
parentDispose?.()
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
|
-
[parentRegisterChild],
|
|
88
|
+
[parentRegisterChild, setSize, setChildLayers],
|
|
89
89
|
)
|
|
90
90
|
|
|
91
91
|
// Register this layer on mount
|
|
@@ -21,7 +21,7 @@ export interface PortalProviderProps {
|
|
|
21
21
|
/**
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
|
-
export function PortalProvider(props: PortalProviderProps): React.ReactElement {
|
|
24
|
+
export function PortalProvider(props: PortalProviderProps): React.ReactElement<any> {
|
|
25
25
|
const {boundaryElement, children, element, __unstable_elements: elementsProp} = props
|
|
26
26
|
const elements = useUnique(elementsProp)
|
|
27
27
|
const fallbackElement = useSyncExternalStore(
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useEffect,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type JSX,
|
|
9
|
+
} from 'react'
|
|
3
10
|
import {styled} from 'styled-components'
|
|
4
11
|
import {_isScrollable} from '../../helpers'
|
|
5
12
|
import {_ResizeObserver} from '../../observers'
|
|
@@ -48,7 +55,7 @@ export const VirtualList = forwardRef(function VirtualList(
|
|
|
48
55
|
StackProps &
|
|
49
56
|
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'onChange' | 'ref'>,
|
|
50
57
|
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
51
|
-
): React.ReactElement {
|
|
58
|
+
): React.ReactElement<any> {
|
|
52
59
|
const {as = 'div', gap = 0, getItemKey, items = [], onChange, renderItem, ...restProps} = props
|
|
53
60
|
const {space} = useTheme_v2()
|
|
54
61
|
const ref = useRef<HTMLDivElement | null>(null)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {ThemeColorBase, ThemeColorMuted,
|
|
1
|
+
import {ThemeColorBase, ThemeColorMuted, ThemeColorName} from '../../../../system'
|
|
2
2
|
import {ThemeColorBuilderOpts} from '../factory'
|
|
3
3
|
|
|
4
4
|
export function createMutedTones(
|
|
5
5
|
opts: ThemeColorBuilderOpts,
|
|
6
6
|
base: ThemeColorBase,
|
|
7
7
|
dark: boolean,
|
|
8
|
-
name:
|
|
8
|
+
name: ThemeColorName,
|
|
9
9
|
): ThemeColorMuted {
|
|
10
10
|
return {
|
|
11
11
|
default: {
|
|
@@ -47,11 +47,13 @@ function buildColorScheme(
|
|
|
47
47
|
): ThemeColorScheme_v2 {
|
|
48
48
|
const {scheme} = options
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
acc[tone] = buildCardColorTheme({scheme, tone}, config)
|
|
50
|
+
const colorScheme = {} as ThemeColorScheme_v2
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
for (const tone of THEME_COLOR_CARD_TONES) {
|
|
53
|
+
colorScheme[tone] = buildCardColorTheme({scheme, tone}, config)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return colorScheme
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
function buildCardColorTheme(
|
|
@@ -165,11 +167,13 @@ function buildBadgeColorTheme(
|
|
|
165
167
|
): ThemeColorBadge_v2 {
|
|
166
168
|
const {scheme} = options
|
|
167
169
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
const colorBadge = {} as ThemeColorBadge_v2
|
|
171
|
+
|
|
172
|
+
for (const tone of THEME_COLOR_STATE_TONES) {
|
|
173
|
+
colorBadge[tone] = _buildBadgeColorTheme(tokens, {scheme, tone}, config)
|
|
174
|
+
}
|
|
170
175
|
|
|
171
|
-
|
|
172
|
-
}, {} as ThemeColorBadge_v2)
|
|
176
|
+
return colorBadge
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
function _buildBadgeColorTheme(
|