@sanity/ui 0.38.2-next.4 → 0.38.2
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/sanity-ui.cjs +260 -9740
- package/dist/sanity-ui.cjs.map +1 -1
- package/dist/sanity-ui.js +260 -9614
- package/dist/sanity-ui.js.map +1 -1
- package/package.json +12 -10
- package/src/components/menu/menu.test.tsx +4 -3
- package/src/components/toast/toast.test.tsx +4 -3
- package/src/primitives/avatar/avatar.tsx +7 -1
- package/src/styles/font/responsiveFont.ts +0 -13
- package/src/styles/helpers.ts +1 -1
- package/src/theme/theme.test.tsx +4 -3
- package/src/utils/boundaryElement/boundaryElement.test.tsx +4 -3
- package/src/utils/layer/layer.test.tsx +4 -3
- package/src/utils/portal/portal.test.tsx +4 -3
- package/src/primitives/badge/badge.test.tsx +0 -14
- package/src/primitives/button/button.test.tsx +0 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "0.38.2
|
|
3
|
+
"version": "0.38.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"module": "./dist/sanity-ui.js",
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
"main": "./dist/sanity-ui.cjs",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"source": "./src/index.ts",
|
|
12
|
-
"default": "./dist/sanity-ui.js",
|
|
13
11
|
"types": "./dist/types/src/index.d.ts",
|
|
14
|
-
"
|
|
12
|
+
"source": "./src/index.ts",
|
|
13
|
+
"import": "./dist/sanity-ui.js",
|
|
14
|
+
"require": "./dist/sanity-ui.cjs",
|
|
15
|
+
"default": "./dist/sanity-ui.js"
|
|
15
16
|
}
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
@@ -21,10 +22,12 @@
|
|
|
21
22
|
"license": "MIT",
|
|
22
23
|
"scripts": {
|
|
23
24
|
"build": "pkg build --tsconfig tsconfig.dist.json",
|
|
25
|
+
"check:package": "pkg --strict --tsconfig tsconfig.dist.json",
|
|
24
26
|
"clean": "rimraf dist",
|
|
25
27
|
"lint": "eslint . --ext .js,.jsx,.mjs,.ts,.tsx --quiet",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
+
"postbuild": "run-s check:package",
|
|
29
|
+
"prebuild": "run-s clean",
|
|
30
|
+
"test": "vitest run",
|
|
28
31
|
"type-check": "tsc --build",
|
|
29
32
|
"watch": "pkg watch --tsconfig tsconfig.dist.json"
|
|
30
33
|
},
|
|
@@ -32,8 +35,8 @@
|
|
|
32
35
|
"@juggle/resize-observer": "^3.4.0",
|
|
33
36
|
"@popperjs/core": "^2.11.6",
|
|
34
37
|
"@reach/auto-id": "^0.17.0",
|
|
35
|
-
"@sanity/color": "2.1.16
|
|
36
|
-
"@sanity/icons": "1.3.6
|
|
38
|
+
"@sanity/color": "^2.1.16",
|
|
39
|
+
"@sanity/icons": "^1.3.6",
|
|
37
40
|
"framer-motion": "6.3.0",
|
|
38
41
|
"popper-max-size-modifier": "^0.2.0",
|
|
39
42
|
"react-is": "^17.0.2",
|
|
@@ -42,7 +45,6 @@
|
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
44
47
|
"@testing-library/dom": "^8.17.1",
|
|
45
|
-
"@testing-library/jest-dom": "^5.16.5",
|
|
46
48
|
"@testing-library/react": "^12.1.5",
|
|
47
49
|
"@types/refractor": "^3.0.2",
|
|
48
50
|
"react": "^17.0.2",
|
|
@@ -71,5 +73,5 @@
|
|
|
71
73
|
"publishConfig": {
|
|
72
74
|
"access": "public"
|
|
73
75
|
},
|
|
74
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "4c9ab2537fa3b3d437de5ca979b6fb932f3d115b"
|
|
75
77
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
|
|
3
3
|
import React, {useCallback, useMemo} from 'react'
|
|
4
|
+
import {vi} from 'vitest'
|
|
4
5
|
import {render} from '../../../test'
|
|
5
6
|
import {MenuContext, MenuContextValue} from './menuContext'
|
|
6
7
|
import {useMenu} from './useMenu'
|
|
@@ -8,7 +9,7 @@ import {useMenu} from './useMenu'
|
|
|
8
9
|
describe('components/menu', () => {
|
|
9
10
|
describe('useMenu', () => {
|
|
10
11
|
it('should get context value', async () => {
|
|
11
|
-
const log =
|
|
12
|
+
const log = vi.fn()
|
|
12
13
|
|
|
13
14
|
function Debug() {
|
|
14
15
|
const rootMenu = useMenu()
|
|
@@ -64,7 +65,7 @@ describe('components/menu', () => {
|
|
|
64
65
|
})
|
|
65
66
|
|
|
66
67
|
it('should fail when no context value is provided', async () => {
|
|
67
|
-
const log =
|
|
68
|
+
const log = vi.fn()
|
|
68
69
|
|
|
69
70
|
function Debug() {
|
|
70
71
|
try {
|
|
@@ -93,7 +94,7 @@ describe('components/menu', () => {
|
|
|
93
94
|
})
|
|
94
95
|
|
|
95
96
|
it('should fail when context value is not compatible', async () => {
|
|
96
|
-
const log =
|
|
97
|
+
const log = vi.fn()
|
|
97
98
|
|
|
98
99
|
function Debug() {
|
|
99
100
|
try {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import {vi} from 'vitest'
|
|
2
3
|
import {render} from '../../../test'
|
|
3
4
|
import {ToastContext} from './toastContext'
|
|
4
5
|
import {ToastContextValue} from './types'
|
|
@@ -7,7 +8,7 @@ import {useToast} from './useToast'
|
|
|
7
8
|
describe('components/toast', () => {
|
|
8
9
|
describe('useToast', () => {
|
|
9
10
|
it('should get context value', async () => {
|
|
10
|
-
const log =
|
|
11
|
+
const log = vi.fn()
|
|
11
12
|
|
|
12
13
|
function Debug() {
|
|
13
14
|
const rootToast = useToast()
|
|
@@ -37,7 +38,7 @@ describe('components/toast', () => {
|
|
|
37
38
|
})
|
|
38
39
|
|
|
39
40
|
it('should fail when no context value is provided', async () => {
|
|
40
|
-
const log =
|
|
41
|
+
const log = vi.fn()
|
|
41
42
|
|
|
42
43
|
function Debug() {
|
|
43
44
|
try {
|
|
@@ -65,7 +66,7 @@ describe('components/toast', () => {
|
|
|
65
66
|
})
|
|
66
67
|
|
|
67
68
|
it('should fail when context value is not compatible', async () => {
|
|
68
|
-
const log =
|
|
69
|
+
const log = vi.fn()
|
|
69
70
|
|
|
70
71
|
function Debug() {
|
|
71
72
|
try {
|
|
@@ -130,7 +130,13 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
130
130
|
<svg viewBox={`0 0 ${_sizeRem} ${_sizeRem}`} fill="none">
|
|
131
131
|
<defs>
|
|
132
132
|
<pattern id={imageId} patternContentUnits="objectBoundingBox" width="1" height="1">
|
|
133
|
-
<image
|
|
133
|
+
<image
|
|
134
|
+
href={src}
|
|
135
|
+
width="1"
|
|
136
|
+
height="1"
|
|
137
|
+
// eslint-disable-next-line react/no-unknown-property
|
|
138
|
+
onError={handleImageError}
|
|
139
|
+
/>
|
|
134
140
|
</pattern>
|
|
135
141
|
</defs>
|
|
136
142
|
|
|
@@ -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
|
package/src/theme/theme.test.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import {vi} from 'vitest'
|
|
2
3
|
import {render} from '../../test'
|
|
3
4
|
import {studioTheme} from './studioTheme'
|
|
4
5
|
import {ThemeContext} from './themeContext'
|
|
@@ -8,7 +9,7 @@ import {useRootTheme} from './useRootTheme'
|
|
|
8
9
|
describe('theme', () => {
|
|
9
10
|
describe('useRootTheme', () => {
|
|
10
11
|
it('should get context value', async () => {
|
|
11
|
-
const log =
|
|
12
|
+
const log = vi.fn()
|
|
12
13
|
|
|
13
14
|
function Debug() {
|
|
14
15
|
const rootTheme = useRootTheme()
|
|
@@ -41,7 +42,7 @@ describe('theme', () => {
|
|
|
41
42
|
})
|
|
42
43
|
|
|
43
44
|
it('should fail when no context value is provided', async () => {
|
|
44
|
-
const log =
|
|
45
|
+
const log = vi.fn()
|
|
45
46
|
|
|
46
47
|
function Debug() {
|
|
47
48
|
try {
|
|
@@ -69,7 +70,7 @@ describe('theme', () => {
|
|
|
69
70
|
})
|
|
70
71
|
|
|
71
72
|
it('should fail when context value is not compatible', async () => {
|
|
72
|
-
const log =
|
|
73
|
+
const log = vi.fn()
|
|
73
74
|
|
|
74
75
|
function Debug() {
|
|
75
76
|
try {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import {vi} from 'vitest'
|
|
2
3
|
import {render} from '../../../test'
|
|
3
4
|
import {BoundaryElementContext} from './boundaryElementContext'
|
|
4
5
|
import {BoundaryElementContextValue} from './types'
|
|
@@ -7,7 +8,7 @@ import {useBoundaryElement} from './useBoundaryElement'
|
|
|
7
8
|
describe('utils/boundaryElement', () => {
|
|
8
9
|
describe('useBoundaryElement', () => {
|
|
9
10
|
it('should get context value', async () => {
|
|
10
|
-
const log =
|
|
11
|
+
const log = vi.fn()
|
|
11
12
|
|
|
12
13
|
function Debug() {
|
|
13
14
|
const rootBoundaryElement = useBoundaryElement()
|
|
@@ -37,7 +38,7 @@ describe('utils/boundaryElement', () => {
|
|
|
37
38
|
})
|
|
38
39
|
|
|
39
40
|
it('should provide default value when no context value is provided', async () => {
|
|
40
|
-
const log =
|
|
41
|
+
const log = vi.fn()
|
|
41
42
|
|
|
42
43
|
function Debug() {
|
|
43
44
|
const rootBoundaryElement = useBoundaryElement()
|
|
@@ -64,7 +65,7 @@ describe('utils/boundaryElement', () => {
|
|
|
64
65
|
})
|
|
65
66
|
|
|
66
67
|
it('should fail when context value is not compatible', async () => {
|
|
67
|
-
const log =
|
|
68
|
+
const log = vi.fn()
|
|
68
69
|
|
|
69
70
|
function Debug() {
|
|
70
71
|
try {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import {vi} from 'vitest'
|
|
2
3
|
import {render} from '../../../test'
|
|
3
4
|
import {LayerContext} from './layerContext'
|
|
4
5
|
import {LayerContextValue} from './types'
|
|
@@ -7,7 +8,7 @@ import {useLayer} from './useLayer'
|
|
|
7
8
|
describe('utils/layer', () => {
|
|
8
9
|
describe('useLayer', () => {
|
|
9
10
|
it('should get context value', async () => {
|
|
10
|
-
const log =
|
|
11
|
+
const log = vi.fn()
|
|
11
12
|
|
|
12
13
|
function Debug() {
|
|
13
14
|
const rootLayer = useLayer()
|
|
@@ -43,7 +44,7 @@ describe('utils/layer', () => {
|
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
it('should fail when no context value is provided', async () => {
|
|
46
|
-
const log =
|
|
47
|
+
const log = vi.fn()
|
|
47
48
|
|
|
48
49
|
function Debug() {
|
|
49
50
|
try {
|
|
@@ -71,7 +72,7 @@ describe('utils/layer', () => {
|
|
|
71
72
|
})
|
|
72
73
|
|
|
73
74
|
it('should fail when context value is not compatible', async () => {
|
|
74
|
-
const log =
|
|
75
|
+
const log = vi.fn()
|
|
75
76
|
|
|
76
77
|
function Debug() {
|
|
77
78
|
try {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import {vi} from 'vitest'
|
|
2
3
|
import {render} from '../../../test'
|
|
3
4
|
import {PortalContext} from './portalContext'
|
|
4
5
|
import {PortalContextValue} from './types'
|
|
@@ -7,7 +8,7 @@ import {usePortal} from './usePortal'
|
|
|
7
8
|
describe('utils/portal', () => {
|
|
8
9
|
describe('usePortal', () => {
|
|
9
10
|
it('should get context value', async () => {
|
|
10
|
-
const log =
|
|
11
|
+
const log = vi.fn()
|
|
11
12
|
|
|
12
13
|
function Debug() {
|
|
13
14
|
const rootPortal = usePortal()
|
|
@@ -39,7 +40,7 @@ describe('utils/portal', () => {
|
|
|
39
40
|
})
|
|
40
41
|
|
|
41
42
|
it('should fail when no context value is provided', async () => {
|
|
42
|
-
const log =
|
|
43
|
+
const log = vi.fn()
|
|
43
44
|
|
|
44
45
|
function Debug() {
|
|
45
46
|
try {
|
|
@@ -67,7 +68,7 @@ describe('utils/portal', () => {
|
|
|
67
68
|
})
|
|
68
69
|
|
|
69
70
|
it('should fail when context value is not compatible', async () => {
|
|
70
|
-
const log =
|
|
71
|
+
const log = vi.fn()
|
|
71
72
|
|
|
72
73
|
function Debug() {
|
|
73
74
|
try {
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {axe} from 'jest-axe'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import {render} from '../../../test'
|
|
4
|
-
import {Badge} from './badge'
|
|
5
|
-
|
|
6
|
-
describe('atoms/badge', () => {
|
|
7
|
-
it('should have no violations (axe)', async () => {
|
|
8
|
-
const lightResult = render(<Badge tone="positive">Label</Badge>, {scheme: 'light'})
|
|
9
|
-
const darkResult = render(<Badge tone="positive">Label</Badge>, {scheme: 'dark'})
|
|
10
|
-
|
|
11
|
-
expect(await axe(lightResult.container.outerHTML)).toHaveNoViolations()
|
|
12
|
-
expect(await axe(darkResult.container.outerHTML)).toHaveNoViolations()
|
|
13
|
-
})
|
|
14
|
-
})
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {AddIcon} from '@sanity/icons'
|
|
2
|
-
import {screen} from '@testing-library/react'
|
|
3
|
-
import {axe} from 'jest-axe'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
import {render} from '../../../test'
|
|
6
|
-
import {Button, ButtonProps} from './button'
|
|
7
|
-
|
|
8
|
-
describe('atoms/button', () => {
|
|
9
|
-
it('Axe: should have no violations', async () => {
|
|
10
|
-
const lightResult = render(<Button icon={AddIcon} text="Label" tone="positive" />, {
|
|
11
|
-
scheme: 'light',
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
expect(await axe(lightResult.container.outerHTML)).toHaveNoViolations()
|
|
15
|
-
|
|
16
|
-
const darkResult = render(<Button icon={AddIcon} text="Label" tone="positive" />, {
|
|
17
|
-
scheme: 'dark',
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
expect(await axe(darkResult.container.outerHTML)).toHaveNoViolations()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('should render text', () => {
|
|
24
|
-
render(<Button text="Button text" />)
|
|
25
|
-
|
|
26
|
-
expect(screen.getByText('Button text')).toBeInTheDocument()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('should wrap button', () => {
|
|
30
|
-
function WrappedButton({button: buttonProps}: {button: ButtonProps}) {
|
|
31
|
-
return <Button {...buttonProps} />
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const buttonProps: ButtonProps = {
|
|
35
|
-
text: 'Button text',
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
render(<WrappedButton button={buttonProps} />)
|
|
39
|
-
|
|
40
|
-
expect(screen.getByText('Button text')).toBeInTheDocument()
|
|
41
|
-
})
|
|
42
|
-
})
|