@sanity/ui 0.38.2 → 0.38.3-next.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.
Files changed (201) hide show
  1. package/README.md +4 -5
  2. package/dist/sanity-ui.js +1 -1320
  3. package/dist/sanity-ui.js.map +1 -1
  4. package/dist/sanity-ui.mjs +2 -0
  5. package/dist/sanity-ui.mjs.map +1 -0
  6. package/dist/types/src/index.d.ts +228 -239
  7. package/package.json +23 -20
  8. package/src/__workshop__/color/overview.tsx +1 -1
  9. package/src/__workshop__/constants.ts +1 -0
  10. package/src/components/autocomplete/__workshop__/async.tsx +1 -1
  11. package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +1 -1
  12. package/src/components/autocomplete/__workshop__/custom.tsx +1 -1
  13. package/src/components/autocomplete/__workshop__/example.tsx +1 -1
  14. package/src/components/autocomplete/__workshop__/focusAndBlur.tsx +1 -1
  15. package/src/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
  16. package/src/components/autocomplete/autocomplete.tsx +31 -33
  17. package/src/components/autocomplete/autocompleteOption.tsx +1 -1
  18. package/src/components/autocomplete/autocompleteReducer.ts +0 -3
  19. package/src/components/breadcrumbs/__workshop__/example.tsx +0 -1
  20. package/src/components/breadcrumbs/breadcrumbs.tsx +1 -9
  21. package/src/components/dialog/__workshop__/autoFocus.tsx +0 -1
  22. package/src/components/dialog/__workshop__/layering.tsx +0 -1
  23. package/src/components/dialog/__workshop__/nested.tsx +1 -1
  24. package/src/components/dialog/__workshop__/onScroll.tsx +1 -1
  25. package/src/components/dialog/__workshop__/position.tsx +0 -1
  26. package/src/components/dialog/__workshop__/props.tsx +1 -1
  27. package/src/components/dialog/__workshop__/provider.tsx +0 -1
  28. package/src/components/dialog/dialog.tsx +1 -1
  29. package/src/components/dialog/dialogProvider.tsx +1 -1
  30. package/src/components/hotkeys/__workshop__/plain.tsx +0 -1
  31. package/src/components/hotkeys/hotkeys.tsx +1 -1
  32. package/src/components/menu/__workshop__/asComponent.tsx +1 -1
  33. package/src/components/menu/__workshop__/closableMenuButton.tsx +1 -1
  34. package/src/components/menu/__workshop__/constrainedInBoundary.tsx +1 -1
  35. package/src/components/menu/__workshop__/customMenuItem.tsx +0 -1
  36. package/src/components/menu/__workshop__/disableFocusOnClose.tsx +0 -1
  37. package/src/components/menu/__workshop__/groups.tsx +0 -1
  38. package/src/components/menu/__workshop__/menuButton.tsx +0 -1
  39. package/src/components/menu/__workshop__/menuGroupRight.tsx +0 -1
  40. package/src/components/menu/__workshop__/nestedMenu.tsx +0 -1
  41. package/src/components/menu/__workshop__/onCloseMenuButton.tsx +1 -1
  42. package/src/components/menu/__workshop__/selectedItem.tsx +1 -1
  43. package/src/components/menu/__workshop__/tones.tsx +0 -1
  44. package/src/components/menu/__workshop__/withoutArrow.tsx +0 -1
  45. package/src/components/menu/menu.test.tsx +3 -4
  46. package/src/components/menu/menu.tsx +1 -1
  47. package/src/components/menu/menuButton.tsx +1 -9
  48. package/src/components/menu/menuGroup.tsx +2 -2
  49. package/src/components/menu/menuItem.tsx +3 -3
  50. package/src/components/menu/useMenuController.ts +1 -1
  51. package/src/components/skeleton/__workshop__/delay.tsx +0 -1
  52. package/src/components/skeleton/__workshop__/skeleton.tsx +0 -1
  53. package/src/components/skeleton/skeleton.tsx +1 -1
  54. package/src/components/skeleton/textSkeleton.tsx +1 -1
  55. package/src/components/tab/__workshop__/example.tsx +1 -1
  56. package/src/components/tab/tab.tsx +2 -2
  57. package/src/components/tab/tabList.tsx +1 -1
  58. package/src/components/tab/tabPanel.tsx +1 -1
  59. package/src/components/toast/__workshop__/hook.tsx +0 -1
  60. package/src/components/toast/__workshop__/toast.tsx +0 -1
  61. package/src/components/toast/toast.test.tsx +3 -5
  62. package/src/components/toast/toast.tsx +0 -1
  63. package/src/components/toast/toastProvider.tsx +1 -1
  64. package/src/components/tree/__workshop__/basic.tsx +1 -1
  65. package/src/components/tree/tree.tsx +1 -1
  66. package/src/components/tree/treeGroup.tsx +1 -1
  67. package/src/components/tree/treeItem.tsx +4 -4
  68. package/src/hooks/useElementRect/__workshop__/example.tsx +0 -1
  69. package/src/hooks/useForwardedRef.ts +1 -1
  70. package/src/hooks/useMediaIndex/__workshop__/test.tsx +0 -1
  71. package/src/icons/__workshop__/overview.tsx +1 -1
  72. package/src/primitives/avatar/__workshop__/asButton.tsx +0 -1
  73. package/src/primitives/avatar/__workshop__/stack.tsx +0 -1
  74. package/src/primitives/avatar/avatar.tsx +2 -3
  75. package/src/primitives/avatar/avatarCounter.tsx +1 -1
  76. package/src/primitives/avatar/avatarStack.tsx +1 -1
  77. package/src/primitives/badge/__workshop__/props.tsx +0 -1
  78. package/src/primitives/badge/__workshop__/tones.tsx +0 -1
  79. package/src/primitives/badge/badge.test.tsx +13 -0
  80. package/src/primitives/badge/badge.tsx +1 -1
  81. package/src/primitives/box/__workshop__/props.tsx +0 -1
  82. package/src/primitives/box/__workshop__/responsive.tsx +0 -1
  83. package/src/primitives/box/box.tsx +1 -1
  84. package/src/primitives/button/__workshop__/custom.tsx +0 -1
  85. package/src/primitives/button/__workshop__/customIcons.tsx +0 -1
  86. package/src/primitives/button/__workshop__/mixedChildren.tsx +0 -1
  87. package/src/primitives/button/__workshop__/props.tsx +0 -1
  88. package/src/primitives/button/__workshop__/sanityUploadButton.tsx +0 -1
  89. package/src/primitives/button/__workshop__/stacked.tsx +0 -1
  90. package/src/primitives/button/__workshop__/styled1.tsx +0 -1
  91. package/src/primitives/button/__workshop__/styled2.tsx +0 -1
  92. package/src/primitives/button/__workshop__/uploadButton.tsx +1 -1
  93. package/src/primitives/button/button.test.tsx +41 -0
  94. package/src/primitives/button/button.tsx +3 -3
  95. package/src/primitives/card/__workshop__/allTones.tsx +0 -1
  96. package/src/primitives/card/__workshop__/asButton.tsx +0 -1
  97. package/src/primitives/card/__workshop__/asComponent.tsx +1 -1
  98. package/src/primitives/card/__workshop__/checkered.tsx +0 -1
  99. package/src/primitives/card/__workshop__/interactive.tsx +0 -1
  100. package/src/primitives/card/__workshop__/listNavigation.tsx +0 -1
  101. package/src/primitives/card/__workshop__/props.tsx +0 -1
  102. package/src/primitives/card/__workshop__/selected.tsx +0 -1
  103. package/src/primitives/card/__workshop__/styled.tsx +0 -1
  104. package/src/primitives/card/card.tsx +1 -1
  105. package/src/primitives/checkbox/__workshop__/example.tsx +1 -1
  106. package/src/primitives/checkbox/__workshop__/props.tsx +0 -1
  107. package/src/primitives/checkbox/__workshop__/readOnly.tsx +0 -1
  108. package/src/primitives/checkbox/__workshop__/tones.tsx +0 -1
  109. package/src/primitives/checkbox/checkbox.tsx +1 -1
  110. package/src/primitives/code/__workshop__/opticalAlignment.tsx +0 -1
  111. package/src/primitives/code/__workshop__/props.tsx +0 -1
  112. package/src/primitives/code/code.tsx +1 -1
  113. package/src/primitives/container/__workshop__/example.tsx +0 -1
  114. package/src/primitives/container/container.tsx +1 -1
  115. package/src/primitives/flex/__workshop__/example.tsx +0 -1
  116. package/src/primitives/flex/__workshop__/gap.tsx +0 -1
  117. package/src/primitives/flex/flex.tsx +1 -1
  118. package/src/primitives/grid/__workshop__/responsive.tsx +0 -1
  119. package/src/primitives/grid/grid.tsx +1 -1
  120. package/src/primitives/heading/__workshop__/opticalAlignment.tsx +0 -1
  121. package/src/primitives/heading/__workshop__/plain.tsx +0 -1
  122. package/src/primitives/heading/heading.tsx +1 -1
  123. package/src/primitives/inline/__workshop__/plain.tsx +0 -1
  124. package/src/primitives/inline/inline.tsx +1 -1
  125. package/src/primitives/kbd/__workshop__/plain.tsx +0 -1
  126. package/src/primitives/kbd/kbd.tsx +1 -1
  127. package/src/primitives/label/__workshop__/opticalAlignment.tsx +0 -1
  128. package/src/primitives/label/__workshop__/plain.tsx +0 -1
  129. package/src/primitives/label/label.tsx +1 -1
  130. package/src/primitives/popover/__workshop__/MarginsStory.tsx +0 -1
  131. package/src/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -1
  132. package/src/primitives/popover/__workshop__/PlainStory.tsx +1 -1
  133. package/src/primitives/popover/__workshop__/RecursiveStory.tsx +1 -1
  134. package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +1 -1
  135. package/src/primitives/popover/__workshop__/TestStory.tsx +1 -1
  136. package/src/primitives/popover/arrow.tsx +1 -1
  137. package/src/primitives/popover/popover.tsx +1 -9
  138. package/src/primitives/radio/__workshop__/example.tsx +1 -1
  139. package/src/primitives/radio/__workshop__/plain.tsx +0 -1
  140. package/src/primitives/radio/radio.tsx +1 -1
  141. package/src/primitives/select/__workshop__/plain.tsx +0 -1
  142. package/src/primitives/select/__workshop__/readOnly.tsx +0 -1
  143. package/src/primitives/select/select.tsx +1 -1
  144. package/src/primitives/spinner/__workshop__/Props.tsx +0 -1
  145. package/src/primitives/spinner/spinner.tsx +1 -1
  146. package/src/primitives/stack/__workshop__/plain.tsx +0 -1
  147. package/src/primitives/stack/stack.tsx +1 -1
  148. package/src/primitives/switch/__workshop__/example.tsx +1 -1
  149. package/src/primitives/switch/__workshop__/props.tsx +1 -1
  150. package/src/primitives/switch/switch.tsx +1 -1
  151. package/src/primitives/text/__workshop__/colored.tsx +0 -1
  152. package/src/primitives/text/__workshop__/example.tsx +0 -1
  153. package/src/primitives/text/__workshop__/opticalAlignment.tsx +0 -1
  154. package/src/primitives/text/text.tsx +1 -1
  155. package/src/primitives/textArea/__workshop__/plain.tsx +0 -1
  156. package/src/primitives/textArea/textArea.tsx +1 -1
  157. package/src/primitives/textInput/__workshop__/clearButton.tsx +1 -1
  158. package/src/primitives/textInput/__workshop__/customValidity.tsx +0 -1
  159. package/src/primitives/textInput/__workshop__/multipleTones.tsx +0 -1
  160. package/src/primitives/textInput/__workshop__/plain.tsx +1 -1
  161. package/src/primitives/textInput/__workshop__/readOnly.tsx +0 -1
  162. package/src/primitives/textInput/__workshop__/states.tsx +0 -1
  163. package/src/primitives/textInput/__workshop__/tones.tsx +0 -1
  164. package/src/primitives/textInput/__workshop__/typed.tsx +1 -1
  165. package/src/primitives/textInput/textInput.tsx +4 -3
  166. package/src/primitives/tooltip/__workshop__/props.tsx +0 -1
  167. package/src/primitives/tooltip/tooltip.tsx +1 -1
  168. package/src/primitives/tooltip/tooltipArrow.tsx +1 -1
  169. package/src/styles/font/responsiveFont.ts +13 -0
  170. package/src/theme/__workshop__/canvas.tsx +1 -1
  171. package/src/theme/__workshop__/color.tsx +0 -1
  172. package/src/theme/__workshop__/layer.tsx +1 -1
  173. package/src/theme/__workshop__/nestedProvider.tsx +0 -1
  174. package/src/theme/theme.test.tsx +3 -5
  175. package/src/theme/themeColorProvider.tsx +0 -1
  176. package/src/theme/themeProvider.tsx +1 -1
  177. package/src/utils/boundaryElement/__workshop__/plain.tsx +1 -1
  178. package/src/utils/boundaryElement/boundaryElement.test.tsx +3 -5
  179. package/src/utils/boundaryElement/boundaryElementProvider.tsx +1 -1
  180. package/src/utils/elementQuery/__workshop__/customMedia.tsx +0 -1
  181. package/src/utils/elementQuery/elementQuery.tsx +1 -1
  182. package/src/utils/errorBoundary.tsx +4 -4
  183. package/src/utils/layer/__workshop__/_debug.tsx +0 -1
  184. package/src/utils/layer/__workshop__/multipleRoots.tsx +0 -1
  185. package/src/utils/layer/__workshop__/plain.tsx +1 -1
  186. package/src/utils/layer/__workshop__/responsiveZOffset.tsx +0 -1
  187. package/src/utils/layer/layer.test.tsx +3 -5
  188. package/src/utils/layer/layer.tsx +1 -1
  189. package/src/utils/layer/layerProvider.tsx +1 -1
  190. package/src/utils/portal/__workshop__/named.tsx +1 -1
  191. package/src/utils/portal/portal.test.tsx +3 -5
  192. package/src/utils/portal/portal.ts +2 -3
  193. package/src/utils/portal/portalProvider.tsx +1 -1
  194. package/src/utils/srOnly/srOnly.tsx +1 -1
  195. package/src/utils/virtualList/__workshop__/changingProps.tsx +1 -1
  196. package/src/utils/virtualList/__workshop__/elementScroll.tsx +1 -1
  197. package/src/utils/virtualList/__workshop__/infiniteList.tsx +1 -1
  198. package/src/utils/virtualList/__workshop__/windowScrolll.tsx +1 -1
  199. package/src/utils/virtualList/virtualList.tsx +1 -1
  200. package/dist/sanity-ui.cjs +0 -1321
  201. package/dist/sanity-ui.cjs.map +0 -1
