@sanity/ui 2.10.17 → 2.10.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 (49) hide show
  1. package/dist/index.esm.js +370 -310
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.js +370 -310
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +370 -310
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +3 -2
  8. package/src/core/components/autocomplete/autocomplete.styles.tsx +1 -1
  9. package/src/core/components/autocomplete/autocomplete.tsx +3 -3
  10. package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +1 -1
  11. package/src/core/components/breadcrumbs/breadcrumbs.tsx +3 -3
  12. package/src/core/components/dialog/dialog.tsx +3 -3
  13. package/src/core/components/hotkeys/hotkeys.tsx +3 -3
  14. package/src/core/components/menu/menu.tsx +3 -3
  15. package/src/core/components/skeleton/skeleton.tsx +4 -5
  16. package/src/core/components/skeleton/textSkeleton.tsx +5 -5
  17. package/src/core/components/toast/toast.tsx +3 -3
  18. package/src/core/components/toast/toastProvider.tsx +3 -3
  19. package/src/core/components/tree/treeItem.tsx +5 -5
  20. package/src/core/primitives/avatar/avatar.tsx +6 -6
  21. package/src/core/primitives/avatar/avatarCounter.tsx +3 -3
  22. package/src/core/primitives/avatar/avatarStack.tsx +6 -3
  23. package/src/core/primitives/badge/badge.tsx +3 -3
  24. package/src/core/primitives/box/box.tsx +3 -3
  25. package/src/core/primitives/button/button.tsx +3 -3
  26. package/src/core/primitives/card/card.tsx +2 -2
  27. package/src/core/primitives/checkbox/checkbox.tsx +3 -3
  28. package/src/core/primitives/code/code.tsx +3 -3
  29. package/src/core/primitives/container/container.tsx +2 -2
  30. package/src/core/primitives/flex/flex.tsx +2 -2
  31. package/src/core/primitives/grid/grid.tsx +3 -3
  32. package/src/core/primitives/heading/heading.tsx +4 -11
  33. package/src/core/primitives/inline/inline.tsx +3 -3
  34. package/src/core/primitives/kbd/kbd.tsx +3 -3
  35. package/src/core/primitives/label/label.tsx +4 -11
  36. package/src/core/primitives/radio/radio.tsx +3 -3
  37. package/src/core/primitives/select/select.tsx +3 -3
  38. package/src/core/primitives/spinner/spinner.tsx +3 -3
  39. package/src/core/primitives/stack/stack.tsx +5 -2
  40. package/src/core/primitives/switch/switch.tsx +3 -3
  41. package/src/core/primitives/text/text.tsx +4 -11
  42. package/src/core/primitives/textArea/textArea.tsx +3 -3
  43. package/src/core/primitives/textInput/textInput.tsx +3 -3
  44. package/src/core/primitives/tooltip/tooltip.tsx +3 -3
  45. package/src/core/utils/arrow/arrow.tsx +3 -3
  46. package/src/core/utils/layer/layer.tsx +9 -3
  47. package/src/core/utils/spanWithTextOverflow.tsx +10 -0
  48. package/src/core/utils/srOnly/srOnly.tsx +3 -3
  49. package/src/core/utils/virtualList/virtualList.tsx +3 -3
@@ -9,6 +9,7 @@ import {
9
9
  ResponsiveTextAlignStyleProps,
10
10
  } from '../../styles/internal'
11
11
  import {TextAlign} from '../../types'
12
+ import {SpanWithTextOverflow} from '../../utils/spanWithTextOverflow'
12
13
  import {headingBaseStyle} from './styles'
13
14
  import {HeadingStyleProps} from './types'
14
15
 
@@ -30,18 +31,10 @@ export interface HeadingProps {
30
31
  weight?: ThemeFontWeightKey
31
32
  }
32
33
 
33
- const Root = styled.div<
34
+ const StyledHeading = styled.div<
34
35
  HeadingStyleProps & ResponsiveTextAlignStyleProps & ResponsiveFontStyleProps
35
36
  >(headingBaseStyle, responsiveTextAlignStyle, responsiveHeadingFont)
