@sanity/ui 2.8.16 → 2.8.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.8.16",
3
+ "version": "2.8.18",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -126,20 +126,20 @@
126
126
  "@sanity/prettier-config": "^1.0.2",
127
127
  "@sanity/semantic-release-preset": "^5.0.0",
128
128
  "@sanity/ui-workshop": "^2.0.16",
129
- "@storybook/addon-a11y": "^8.3.6",
130
- "@storybook/addon-docs": "^8.3.6",
131
- "@storybook/addon-essentials": "^8.3.6",
132
- "@storybook/addon-interactions": "^8.3.6",
133
- "@storybook/addon-links": "^8.3.6",
134
- "@storybook/addon-mdx-gfm": "^8.3.6",
135
- "@storybook/addon-storysource": "^8.3.6",
136
- "@storybook/addon-themes": "^8.3.6",
137
- "@storybook/blocks": "^8.3.6",
138
- "@storybook/manager-api": "^8.3.6",
139
- "@storybook/react": "^8.3.6",
140
- "@storybook/react-vite": "^8.3.6",
141
- "@storybook/test": "^8.3.6",
142
- "@storybook/theming": "^8.3.6",
129
+ "@storybook/addon-a11y": "^8.4.0",
130
+ "@storybook/addon-docs": "^8.4.0",
131
+ "@storybook/addon-essentials": "^8.4.0",
132
+ "@storybook/addon-interactions": "^8.4.0",
133
+ "@storybook/addon-links": "^8.4.0",
134
+ "@storybook/addon-mdx-gfm": "^8.4.0",
135
+ "@storybook/addon-storysource": "^8.4.0",
136
+ "@storybook/addon-themes": "^8.4.0",
137
+ "@storybook/blocks": "^8.4.0",
138
+ "@storybook/manager-api": "^8.4.0",
139
+ "@storybook/react": "^8.4.0",
140
+ "@storybook/react-vite": "^8.4.0",
141
+ "@storybook/test": "^8.4.0",
142
+ "@storybook/theming": "^8.4.0",
143
143
  "@testing-library/dom": "^10.4.0",
144
144
  "@testing-library/jest-dom": "^6.6.2",
145
145
  "@testing-library/react": "^16.0.1",
@@ -185,17 +185,17 @@
185
185
  "rimraf": "^5.0.5",
186
186
  "semantic-release": "^24.0.0",
187
187
  "start-server-and-test": "^2.0.5",
188
- "storybook": "^8.3.6",
188
+ "storybook": "^8.4.0",
189
189
  "styled-components": "^6.1.13",
190
190
  "tsconfig-paths": "^4.2.0",
191
191
  "typescript": "5.6.3",
192
- "vite": "^5.4.2",
192
+ "vite": "^5.4.10",
193
193
  "vite-tsconfig-paths": "^5.0.1"
194
194
  },
195
195
  "peerDependencies": {
196
- "react": "^18",
197
- "react-dom": "^18",
198
- "react-is": "^18",
196
+ "react": "^18 || >=19.0.0-0",
197
+ "react-dom": "^18 || >=19.0.0-0",
198
+ "react-is": "^18 || >=19.0.0-0",
199
199
  "styled-components": "^5.2 || ^6"
200
200
  },
201
201
  "packageManager": "pnpm@9.12.3",
