@sanity/ui 0.38.2-next.14 → 0.38.2-next.16
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/README.md +5 -4
- package/dist/sanity-ui.cjs +260 -10107
- package/dist/sanity-ui.cjs.map +1 -1
- package/dist/sanity-ui.js +260 -9983
- package/dist/sanity-ui.js.map +1 -1
- package/dist/types/src/index.d.ts +239 -227
- package/package.json +20 -17
- package/src/__workshop__/color/overview.tsx +1 -1
- package/src/components/autocomplete/__workshop__/async.tsx +1 -1
- package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +1 -1
- package/src/components/autocomplete/__workshop__/custom.tsx +1 -1
- package/src/components/autocomplete/__workshop__/example.tsx +1 -1
- package/src/components/autocomplete/__workshop__/focusAndBlur.tsx +1 -1
- package/src/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
- package/src/components/autocomplete/autocomplete.tsx +1 -1
- package/src/components/autocomplete/autocompleteOption.tsx +1 -1
- package/src/components/breadcrumbs/__workshop__/example.tsx +1 -0
- package/src/components/breadcrumbs/breadcrumbs.tsx +9 -1
- package/src/components/dialog/__workshop__/autoFocus.tsx +1 -0
- package/src/components/dialog/__workshop__/layering.tsx +1 -0
- package/src/components/dialog/__workshop__/nested.tsx +1 -1
- package/src/components/dialog/__workshop__/onScroll.tsx +1 -1
- package/src/components/dialog/__workshop__/position.tsx +1 -0
- package/src/components/dialog/__workshop__/props.tsx +1 -1
- package/src/components/dialog/__workshop__/provider.tsx +1 -0
- package/src/components/dialog/dialog.tsx +1 -1
- package/src/components/dialog/dialogProvider.tsx +1 -1
- package/src/components/hotkeys/__workshop__/plain.tsx +1 -0
- package/src/components/hotkeys/hotkeys.tsx +1 -1
- package/src/components/menu/__workshop__/asComponent.tsx +1 -1
- package/src/components/menu/__workshop__/closableMenuButton.tsx +1 -1
- package/src/components/menu/__workshop__/constrainedInBoundary.tsx +1 -1
- package/src/components/menu/__workshop__/customMenuItem.tsx +1 -0
- package/src/components/menu/__workshop__/disableFocusOnClose.tsx +1 -0
- package/src/components/menu/__workshop__/groups.tsx +1 -0
- package/src/components/menu/__workshop__/menuButton.tsx +1 -0
- package/src/components/menu/__workshop__/menuGroupRight.tsx +1 -0
- package/src/components/menu/__workshop__/nestedMenu.tsx +1 -0
- package/src/components/menu/__workshop__/onCloseMenuButton.tsx +1 -1
- package/src/components/menu/__workshop__/selectedItem.tsx +1 -1
- package/src/components/menu/__workshop__/tones.tsx +1 -0
- package/src/components/menu/__workshop__/withoutArrow.tsx +1 -0
- package/src/components/menu/menu.test.tsx +5 -4
- package/src/components/menu/menu.tsx +1 -1
- package/src/components/menu/menuButton.tsx +9 -1
- package/src/components/menu/menuGroup.tsx +1 -1
- package/src/components/menu/menuItem.tsx +1 -1
- package/src/components/menu/useMenuController.ts +1 -1
- package/src/components/skeleton/__workshop__/delay.tsx +1 -0
- package/src/components/skeleton/__workshop__/skeleton.tsx +1 -0
- package/src/components/skeleton/skeleton.tsx +1 -1
- package/src/components/skeleton/textSkeleton.tsx +1 -1
- package/src/components/tab/__workshop__/example.tsx +1 -1
- package/src/components/tab/tab.tsx +1 -1
- package/src/components/tab/tabList.tsx +1 -1
- package/src/components/tab/tabPanel.tsx +1 -1
- package/src/components/toast/__workshop__/hook.tsx +1 -0
- package/src/components/toast/__workshop__/toast.tsx +1 -0
- package/src/components/toast/toast.test.tsx +5 -3
- package/src/components/toast/toast.tsx +1 -0
- package/src/components/toast/toastProvider.tsx +1 -1
- package/src/components/tree/__workshop__/basic.tsx +1 -1
- package/src/components/tree/tree.tsx +1 -1
- package/src/components/tree/treeGroup.tsx +1 -1
- package/src/components/tree/treeItem.tsx +3 -3
- package/src/hooks/useElementRect/__workshop__/example.tsx +1 -0
- package/src/hooks/useForwardedRef.ts +1 -1
- package/src/hooks/useMediaIndex/__workshop__/test.tsx +1 -0
- package/src/icons/__workshop__/overview.tsx +1 -1
- package/src/primitives/avatar/__workshop__/asButton.tsx +1 -0
- package/src/primitives/avatar/__workshop__/stack.tsx +1 -0
- package/src/primitives/avatar/avatar.tsx +3 -2
- package/src/primitives/avatar/avatarCounter.tsx +1 -1
- package/src/primitives/avatar/avatarStack.tsx +1 -1
- package/src/primitives/badge/__workshop__/props.tsx +1 -0
- package/src/primitives/badge/__workshop__/tones.tsx +1 -0
- package/src/primitives/badge/badge.tsx +1 -1
- package/src/primitives/box/__workshop__/props.tsx +1 -0
- package/src/primitives/box/__workshop__/responsive.tsx +1 -0
- package/src/primitives/box/box.tsx +1 -1
- package/src/primitives/button/__workshop__/custom.tsx +1 -0
- package/src/primitives/button/__workshop__/customIcons.tsx +1 -0
- package/src/primitives/button/__workshop__/mixedChildren.tsx +1 -0
- package/src/primitives/button/__workshop__/props.tsx +1 -0
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +1 -0
- package/src/primitives/button/__workshop__/stacked.tsx +1 -0
- package/src/primitives/button/__workshop__/styled1.tsx +1 -0
- package/src/primitives/button/__workshop__/styled2.tsx +1 -0
- package/src/primitives/button/__workshop__/uploadButton.tsx +1 -1
- package/src/primitives/button/button.tsx +1 -1
- package/src/primitives/card/__workshop__/allTones.tsx +1 -0
- package/src/primitives/card/__workshop__/asButton.tsx +1 -0
- package/src/primitives/card/__workshop__/asComponent.tsx +1 -1
- package/src/primitives/card/__workshop__/checkered.tsx +1 -0
- package/src/primitives/card/__workshop__/interactive.tsx +1 -0
- package/src/primitives/card/__workshop__/listNavigation.tsx +1 -0
- package/src/primitives/card/__workshop__/props.tsx +1 -0
- package/src/primitives/card/__workshop__/selected.tsx +1 -0
- package/src/primitives/card/__workshop__/styled.tsx +1 -0
- package/src/primitives/card/card.tsx +1 -1
- package/src/primitives/checkbox/__workshop__/example.tsx +1 -1
- package/src/primitives/checkbox/__workshop__/props.tsx +1 -0
- package/src/primitives/checkbox/__workshop__/readOnly.tsx +1 -0
- package/src/primitives/checkbox/__workshop__/tones.tsx +1 -0
- package/src/primitives/checkbox/checkbox.tsx +1 -1
- package/src/primitives/code/__workshop__/opticalAlignment.tsx +1 -0
- package/src/primitives/code/__workshop__/props.tsx +1 -0
- package/src/primitives/code/code.tsx +1 -1
- package/src/primitives/container/__workshop__/example.tsx +1 -0
- package/src/primitives/container/container.tsx +1 -1
- package/src/primitives/flex/__workshop__/example.tsx +1 -0
- package/src/primitives/flex/__workshop__/gap.tsx +1 -0
- package/src/primitives/flex/flex.tsx +1 -1
- package/src/primitives/grid/__workshop__/responsive.tsx +1 -0
- package/src/primitives/grid/grid.tsx +1 -1
- package/src/primitives/heading/__workshop__/opticalAlignment.tsx +1 -0
- package/src/primitives/heading/__workshop__/plain.tsx +1 -0
- package/src/primitives/heading/heading.tsx +1 -1
- package/src/primitives/inline/__workshop__/plain.tsx +1 -0
- package/src/primitives/inline/inline.tsx +1 -1
- package/src/primitives/kbd/__workshop__/plain.tsx +1 -0
- package/src/primitives/kbd/kbd.tsx +1 -1
- package/src/primitives/label/__workshop__/opticalAlignment.tsx +1 -0
- package/src/primitives/label/__workshop__/plain.tsx +1 -0
- package/src/primitives/label/label.tsx +1 -1
- package/src/primitives/popover/__workshop__/MarginsStory.tsx +1 -0
- package/src/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +1 -0
- package/src/primitives/popover/__workshop__/PlainStory.tsx +1 -1
- package/src/primitives/popover/__workshop__/RecursiveStory.tsx +1 -1
- package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +1 -1
- package/src/primitives/popover/__workshop__/TestStory.tsx +1 -1
- package/src/primitives/popover/arrow.tsx +1 -1
- package/src/primitives/popover/popover.tsx +9 -1
- package/src/primitives/radio/__workshop__/example.tsx +1 -1
- package/src/primitives/radio/__workshop__/plain.tsx +1 -0
- package/src/primitives/radio/radio.tsx +1 -1
- package/src/primitives/select/__workshop__/plain.tsx +1 -0
- package/src/primitives/select/__workshop__/readOnly.tsx +1 -0
- package/src/primitives/select/select.tsx +1 -1
- package/src/primitives/spinner/__workshop__/Props.tsx +1 -0
- package/src/primitives/spinner/spinner.tsx +1 -1
- package/src/primitives/stack/__workshop__/plain.tsx +1 -0
- package/src/primitives/stack/stack.tsx +1 -1
- package/src/primitives/switch/__workshop__/example.tsx +1 -1
- package/src/primitives/switch/__workshop__/props.tsx +1 -1
- package/src/primitives/switch/switch.tsx +1 -1
- package/src/primitives/text/__workshop__/colored.tsx +1 -0
- package/src/primitives/text/__workshop__/example.tsx +1 -0
- package/src/primitives/text/__workshop__/opticalAlignment.tsx +1 -0
- package/src/primitives/text/text.tsx +1 -1
- package/src/primitives/textArea/__workshop__/plain.tsx +1 -0
- package/src/primitives/textArea/textArea.tsx +1 -1
- package/src/primitives/textInput/__workshop__/clearButton.tsx +1 -1
- package/src/primitives/textInput/__workshop__/customValidity.tsx +1 -0
- package/src/primitives/textInput/__workshop__/multipleTones.tsx +1 -0
- package/src/primitives/textInput/__workshop__/plain.tsx +1 -1
- package/src/primitives/textInput/__workshop__/readOnly.tsx +1 -0
- package/src/primitives/textInput/__workshop__/states.tsx +1 -0
- package/src/primitives/textInput/__workshop__/tones.tsx +1 -0
- package/src/primitives/textInput/__workshop__/typed.tsx +1 -1
- package/src/primitives/textInput/textInput.tsx +1 -1
- package/src/primitives/tooltip/__workshop__/props.tsx +1 -0
- package/src/primitives/tooltip/tooltip.tsx +1 -1
- package/src/primitives/tooltip/tooltipArrow.tsx +1 -1
- package/src/styles/font/responsiveFont.ts +0 -13
- package/src/styles/helpers.ts +1 -1
- package/src/theme/__workshop__/canvas.tsx +1 -1
- package/src/theme/__workshop__/color.tsx +1 -0
- package/src/theme/__workshop__/layer.tsx +1 -1
- package/src/theme/__workshop__/nestedProvider.tsx +1 -0
- package/src/theme/theme.test.tsx +5 -3
- package/src/theme/themeColorProvider.tsx +1 -0
- package/src/theme/themeProvider.tsx +1 -1
- package/src/utils/boundaryElement/__workshop__/plain.tsx +1 -1
- package/src/utils/boundaryElement/boundaryElement.test.tsx +5 -3
- package/src/utils/boundaryElement/boundaryElementProvider.tsx +1 -1
- package/src/utils/elementQuery/__workshop__/customMedia.tsx +1 -0
- package/src/utils/elementQuery/elementQuery.tsx +1 -1
- package/src/utils/errorBoundary.tsx +4 -4
- package/src/utils/layer/__workshop__/_debug.tsx +1 -0
- package/src/utils/layer/__workshop__/multipleRoots.tsx +1 -0
- package/src/utils/layer/__workshop__/plain.tsx +1 -1
- package/src/utils/layer/__workshop__/responsiveZOffset.tsx +1 -0
- package/src/utils/layer/layer.test.tsx +5 -3
- package/src/utils/layer/layer.tsx +1 -1
- package/src/utils/layer/layerProvider.tsx +1 -1
- package/src/utils/portal/__workshop__/named.tsx +1 -1
- package/src/utils/portal/portal.test.tsx +5 -3
- package/src/utils/portal/portal.ts +3 -2
- package/src/utils/portal/portalProvider.tsx +1 -1
- package/src/utils/srOnly/srOnly.tsx +1 -1
- package/src/utils/virtualList/__workshop__/changingProps.tsx +1 -1
- package/src/utils/virtualList/__workshop__/elementScroll.tsx +1 -1
- package/src/utils/virtualList/__workshop__/infiniteList.tsx +1 -1
- package/src/utils/virtualList/__workshop__/windowScrolll.tsx +1 -1
- package/src/utils/virtualList/virtualList.tsx +1 -1
- package/src/primitives/badge/badge.test.tsx +0 -13
- package/src/primitives/button/button.test.tsx +0 -41
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Flex, Switch, useTheme} from '@sanity/ui'
|
|
2
2
|
import {useBoolean, useNumber} from '@sanity/ui-workshop'
|
|
3
|
-
import {useCallback, useMemo} from 'react'
|
|
3
|
+
import React, {useCallback, useMemo} from 'react'
|
|
4
4
|
import {ThemeProvider} from 'styled-components'
|
|
5
5
|
|
|
6
6
|
export default function PropsStory() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Flex, Text, Theme, ThemeColorSpotKey, useTheme} from '@sanity/ui'
|
|
2
2
|
import {useSelect} from '@sanity/ui-workshop'
|
|
3
|
+
import React from 'react'
|
|
3
4
|
import styled, {css} from 'styled-components'
|
|
4
5
|
import {WORKSHOP_SPOT_COLOR_OPTIONS} from '../../../__workshop__/constants'
|
|
5
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Box, TextInput} from '@sanity/ui'
|
|
2
2
|
import {useText} from '@sanity/ui-workshop'
|
|
3
|
-
import {useCallback, useState} from 'react'
|
|
3
|
+
import React, {useCallback, useState} from 'react'
|
|
4
4
|
|
|
5
5
|
export default function ClearButtonStory() {
|
|
6
6
|
const customValidity = useText('Custom validitiy')
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Button, Card, Container, Stack, TextInput} from '@sanity/ui'
|
|
2
2
|
import {useText} from '@sanity/ui-workshop'
|
|
3
|
+
import React from 'react'
|
|
3
4
|
|
|
4
5
|
export default function CustomValidityStory() {
|
|
5
6
|
const customValidity = useText('Custom validity', 'Invalid value', 'Props') || undefined
|
|
@@ -2,7 +2,7 @@ import {icons, IconSymbol} from '@sanity/icons'
|
|
|
2
2
|
import {Container, Flex, Stack, Text, TextInput} from '@sanity/ui'
|
|
3
3
|
import {PerfTestProps, useBoolean, usePerfTest, useSelect, useText} from '@sanity/ui-workshop'
|
|
4
4
|
import {fireEvent} from '@testing-library/dom'
|
|
5
|
-
import {useCallback, useState} from 'react'
|
|
5
|
+
import React, {useCallback, useState} from 'react'
|
|
6
6
|
import {
|
|
7
7
|
WORKSHOP_TEXT_FONT_SIZE_OPTIONS,
|
|
8
8
|
WORKSHOP_FONT_WEIGHT_OPTIONS,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Box, Container, TextInput} from '@sanity/ui'
|
|
2
2
|
import {useSelect} from '@sanity/ui-workshop'
|
|
3
|
-
import {useCallback, useState} from 'react'
|
|
3
|
+
import React, {useCallback, useState} from 'react'
|
|
4
4
|
import {WORKSHOP_TEXT_INPUT_TYPE_OPTIONS} from '../../../__workshop__/constants'
|
|
5
5
|
|
|
6
6
|
export default function TypedStory() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CloseIcon} from '@sanity/icons'
|
|
2
|
-
import {createElement, forwardRef, isValidElement, useCallback, useMemo} from 'react'
|
|
2
|
+
import React, {createElement, forwardRef, isValidElement, useCallback, useMemo} from 'react'
|
|
3
3
|
import {isValidElementType} from 'react-is'
|
|
4
4
|
import styled from 'styled-components'
|
|
5
5
|
import {EMPTY_RECORD} from '../../constants'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Box, Button, Card, Flex, Text, Tooltip} from '@sanity/ui'
|
|
2
2
|
import {useSelect, useText} from '@sanity/ui-workshop'
|
|
3
|
+
import React from 'react'
|
|
3
4
|
import {WORKSHOP_PLACEMENT_OPTIONS} from '../../../__workshop__/constants'
|
|
4
5
|
|
|
5
6
|
export default function PropsStory() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {cloneElement, forwardRef, useCallback, useEffect, useRef, useState} from 'react'
|
|
1
|
+
import React, {cloneElement, forwardRef, useCallback, useEffect, useRef, useState} from 'react'
|
|
2
2
|
import {usePopper} from 'react-popper'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
4
|
import {useArrayProp, useForwardedRef} from '../../hooks'
|
|
@@ -48,19 +48,6 @@ export function responsiveFont(
|
|
|
48
48
|
},
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
// @TODO fix the real condition that is causing $size to be undefined sometimes
|
|
52
|
-
if (!$size) {
|
|
53
|
-
// @ts-expect-error: `warned` isn't typed, the underlying issue should be solved rather than typing it
|
|
54
|
-
if (!responsiveFont.warned) {
|
|
55
|
-
// eslint-disable-next-line no-console
|
|
56
|
-
console.warn('No size specified for responsive font', {fontKey, $size, props, base})
|
|
57
|
-
// @ts-expect-error: `warned` isn't typed, the underlying issue should be solved rather than typing it
|
|
58
|
-
responsiveFont.warned = true
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return [base]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
51
|
const resp = _responsive(media, $size, (sizeIndex) => fontSize(sizes[sizeIndex] || defaultSize))
|
|
65
52
|
|
|
66
53
|
return [base, ...resp]
|
package/src/styles/helpers.ts
CHANGED
|
@@ -30,7 +30,7 @@ export function _responsive<T>(
|
|
|
30
30
|
values: T[],
|
|
31
31
|
callback: (value: T, index: number, array: T[]) => CSSObject
|
|
32
32
|
): CSSObject[] {
|
|
33
|
-
const statements = values
|
|
33
|
+
const statements = values?.map(callback) || []
|
|
34
34
|
|
|
35
35
|
return statements.map((statement, mediaIndex) => {
|
|
36
36
|
if (mediaIndex === 0) return statement
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
useRootTheme,
|
|
23
23
|
} from '@sanity/ui'
|
|
24
24
|
import {useBoolean} from '@sanity/ui-workshop'
|
|
25
|
-
import {createContext, useContext} from 'react'
|
|
25
|
+
import React, {createContext, useContext} from 'react'
|
|
26
26
|
import {ThemeColorCard} from '../lib/theme'
|
|
27
27
|
|
|
28
28
|
interface Features {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Box, Button, Container, Dialog, Flex, Popover, Stack, Text, Tooltip} from '@sanity/ui'
|
|
2
|
-
import {useCallback, useState} from 'react'
|
|
2
|
+
import React, {useCallback, useState} from 'react'
|
|
3
3
|
|
|
4
4
|
export default function LayerStory() {
|
|
5
5
|
const [dialogOpen, setDialogOpen] = useState(false)
|
package/src/theme/theme.test.tsx
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {vi} from 'vitest'
|
|
1
3
|
import {render} from '../../test'
|
|
2
4
|
import {studioTheme} from './studioTheme'
|
|
3
5
|
import {ThemeContext} from './themeContext'
|
|
@@ -7,7 +9,7 @@ import {useRootTheme} from './useRootTheme'
|
|
|
7
9
|
describe('theme', () => {
|
|
8
10
|
describe('useRootTheme', () => {
|
|
9
11
|
it('should get context value', async () => {
|
|
10
|
-
const log =
|
|
12
|
+
const log = vi.fn()
|
|
11
13
|
|
|
12
14
|
function Debug() {
|
|
13
15
|
const rootTheme = useRootTheme()
|
|
@@ -40,7 +42,7 @@ describe('theme', () => {
|
|
|
40
42
|
})
|
|
41
43
|
|
|
42
44
|
it('should fail when no context value is provided', async () => {
|
|
43
|
-
const log =
|
|
45
|
+
const log = vi.fn()
|
|
44
46
|
|
|
45
47
|
function Debug() {
|
|
46
48
|
try {
|
|
@@ -68,7 +70,7 @@ describe('theme', () => {
|
|
|
68
70
|
})
|
|
69
71
|
|
|
70
72
|
it('should fail when context value is not compatible', async () => {
|
|
71
|
-
const log =
|
|
73
|
+
const log = vi.fn()
|
|
72
74
|
|
|
73
75
|
function Debug() {
|
|
74
76
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useContext, useMemo} from 'react'
|
|
1
|
+
import React, {useContext, useMemo} from 'react'
|
|
2
2
|
import {ThemeProvider as StyledThemeProvider} from 'styled-components'
|
|
3
3
|
import {DEFAULT_THEME_LAYER} from './defaults'
|
|
4
4
|
import {ThemeColorSchemeKey, ThemeColorName} from './lib/theme'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Box, BoundaryElementProvider, Button, Card, Text, Tooltip} from '@sanity/ui'
|
|
2
|
-
import {useState} from 'react'
|
|
2
|
+
import React, {useState} from 'react'
|
|
3
3
|
|
|
4
4
|
export default function PlainStory() {
|
|
5
5
|
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {vi} from 'vitest'
|
|
1
3
|
import {render} from '../../../test'
|
|
2
4
|
import {BoundaryElementContext} from './boundaryElementContext'
|
|
3
5
|
import {BoundaryElementContextValue} from './types'
|
|
@@ -6,7 +8,7 @@ import {useBoundaryElement} from './useBoundaryElement'
|
|
|
6
8
|
describe('utils/boundaryElement', () => {
|
|
7
9
|
describe('useBoundaryElement', () => {
|
|
8
10
|
it('should get context value', async () => {
|
|
9
|
-
const log =
|
|
11
|
+
const log = vi.fn()
|
|
10
12
|
|
|
11
13
|
function Debug() {
|
|
12
14
|
const rootBoundaryElement = useBoundaryElement()
|
|
@@ -36,7 +38,7 @@ describe('utils/boundaryElement', () => {
|
|
|
36
38
|
})
|
|
37
39
|
|
|
38
40
|
it('should provide default value when no context value is provided', async () => {
|
|
39
|
-
const log =
|
|
41
|
+
const log = vi.fn()
|
|
40
42
|
|
|
41
43
|
function Debug() {
|
|
42
44
|
const rootBoundaryElement = useBoundaryElement()
|
|
@@ -63,7 +65,7 @@ describe('utils/boundaryElement', () => {
|
|
|
63
65
|
})
|
|
64
66
|
|
|
65
67
|
it('should fail when context value is not compatible', async () => {
|
|
66
|
-
const log =
|
|
68
|
+
const log = vi.fn()
|
|
67
69
|
|
|
68
70
|
function Debug() {
|
|
69
71
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {forwardRef, useCallback, useMemo, useState} from 'react'
|
|
1
|
+
import React, {forwardRef, useCallback, useMemo, useState} from 'react'
|
|
2
2
|
import {useElementSize, useForwardedRef} from '../../hooks'
|
|
3
3
|
import {useTheme} from '../../theme'
|
|
4
4
|
import {findMaxBreakpoints, findMinBreakpoints} from './helpers'
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import {Code} from '../primitives/code'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* DO NOT USE IN PRODUCTION
|
|
6
6
|
* @beta
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export interface ErrorBoundaryProps {
|
|
9
9
|
onCatch: (params: {error: Error; info: React.ErrorInfo}) => void
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* DO NOT USE IN PRODUCTION
|
|
@@ -21,7 +21,7 @@ export interface ErrorBoundaryState {
|
|
|
21
21
|
* DO NOT USE IN PRODUCTION
|
|
22
22
|
* @beta
|
|
23
23
|
*/
|
|
24
|
-
export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
24
|
+
export class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
25
25
|
state: ErrorBoundaryState = {error: null}
|
|
26
26
|
|
|
27
27
|
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {CloseIcon} from '@sanity/icons'
|
|
2
2
|
import {Box, Button, Card, Flex, Layer, LayerProvider, Stack, Text} from '@sanity/ui'
|
|
3
|
-
import {useCallback, useState} from 'react'
|
|
3
|
+
import React, {useCallback, useState} from 'react'
|
|
4
4
|
import {LayerDebugInfo} from './_debug'
|
|
5
5
|
|
|
6
6
|
export default function PlainStory() {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {vi} from 'vitest'
|
|
1
3
|
import {render} from '../../../test'
|
|
2
4
|
import {LayerContext} from './layerContext'
|
|
3
5
|
import {LayerContextValue} from './types'
|
|
@@ -6,7 +8,7 @@ import {useLayer} from './useLayer'
|
|
|
6
8
|
describe('utils/layer', () => {
|
|
7
9
|
describe('useLayer', () => {
|
|
8
10
|
it('should get context value', async () => {
|
|
9
|
-
const log =
|
|
11
|
+
const log = vi.fn()
|
|
10
12
|
|
|
11
13
|
function Debug() {
|
|
12
14
|
const rootLayer = useLayer()
|
|
@@ -42,7 +44,7 @@ describe('utils/layer', () => {
|
|
|
42
44
|
})
|
|
43
45
|
|
|
44
46
|
it('should fail when no context value is provided', async () => {
|
|
45
|
-
const log =
|
|
47
|
+
const log = vi.fn()
|
|
46
48
|
|
|
47
49
|
function Debug() {
|
|
48
50
|
try {
|
|
@@ -70,7 +72,7 @@ describe('utils/layer', () => {
|
|
|
70
72
|
})
|
|
71
73
|
|
|
72
74
|
it('should fail when context value is not compatible', async () => {
|
|
73
|
-
const log =
|
|
75
|
+
const log = vi.fn()
|
|
74
76
|
|
|
75
77
|
function Debug() {
|
|
76
78
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useCallback, useContext, useEffect, useMemo, useState} from 'react'
|
|
1
|
+
import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react'
|
|
2
2
|
import {useMediaIndex, useArrayProp} from '../../hooks'
|
|
3
3
|
import {LayerContext} from './layerContext'
|
|
4
4
|
import {LayerContextValue} from './types'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Card, Container, Portal, PortalProvider, Stack, Text} from '@sanity/ui'
|
|
2
|
-
import {useState} from 'react'
|
|
2
|
+
import React, {useState} from 'react'
|
|
3
3
|
|
|
4
4
|
export default function NamedStory() {
|
|
5
5
|
const [portal1Element, setPortal1Element] = useState<HTMLDivElement | null>(null)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {vi} from 'vitest'
|
|
1
3
|
import {render} from '../../../test'
|
|
2
4
|
import {PortalContext} from './portalContext'
|
|
3
5
|
import {PortalContextValue} from './types'
|
|
@@ -6,7 +8,7 @@ import {usePortal} from './usePortal'
|
|
|
6
8
|
describe('utils/portal', () => {
|
|
7
9
|
describe('usePortal', () => {
|
|
8
10
|
it('should get context value', async () => {
|
|
9
|
-
const log =
|
|
11
|
+
const log = vi.fn()
|
|
10
12
|
|
|
11
13
|
function Debug() {
|
|
12
14
|
const rootPortal = usePortal()
|
|
@@ -38,7 +40,7 @@ describe('utils/portal', () => {
|
|
|
38
40
|
})
|
|
39
41
|
|
|
40
42
|
it('should fail when no context value is provided', async () => {
|
|
41
|
-
const log =
|
|
43
|
+
const log = vi.fn()
|
|
42
44
|
|
|
43
45
|
function Debug() {
|
|
44
46
|
try {
|
|
@@ -66,7 +68,7 @@ describe('utils/portal', () => {
|
|
|
66
68
|
})
|
|
67
69
|
|
|
68
70
|
it('should fail when context value is not compatible', async () => {
|
|
69
|
-
const log =
|
|
71
|
+
const log = vi.fn()
|
|
70
72
|
|
|
71
73
|
function Debug() {
|
|
72
74
|
try {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import ReactDOM from 'react-dom'
|
|
2
3
|
import {usePortal} from './usePortal'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -25,5 +26,5 @@ export function Portal(props: PortalProps): React.ReactPortal | null {
|
|
|
25
26
|
return null
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
return createPortal(children, portalElement)
|
|
29
|
+
return ReactDOM.createPortal(children, portalElement)
|
|
29
30
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {forwardRef, useEffect, useMemo, useRef, useState} from 'react'
|
|
1
|
+
import React, {forwardRef, useEffect, useMemo, useRef, useState} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
import {_isScrollable} from '../../helpers'
|
|
4
4
|
import {useForwardedRef} from '../../hooks'
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {axe} from 'jest-axe'
|
|
2
|
-
import {render} from '../../../test'
|
|
3
|
-
import {Badge} from './badge'
|
|
4
|
-
|
|
5
|
-
describe('atoms/badge', () => {
|
|
6
|
-
it('should have no violations (axe)', async () => {
|
|
7
|
-
const lightResult = render(<Badge tone="positive">Label</Badge>, {scheme: 'light'})
|
|
8
|
-
const darkResult = render(<Badge tone="positive">Label</Badge>, {scheme: 'dark'})
|
|
9
|
-
|
|
10
|
-
expect(await axe(lightResult.container.outerHTML)).toHaveNoViolations()
|
|
11
|
-
expect(await axe(darkResult.container.outerHTML)).toHaveNoViolations()
|
|
12
|
-
})
|
|
13
|
-
})
|