36
37
 
37
- const SpanWithTextOverflow = styled.span`
38
- display: block;
39
- white-space: nowrap;
40
- text-overflow: ellipsis;
41
- overflow: hidden;
42
- overflow: clip;
43
- `
44
-
45
38
  /**
46
39
  * Typographic headings.
47
40
  *
@@ -69,7 +62,7 @@ export const Heading = forwardRef(function Heading(
69
62
  }
70
63
 
71
64
  return (
72
- <Root
65
+ <StyledHeading
73
66
  data-ui="Heading"
74
67
  {...restProps}
75
68
  $accent={accent}
@@ -80,7 +73,7 @@ export const Heading = forwardRef(function Heading(
80
73
  ref={ref}
81
74
  >
82
75
  <span>{children}</span>
83
- </Root>
76
+ </StyledHeading>
84
77
  )
85
78
  })
86
79
  Heading.displayName = 'ForwardRef(Heading)'
@@ -13,7 +13,7 @@ export interface InlineProps extends Omit<BoxProps, 'display'> {
13
13
  space?: number | number[]
14
14
  }
15
15
 
16
- const Root = styled(Box)<ResponsiveInlineSpaceStyleProps>(inlineBaseStyle, inlineSpaceStyle)
16
+ const StyledInline = styled(Box)<ResponsiveInlineSpaceStyleProps>(inlineBaseStyle, inlineSpaceStyle)
17
17
 
18
18
  /**
19
19
  * The `Inline` component is a layout utility for aligning and spacing items horizontally.
@@ -32,7 +32,7 @@ export const Inline = forwardRef(function Inline(
32
32
  )
33
33
 
34
34
  return (
35
- <Root
35
+ <StyledInline
36
36
  data-ui="Inline"
37
37
  {...restProps}
38
38
  $space={useArrayProp(space)}
@@ -40,7 +40,7 @@ export const Inline = forwardRef(function Inline(
40
40
  ref={ref as any}
41
41
  >
42
42
  {children}
43
- </Root>
43
+ </StyledInline>
44
44
  )
45
45
  })
46
46
  Inline.displayName = 'ForwardRef(Inline)'
@@ -34,7 +34,7 @@ function kbdStyle() {
34
34
  `
35
35
  }
36
36
 
37
- const Root = styled.kbd<ResponsiveRadiusStyleProps>(responsiveRadiusStyle, kbdStyle)
37
+ const StyledKBD = styled.kbd<ResponsiveRadiusStyleProps>(responsiveRadiusStyle, kbdStyle)
38
38
 
39
39
  /**
40
40
  * Used to define some text as keyboard input.
@@ -48,13 +48,13 @@ export const KBD = forwardRef(function KBD(
48
48
  const {children, fontSize = 0, padding = 1, radius = 2, ...restProps} = props
49
49
 
50
50
  return (
51
- <Root data-ui="KBD" {...restProps} $radius={useArrayProp(radius)} ref={ref}>
51
+ <StyledKBD data-ui="KBD" {...restProps} $radius={useArrayProp(radius)} ref={ref}>
52
52
  <Box as="span" padding={padding}>
53
53
  <Text as="span" size={fontSize} weight="semibold">
54
54
  {children}
55
55
  </Text>
56
56
  </Box>
57
- </Root>
57
+ </StyledKBD>
58
58
  )
59
59
  })
60
60
  KBD.displayName = 'ForwardRef(KBD)'
@@ -4,6 +4,7 @@ import {styled} from 'styled-components'
4
4
  import {useArrayProp} from '../../hooks'
5
5
  import {responsiveLabelFont, responsiveTextAlignStyle} from '../../styles/internal'
6
6
  import {TextAlign} from '../../types'
7
+ import {SpanWithTextOverflow} from '../../utils/spanWithTextOverflow'
7
8
  import {labelBaseStyle} from './styles'
8
9
 
9
10
  /**
@@ -24,21 +25,13 @@ export interface LabelProps {
24
25
  weight?: ThemeFontWeightKey
25
26
  }
26
27
 
27
- const Root = styled.div<{
28
+ const StyledLabel = styled.div<{
28
29
  $accent?: boolean
29
30
  $align: TextAlign[]
30
31
  $muted: boolean
31
32
  $size: number[]
32
33
  }>(responsiveLabelFont, responsiveTextAlignStyle, labelBaseStyle)
33
34
 
34
- const SpanWithTextOverflow = styled.span`
35
- display: block;
36
- white-space: nowrap;
37
- text-overflow: ellipsis;
38
- overflow: hidden;
39
- overflow: clip;
40
- `
41
-
42
35
  /**
43
36
  * Typographic labels.
44
37
  *
@@ -68,7 +61,7 @@ export const Label = forwardRef(function Label(
68
61
  }
69
62
 
70
63
  return (
71
- <Root
64
+ <StyledLabel
72
65
  data-ui="Label"
73
66
  {...restProps}
74
67
  $accent={accent}
@@ -79,7 +72,7 @@ export const Label = forwardRef(function Label(
79
72
  ref={ref}
80
73
  >
81
74
  {children}
82
- </Root>
75
+ </StyledLabel>
83
76
  )
84
77
  })
85
78
  Label.displayName = 'ForwardRef(Label)'
@@ -10,7 +10,7 @@ export interface RadioProps {
10
10
  customValidity?: string
11
11
  }
12
12
 
13
- const Root = styled.div(radioBaseStyle)
13
+ const StyledRadio = styled.div(radioBaseStyle)
14
14
  const Input = styled.input(inputElementStyle)
15
15
 
16
16
  /**
@@ -33,7 +33,7 @@ export const Radio = forwardRef(function Radio(
33
33
  useCustomValidity(ref, customValidity)
34
34
 
35
35
  return (
36
- <Root className={className} data-ui="Radio" style={style}>
36
+ <StyledRadio className={className} data-ui="Radio" style={style}>
37
37
  <Input
38
38
  data-read-only={!disabled && readOnly ? '' : undefined}
39
39
  data-error={customValidity ? '' : undefined}
@@ -44,7 +44,7 @@ export const Radio = forwardRef(function Radio(
44
44
  type="radio"
45
45
  />
46
46
  <span />
47
- </Root>
47
+ </StyledRadio>
48
48
  )
49
49
  })
50
50
  Radio.displayName = 'ForwardRef(Radio)'
@@ -18,7 +18,7 @@ export interface SelectProps {
18
18
  customValidity?: string
19
19
  }
20
20
 
21
- const Root = styled.div(selectStyle.root)
21
+ const StyledSelect = styled.div(selectStyle.root)
22
22
 
23
23
  const Input = styled.select<{
24
24
  $fontSize: number[]
@@ -60,7 +60,7 @@ export const Select = forwardRef(function Select(
60
60
  useCustomValidity(ref, customValidity)
61
61
 
62
62
  return (
63
- <Root data-ui="Select">
63
+ <StyledSelect data-ui="Select">
64
64
  <Input
65
65
  data-read-only={!disabled && readOnly ? '' : undefined}
66
66
  data-ui="Select"
@@ -80,7 +80,7 @@ export const Select = forwardRef(function Select(
80
80
  <ChevronDownIcon />
81
81
  </Text>
82
82
  </IconBox>
83
- </Root>
83
+ </StyledSelect>
84
84
  )
85
85
  })
86
86
  Select.displayName = 'ForwardRef(Select)'
@@ -21,7 +21,7 @@ const rotate = keyframes`
21
21
  }
22
22
  `
23
23
 
24
- const Root = styled(Text)`
24
+ const StyledSpinner = styled(Text)`
25
25
  & > span > svg {
26
26
  animation: ${rotate} 500ms linear infinite;
27
27
  }
@@ -37,9 +37,9 @@ export const Spinner = forwardRef(function Spinner(
37
37
  ref: React.ForwardedRef<HTMLDivElement>,
38
38
  ) {
39
39
  return (
40
- <Root data-ui="Spinner" {...props} ref={ref}>
40
+ <StyledSpinner data-ui="Spinner" {...props} ref={ref}>
41
41
  <SpinnerIcon />
42
- </Root>
42
+ </StyledSpinner>
43
43
  )
44
44
  })
45
45
  Spinner.displayName = 'ForwardRef(Spinner)'
@@ -12,7 +12,10 @@ export interface StackProps extends BoxProps {
12
12
  space?: number | number[]
13
13
  }
14
14
 
15
- const Root = styled(Box)<ResponsiveStackSpaceStyleProps>(stackBaseStyle, responsiveStackSpaceStyle)
15
+ const StyledStack = styled(Box)<ResponsiveStackSpaceStyleProps>(
16
+ stackBaseStyle,
17
+ responsiveStackSpaceStyle,
18
+ )
16
19
 
17
20
  /**
18
21
  * The `Stack` component is used to place elements on top of each other.
@@ -26,7 +29,7 @@ export const Stack = forwardRef(function Stack(
26
29
  const {as, space, ...restProps} = props
27
30
 
28
31
  return (
29
- <Root
32
+ <StyledStack
30
33
  data-as={typeof as === 'string' ? as : undefined}
31
34
  data-ui="Stack"
32
35
  {...restProps}
@@ -15,7 +15,7 @@ export interface SwitchProps {
15
15
  indeterminate?: boolean
16
16
  }
17
17
 
18
- const Root = styled.span(switchBaseStyles)
18
+ const StyledSwitch = styled.span(switchBaseStyles)
19
19
  const Input = styled.input(switchInputStyles)
20
20
  const Representation = styled.span(switchRepresentationStyles)
21
21
  const Track = styled.span(switchTrackStyles)
@@ -48,7 +48,7 @@ export const Switch = forwardRef(function Switch(
48
48
  }, [indeterminate])
49
49
 
50
50
  return (
51
- <Root className={className} data-ui="Switch" style={style}>
51
+ <StyledSwitch className={className} data-ui="Switch" style={style}>
52
52
  <Input
53
53
  data-read-only={!disabled && readOnly ? '' : undefined}
54
54
  {...restProps}
@@ -61,7 +61,7 @@ export const Switch = forwardRef(function Switch(
61
61
  <Track />
62
62
  <Thumb $checked={checked} $indeterminate={indeterminate} />
63
63
  </Representation>
64
- </Root>
64
+ </StyledSwitch>
65
65
  )
66
66
  })
67
67
  Switch.displayName = 'ForwardRef(Switch)'
@@ -8,6 +8,7 @@ import {
8
8
  responsiveTextFont,
9
9
  } from '../../styles/internal'
10
10
  import {TextAlign} from '../../types'
11
+ import {SpanWithTextOverflow} from '../../utils/spanWithTextOverflow'
11
12
  import {textBaseStyle} from './styles'
12
13
 
13
14
  /**
@@ -29,20 +30,12 @@ export interface TextProps {
29
30
  weight?: ThemeFontWeightKey
30
31
  }
31
32
 
32
- const Root = styled.div<ResponsiveFontStyleProps>(
33
+ const StyledText = styled.div<ResponsiveFontStyleProps>(
33
34
  responsiveTextFont,
34
35
  responsiveTextAlignStyle,
35
36
  textBaseStyle,
36
37
  )
37
38
 
38
- const SpanWithTextOverflow = styled.span`
39
- display: block;
40
- white-space: nowrap;
41
- text-overflow: ellipsis;
42
- overflow: hidden;
43
- overflow: clip;
44
- `
45
-
46
39
  /**
47
40
  * The `Text` component is an agile, themed typographic element.
48
41
  *
@@ -70,7 +63,7 @@ export const Text = forwardRef(function Text(
70
63
  }
71
64
 
72
65
  return (
73
- <Root
66
+ <StyledText
74
67
  data-ui="Text"
75
68
  {...restProps}
76
69
  $accent={accent}
@@ -81,7 +74,7 @@ export const Text = forwardRef(function Text(
81
74
  $weight={weight}
82
75
  >
83
76
  <span>{children}</span>
84
- </Root>
77
+ </StyledText>
85
78
  )
86
79
  })
87
80
  Text.displayName = 'ForwardRef(Text)'
@@ -32,7 +32,7 @@ export interface TextAreaProps extends ResponsiveRadiusProps {
32
32
  weight?: ThemeFontWeightKey
33
33
  }
34
34
 
35
- const Root = styled.span(textInputRootStyle)
35
+ const StyledTextArea = styled.span(textInputRootStyle)
36
36
 
37
37
  const InputRoot = styled.span`
38
38
  flex: 1;
@@ -86,7 +86,7 @@ export const TextArea = forwardRef(function TextArea(
86
86
  useCustomValidity(ref, customValidity)
87
87
 
88
88
  return (
89
- <Root data-ui="TextArea">
89
+ <StyledTextArea data-ui="TextArea">
90
90
  <InputRoot>
91
91
  <Input
92
92
  data-as="textarea"
@@ -112,7 +112,7 @@ export const TextArea = forwardRef(function TextArea(
112
112
  data-tone={rootTheme.tone}
113
113
  />
114
114
  </InputRoot>
115
- </Root>
115
+ </StyledTextArea>
116
116
  )
117
117
  })
118
118
  TextArea.displayName = 'ForwardRef(TextArea)'
@@ -80,7 +80,7 @@ export interface TextInputProps {
80
80
 
81
81
  const CLEAR_BUTTON_BOX_STYLE: React.CSSProperties = {zIndex: 2}
82
82
 
83
- const Root = styled(Card).attrs({forwardedAs: 'span'})(textInputRootStyle)
83
+ const StyledTextInput = styled(Card).attrs({forwardedAs: 'span'})(textInputRootStyle)
84
84
 
85
85
  const InputRoot = styled.span`
86
86
  flex: 1;
@@ -354,7 +354,7 @@ export const TextInput = forwardRef(function TextInput(
354
354
  )
355
355
 
356
356
  return (
357
- <Root data-ui="TextInput" tone={rootTheme.tone}>
357
+ <StyledTextInput data-ui="TextInput" tone={rootTheme.tone}>
358
358
  {prefixNode}
359
359
 
360
360
  <InputRoot>
@@ -382,7 +382,7 @@ export const TextInput = forwardRef(function TextInput(
382
382
  </InputRoot>
383
383
 
384
384
  {suffixNode}
385
- </Root>
385
+ </StyledTextInput>
386
386
  )
387
387
  })
388
388
  TextInput.displayName = 'ForwardRef(TextInput)'
@@ -78,7 +78,7 @@ export interface TooltipProps extends Omit<LayerProps, 'as'> {
78
78
  animate?: boolean
79
79
  }
80
80
 
81
- const Root = styled(Layer)`
81
+ const StyledTooltip = styled(Layer)`
82
82
  pointer-events: none;
83
83
  `
84
84
 
@@ -362,7 +362,7 @@ export const Tooltip = forwardRef(function Tooltip(
362
362
  if (disabled) return child
363
363
 
364
364
  const tooltip = (
365
- <Root
365
+ <StyledTooltip
366
366
  data-ui="Tooltip"
367
367
  {...restProps}
368
368
  ref={setFloating}
@@ -390,7 +390,7 @@ export const Tooltip = forwardRef(function Tooltip(
390
390
  >
391
391
  {content}
392
392
  </TooltipCard>
393
- </Root>
393
+ </StyledTooltip>
394
394
  )
395
395
 
396
396
  const children =
@@ -3,7 +3,7 @@ import {styled, css} from 'styled-components'
3
3
  import {useTheme_v2} from '../../theme'
4
4
  import {Point, compileCommands, getRoundedCommands} from './cmds'
5
5
 
6
- const Root = styled.div<{$w: number}>(
6
+ const StyledArrow = styled.div<{$w: number}>(
7
7
  ({$w: w}) => css`
8
8
  position: absolute;
9
9
  width: ${w}px;
@@ -108,7 +108,7 @@ export const Arrow = forwardRef(function Arrow(
108
108
  const fillPath = `${path} M ${w} -1 M 0 -1 Z`
109
109
 
110
110
  return (
111
- <Root {...restProps} $w={w} ref={ref}>
111
+ <StyledArrow {...restProps} $w={w} ref={ref}>
112
112
  <svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>
113
113
  <mask id="stroke-mask">
114
114
  <rect x={0} y={strokeWidth} width={w} height={w} fill="white" />
@@ -116,7 +116,7 @@ export const Arrow = forwardRef(function Arrow(
116
116
  <StrokePath d={strokePath} mask="url(#stroke-mask)" strokeWidth={strokeWidth * 2} />
117
117
  <ShapePath d={fillPath} />
118
118
  </svg>
119
- </Root>
119
+ </StyledArrow>
120
120
  )
121
121
  })
122
122
  Arrow.displayName = 'ForwardRef(Arrow)'
@@ -20,7 +20,7 @@ interface LayerChildrenProps {
20
20
  onActivate?: LayerProps['onActivate']
21
21
  }
22
22
 
23
- const Root = styled.div({position: 'relative'})
23
+ const StyledLayer = styled.div({position: 'relative'})
24
24
 
25
25
  const LayerChildren = forwardRef(function LayerChildren(
26
26
  props: LayerChildrenProps & Omit<React.HTMLProps<HTMLDivElement>, 'as'>,
@@ -65,9 +65,15 @@ const LayerChildren = forwardRef(function LayerChildren(
65
65
  )
66
66
 
67
67
  return (
68
- <Root {...restProps} data-ui="Layer" onFocus={handleFocus} ref={ref} style={{...style, zIndex}}>
68
+ <StyledLayer
69
+ {...restProps}
70
+ data-ui="Layer"
71
+ onFocus={handleFocus}
72
+ ref={ref}
73
+ style={{...style, zIndex}}
74
+ >
69
75
  {children}
70
- </Root>
76
+ </StyledLayer>
71
77
  )
72
78
  })
73
79
 
@@ -0,0 +1,10 @@
1
+ import {styled} from 'styled-components'
2
+
3
+ /** @internal */
4
+ export const SpanWithTextOverflow = styled.span`
5
+ display: block;
6
+ white-space: nowrap;
7
+ text-overflow: ellipsis;
8
+ overflow: hidden;
9
+ overflow: clip;
10
+ `
@@ -9,7 +9,7 @@ export interface SrOnlyProps {
9
9
  children?: React.ReactNode
10
10
  }
