@sanity/ui 3.2.0 → 3.3.1
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 +12 -0
- package/dist/_chunks-cjs/_visual-editing.js +54 -43
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +54 -43
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +129 -75
- package/dist/_visual-editing.d.ts +129 -75
- package/dist/index.d.mts +222 -139
- package/dist/index.d.ts +222 -139
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +10 -4
- package/dist/theme.d.ts +10 -4
- package/package.json +19 -82
- package/src/core/components/autocomplete/autocomplete.tsx +1 -1
- package/src/core/components/autocomplete/types.ts +2 -2
- package/src/core/components/menu/__workshop__/asComponent.tsx +1 -1
- package/src/core/components/menu/menuDivider.ts +16 -5
- package/src/core/components/menu/menuGroup.spacing.test.tsx +1 -7
- package/src/core/components/menu/menuGroup.tsx +14 -6
- package/src/core/components/menu/menuItem.tsx +17 -6
- package/src/core/components/skeleton/skeleton.tsx +2 -2
- package/src/core/components/tab/tabList.tsx +2 -2
- package/src/core/components/tab/tabPanel.tsx +2 -2
- package/src/core/components/toast/styles.ts +2 -2
- package/src/core/components/tree/__workshop__/basic.perf.ts +1 -1
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +1 -1
- package/src/core/components/tree/tree.tsx +9 -6
- package/src/core/components/tree/treeGroup.tsx +1 -1
- package/src/core/components/tree/treeItem.tsx +3 -2
- package/src/core/primitives/avatar/avatar.tsx +19 -11
- package/src/core/primitives/badge/badge.tsx +20 -12
- package/src/core/primitives/box/__workshop__/asComponent.tsx +31 -0
- package/src/core/primitives/box/__workshop__/index.ts +5 -0
- package/src/core/primitives/box/box.test.tsx +12 -4
- package/src/core/primitives/box/box.tsx +23 -12
- package/src/core/primitives/button/__workshop__/disabled.tsx +2 -2
- package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +1 -1
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +1 -1
- package/src/core/primitives/button/button.test.tsx +3 -3
- package/src/core/primitives/button/button.tsx +28 -9
- package/src/core/primitives/card/__workshop__/asComponent.tsx +1 -1
- package/src/core/primitives/card/card.tsx +24 -13
- package/src/core/primitives/code/code.tsx +16 -7
- package/src/core/primitives/container/container.tsx +23 -10
- package/src/core/primitives/flex/flex.tsx +21 -11
- package/src/core/primitives/grid/grid.test.tsx +3 -1
- package/src/core/primitives/grid/grid.tsx +22 -9
- package/src/core/primitives/heading/heading.tsx +19 -11
- package/src/core/primitives/inline/inline.tsx +19 -9
- package/src/core/primitives/kbd/kbd.tsx +19 -11
- package/src/core/primitives/label/label.tsx +19 -11
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +1 -1
- package/src/core/primitives/stack/stack.tsx +20 -11
- package/src/core/primitives/text/text.tsx +19 -11
- package/src/core/primitives/textInput/textInput.tsx +2 -2
- package/src/core/types/component.ts +32 -0
- package/src/core/types/index.ts +1 -0
- package/src/core/utils/virtualList/virtualList.tsx +2 -2
- package/src/theme/system/css.ts +10 -4
package/dist/theme.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ColorHueKey} from '@sanity/color'
|
|
2
2
|
import {ColorTint} from '@sanity/color'
|
|
3
3
|
import {ColorTintKey} from '@sanity/color'
|
|
4
|
-
import type
|
|
4
|
+
import type * as CSS_2 from 'csstype'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @public
|
|
@@ -229,11 +229,17 @@ export declare function createColorTheme(
|
|
|
229
229
|
): ThemeColorSchemes
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
232
|
+
* A CSS-in-JS style object: standard CSS properties plus an index signature that allows nested
|
|
233
|
+
* selectors, at-rules and custom properties.
|
|
234
|
+
*
|
|
235
|
+
* This is a self-owned definition (based on `csstype`) so the published `.d.ts` types stay fully
|
|
236
|
+
* controlled by us and do not reference any external CSS-in-JS library types.
|
|
237
|
+
*
|
|
234
238
|
* @internal
|
|
235
239
|
*/
|
|
236
|
-
export declare
|
|
240
|
+
export declare interface CSSObject extends CSS_2.Properties<number | (string & {})> {
|
|
241
|
+
[key: string]: CSSObject | string | number | undefined
|
|
242
|
+
}
|
|
237
243
|
|
|
238
244
|
/** @internal */
|
|
239
245
|
export declare function getContrastRatio(bg: string, fg: string): number
|
package/dist/theme.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ColorHueKey} from '@sanity/color'
|
|
2
2
|
import {ColorTint} from '@sanity/color'
|
|
3
3
|
import {ColorTintKey} from '@sanity/color'
|
|
4
|
-
import type
|
|
4
|
+
import type * as CSS_2 from 'csstype'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @public
|
|
@@ -229,11 +229,17 @@ export declare function createColorTheme(
|
|
|
229
229
|
): ThemeColorSchemes
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
232
|
+
* A CSS-in-JS style object: standard CSS properties plus an index signature that allows nested
|
|
233
|
+
* selectors, at-rules and custom properties.
|
|
234
|
+
*
|
|
235
|
+
* This is a self-owned definition (based on `csstype`) so the published `.d.ts` types stay fully
|
|
236
|
+
* controlled by us and do not reference any external CSS-in-JS library types.
|
|
237
|
+
*
|
|
234
238
|
* @internal
|
|
235
239
|
*/
|
|
236
|
-
export declare
|
|
240
|
+
export declare interface CSSObject extends CSS_2.Properties<number | (string & {})> {
|
|
241
|
+
[key: string]: CSSObject | string | number | undefined
|
|
242
|
+
}
|
|
237
243
|
|
|
238
244
|
/** @internal */
|
|
239
245
|
export declare function getContrastRatio(bg: string, fg: string): number
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"sanity",
|
|
6
6
|
"ui",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/sanity-io/ui.git"
|
|
18
|
+
"url": "git+https://github.com/sanity-io/ui.git",
|
|
19
|
+
"directory": "packages/ui"
|
|
19
20
|
},
|
|
20
21
|
"license": "MIT",
|
|
21
22
|
"author": "Sanity.io <hello@sanity.io>",
|
|
@@ -60,59 +61,6 @@
|
|
|
60
61
|
"exports",
|
|
61
62
|
"src"
|
|
62
63
|
],
|
|
63
|
-
"scripts": {
|
|
64
|
-
"build": "run-s clean pkg:build pkg:check figma:pkg:build",
|
|
65
|
-
"clean": "rimraf .workshop dist",
|
|
66
|
-
"commit": "cz",
|
|
67
|
-
"cypress:dev": "run-p dev cypress:open",
|
|
68
|
-
"cypress:open": "cypress open",
|
|
69
|
-
"cypress:run": "cypress run",
|
|
70
|
-
"dev": "run-p storybook:dev workshop:dev",
|
|
71
|
-
"figma:pkg:build": "cd figma && pnpm build",
|
|
72
|
-
"format": "prettier --write --cache --ignore-unknown .",
|
|
73
|
-
"lint": "eslint .",
|
|
74
|
-
"prepack": "pnpm build",
|
|
75
|
-
"pkg:build": "pkg build --strict",
|
|
76
|
-
"pkg:check": "pkg --strict",
|
|
77
|
-
"prepare": "husky install",
|
|
78
|
-
"release": "semantic-release",
|
|
79
|
-
"storybook:build": "storybook build -o storybook/storybook-static",
|
|
80
|
-
"storybook:dev": "storybook dev -p 6006",
|
|
81
|
-
"test": "jest",
|
|
82
|
-
"test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
|
|
83
|
-
"ts:check": "tsc",
|
|
84
|
-
"watch": "pkg watch --strict",
|
|
85
|
-
"workshop:build": "workshop build",
|
|
86
|
-
"workshop:dev": "workshop dev",
|
|
87
|
-
"workshop:start": "http-server -a localhost -c-0 -p 1337 -s -P http://localhost:1337/index.html? dist"
|
|
88
|
-
},
|
|
89
|
-
"commitlint": {
|
|
90
|
-
"extends": [
|
|
91
|
-
"@commitlint/config-conventional"
|
|
92
|
-
]
|
|
93
|
-
},
|
|
94
|
-
"lint-staged": {
|
|
95
|
-
"*": [
|
|
96
|
-
"prettier --write --cache --ignore-unknown"
|
|
97
|
-
]
|
|
98
|
-
},
|
|
99
|
-
"prettier": "@sanity/prettier-config",
|
|
100
|
-
"release": {
|
|
101
|
-
"branches": [
|
|
102
|
-
{
|
|
103
|
-
"name": "v2",
|
|
104
|
-
"range": "2.x",
|
|
105
|
-
"channel": "v2"
|
|
106
|
-
},
|
|
107
|
-
"main",
|
|
108
|
-
{
|
|
109
|
-
"name": "static",
|
|
110
|
-
"channel": "static",
|
|
111
|
-
"prerelease": true
|
|
112
|
-
}
|
|
113
|
-
],
|
|
114
|
-
"extends": "@sanity/semantic-release-preset"
|
|
115
|
-
},
|
|
116
64
|
"dependencies": {
|
|
117
65
|
"@floating-ui/react-dom": "^2.1.6",
|
|
118
66
|
"@juggle/resize-observer": "^3.4.0",
|
|
@@ -129,12 +77,8 @@
|
|
|
129
77
|
"@babel/preset-env": "^7.28.5",
|
|
130
78
|
"@babel/preset-react": "^7.28.5",
|
|
131
79
|
"@babel/preset-typescript": "^7.28.5",
|
|
132
|
-
"@commitlint/cli": "^19.8.1",
|
|
133
|
-
"@commitlint/config-conventional": "^19.8.1",
|
|
134
80
|
"@eslint/js": "^9.39.1",
|
|
135
81
|
"@sanity/pkg-utils": "^8.1.29",
|
|
136
|
-
"@sanity/prettier-config": "^2.0.1",
|
|
137
|
-
"@sanity/semantic-release-preset": "^5.0.0",
|
|
138
82
|
"@sanity/ui-workshop": "^3.4.0",
|
|
139
83
|
"@storybook/addon-a11y": "^8.6.14",
|
|
140
84
|
"@storybook/addon-docs": "^8.6.14",
|
|
@@ -163,10 +107,6 @@
|
|
|
163
107
|
"@vitejs/plugin-react": "^5.0.4",
|
|
164
108
|
"babel-plugin-react-compiler": "1.0.0",
|
|
165
109
|
"babel-plugin-styled-components": "^2.1.4",
|
|
166
|
-
"commitizen": "^4.3.1",
|
|
167
|
-
"cypress": "^13.17.0",
|
|
168
|
-
"cypress-real-events": "^1.14.0",
|
|
169
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
170
110
|
"eslint": "^9.39.1",
|
|
171
111
|
"eslint-config-prettier": "^10.1.8",
|
|
172
112
|
"eslint-formatter-gha": "^1.6.0",
|
|
@@ -179,22 +119,16 @@
|
|
|
179
119
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
180
120
|
"eslint-plugin-storybook": "^0.12.0",
|
|
181
121
|
"globals": "^16.3.0",
|
|
182
|
-
"http-server": "^14.1.1",
|
|
183
|
-
"husky": "^8.0.3",
|
|
184
122
|
"jest": "^30.1.3",
|
|
185
123
|
"jest-axe": "^10.0.0",
|
|
186
124
|
"jest-environment-jsdom": "^30.1.2",
|
|
187
|
-
"lint-staged": "^14.0.1",
|
|
188
125
|
"module-alias": "^2.2.3",
|
|
189
126
|
"npm-run-all2": "^8.0.4",
|
|
190
|
-
"prettier": "^3.6.2",
|
|
191
127
|
"react": "^19.2.0",
|
|
192
128
|
"react-dom": "^19.2.0",
|
|
193
129
|
"react-is": "^19.2.0",
|
|
194
130
|
"refractor": "^5.0.0",
|
|
195
131
|
"rimraf": "^5.0.5",
|
|
196
|
-
"semantic-release": "^24.2.7",
|
|
197
|
-
"start-server-and-test": "^2.1.0",
|
|
198
132
|
"storybook": "^8.6.14",
|
|
199
133
|
"styled-components": "npm:@sanity/styled-components@^6.1.23",
|
|
200
134
|
"tsconfig-paths": "^4.2.0",
|
|
@@ -209,25 +143,28 @@
|
|
|
209
143
|
"react-is": "^18 || >=19.0.0-0",
|
|
210
144
|
"styled-components": "^5.2 || ^6"
|
|
211
145
|
},
|
|
212
|
-
"packageManager": "pnpm@9.15.9",
|
|
213
146
|
"engines": {
|
|
214
147
|
"node": ">=20.19 <22 || >=22.12"
|
|
215
148
|
},
|
|
216
149
|
"publishConfig": {
|
|
217
150
|
"access": "public"
|
|
218
151
|
},
|
|
219
|
-
"pnpm": {
|
|
220
|
-
"overrides": {
|
|
221
|
-
"@types/react": "$@types/react",
|
|
222
|
-
"@types/react-dom": "$@types/react-dom",
|
|
223
|
-
"@types/react-is": "$@types/react-is",
|
|
224
|
-
"conventional-changelog-conventionalcommits": ">= 8.0.0",
|
|
225
|
-
"react": "$react",
|
|
226
|
-
"react-dom": "$react-dom",
|
|
227
|
-
"react-is": "$react-is"
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
152
|
"esm.sh": {
|
|
231
153
|
"bundle": false
|
|
154
|
+
},
|
|
155
|
+
"scripts": {
|
|
156
|
+
"build": "run-s clean pkg:build pkg:check",
|
|
157
|
+
"clean": "rimraf .workshop dist",
|
|
158
|
+
"dev": "run-p storybook:dev workshop:dev",
|
|
159
|
+
"lint": "eslint .",
|
|
160
|
+
"pkg:build": "pkg build --strict",
|
|
161
|
+
"pkg:check": "pkg --strict",
|
|
162
|
+
"storybook:build": "storybook build -o storybook/storybook-static",
|
|
163
|
+
"storybook:dev": "storybook dev -p 6006",
|
|
164
|
+
"test": "jest",
|
|
165
|
+
"ts:check": "tsc",
|
|
166
|
+
"watch": "pkg watch --strict",
|
|
167
|
+
"workshop:build": "pnpm build && workshop build",
|
|
168
|
+
"workshop:dev": "workshop dev"
|
|
232
169
|
}
|
|
233
|
-
}
|
|
170
|
+
}
|
|
@@ -190,7 +190,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
190
190
|
const rootElementRef = useRef<HTMLDivElement | null>(null)
|
|
191
191
|
const resultsPopoverElementRef = useRef<HTMLDivElement | null>(null)
|
|
192
192
|
const inputElementRef = useRef<HTMLInputElement | null>(null)
|
|
193
|
-
const listBoxElementRef = useRef<
|
|
193
|
+
const listBoxElementRef = useRef<HTMLUListElement | null>(null)
|
|
194
194
|
// Element refs that need to be accessed during render
|
|
195
195
|
const [inputElement, _setInputElement] = useState<HTMLInputElement | null>(null)
|
|
196
196
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {ButtonOwnProps} from '../../primitives'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export type AutocompleteOpenButtonProps =
|
|
6
|
+
export type AutocompleteOpenButtonProps = ButtonOwnProps &
|
|
7
7
|
Omit<React.HTMLProps<HTMLButtonElement>, 'as' | 'ref'>
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import {styled} from 'styled-components'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const MenuDivider = styled.hr`
|
|
3
|
+
import {ElementType, EmptyProps, Props} from '../../types'
|
|
4
|
+
|
|
5
|
+
const StyledMenuDivider = styled.hr`
|
|
7
6
|
height: 1px;
|
|
8
7
|
border: 0;
|
|
9
8
|
background: var(--card-hairline-soft-color);
|
|
10
9
|
margin: 0;
|
|
11
10
|
`
|
|
12
|
-
|
|
11
|
+
StyledMenuDivider.displayName = 'MenuDivider'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export type MenuDividerProps<E extends ElementType = 'hr'> = Props<EmptyProps, E>
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export const MenuDivider = StyledMenuDivider as unknown as <E extends ElementType = 'hr'>(
|
|
22
|
+
props: MenuDividerProps<E>,
|
|
23
|
+
) => React.JSX.Element
|
|
@@ -12,13 +12,7 @@ jest.mock('../../primitives', () => {
|
|
|
12
12
|
return {
|
|
13
13
|
...actual,
|
|
14
14
|
Flex: jest.fn((props: Record<string, unknown>) => (actual.Flex as any).render(props, null)),
|
|
15
|
-
Popover: jest.fn(
|
|
16
|
-
({
|
|
17
|
-
children,
|
|
18
|
-
}: {
|
|
19
|
-
children?: React.ReactNode
|
|
20
|
-
}) => children,
|
|
21
|
-
),
|
|
15
|
+
Popover: jest.fn(({children}: {children?: React.ReactNode}) => children),
|
|
22
16
|
}
|
|
23
17
|
})
|
|
24
18
|
|
|
@@ -6,15 +6,14 @@ import {Box, Flex, Popover, PopoverProps, Text} from '../../primitives'
|
|
|
6
6
|
import {Selectable} from '../../primitives/_selectable'
|
|
7
7
|
import {_getArrayProp} from '../../styles'
|
|
8
8
|
import {useRootTheme} from '../../theme'
|
|
9
|
-
import {Radius, SelectableTone} from '../../types'
|
|
9
|
+
import {ElementType, Props, Radius, SelectableTone} from '../../types'
|
|
10
10
|
import {Menu, MenuProps} from './menu'
|
|
11
11
|
import {useMenu} from './useMenu'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
export interface
|
|
17
|
-
as?: React.ElementType | keyof React.JSX.IntrinsicElements
|
|
16
|
+
export interface MenuGroupOwnProps {
|
|
18
17
|
fontSize?: number | number[]
|
|
19
18
|
icon?: React.ElementType | React.ReactNode
|
|
20
19
|
menu?: Omit<
|
|
@@ -43,9 +42,11 @@ export interface MenuGroupProps {
|
|
|
43
42
|
/**
|
|
44
43
|
* @public
|
|
45
44
|
*/
|
|
46
|
-
export
|
|
45
|
+
export type MenuGroupProps<E extends ElementType = 'button'> = Props<MenuGroupOwnProps, E>
|
|
46
|
+
|
|
47
|
+
function MenuGroupComponent(
|
|
47
48
|
props: Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'popover' | 'ref' | 'tabIndex'> &
|
|
48
|
-
|
|
49
|
+
MenuGroupOwnProps & {as?: ElementType},
|
|
49
50
|
): React.JSX.Element {
|
|
50
51
|
const {
|
|
51
52
|
as = 'button',
|
|
@@ -222,4 +223,11 @@ export function MenuGroup(
|
|
|
222
223
|
)
|
|
223
224
|
}
|
|
224
225
|
|
|
225
|
-
|
|
226
|
+
MenuGroupComponent.displayName = 'MenuGroup'
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @public
|
|
230
|
+
*/
|
|
231
|
+
export const MenuGroup = MenuGroupComponent as unknown as <E extends ElementType = 'button'>(
|
|
232
|
+
props: MenuGroupProps<E>,
|
|
233
|
+
) => React.JSX.Element
|
|
@@ -15,6 +15,7 @@ import {Selectable} from '../../primitives/_selectable'
|
|
|
15
15
|
import {ResponsivePaddingProps, ResponsiveRadiusProps} from '../../primitives/types'
|
|
16
16
|
import {_getArrayProp} from '../../styles'
|
|
17
17
|
import {useRootTheme} from '../../theme'
|
|
18
|
+
import {ElementType, Props} from '../../types'
|
|
18
19
|
import {SelectableTone} from '../../types/selectable'
|
|
19
20
|
import {Hotkeys} from '../hotkeys'
|
|
20
21
|
import {useMenu} from './useMenu'
|
|
@@ -22,8 +23,7 @@ import {useMenu} from './useMenu'
|
|
|
22
23
|
/**
|
|
23
24
|
* @public
|
|
24
25
|
*/
|
|
25
|
-
export interface
|
|
26
|
-
as?: React.ElementType | keyof React.JSX.IntrinsicElements
|
|
26
|
+
export interface MenuItemOwnProps extends ResponsivePaddingProps, ResponsiveRadiusProps {
|
|
27
27
|
fontSize?: number | number[]
|
|
28
28
|
hotkeys?: string[]
|
|
29
29
|
icon?: React.ElementType | React.ReactNode
|
|
@@ -42,9 +42,13 @@ export interface MenuItemProps extends ResponsivePaddingProps, ResponsiveRadiusP
|
|
|
42
42
|
/**
|
|
43
43
|
* @public
|
|
44
44
|
*/
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
export type MenuItemProps<E extends ElementType = 'button'> = Props<MenuItemOwnProps, E>
|
|
46
|
+
|
|
47
|
+
const MenuItemComponent = forwardRef(function MenuItem(
|
|
48
|
+
props: MenuItemOwnProps & {as?: ElementType} & Omit<
|
|
49
|
+
React.HTMLProps<HTMLDivElement>,
|
|
50
|
+
'as' | 'height' | 'ref' | 'selected' | 'tabIndex'
|
|
51
|
+
>,
|
|
48
52
|
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
49
53
|
) {
|
|
50
54
|
const {
|
|
@@ -183,4 +187,11 @@ export const MenuItem = forwardRef(function MenuItem(
|
|
|
183
187
|
</Selectable>
|
|
184
188
|
)
|
|
185
189
|
})
|
|
186
|
-
|
|
190
|
+
MenuItemComponent.displayName = 'ForwardRef(MenuItem)'
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
export const MenuItem = MenuItemComponent as unknown as <E extends ElementType = 'button'>(
|
|
196
|
+
props: MenuItemProps<E>,
|
|
197
|
+
) => React.JSX.Element
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {forwardRef, useEffect, useState} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {Box,
|
|
4
|
+
import {Box, BoxOwnProps, ResponsiveRadiusProps} from '../../primitives'
|
|
5
5
|
import {_getArrayProp} from '../../styles'
|
|
6
6
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
7
7
|
import {skeletonStyle} from './styles'
|
|
@@ -14,7 +14,7 @@ const StyledSkeleton = styled(Box)<
|
|
|
14
14
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
15
15
|
* @beta
|
|
16
16
|
*/
|
|
17
|
-
export interface SkeletonProps extends ResponsiveRadiusProps, Omit<
|
|
17
|
+
export interface SkeletonProps extends ResponsiveRadiusProps, Omit<BoxOwnProps, 'children'> {
|
|
18
18
|
animated?: boolean
|
|
19
19
|
delay?: number
|
|
20
20
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {Children, cloneElement, forwardRef, isValidElement, useCallback, useState} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {Inline,
|
|
4
|
+
import {Inline, InlineOwnProps} from '../../primitives'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
export interface TabListProps extends Omit<
|
|
9
|
+
export interface TabListProps extends Omit<InlineOwnProps, 'height'> {
|
|
10
10
|
children: Array<React.JSX.Element | null | undefined | false>
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
2
|
|
|
3
|
-
import {Box,
|
|
3
|
+
import {Box, BoxOwnProps} from '../../primitives'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export interface TabPanelProps extends
|
|
8
|
+
export interface TabPanelProps extends BoxOwnProps {
|
|
9
9
|
/**
|
|
10
10
|
* The `id` of the correlating `Tab` component.
|
|
11
11
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {getTheme_v2, ThemeColorStateToneKey} from '@sanity/ui/theme'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {Card, Flex} from '../../primitives'
|
|
4
|
+
import {Card, type CardProps, Flex} from '../../primitives'
|
|
5
5
|
import type {ButtonTone} from '../../types'
|
|
6
6
|
|
|
7
7
|
const LOADING_BAR_HEIGHT = 2
|
|
@@ -61,7 +61,7 @@ export const LoadingBarMask = styled(Card)`
|
|
|
61
61
|
z-index: 1;
|
|
62
62
|
`
|
|
63
63
|
|
|
64
|
-
type LoadingBarProgressProps = Omit<
|
|
64
|
+
type LoadingBarProgressProps = Omit<CardProps, 'tone'> & {
|
|
65
65
|
tone: ThemeColorStateToneKey
|
|
66
66
|
}
|
|
67
67
|
export const LoadingBarProgress = styled<React.ComponentType<LoadingBarProgressProps>>(Card)`
|
|
@@ -9,7 +9,7 @@ function test<ElementType = unknown>(
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const perfTests = [
|
|
12
|
-
test('Toggle tree groups', async ({target}: {target:
|
|
12
|
+
test('Toggle tree groups', async ({target}: {target: HTMLUListElement}) => {
|
|
13
13
|
const apples = await findByTestId(target, 'apples')
|
|
14
14
|
const oranges = await findByTestId(target, 'oranges')
|
|
15
15
|
|
|
@@ -19,7 +19,7 @@ export default function BasicStory() {
|
|
|
19
19
|
if (testid) setId(testid)
|
|
20
20
|
}, [])
|
|
21
21
|
|
|
22
|
-
const handleFocus = useCallback((event: React.FocusEvent<
|
|
22
|
+
const handleFocus = useCallback((event: React.FocusEvent<HTMLElement>) => {
|
|
23
23
|
const elementFocus = event.target.getAttribute('data-testid')
|
|
24
24
|
if (elementFocus) setFocus(elementFocus)
|
|
25
25
|
}, [])
|
|
@@ -31,12 +31,12 @@ export interface TreeProps {
|
|
|
31
31
|
*/
|
|
32
32
|
export const Tree = forwardRef(function Tree(
|
|
33
33
|
props: TreeProps &
|
|
34
|
-
Omit<React.HTMLProps<
|
|
35
|
-
forwardedRef: React.ForwardedRef<
|
|
34
|
+
Omit<React.HTMLProps<HTMLUListElement>, 'align' | 'as' | 'height' | 'ref' | 'role' | 'wrap'>,
|
|
35
|
+
forwardedRef: React.ForwardedRef<HTMLUListElement>,
|
|
36
36
|
): React.JSX.Element {
|
|
37
37
|
const {children, gap, space: deprecated_space = 1, onFocus, ...restProps} = props
|
|
38
38
|
const spacing = gap === undefined ? deprecated_space : gap
|
|
39
|
-
const ref = useRef<
|
|
39
|
+
const ref = useRef<HTMLUListElement | null>(null)
|
|
40
40
|
const [focusedElement, setFocusedElement] = useState<HTMLElement | null>(null)
|
|
41
41
|
const focusedElementRef = useRef(focusedElement)
|
|
42
42
|
const path: string[] = useMemo(() => [], [])
|
|
@@ -44,7 +44,10 @@ export const Tree = forwardRef(function Tree(
|
|
|
44
44
|
const [state, setState] = useState<TreeState>({})
|
|
45
45
|
const stateRef = useRef(state)
|
|
46
46
|
|
|
47
|
-
useImperativeHandle<
|
|
47
|
+
useImperativeHandle<HTMLUListElement | null, HTMLUListElement | null>(
|
|
48
|
+
forwardedRef,
|
|
49
|
+
() => ref.current,
|
|
50
|
+
)
|
|
48
51
|
|
|
49
52
|
useEffect(() => {
|
|
50
53
|
focusedElementRef.current = focusedElement
|
|
@@ -102,7 +105,7 @@ export const Tree = forwardRef(function Tree(
|
|
|
102
105
|
)
|
|
103
106
|
|
|
104
107
|
const handleKeyDown = useCallback(
|
|
105
|
-
(event: React.KeyboardEvent<
|
|
108
|
+
(event: React.KeyboardEvent<HTMLUListElement>) => {
|
|
106
109
|
if (!focusedElementRef.current) return
|
|
107
110
|
|
|
108
111
|
if (event.key === 'ArrowDown') {
|
|
@@ -199,7 +202,7 @@ export const Tree = forwardRef(function Tree(
|
|
|
199
202
|
)
|
|
200
203
|
|
|
201
204
|
const handleFocus = useCallback(
|
|
202
|
-
(event: React.FocusEvent<
|
|
205
|
+
(event: React.FocusEvent<HTMLUListElement>) => {
|
|
203
206
|
setFocusedElement(event.target)
|
|
204
207
|
|
|
205
208
|
// Call the element's `focus` handler
|
|
@@ -7,7 +7,7 @@ export interface TreeGroupProps {
|
|
|
7
7
|
|
|
8
8
|
export function TreeGroup(
|
|
9
9
|
props: TreeGroupProps &
|
|
10
|
-
Omit<React.HTMLProps<
|
|
10
|
+
Omit<React.HTMLProps<HTMLUListElement>, 'as' | 'height' | 'ref' | 'role' | 'wrap'>,
|
|
11
11
|
): React.JSX.Element {
|
|
12
12
|
const {children, expanded = false, ...restProps} = props
|
|
13
13
|
const tree = useTree()
|
|
@@ -3,7 +3,8 @@ import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
|
3
3
|
import {startTransition, useCallback, useEffect, useId, useMemo, useRef, useState} from 'react'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
|
-
import {Box,
|
|
6
|
+
import {Box, Flex, Text} from '../../primitives'
|
|
7
|
+
import {ElementType} from '../../types'
|
|
7
8
|
import {
|
|
8
9
|
treeItemBoxStyle,
|
|
9
10
|
TreeItemBoxStyleProps,
|
|
@@ -24,7 +25,7 @@ export interface TreeItemProps {
|
|
|
24
25
|
/**
|
|
25
26
|
* Allows passing a custom element type to the link component
|
|
26
27
|
*/
|
|
27
|
-
linkAs?:
|
|
28
|
+
linkAs?: ElementType
|
|
28
29
|
padding?: number | number[]
|
|
29
30
|
gap?: number | number[]
|
|
30
31
|
/**
|
|
@@ -5,19 +5,18 @@ import {styled} from 'styled-components'
|
|
|
5
5
|
|
|
6
6
|
import {_getArrayProp} from '../../styles'
|
|
7
7
|
import {useTheme_v2} from '../../theme'
|
|
8
|
-
import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
|
|
8
|
+
import {AvatarPosition, AvatarSize, AvatarStatus, ElementType, Props} from '../../types'
|
|
9
9
|
import {Label} from '../label'
|
|
10
10
|
import {avatarStyle, responsiveAvatarSizeStyle} from './styles'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
export interface
|
|
15
|
+
export interface AvatarOwnProps {
|
|
16
16
|
/** @beta */
|
|
17
17
|
__unstable_hideInnerStroke?: boolean
|
|
18
18
|
animateArrowFrom?: AvatarPosition
|
|
19
19
|
arrowPosition?: AvatarPosition
|
|
20
|
-
as?: React.ElementType | keyof React.JSX.IntrinsicElements
|
|
21
20
|
color?: ThemeColorAvatarColorKey
|
|
22
21
|
initials?: string
|
|
23
22
|
onImageLoadError?: (event: Error) => void
|
|
@@ -31,6 +30,11 @@ export interface AvatarProps {
|
|
|
31
30
|
title?: string
|
|
32
31
|
}
|
|
33
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export type AvatarProps<E extends ElementType = 'div'> = Props<AvatarOwnProps, E>
|
|
37
|
+
|
|
34
38
|
const StyledAvatar = styled.div<{$color: ThemeColorAvatarColorKey; $size: AvatarSize[]}>(
|
|
35
39
|
responsiveAvatarSizeStyle,
|
|
36
40
|
avatarStyle.root,
|
|
@@ -50,13 +54,8 @@ const InitialsLabel = styled(Label)({
|
|
|
50
54
|
|
|
51
55
|
const AvatarImage = styled.svg(avatarStyle.image)
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export const Avatar = forwardRef(function Avatar(
|
|
59
|
-
props: AvatarProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'ref'>,
|
|
57
|
+
const AvatarComponent = forwardRef(function Avatar(
|
|
58
|
+
props: AvatarOwnProps & {as?: ElementType} & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'ref'>,
|
|
60
59
|
ref: React.ForwardedRef<HTMLDivElement>,
|
|
61
60
|
) {
|
|
62
61
|
const {
|
|
@@ -189,4 +188,13 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
189
188
|
</StyledAvatar>
|
|
190
189
|
)
|
|
191
190
|
})
|
|
192
|
-
|
|
191
|
+
AvatarComponent.displayName = 'ForwardRef(Avatar)'
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Avatars are used to represent people and other agents (e.g. bots).
|
|
195
|
+
*
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
export const Avatar = AvatarComponent as unknown as <E extends ElementType = 'div'>(
|
|
199
|
+
props: AvatarProps<E>,
|
|
200
|
+
) => React.JSX.Element
|