@@ -305,13 +305,15 @@ export const Dialog = forwardRef(function Dialog(
305
305
  onFocus,
306
306
  padding: paddingProp = 3,
307
307
  portal: portalProp,
308
- position: positionProp = dialog.position || 'fixed',
308
+ position: _positionProp,
309
309
  scheme,
310
310
  width: widthProp = 0,
311
- zOffset: zOffsetProp = dialog.zOffset || layer.dialog.zOffset,
311
+ zOffset: _zOffsetProp,
312
312
  animate: _animate = false,
313
313
  ...restProps
314
314
  } = props
315
+ const positionProp = _positionProp ?? (dialog.position || 'fixed')
316
+ const zOffsetProp = _zOffsetProp ?? (dialog.zOffset || layer.dialog.zOffset)
315
317
  const prefersReducedMotion = usePrefersReducedMotion()
316
318
  const animate = prefersReducedMotion ? false : _animate
317
319
  const portal = usePortal()
@@ -57,10 +57,12 @@ export const Menu = forwardRef(function Menu(
57
57
  originElement,
58
58
  padding = 1,
59
59
  registerElement,
60
- shouldFocus = (props.focusFirst && 'first') || (props.focusLast && 'last') || null,
60
+ shouldFocus: _shouldFocus,
61
61
  space = 1,
62
62
  ...restProps
63
63
  } = props
64
+ const shouldFocus =
65
+ _shouldFocus ?? ((props.focusFirst && 'first') || (props.focusLast && 'last') || null)
64
66
 
65
67
  const ref = useRef<HTMLDivElement | null>(null)
66
68
 
@@ -53,9 +53,10 @@ export function MenuGroup(
53
53
  onClickOutside,
54
54
  onEscape,
55
55
  onItemClick,
56
- onItemMouseEnter = menu.onMouseEnter,
56
+ onItemMouseEnter: _onItemMouseEnter,
57
57
  registerElement,
58
58
  } = menu
59
+ const onItemMouseEnter = _onItemMouseEnter ?? menu.onMouseEnter
59
60
  const [rootElement, setRootElement] = useState<HTMLButtonElement | HTMLDivElement | null>(null)
60
61
  const [open, setOpen] = useState(false)
61
62
  const [shouldFocus, setShouldFocus] = useState<'first' | 'last' | null>(null)
@@ -72,9 +72,11 @@ export const MenuItem = forwardRef(function MenuItem(
72
72
  activeElement,
73
73
  mount,
74
74
  onItemClick,
75
- onItemMouseEnter = menu.onMouseEnter,
76
- onItemMouseLeave = menu.onMouseLeave,
75
+ onItemMouseEnter: _onItemMouseEnter,
76
+ onItemMouseLeave: _onItemMouseLeave,
77
77
  } = menu
78
+ const onItemMouseEnter = _onItemMouseEnter ?? menu.onMouseEnter
79
+ const onItemMouseLeave = _onItemMouseLeave ?? menu.onMouseLeave
78
80
  const [rootElement, setRootElement] = useState<HTMLDivElement | null>(null)
79
81
  const active = Boolean(activeElement) && activeElement === rootElement
80
82
  const ref = useRef<HTMLDivElement | null>(null)
@@ -1,4 +1,4 @@
1
- import {cloneElement, forwardRef, useCallback, useMemo, useState} from 'react'
1
+ import {cloneElement, forwardRef, useCallback, useState, Children, isValidElement} from 'react'
2
2
  import {styled} from 'styled-components'
3
3
  import {Inline, InlineProps} from '../../primitives'
4
4
 
@@ -9,10 +9,6 @@ export interface TabListProps extends Omit<InlineProps, 'as' | 'height'> {
9
9
  children: Array<React.ReactElement | null | undefined | false>
10
10
  }
11
11
 
12
- function _isReactElement(node: unknown): node is React.ReactElement {
13
- return Boolean(node)
14
- }
15
-
16
12
  //Limits the width of tabs in tablist
17
13
  const CustomInline = styled(Inline)`
18
14
  & > div {
@@ -33,22 +29,18 @@ export const TabList = forwardRef(function TabList(
33
29
  const {children: childrenProp, ...restProps} = props
34
30
  const [focusedIndex, setFocusedIndex] = useState(-1)
35
31
 
36
- const children = useMemo(() => childrenProp.filter(_isReactElement), [childrenProp])
32
+ const children: React.ReactElement[] = Children.toArray(childrenProp).filter(isValidElement)
37
33
 
38
34
  const tabs = children.map((child, childIndex) =>
39
35
  cloneElement(child, {
40
36
  focused: focusedIndex === childIndex,
41
37
  key: childIndex,
42
- onFocus: () => handleTabFocus(childIndex),
38
+ onFocus: () => setFocusedIndex(childIndex),
43
39
  }),
44
40
  )
45
41
 
46
42
  const numTabs = tabs.length
47
43
 
48
- const handleTabFocus = useCallback((tabIdx: number) => {
49
- setFocusedIndex(tabIdx)
50
- }, [])
51
-
52
44
  const handleKeyDown = useCallback(
53
45
  (event: React.KeyboardEvent<HTMLDivElement>) => {
54
46
  if (event.key === 'ArrowLeft') {
@@ -25,12 +25,10 @@ export interface ThemeProviderProps {
25
25
  */
26
26
  export function ThemeProvider(props: ThemeProviderProps): React.ReactElement {
27
27
  const parentTheme = useContext(ThemeContext)
28
- const {
29
- children,
30
- scheme = parentTheme?.scheme || 'light',
31
- theme: rootTheme = parentTheme?.theme || null,
32
- tone = parentTheme?.tone || 'default',
33
- } = props
28
+ const {children} = props
29
+ const scheme = props.scheme ?? (parentTheme?.scheme || 'light')
30
+ const rootTheme = props.theme ?? (parentTheme?.theme || null)
31
+ const tone = props.tone ?? (parentTheme?.tone || 'default')
34
32
 
35
33
  const themeContext: ThemeContextValue | null = useMemo(() => {
36
34
  if (!rootTheme) return null