11
11
 
12
- const Root = styled.div`
12
+ const StyledSrOnly = styled.div`
13
13
  display: block;
14
14
  width: 0;
15
15
  height: 0;
@@ -28,9 +28,9 @@ export const SrOnly = forwardRef(function SrOnly(
28
28
  const {as, children} = props
29
29
 
30
30
  return (
31
- <Root aria-hidden as={as} data-ui="SrOnly" ref={ref}>
31
+ <StyledSrOnly aria-hidden as={as} data-ui="SrOnly" ref={ref}>
32
32
  {children}
33
- </Root>
33
+ </StyledSrOnly>
34
34
  )
35
35
  })
36
36
  SrOnly.displayName = 'ForwardRef(SrOnly)'
@@ -29,7 +29,7 @@ export interface VirtualListProps<Item = any> {
29
29
  renderItem?: (item: Item) => React.ReactNode
30
30
  }
31
31
 
32
- const Root = styled.div`
32
+ const StyledVirtualList = styled.div`
33
33
  position: relative;
34
34
  `
35
35
 
@@ -159,11 +159,11 @@ export const VirtualList = forwardRef(function VirtualList(
159
159
  const wrapperStyle = useMemo(() => ({height}), [height])
160
160
 
161
161
  return (
162
- <Root as={as} data-ui="VirtualList" {...restProps} ref={ref}>
162
+ <StyledVirtualList as={as} data-ui="VirtualList" {...restProps} ref={ref}>
163
163
  <div ref={wrapperRef} style={wrapperStyle}>
164
164
  {children}
165
165
  </div>
166
- </Root>
166
+ </StyledVirtualList>
167
167
  )
168
168
  })
169
169
  VirtualList.displayName = 'ForwardRef(VirtualList)'