@@ -33,7 +33,7 @@ export function useMenuController(props: {
33
33
  const activeElement = elementsRef.current[activeIndex] || null
34
34
  const mounted = Boolean(rootElement)
35
35
 
36
- const setActiveIndex = useCallback((nextActiveIndex) => {
36
+ const setActiveIndex = useCallback((nextActiveIndex: number) => {
37
37
  _setActiveIndex(nextActiveIndex)
38
38
  activeIndexRef.current = nextActiveIndex
39
39
  }, [])
@@ -12,7 +12,6 @@ import {
12
12
  TextSkeleton,
13
13
  } from '@sanity/ui'
14
14
  import {useBoolean, useSelect} from '@sanity/ui-workshop'
15
- import React from 'react'
16
15
  import {WORKSHOP_CARD_TONE_OPTIONS} from '../../../__workshop__/constants'
17
16
 
18
17
  export default function SkeletonDelayStory() {
@@ -12,7 +12,6 @@ import {
12
12
  TextSkeleton,
13
13
  } from '@sanity/ui'
14
14
  import {useBoolean, useSelect} from '@sanity/ui-workshop'
15
- import React from 'react'
16
15
  import {WORKSHOP_CARD_TONE_OPTIONS} from '../../../__workshop__/constants'
17
16
 
18
17
  export default function SkeletonStory() {
@@ -1,4 +1,4 @@
1
- import React, {forwardRef, useEffect, useState} from 'react'
1
+ import {forwardRef, useEffect, useState} from 'react'
2
2
  import styled from 'styled-components'
3
3
  import {useArrayProp} from '../../hooks'
4
4
  import {Box} from '../../primitives'
@@ -1,4 +1,4 @@
1
- import React, {forwardRef} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
3
  import {useArrayProp} from '../../hooks'
4
4
  import {_responsive} from '../../styles'
@@ -1,6 +1,6 @@
1
1
  import {OkHandIcon, RocketIcon, SunIcon} from '@sanity/icons'
2
2
  import {Box, Card, Tab, TabList, TabPanel, Text} from '@sanity/ui'
3
- import React, {useState} from 'react'
3
+ import {useState} from 'react'
4
4
 
5
5
  export default function ExampleStory() {
6
6
  const [tab, setTab] = useState('foo')
@@ -1,4 +1,4 @@
1
- import React, {forwardRef, useCallback, useEffect, useRef} from 'react'
1
+ import {forwardRef, useCallback, useEffect, useRef} from 'react'
2
2
  import {useForwardedRef} from '../../hooks'
3
3
  import {Button} from '../../primitives'
4
4
  import {ButtonTone} from '../../types'
@@ -12,7 +12,7 @@ export interface TabProps {
12
12
  */
13
13
  'aria-controls': string
14
14
  id: string
15
- icon?: React.ComponentType | React.ReactNode
15
+ icon?: React.ElementType | React.ReactNode
16
16
  focused?: boolean
17
17
  fontSize?: number | number[]
18
18
  label?: React.ReactNode
@@ -1,4 +1,4 @@
1
- import React, {cloneElement, forwardRef, useCallback, useMemo, useState} from 'react'
1
+ import {cloneElement, forwardRef, useCallback, useMemo, useState} from 'react'
2
2
  import {Inline, InlineProps} from '../../primitives'
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import React, {forwardRef} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import {Box, BoxProps} from '../../primitives'
3
3
 
4
4
  /**
@@ -1,5 +1,4 @@
1
1
  import {Box, Button, Inline, ToastProvider, useToast} from '@sanity/ui'
2
- import React from 'react'
3
2
 
4
3
  export default function HookStory() {
5
4
  const toast = useToast()
@@ -1,6 +1,5 @@
1
1
  import {Box, Container, Toast} from '@sanity/ui'
2
2
  import {useAction, useBoolean, useSelect, useString, useText} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
  import {WORKSHOP_TOAST_STATUS_OPTIONS} from '../../../__workshop__/constants'
5
4
 
6
5
  export default function ToastStory() {
@@ -1,5 +1,3 @@
1
- import React from 'react'
2
- import {vi} from 'vitest'
3
1
  import {render} from '../../../test'
4
2
  import {ToastContext} from './toastContext'
5
3
  import {ToastContextValue} from './types'
@@ -8,7 +6,7 @@ import {useToast} from './useToast'
8
6
  describe('components/toast', () => {
9
7
  describe('useToast', () => {
10
8
  it('should get context value', async () => {
11
- const log = vi.fn()
9
+ const log = jest.fn()
12
10
 
13
11
  function Debug() {
14
12
  const rootToast = useToast()
@@ -38,7 +36,7 @@ describe('components/toast', () => {
38
36
  })
39
37
 
40
38
  it('should fail when no context value is provided', async () => {
41
- const log = vi.fn()
39
+ const log = jest.fn()
42
40
 
43
41
  function Debug() {
44
42
  try {
@@ -66,7 +64,7 @@ describe('components/toast', () => {
66
64
  })
67
65
 
68
66
  it('should fail when context value is not compatible', async () => {
69
- const log = vi.fn()
67
+ const log = jest.fn()
70
68
 
71
69
  function Debug() {
72
70
  try {
@@ -1,5 +1,4 @@
1
1
  import {CloseIcon} from '@sanity/icons'
2
- import React from 'react'
3
2
  import styled from 'styled-components'
4
3
  import {Box, Button, Card, Flex, Stack, Text} from '../../primitives'
5
4
  import {ThemeColorToneKey} from '../../theme'
@@ -1,5 +1,5 @@
1
1
  import {AnimatePresence, motion} from 'framer-motion'
2
- import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'
2
+ import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
3
3
  import styled from 'styled-components'
4
4
  import {Box} from '../../primitives'
5
5
  import {Layer} from '../../utils'
@@ -1,7 +1,7 @@
1
1
  import {LinkIcon} from '@sanity/icons'
2
2
  import {Box, Tree, TreeItem} from '@sanity/ui'
3
3
  import {usePerfTest} from '@sanity/ui-workshop'
4
- import React, {useCallback, useState} from 'react'
4
+ import {useCallback, useState} from 'react'
5
5
  import {perfTests} from './basic.perf'
6
6
 
7
7
  export default function BasicStory() {
@@ -1,4 +1,4 @@
1
- import React, {forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState} from 'react'
1
+ import {forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState} from 'react'
2
2
  import {useForwardedRef} from '../../hooks'
3
3
  import {Stack} from '../../primitives'
4
4
  import {_findNextItemElement, _findPrevItemElement, _focusItemElement} from './helpers'
@@ -1,4 +1,4 @@
1
- import React, {memo} from 'react'
1
+ import {memo} from 'react'
2
2
  import {Stack} from '../../primitives'
3
3
  import {useTree} from './useTree'
4
4
 
@@ -1,6 +1,5 @@
1
- import {useId} from '@reach/auto-id'
2
1
  import {ToggleArrowRightIcon} from '@sanity/icons'
3
- import React, {createElement, memo, useCallback, useEffect, useMemo, useRef} from 'react'
2
+ import {createElement, memo, useCallback, useEffect, useId, useMemo, useRef} from 'react'
4
3
  import styled from 'styled-components'
5
4
  import {Box, Flex, Text} from '../../primitives'
6
5
  import {ThemeFontWeightKey} from '../../theme'
@@ -20,7 +19,7 @@ import {useTree} from './useTree'
20
19
  export interface TreeItemProps {
21
20
  expanded?: boolean
22
21
  fontSize?: number | number[]
23
- icon?: React.ComponentType
22
+ icon?: React.ElementType
24
23
  padding?: number | number[]
25
24
  space?: number | number[]
26
25
  text?: React.ReactNode
@@ -64,7 +63,8 @@ export const TreeItem = memo(function TreeItem(
64
63
  const treeitemRef = useRef<HTMLDivElement | null>(null)
65
64
  const tree = useTree()
66
65
  const {path, registerItem, setExpanded, setFocusedElement} = tree
67
- const id = useId(idProp) || idProp
66
+ const _id = useId()
67
+ const id = idProp || _id
68
68
  const itemPath = useMemo(() => path.concat([id || '']), [id, path])
69
69
  const itemKey = itemPath.join('/')
70
70
  const itemState = tree.state[itemKey]
@@ -1,6 +1,5 @@
1
1
  import {Box, Card, Code, Container, Stack, Text, useElementRect} from '@sanity/ui'
2
2
  import {useMemo, useState} from 'react'
3
- import React from 'react'
4
3
  import {Grid} from '../../../primitives'
5
4
 
6
5
  export default function ExampleStory() {
@@ -1,4 +1,4 @@
1
- import React, {useRef} from 'react'
1
+ import {useRef} from 'react'
2
2
  import {useIsomorphicEffect} from './useIsomorphicEffect'
3
3
 
4
4
  /**
@@ -1,5 +1,4 @@
1
1
  import {Card, Stack, Text, useMediaIndex} from '@sanity/ui'
2
- import React from 'react'
3
2
 
4
3
  export default function TestStory() {
5
4
  const mediaIndex = useMediaIndex()
@@ -1,6 +1,6 @@
1
1
  import {Icon, icons, IconSymbol, SearchIcon} from '@sanity/icons'
2
2
  import {Box, Card, Code, Container, Flex, Heading, Stack, Text, TextInput} from '@sanity/ui'
3
- import React, {useCallback, useMemo, useState} from 'react'
3
+ import {useCallback, useMemo, useState} from 'react'
4
4
  import {packages} from '$packages'
5
5
 
6
6
  function ucfirst(str: string) {
@@ -1,6 +1,5 @@
1
1
  import {Avatar, Flex} from '@sanity/ui'
2
2
  import {useSelect} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
  import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '../../../__workshop__/constants'
5
4
 
6
5
  export default function AsButtonStory() {
@@ -1,6 +1,5 @@
1
1
  import {Avatar, AvatarCounter, AvatarStack, Flex} from '@sanity/ui'
2
2
  import {useSelect} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
  import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '../../../__workshop__/constants'
5
4
 
6
5
  export default function StackStory() {
@@ -1,5 +1,4 @@
1
- import {useId} from '@reach/auto-id'
2
- import React, {forwardRef, useCallback, useEffect, useMemo, useState} from 'react'
1
+ import {forwardRef, useCallback, useEffect, useId, useMemo, useState} from 'react'
3
2
  import ReactIs from 'react-is'
4
3
  import styled from 'styled-components'
5
4
  import {useArrayProp} from '../../hooks'
@@ -71,7 +70,7 @@ export const Avatar = forwardRef(function Avatar(
71
70
  const _sizeRem = avatarSize.size
72
71
  const _radius = _sizeRem / 2
73
72
 
74
- const elementId = useId() || ''
73
+ const elementId = useId()
75
74
  const [arrowPosition, setArrowPosition] = useState<AvatarPosition | undefined>(
76
75
  animateArrowFrom || arrowPositionProp || 'inside'
77
76
  )
@@ -1,4 +1,4 @@
1
- import React, {forwardRef, useMemo} from 'react'
1
+ import {forwardRef, useMemo} from 'react'
2
2
  import styled, {css} from 'styled-components'
3
3
  import {EMPTY_RECORD} from '../../constants'
4
4
  import {useArrayProp} from '../../hooks'
@@ -1,4 +1,4 @@
1
- import React, {cloneElement, forwardRef} from 'react'
1
+ import {cloneElement, forwardRef} from 'react'
2
2
  import styled, {css} from 'styled-components'
3
3
  import {EMPTY_RECORD} from '../../constants'
4
4
  import {useArrayProp} from '../../hooks'
@@ -1,6 +1,5 @@
1
1
  import {Badge, Flex} from '@sanity/ui'
2
2
  import {useAction, useSelect, useText} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
  import {
5
4
  WORKSHOP_BADGE_MODE_OPTIONS,
6
5
  WORKSHOP_BADGE_TONE_OPTIONS,
@@ -1,6 +1,5 @@
1
1
  import {Badge, Flex, Inline} from '@sanity/ui'
2
2
  import {useSelect} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
  import {WORKSHOP_BADGE_MODE_OPTIONS} from '../../../__workshop__/constants'
5
4
 
6
5
  export default function Tones() {
@@ -0,0 +1,13 @@
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
+ })
@@ -1,4 +1,4 @@
1
- import React, {forwardRef} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
3
  import {useArrayProp} from '../../hooks'
4
4
  import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
@@ -1,6 +1,5 @@
1
1
  import {Box, Card, Text} from '@sanity/ui'
2
2
  import {useAction, useSelect} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
  import {WORKSHOP_SPACE_OPTIONS} from '../../../__workshop__/constants'
5
4
 
6
5
  export default function PropsStory() {
@@ -1,5 +1,4 @@
1
1
  import {Box, Text} from '@sanity/ui'
2
- import React from 'react'
3
2
 
4
3
  export default function ResponsiveStory() {
5
4
  return (
@@ -1,4 +1,4 @@
1
- import React, {forwardRef} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
3
  import {useArrayProp} from '../../hooks'
4
4
  import {
@@ -1,5 +1,4 @@
1
1
  import {Button, Flex, Grid, Stack, Text} from '@sanity/ui'
2
- import React from 'react'
3
2
  import {WORKSHOP_BUTTON_TONE_OPTIONS} from '../../../__workshop__/constants'
4
3
 
5
4
  export default function CustomStory() {
@@ -1,6 +1,5 @@
1
1
  import {RocketIcon} from '@sanity/icons'
2
2
  import {Button, Flex, Inline} from '@sanity/ui'
3
- import React from 'react'
4
3
 
5
4
  export default function CustomIconsStory() {
6
5
  return (
@@ -1,6 +1,5 @@
1
1
  import {AddIcon} from '@sanity/icons'
2
2
  import {Button, Flex} from '@sanity/ui'
3
- import React from 'react'
4
3
 
5
4
  export default function MixedChildrenStory() {
6
5
  return (
@@ -1,7 +1,6 @@
1
1
  import {icons} from '@sanity/icons'
2
2
  import {Button, Flex} from '@sanity/ui'
3
3
  import {useAction, useBoolean, useSelect, useText} from '@sanity/ui-workshop'
4
- import React from 'react'
5
4
  import {
6
5
  WORKSHOP_BUTTON_MODE_OPTIONS,
7
6
  WORKSHOP_BUTTON_TEXT_ALIGN_OPTIONS,
@@ -1,6 +1,5 @@
1
1
  import {UploadIcon} from '@sanity/icons'
2
2
  import {Button, Flex} from '@sanity/ui'
3
- import React from 'react'
4
3
  import styled from 'styled-components'
5
4
 
6
5
  const SanityUploadButton = styled(Button).attrs({forwardedAs: 'label'})`
@@ -1,7 +1,6 @@
1
1
  import {icons} from '@sanity/icons'
2
2
  import {Box, Button, Card, Container, Flex, Stack} from '@sanity/ui'
3
3
  import {useAction, useBoolean, useSelect} from '@sanity/ui-workshop'
4
- import React from 'react'
5
4
  import {
6
5
  WORKSHOP_BUTTON_MODE_OPTIONS,
7
6
  WORKSHOP_BUTTON_TONE_OPTIONS,
@@ -1,5 +1,4 @@
1
1
  import {Button, Flex} from '@sanity/ui'
2
- import React from 'react'
3
2
  import styled from 'styled-components'
4
3
 
5
4
  const StyledButton1 = styled.a`
@@ -1,5 +1,4 @@
1
1
  import {Button, Flex} from '@sanity/ui'
2
- import React from 'react'
3
2
  import styled from 'styled-components'
4
3
 
5
4
  const StyledButton2 = styled(Button)<{$color?: boolean}>`
@@ -1,5 +1,5 @@
1
1
  import {Button, Flex} from '@sanity/ui'
2
- import React, {useCallback, useRef} from 'react'
2
+ import {useCallback, useRef} from 'react'
3
3
 
4
4
  export default function UploadButtonStory() {
5
5
  const inputRef = useRef<HTMLInputElement | null>(null)
@@ -0,0 +1,41 @@
1
+ import {AddIcon} from '@sanity/icons'
2
+ import {screen} from '@testing-library/react'
3
+ import {axe} from 'jest-axe'
4
+ import {render} from '../../../test'
5
+ import {Button, ButtonProps} from './button'
6
+
7
+ describe('atoms/button', () => {
8
+ it('Axe: should have no violations', async () => {
9
+ const lightResult = render(<Button icon={AddIcon} text="Label" tone="positive" />, {
10
+ scheme: 'light',
11
+ })
12
+
13
+ expect(await axe(lightResult.container.outerHTML)).toHaveNoViolations()
14
+
15
+ const darkResult = render(<Button icon={AddIcon} text="Label" tone="positive" />, {
16
+ scheme: 'dark',
17
+ })
18
+
19
+ expect(await axe(darkResult.container.outerHTML)).toHaveNoViolations()
20
+ })
21
+
22
+ it('should render text', () => {
23
+ render(<Button text="Button text" />)
24
+
25
+ expect(screen.getByText('Button text')).toBeInTheDocument()
26
+ })
27
+
28
+ it('should wrap button', () => {
29
+ function WrappedButton({button: buttonProps}: {button: ButtonProps}) {
30
+ return <Button {...buttonProps} />
31
+ }
32
+
33
+ const buttonProps: ButtonProps = {
34
+ text: 'Button text',
35
+ }
36
+
37
+ render(<WrappedButton button={buttonProps} />)
38
+
39
+ expect(screen.getByText('Button text')).toBeInTheDocument()
40
+ })
41
+ })
@@ -1,4 +1,4 @@
1
- import React, {createElement, forwardRef, isValidElement, useMemo} from 'react'
1
+ import {createElement, forwardRef, isValidElement, useMemo} from 'react'
2
2
  import {isValidElementType} from 'react-is'
3
3
  import styled from 'styled-components'
4
4
  import {useArrayProp} from '../../hooks'
@@ -20,8 +20,8 @@ export interface ButtonProps extends ResponsivePaddingProps, ResponsiveRadiusPro
20
20
  as?: React.ElementType | keyof JSX.IntrinsicElements
21
21
  fontSize?: number | number[]
22
22
  mode?: ButtonMode
23
- icon?: React.ComponentType | React.ReactNode
24
- iconRight?: React.ComponentType | React.ReactNode
23
+ icon?: React.ElementType | React.ReactNode
24
+ iconRight?: React.ElementType | React.ReactNode
25
25
  justify?: FlexJustify | FlexJustify[]
26
26
  /**
27
27
  * @beta Do not use in production, as this might change.
@@ -1,5 +1,4 @@
1
1
  import {Card, Container, Flex, Stack, Text} from '@sanity/ui'
2
- import React from 'react'
3
2
  import {WORKSHOP_CARD_TONE_OPTIONS} from '../../../__workshop__/constants'
4
3
 
5
4
  export default function AllTonesStory() {
@@ -1,5 +1,4 @@
1
1
  import {Box, Card, Container, Flex, Grid, Stack, Text} from '@sanity/ui'
2
- import React from 'react'
3
2
  import {WORKSHOP_CARD_TONE_OPTIONS} from '../../../__workshop__/constants'
4
3
 
5
4
  export default function AsButtonStory() {
@@ -1,5 +1,5 @@
1
1
  import {Card, Flex, Text} from '@sanity/ui'
2
- import React, {forwardRef} from 'react'
2
+ import {forwardRef} from 'react'
3
3
 
4
4
  const CustomLink = forwardRef(function CustomLink(
5
5
  props: {req: string} & Omit<React.HTMLProps<HTMLAnchorElement>, 'as' | 'href'>,
@@ -1,5 +1,4 @@
1
1
  import {Card, Flex, Stack} from '@sanity/ui'
2
- import React from 'react'
3
2
 
4
3
  export default function CheckeredStory() {
5
4
  return (
@@ -1,6 +1,5 @@
1
1
  import {Card, Flex, Stack, Text} from '@sanity/ui'
2
2
  import {useBoolean} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
 
5
4
  export default function InteractiveCardStory() {
6
5
  const selected = useBoolean('Selected', false, 'Props')
@@ -1,5 +1,4 @@
1
1
  import {Box, Card, Flex, Skeleton, Text} from '@sanity/ui'
2
- import React from 'react'
3
2
  import {Stack} from '../../stack'
4
3
 
5
4
  export default function ListNavigationStory() {
@@ -1,6 +1,5 @@
1
1
  import {Card, Flex, Stack, Text} from '@sanity/ui'
2
2
  import {useAction, useBoolean, useSelect} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
  import {
5
4
  WORKSHOP_CARD_AS_OPTIONS,
6
5
  WORKSHOP_CARD_TONE_OPTIONS,
@@ -12,7 +12,6 @@ import {
12
12
  useRootTheme,
13
13
  } from '@sanity/ui'
14
14
  import {useBoolean} from '@sanity/ui-workshop'
15
- import React from 'react'
16
15
  import styled, {css} from 'styled-components'
17
16
 
18
17
  const TextWithTone = styled(Text)<{$tone: ThemeColorToneKey}>(
@@ -1,5 +1,4 @@
1
1
  import {Card, Flex, Text} from '@sanity/ui'
2
- import React from 'react'
3
2
  import styled from 'styled-components'
4
3
 
5
4
  const StyledCard = styled(Card).attrs({forwardedAs: 'ol'})``
@@ -1,4 +1,4 @@
1
- import React, {forwardRef} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import {isValidElementType} from 'react-is'
3
3
  import styled from 'styled-components'
4
4
  import {useArrayProp} from '../../hooks'
@@ -1,5 +1,5 @@
1
1
  import {Box, Checkbox, Flex, Text} from '@sanity/ui'
2
- import React, {useCallback, useState} from 'react'
2
+ import {useCallback, useState} from 'react'
3
3
 
4
4
  export default function ExampleStory() {
5
5
  const [checked, setChecked] = useState<boolean | undefined>(undefined)
@@ -1,6 +1,5 @@
1
1
  import {Box, Checkbox, Flex, Text} from '@sanity/ui'
2
2
  import {useAction, useBoolean} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
 
5
4
  export default function PropsStory() {
6
5
  const checked = useBoolean('Checked', false, 'Props')
@@ -1,5 +1,4 @@
1
1
  import {Box, Checkbox, Flex, Text} from '@sanity/ui'
2
- import React from 'react'
3
2
 
4
3
  export default function ReadOnlyStory() {
5
4
  return (
@@ -1,5 +1,4 @@
1
1
  import {Card, Checkbox, Flex, Stack} from '@sanity/ui'
2
- import React from 'react'
3
2
 
4
3
  export default function MultipleTonesStory() {
5
4
  return (
@@ -1,5 +1,5 @@
1
1
  import {CheckmarkIcon, RemoveIcon} from '@sanity/icons'
2
- import React, {forwardRef, useEffect} from 'react'
2
+ import {forwardRef, useEffect} from 'react'
3
3
  import styled from 'styled-components'
4
4
  import {useForwardedRef, useCustomValidity} from '../../hooks'
5
5
  import {checkboxBaseStyles, inputElementStyles} from './styles'
@@ -1,6 +1,5 @@
1
1
  import {AddCircleIcon} from '@sanity/icons'
2
2
  import {Box, Card, Code, Flex, Stack} from '@sanity/ui'
3
- import React from 'react'
4
3
 
5
4
  export default function OpticalAlignment() {
6
5
  return (
@@ -1,6 +1,5 @@
1
1
  import {Box, Code} from '@sanity/ui'
2
2
  import {useSelect, useText} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
  import {
5
4
  WORKSHOP_CODE_LANGUAGE_OPTIONS,
6
5
  WORKSHOP_TEXT_FONT_SIZE_OPTIONS,
@@ -1,4 +1,4 @@
1
- import React, {forwardRef} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import Refractor from 'react-refractor'
3
3
  import styled from 'styled-components'
4
4
  import {useArrayProp} from '../../hooks'
@@ -1,6 +1,5 @@
1
1
  import {Card, Container, Flex, Text} from '@sanity/ui'
2
2
  import {useAction, useSelect} from '@sanity/ui-workshop'
3
- import React from 'react'
4
3
  import {WORKSHOP_CONTAINER_WIDTH_OPTIONS} from '../../../__workshop__/constants'
5
4
 
6
5
  export default function PlainStory() {
@@ -1,4 +1,4 @@
1
- import React, {forwardRef} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
3
  import {useArrayProp} from '../../hooks'
4
4
  import {Box, BoxProps} from '../box'