@sanity/ui 0.38.1-next.6 → 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/dist/sanity-ui.cjs +238 -238
- package/dist/sanity-ui.cjs.map +1 -1
- package/dist/sanity-ui.js +246 -246
- package/dist/sanity-ui.js.map +1 -1
- package/dist/types/src/index.d.ts +9 -6
- 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/hooks/useArrayProp.ts +3 -2
- package/src/hooks/useElementRect/useElementRect.ts +2 -0
- package/src/primitives/avatar/avatar.tsx +7 -1
- package/src/styles/helpers.ts +1 -1
- package/src/theme/lib/theme/color/button/types.ts +1 -1
- package/src/theme/lib/theme/shadow.ts +1 -1
- package/src/theme/theme.test.tsx +4 -3
- package/src/theme/types.ts +1 -1
- 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
|
@@ -4,6 +4,9 @@ import {CSSObject} from 'styled-components'
|
|
|
4
4
|
import {default as React_2} from 'react'
|
|
5
5
|
import {StyledComponent} from 'styled-components'
|
|
6
6
|
|
|
7
|
+
/** @beta */
|
|
8
|
+
export declare type ArrayPropPrimitive = string | number | boolean | undefined | null
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* @internal
|
|
9
12
|
*/
|
|
@@ -1153,8 +1156,8 @@ export declare interface BoxProps
|
|
|
1153
1156
|
}
|
|
1154
1157
|
|
|
1155
1158
|
/**
|
|
1159
|
+
* TODO: Rename to `ThemeBoxShadow`
|
|
1156
1160
|
* @public
|
|
1157
|
-
* @todo Rename to `ThemeBoxShadow`
|
|
1158
1161
|
*/
|
|
1159
1162
|
export declare type BoxShadow = [number, number, number, number]
|
|
1160
1163
|
|
|
@@ -8669,8 +8672,6 @@ export declare interface PortalProviderProps {
|
|
|
8669
8672
|
__unstable_elements?: Record<string, HTMLElement | null | undefined>
|
|
8670
8673
|
}
|
|
8671
8674
|
|
|
8672
|
-
export declare type Primitive = string | number | boolean | undefined | null
|
|
8673
|
-
|
|
8674
8675
|
/**
|
|
8675
8676
|
* @public
|
|
8676
8677
|
*/
|
|
@@ -10872,7 +10873,7 @@ export declare interface StackProps extends BoxProps {
|
|
|
10872
10873
|
export declare const studioTheme: RootTheme
|
|
10873
10874
|
|
|
10874
10875
|
/**
|
|
10875
|
-
*
|
|
10876
|
+
* TODO: Rename to `ThemeStyles`
|
|
10876
10877
|
* @public
|
|
10877
10878
|
*/
|
|
10878
10879
|
export declare interface Styles {
|
|
@@ -14104,8 +14105,8 @@ export declare interface ThemeColorButtonStates {
|
|
|
14104
14105
|
}
|
|
14105
14106
|
|
|
14106
14107
|
/**
|
|
14108
|
+
* TODO: Rename to `ThemeColorButtonMode`.
|
|
14107
14109
|
* @public
|
|
14108
|
-
* @todo Rename to `ThemeColorButtonMode`.
|
|
14109
14110
|
*/
|
|
14110
14111
|
export declare interface ThemeColorButtonTones {
|
|
14111
14112
|
default: ThemeColorButtonStates
|
|
@@ -15038,7 +15039,7 @@ export declare interface TreeState {
|
|
|
15038
15039
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
15039
15040
|
* @beta
|
|
15040
15041
|
*/
|
|
15041
|
-
export declare function useArrayProp<T extends
|
|
15042
|
+
export declare function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
|
|
15042
15043
|
val: T | T[] | undefined,
|
|
15043
15044
|
defaultVal?: T[]
|
|
15044
15045
|
): T[]
|
|
@@ -15077,6 +15078,8 @@ export declare function useDialog(): DialogContextValue
|
|
|
15077
15078
|
|
|
15078
15079
|
/**
|
|
15079
15080
|
* Subscribe to the rect of a DOM element.
|
|
15081
|
+
* @beta
|
|
15082
|
+
*
|
|
15080
15083
|
* @deprecated Use `useElementSize` instead
|
|
15081
15084
|
*/
|
|
15082
15085
|
export declare function useElementRect(element: HTMLElement | null): DOMRectReadOnly | null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.2-next.16+92171d95",
|
|
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.
|
|
36
|
-
"@sanity/icons": "1.3.
|
|
38
|
+
"@sanity/color": "2.1.16-next.16+92171d95",
|
|
39
|
+
"@sanity/icons": "1.3.6-next.16+92171d95",
|
|
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": "92171d95fb67bb758aa160067afba1739d344a04"
|
|
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 {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {useMemo} from 'react'
|
|
2
2
|
import {_getArrayProp} from '../styles'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/** @beta */
|
|
5
|
+
export type ArrayPropPrimitive = string | number | boolean | undefined | null
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
8
9
|
* @beta
|
|
9
10
|
*/
|
|
10
|
-
export function useArrayProp<T extends
|
|
11
|
+
export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
|
|
11
12
|
val: T | T[] | undefined,
|
|
12
13
|
defaultVal?: T[]
|
|
13
14
|
): T[] {
|
|
@@ -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
|
|
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 {
|
package/src/theme/types.ts
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 {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
|
-
})
|