@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.
Files changed (60) hide show
  1. package/README.md +12 -0
  2. package/dist/_chunks-cjs/_visual-editing.js +54 -43
  3. package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
  4. package/dist/_chunks-es/_visual-editing.mjs +54 -43
  5. package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
  6. package/dist/_visual-editing.d.mts +129 -75
  7. package/dist/_visual-editing.d.ts +129 -75
  8. package/dist/index.d.mts +222 -139
  9. package/dist/index.d.ts +222 -139
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/theme.d.mts +10 -4
  13. package/dist/theme.d.ts +10 -4
  14. package/package.json +19 -82
  15. package/src/core/components/autocomplete/autocomplete.tsx +1 -1
  16. package/src/core/components/autocomplete/types.ts +2 -2
  17. package/src/core/components/menu/__workshop__/asComponent.tsx +1 -1
  18. package/src/core/components/menu/menuDivider.ts +16 -5
  19. package/src/core/components/menu/menuGroup.spacing.test.tsx +1 -7
  20. package/src/core/components/menu/menuGroup.tsx +14 -6
  21. package/src/core/components/menu/menuItem.tsx +17 -6
  22. package/src/core/components/skeleton/skeleton.tsx +2 -2
  23. package/src/core/components/tab/tabList.tsx +2 -2
  24. package/src/core/components/tab/tabPanel.tsx +2 -2
  25. package/src/core/components/toast/styles.ts +2 -2
  26. package/src/core/components/tree/__workshop__/basic.perf.ts +1 -1
  27. package/src/core/components/tree/__workshop__/tabFromElement.tsx +1 -1
  28. package/src/core/components/tree/tree.tsx +9 -6
  29. package/src/core/components/tree/treeGroup.tsx +1 -1
  30. package/src/core/components/tree/treeItem.tsx +3 -2
  31. package/src/core/primitives/avatar/avatar.tsx +19 -11
  32. package/src/core/primitives/badge/badge.tsx +20 -12
  33. package/src/core/primitives/box/__workshop__/asComponent.tsx +31 -0
  34. package/src/core/primitives/box/__workshop__/index.ts +5 -0
  35. package/src/core/primitives/box/box.test.tsx +12 -4
  36. package/src/core/primitives/box/box.tsx +23 -12
  37. package/src/core/primitives/button/__workshop__/disabled.tsx +2 -2
  38. package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +1 -1
  39. package/src/core/primitives/button/__workshop__/uploadButton.tsx +1 -1
  40. package/src/core/primitives/button/button.test.tsx +3 -3
  41. package/src/core/primitives/button/button.tsx +28 -9
  42. package/src/core/primitives/card/__workshop__/asComponent.tsx +1 -1
  43. package/src/core/primitives/card/card.tsx +24 -13
  44. package/src/core/primitives/code/code.tsx +16 -7
  45. package/src/core/primitives/container/container.tsx +23 -10
  46. package/src/core/primitives/flex/flex.tsx +21 -11
  47. package/src/core/primitives/grid/grid.test.tsx +3 -1
  48. package/src/core/primitives/grid/grid.tsx +22 -9
  49. package/src/core/primitives/heading/heading.tsx +19 -11
  50. package/src/core/primitives/inline/inline.tsx +19 -9
  51. package/src/core/primitives/kbd/kbd.tsx +19 -11
  52. package/src/core/primitives/label/label.tsx +19 -11
  53. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +1 -1
  54. package/src/core/primitives/stack/stack.tsx +20 -11
  55. package/src/core/primitives/text/text.tsx +19 -11
  56. package/src/core/primitives/textInput/textInput.tsx +2 -2
  57. package/src/core/types/component.ts +32 -0
  58. package/src/core/types/index.ts +1 -0
  59. package/src/core/utils/virtualList/virtualList.tsx +2 -2
  60. package/src/theme/system/css.ts +10 -4
package/dist/index.d.mts CHANGED
@@ -3,16 +3,12 @@ import {Component} from 'react'
3
3
  import {Context} from 'react'
4
4
  import {createColorTheme as createColorTheme_2} from '@sanity/ui/theme'
5
5
  import {CSSObject} from '@sanity/ui/theme'
6
- import {DetailedHTMLProps} from 'react'
7
- import {ElementType} from 'react'
8
- import {FastOmit} from 'styled-components'
6
+ import {ElementType as ElementType_2} from 'react'
9
7
  import {ForwardRefExoticComponent} from 'react'
10
8
  import {hexToRgb as hexToRgb_2} from '@sanity/ui/theme'
11
9
  import {HSL as HSL_2} from '@sanity/ui/theme'
12
10
  import {hslToRgb as hslToRgb_2} from '@sanity/ui/theme'
13
- import {HTMLAttributes} from 'react'
14
11
  import {HTMLProps} from 'react'
15
- import {IStyledComponentBase} from 'styled-components/dist/types'
16
12
  import {multiply as multiply_2} from '@sanity/ui/theme'
17
13
  import {parseColor as parseColor_2} from '@sanity/ui/theme'
18
14
  import {PartialThemeColorBuilderOpts} from '@sanity/ui/theme'
@@ -89,6 +85,13 @@ export declare const Arrow: ForwardRefExoticComponent<
89
85
  RefAttributes<HTMLDivElement>
90
86
  >
91
87
 
88
+ /**
89
+ * Assign properties from `U` to `T`, excluding properties that already exist in `T`.
90
+ *
91
+ * @public
92
+ */
93
+ export declare type Assign<T extends object, U extends object> = Omit<T, keyof U> & U
94
+
92
95
  /**
93
96
  * @internal
94
97
  */
@@ -160,7 +163,7 @@ export declare type AutocompleteMsg =
160
163
  /**
161
164
  * @public
162
165
  */
163
- export declare type AutocompleteOpenButtonProps = Omit<ButtonProps, 'as'> &
166
+ export declare type AutocompleteOpenButtonProps = ButtonOwnProps &
164
167
  Omit<React.HTMLProps<HTMLButtonElement>, 'as' | 'ref'>
165
168
 
166
169
  /**
@@ -173,7 +176,7 @@ export declare interface AutocompleteProps<
173
176
  customValidity?: string
174
177
  filterOption?: (query: string, option: Option) => boolean
175
178
  fontSize?: number | number[]
176
- icon?: ElementType | ReactNode
179
+ icon?: ElementType_2 | ReactNode
177
180
  id: string
178
181
  /** @beta */
179
182
  listBox?: BoxProps
@@ -283,9 +286,9 @@ export declare interface AutocompleteValueChangeMsg {
283
286
  *
284
287
  * @public
285
288
  */
286
- export declare const Avatar: ForwardRefExoticComponent<
287
- AvatarProps & Omit<HTMLProps<HTMLDivElement>, 'ref' | 'as'> & RefAttributes<HTMLDivElement>
288
- >
289
+ export declare const Avatar: <E extends ElementType = 'div'>(
290
+ props: AvatarProps<E>,
291
+ ) => React.JSX.Element
289
292
 
290
293
  /**
291
294
  * @public
@@ -307,17 +310,11 @@ export declare interface AvatarCounterProps {
307
310
  /**
308
311
  * @public
309
312
  */
310
- export declare type AvatarPosition = 'top' | 'bottom' | 'inside'
311
-
312
- /**
313
- * @public
314
- */
315
- export declare interface AvatarProps {
313
+ export declare interface AvatarOwnProps {
316
314
  /** @beta */
317
315
  __unstable_hideInnerStroke?: boolean
318
316
  animateArrowFrom?: AvatarPosition
319
317
  arrowPosition?: AvatarPosition
320
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
321
318
  color?: ThemeColorAvatarColorKey
322
319
  initials?: string
323
320
  onImageLoadError?: (event: Error) => void
@@ -331,6 +328,16 @@ export declare interface AvatarProps {
331
328
  title?: string
332
329
  }
333
330
 
331
+ /**
332
+ * @public
333
+ */
334
+ export declare type AvatarPosition = 'top' | 'bottom' | 'inside'
335
+
336
+ /**
337
+ * @public
338
+ */
339
+ export declare type AvatarProps<E extends ElementType = 'div'> = Props<AvatarOwnProps, E>
340
+
334
341
  /**
335
342
  * @internal
336
343
  */
@@ -347,7 +354,7 @@ export declare type AvatarSize = 0 | 1 | 2 | 3
347
354
  * @public
348
355
  */
349
356
  export declare const AvatarStack: ForwardRefExoticComponent<
350
- AvatarStackProps & Omit<HTMLProps<HTMLDivElement>, 'ref' | 'as'> & RefAttributes<HTMLDivElement>
357
+ AvatarStackProps & Omit<HTMLProps<HTMLDivElement>, 'as' | 'ref'> & RefAttributes<HTMLDivElement>
351
358
  >
352
359
 
353
360
  /**
@@ -371,9 +378,9 @@ export declare type AvatarStatus = 'online' | 'editing' | 'inactive'
371
378
  *
372
379
  * @public
373
380
  */
374
- export declare const Badge: ForwardRefExoticComponent<
375
- Omit<BadgeProps & HTMLProps<HTMLDivElement>, 'ref'> & RefAttributes<unknown>
376
- >
381
+ export declare const Badge: <E extends ElementType = 'div'>(
382
+ props: BadgeProps<E>,
383
+ ) => React.JSX.Element
377
384
 
378
385
  /**
379
386
  * @public
@@ -384,14 +391,18 @@ export declare type BadgeMode = 'default' | 'outline'
384
391
  /**
385
392
  * @public
386
393
  */
387
- export declare interface BadgeProps extends BoxProps, ResponsiveRadiusProps {
388
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
394
+ export declare interface BadgeOwnProps extends BoxOwnProps, ResponsiveRadiusProps {
389
395
  fontSize?: number | number[]
390
396
  /** @deprecated No longer used. */
391
397
  mode?: BadgeMode
392
398
  tone?: BadgeTone
393
399
  }
394
400
 
401
+ /**
402
+ * @public
403
+ */
404
+ export declare type BadgeProps<E extends ElementType = 'div'> = Props<BadgeOwnProps, E>
405
+
395
406
  /**
396
407
  * @public
397
408
  */
@@ -443,10 +454,7 @@ export declare interface BoundaryElementProviderProps {
443
454
  *
444
455
  * @public
445
456
  */
446
- export declare const Box: ForwardRefExoticComponent<
447
- Omit<BoxProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'as'>, 'ref'> &
448
- RefAttributes<HTMLDivElement>
449
- >
457
+ export declare const Box: <E extends ElementType = 'div'>(props: BoxProps<E>) => React.JSX.Element
450
458
 
451
459
  /**
452
460
  * @public
@@ -464,18 +472,24 @@ export declare type BoxHeight = 'stretch' | 'fill'
464
472
  export declare type BoxOverflow = 'visible' | 'hidden' | 'auto'
465
473
 
466
474
  /**
475
+ * The props that `Box` adds on top of the element it renders as.
476
+ *
467
477
  * @public
468
478
  */
469
- export declare interface BoxProps
479
+ export declare interface BoxOwnProps
470
480
  extends ResponsiveFlexItemProps,
471
481
  ResponsiveBoxProps,
472
482
  ResponsiveGridItemProps,
473
483
  ResponsiveMarginProps,
474
484
  ResponsivePaddingProps {
475
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
476
- forwardedAs?: React.ElementType | keyof React.JSX.IntrinsicElements
485
+ forwardedAs?: ElementType
477
486
  }
478
487
 
488
+ /**
489
+ * @public
490
+ */
491
+ export declare type BoxProps<E extends ElementType = 'div'> = Props<BoxOwnProps, E>
492
+
479
493
  /**
480
494
  * @public
481
495
  * @deprecated Use `ThemeBoxShadow` from `@sanity/ui/theme` instead.
@@ -492,7 +506,7 @@ export declare type BoxSizing = 'content' | 'border'
492
506
  */
493
507
  export declare const Breadcrumbs: ForwardRefExoticComponent<
494
508
  BreadcrumbsProps &
495
- Omit<HTMLProps<HTMLOListElement>, 'type' | 'ref' | 'as'> &
509
+ Omit<HTMLProps<HTMLOListElement>, 'type' | 'as' | 'ref'> &
496
510
  RefAttributes<HTMLOListElement>
497
511
  >
498
512
 
@@ -512,10 +526,9 @@ export declare interface BreadcrumbsProps {
512
526
  /**
513
527
  * @public
514
528
  */
515
- export declare const Button: ForwardRefExoticComponent<
516
- Omit<ButtonProps & Omit<HTMLProps<HTMLButtonElement>, 'width' | 'as'>, 'ref'> &
517
- RefAttributes<HTMLButtonElement>
518
- >
529
+ export declare const Button: <E extends ElementType = 'button'>(
530
+ props: ButtonProps<E>,
531
+ ) => React.JSX.Element
519
532
 
520
533
  /**
521
534
  * @public
@@ -525,8 +538,7 @@ export declare type ButtonMode = ThemeColorButtonModeKey_2
525
538
  /**
526
539
  * @public
527
540
  */
528
- export declare interface ButtonProps extends ResponsivePaddingProps, ResponsiveRadiusProps {
529
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
541
+ export declare interface ButtonOwnProps extends ResponsivePaddingProps, ResponsiveRadiusProps {
530
542
  fontSize?: number | number[]
531
543
  mode?: ButtonMode
532
544
  icon?: React.ElementType | React.ReactNode
@@ -551,6 +563,11 @@ export declare interface ButtonProps extends ResponsivePaddingProps, ResponsiveR
551
563
  width?: ButtonWidth
552
564
  }
553
565
 
566
+ /**
567
+ * @public
568
+ */
569
+ export declare type ButtonProps<E extends ElementType = 'button'> = Props<ButtonOwnProps, E>
570
+
554
571
  /**
555
572
  * @public
556
573
  */
@@ -572,16 +589,13 @@ export declare type ButtonWidth = 'fill'
572
589
  *
573
590
  * @public
574
591
  */
575
- export declare const Card: ForwardRefExoticComponent<
576
- Omit<CardProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'as'>, 'ref'> &
577
- RefAttributes<HTMLDivElement>
578
- >
592
+ export declare const Card: <E extends ElementType = 'div'>(props: CardProps<E>) => React.JSX.Element
579
593
 
580
594
  /**
581
595
  * @public
582
596
  */
583
- export declare interface CardProps
584
- extends BoxProps,
597
+ export declare interface CardOwnProps
598
+ extends BoxOwnProps,
585
599
  ResponsiveBorderProps,
586
600
  ResponsiveRadiusProps,
587
601
  ResponsiveShadowProps {
@@ -595,12 +609,19 @@ export declare interface CardProps
595
609
  * @beta
596
610
  */
597
611
  __unstable_focusRing?: boolean
612
+ disabled?: boolean
598
613
  muted?: boolean
599
614
  pressed?: boolean
600
615
  scheme?: ThemeColorSchemeKey_2
616
+ selected?: boolean
601
617
  tone?: CardTone
602
618
  }
603
619
 
620
+ /**
621
+ * @public
622
+ */
623
+ export declare type CardProps<E extends ElementType = 'div'> = Props<CardOwnProps, E>
624
+
604
625
  /**
605
626
  * @internal
606
627
  */
@@ -657,28 +678,30 @@ export declare type ClickOutsideListener = (event: MouseEvent) => void
657
678
  /**
658
679
  * @public
659
680
  */
660
- export declare const Code: ForwardRefExoticComponent<
661
- Omit<CodeProps & Omit<HTMLProps<HTMLElement>, 'size' | 'as'>, 'ref'> & RefAttributes<HTMLElement>
662
- >
681
+ export declare const Code: <E extends ElementType = 'pre'>(props: CodeProps<E>) => React.JSX.Element
663
682
 
664
683
  /**
665
684
  * @public
666
685
  */
667
- export declare interface CodeProps {
668
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
686
+ export declare interface CodeOwnProps {
669
687
  /** Define the language to use for syntax highlighting. */
670
688
  language?: string
671
689
  size?: number | number[]
672
690
  weight?: string
673
691
  }
674
692
 
693
+ /**
694
+ * @public
695
+ */
696
+ export declare type CodeProps<E extends ElementType = 'pre'> = Props<CodeOwnProps, E>
697
+
675
698
  /**
676
699
  * This API might change. DO NOT USE IN PRODUCTION.
677
700
  * @beta
678
701
  */
679
702
  export declare const CodeSkeleton: ForwardRefExoticComponent<
680
703
  Omit<
681
- CodeSkeletonProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'size' | 'children' | 'as'>,
704
+ CodeSkeletonProps & Omit<HTMLProps<HTMLDivElement>, 'size' | 'height' | 'as' | 'children'>,
682
705
  'ref'
683
706
  > &
684
707
  RefAttributes<HTMLDivElement>
@@ -692,6 +715,12 @@ export declare interface CodeSkeletonProps extends SkeletonProps {
692
715
  size?: number | number[]
693
716
  }
694
717
 
718
+ /** @public */
719
+ export declare type ComponentType<P = any> =
720
+ | React.FunctionComponent<P>
721
+ | React.ComponentClass<P>
722
+ | React.ExoticComponent<P>
723
+
695
724
  /**
696
725
  * @internal
697
726
  * @deprecated this component will be removed in the next major release
@@ -715,15 +744,19 @@ export declare namespace ConditionalWrapper {
715
744
  *
716
745
  * @public
717
746
  */
718
- export declare const Container: ForwardRefExoticComponent<
719
- Omit<ContainerProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'width' | 'as'>, 'ref'> &
720
- RefAttributes<HTMLDivElement>
721
- >
747
+ export declare const Container: <E extends ElementType = 'div'>(
748
+ props: ContainerProps<E>,
749
+ ) => React.JSX.Element
722
750
 
723
751
  /**
724
752
  * @public
725
753
  */
726
- export declare interface ContainerProps extends BoxProps, ResponsiveWidthProps {}
754
+ export declare interface ContainerOwnProps extends BoxOwnProps, ResponsiveWidthProps {}
755
+
756
+ /**
757
+ * @public
758
+ */
759
+ export declare type ContainerProps<E extends ElementType = 'div'> = Props<ContainerOwnProps, E>
727
760
 
728
761
  /**
729
762
  * @internal
@@ -752,7 +785,7 @@ export declare type Delay =
752
785
  * @public
753
786
  */
754
787
  export declare const Dialog: ForwardRefExoticComponent<
755
- Omit<DialogProps & Omit<HTMLProps<HTMLDivElement>, 'id' | 'width' | 'as'>, 'ref'> &
788
+ Omit<DialogProps & Omit<HTMLProps<HTMLDivElement>, 'width' | 'id' | 'as'>, 'ref'> &
756
789
  RefAttributes<HTMLDivElement>
757
790
  >
758
791
 
@@ -882,6 +915,12 @@ export declare const _elementSizeObserver: _ElementSizeObserver
882
915
  */
883
916
  export declare type _ElementSizeSubscriber = (elementRect: ElementSize) => void
884
917
 
918
+ /** @public */
919
+ export declare type ElementType<P = any> = TagType | ComponentType<P>
920
+
921
+ /** @public */
922
+ export declare type EmptyProps = object
923
+
885
924
  /**
886
925
  * DO NOT USE IN PRODUCTION
887
926
  * @beta
@@ -922,10 +961,7 @@ export declare function _fillCSSObject(
922
961
  *
923
962
  * @public
924
963
  */
925
- export declare const Flex: ForwardRefExoticComponent<
926
- Omit<FlexProps & Omit<HTMLProps<HTMLDivElement>, 'wrap' | 'as'>, 'ref'> &
927
- RefAttributes<HTMLDivElement>
928
- >
964
+ export declare const Flex: <E extends ElementType = 'div'>(props: FlexProps<E>) => React.JSX.Element
929
965
 
930
966
  /**
931
967
  * @public
@@ -951,13 +987,18 @@ export declare type FlexJustify =
951
987
  /**
952
988
  * @public
953
989
  */
954
- export declare interface FlexProps
955
- extends Omit<BoxProps, 'display'>,
990
+ export declare interface FlexOwnProps
991
+ extends Omit<BoxOwnProps, 'display'>,
956
992
  ResponsiveFlexProps,
957
993
  ResponsiveFlexItemProps {
958
994
  gap?: number | number[]
959
995
  }
960
996
 
997
+ /**
998
+ * @public
999
+ */
1000
+ export declare type FlexProps<E extends ElementType = 'div'> = Props<FlexOwnProps, E>
1001
+
961
1002
  /**
962
1003
  * @public
963
1004
  */
@@ -1004,10 +1045,7 @@ export declare function _getResponsiveSpace(
1004
1045
  *
1005
1046
  * @public
1006
1047
  */
1007
- export declare const Grid: ForwardRefExoticComponent<
1008
- Omit<GridProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'as' | 'rows'>, 'ref'> &
1009
- RefAttributes<HTMLDivElement>
1010
- >
1048
+ export declare const Grid: <E extends ElementType = 'div'>(props: GridProps<E>) => React.JSX.Element
1011
1049
 
1012
1050
  /**
1013
1051
  * @public
@@ -1057,7 +1095,12 @@ export declare type GridItemRowStart = 'auto' | number
1057
1095
  /**
1058
1096
  * @public
1059
1097
  */
1060
- export declare interface GridProps extends Omit<BoxProps, 'display'>, ResponsiveGridProps {}
1098
+ export declare interface GridOwnProps extends Omit<BoxOwnProps, 'display'>, ResponsiveGridProps {}
1099
+
1100
+ /**
1101
+ * @public
1102
+ */
1103
+ export declare type GridProps<E extends ElementType = 'div'> = Props<GridOwnProps, E>
1061
1104
 
1062
1105
  /**
1063
1106
  * @internal
@@ -1069,18 +1112,16 @@ export declare function _hasFocus(element: HTMLElement): boolean
1069
1112
  *
1070
1113
  * @public
1071
1114
  */
1072
- export declare const Heading: ForwardRefExoticComponent<
1073
- Omit<HeadingProps & Omit<HTMLProps<HTMLElement>, 'size' | 'as'>, 'ref'> &
1074
- RefAttributes<HTMLElement>
1075
- >
1115
+ export declare const Heading: <E extends ElementType = 'div'>(
1116
+ props: HeadingProps<E>,
1117
+ ) => React.JSX.Element
1076
1118
 
1077
1119
  /**
1078
1120
  * @public
1079
1121
  */
1080
- export declare interface HeadingProps {
1122
+ export declare interface HeadingOwnProps {
1081
1123
  accent?: boolean
1082
1124
  align?: TextAlign | TextAlign[]
1083
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
1084
1125
  muted?: boolean
1085
1126
  size?: number | number[]
1086
1127
  /**
@@ -1092,13 +1133,18 @@ export declare interface HeadingProps {
1092
1133
  weight?: ThemeFontWeightKey_2
1093
1134
  }
1094
1135
 
1136
+ /**
1137
+ * @public
1138
+ */
1139
+ export declare type HeadingProps<E extends ElementType = 'div'> = Props<HeadingOwnProps, E>
1140
+
1095
1141
  /**
1096
1142
  * This API might change. DO NOT USE IN PRODUCTION.
1097
1143
  * @beta
1098
1144
  */
1099
1145
  export declare const HeadingSkeleton: ForwardRefExoticComponent<
1100
1146
  Omit<
1101
- HeadingSkeletonProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'size' | 'children' | 'as'>,
1147
+ HeadingSkeletonProps & Omit<HTMLProps<HTMLDivElement>, 'size' | 'height' | 'as' | 'children'>,
1102
1148
  'ref'
1103
1149
  > &
1104
1150
  RefAttributes<HTMLDivElement>
@@ -1124,7 +1170,7 @@ export declare const hexToRgb: typeof hexToRgb_2
1124
1170
  * @public
1125
1171
  */
1126
1172
  export declare const Hotkeys: ForwardRefExoticComponent<
1127
- HotkeysProps & Omit<HTMLProps<HTMLElement>, 'size' | 'ref' | 'as'> & RefAttributes<HTMLElement>
1173
+ HotkeysProps & Omit<HTMLProps<HTMLElement>, 'size' | 'as' | 'ref'> & RefAttributes<HTMLElement>
1128
1174
  >
1129
1175
 
1130
1176
  /**
@@ -1159,14 +1205,14 @@ export declare const hslToRgb: typeof hslToRgb_2
1159
1205
  *
1160
1206
  * @public
1161
1207
  */
1162
- export declare const Inline: ForwardRefExoticComponent<
1163
- Omit<InlineProps & HTMLProps<HTMLDivElement>, 'ref'> & RefAttributes<unknown>
1164
- >
1208
+ export declare const Inline: <E extends ElementType = 'div'>(
1209
+ props: InlineProps<E>,
1210
+ ) => React.JSX.Element
1165
1211
 
1166
1212
  /**
1167
1213
  * @public
1168
1214
  */
1169
- export declare interface InlineProps extends Omit<BoxProps, 'display'> {
1215
+ export declare interface InlineOwnProps extends Omit<BoxOwnProps, 'display'> {
1170
1216
  /**
1171
1217
  * The spacing between children.
1172
1218
  * @deprecated Use `gap` instead. `space` will be removed in v4.
@@ -1176,6 +1222,11 @@ export declare interface InlineProps extends Omit<BoxProps, 'display'> {
1176
1222
  gap?: number | number[]
1177
1223
  }
1178
1224
 
1225
+ /**
1226
+ * @public
1227
+ */
1228
+ export declare type InlineProps<E extends ElementType = 'div'> = Props<InlineOwnProps, E>
1229
+
1179
1230
  /**
1180
1231
  * @internal
1181
1232
  */
@@ -1226,37 +1277,37 @@ export declare function _isScrollable(el: Node): boolean
1226
1277
  *
1227
1278
  * @public
1228
1279
  */
1229
- export declare const KBD: ForwardRefExoticComponent<
1230
- KBDProps & Omit<HTMLProps<HTMLElement>, 'size' | 'ref' | 'as'> & RefAttributes<HTMLDivElement>
1231
- >
1280
+ export declare const KBD: <E extends ElementType = 'kbd'>(props: KBDProps<E>) => React.JSX.Element
1232
1281
 
1233
1282
  /**
1234
1283
  * @public
1235
1284
  */
1236
- export declare interface KBDProps {
1237
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
1285
+ export declare interface KBDOwnProps {
1238
1286
  fontSize?: number | number[]
1239
1287
  padding?: number | number[]
1240
1288
  radius?: Radius | Radius[]
1241
1289
  }
1242
1290
 
1291
+ /**
1292
+ * @public
1293
+ */
1294
+ export declare type KBDProps<E extends ElementType = 'kbd'> = Props<KBDOwnProps, E>
1295
+
1243
1296
  /**
1244
1297
  * Typographic labels.
1245
1298
  *
1246
1299
  * @public
1247
1300
  */
1248
- export declare const Label: ForwardRefExoticComponent<
1249
- Omit<LabelProps & Omit<HTMLProps<HTMLDivElement>, 'size' | 'as'>, 'ref'> &
1250
- RefAttributes<HTMLDivElement>
1251
- >
1301
+ export declare const Label: <E extends ElementType = 'div'>(
1302
+ props: LabelProps<E>,
1303
+ ) => React.JSX.Element
1252
1304
 
1253
1305
  /**
1254
1306
  * @public
1255
1307
  */
1256
- export declare interface LabelProps {
1308
+ export declare interface LabelOwnProps {
1257
1309
  accent?: boolean
1258
1310
  align?: TextAlign | TextAlign[]
1259
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
1260
1311
  muted?: boolean
1261
1312
  size?: number | number[]
1262
1313
  /**
@@ -1268,13 +1319,18 @@ export declare interface LabelProps {
1268
1319
  weight?: ThemeFontWeightKey_2
1269
1320
  }
1270
1321
 
1322
+ /**
1323
+ * @public
1324
+ */
1325
+ export declare type LabelProps<E extends ElementType = 'div'> = Props<LabelOwnProps, E>
1326
+
1271
1327
  /**
1272
1328
  * This API might change. DO NOT USE IN PRODUCTION.
1273
1329
  * @beta
1274
1330
  */
1275
1331
  export declare const LabelSkeleton: ForwardRefExoticComponent<
1276
1332
  Omit<
1277
- LabelSkeletonProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'size' | 'children' | 'as'>,
1333
+ LabelSkeletonProps & Omit<HTMLProps<HTMLDivElement>, 'size' | 'height' | 'as' | 'children'>,
1278
1334
  'ref'
1279
1335
  > &
1280
1336
  RefAttributes<HTMLDivElement>
@@ -1355,7 +1411,7 @@ export declare interface _MediaStore {
1355
1411
  * @public
1356
1412
  */
1357
1413
  export declare const Menu: ForwardRefExoticComponent<
1358
- Omit<MenuProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'tabIndex' | 'role' | 'as'>, 'ref'> &
1414
+ Omit<MenuProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'as' | 'tabIndex' | 'role'>, 'ref'> &
1359
1415
  RefAttributes<HTMLDivElement>
1360
1416
  >
1361
1417
 
@@ -1412,29 +1468,26 @@ export declare interface MenuButtonProps {
1412
1468
  /**
1413
1469
  * @public
1414
1470
  */
1415
- export declare const MenuDivider: IStyledComponentBase<
1416
- 'web',
1417
- FastOmit<DetailedHTMLProps<HTMLAttributes<HTMLHRElement>, HTMLHRElement>, never>
1418
- > &
1419
- string
1471
+ export declare const MenuDivider: <E extends ElementType = 'hr'>(
1472
+ props: MenuDividerProps<E>,
1473
+ ) => React.JSX.Element
1420
1474
 
1421
1475
  /**
1422
1476
  * @public
1423
1477
  */
1424
- export declare function MenuGroup(
1425
- props: Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'popover' | 'ref' | 'tabIndex'> &
1426
- MenuGroupProps,
1427
- ): React.JSX.Element
1478
+ export declare type MenuDividerProps<E extends ElementType = 'hr'> = Props<EmptyProps, E>
1428
1479
 
1429
- export declare namespace MenuGroup {
1430
- var displayName: string
1431
- }
1480
+ /**
1481
+ * @public
1482
+ */
1483
+ export declare const MenuGroup: <E extends ElementType = 'button'>(
1484
+ props: MenuGroupProps<E>,
1485
+ ) => React.JSX.Element
1432
1486
 
1433
1487
  /**
1434
1488
  * @public
1435
1489
  */
1436
- export declare interface MenuGroupProps {
1437
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
1490
+ export declare interface MenuGroupOwnProps {
1438
1491
  fontSize?: number | number[]
1439
1492
  icon?: React.ElementType | React.ReactNode
1440
1493
  menu?: Omit<
@@ -1463,17 +1516,19 @@ export declare interface MenuGroupProps {
1463
1516
  /**
1464
1517
  * @public
1465
1518
  */
1466
- export declare const MenuItem: ForwardRefExoticComponent<
1467
- MenuItemProps &
1468
- Omit<HTMLProps<HTMLDivElement>, 'selected' | 'height' | 'ref' | 'tabIndex' | 'as'> &
1469
- RefAttributes<HTMLDivElement>
1470
- >
1519
+ export declare type MenuGroupProps<E extends ElementType = 'button'> = Props<MenuGroupOwnProps, E>
1471
1520
 
1472
1521
  /**
1473
1522
  * @public
1474
1523
  */
1475
- export declare interface MenuItemProps extends ResponsivePaddingProps, ResponsiveRadiusProps {
1476
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
1524
+ export declare const MenuItem: <E extends ElementType = 'button'>(
1525
+ props: MenuItemProps<E>,
1526
+ ) => React.JSX.Element
1527
+
1528
+ /**
1529
+ * @public
1530
+ */
1531
+ export declare interface MenuItemOwnProps extends ResponsivePaddingProps, ResponsiveRadiusProps {
1477
1532
  fontSize?: number | number[]
1478
1533
  hotkeys?: string[]
1479
1534
  icon?: React.ElementType | React.ReactNode
@@ -1489,6 +1544,11 @@ export declare interface MenuItemProps extends ResponsivePaddingProps, Responsiv
1489
1544
  tone?: SelectableTone
1490
1545
  }
1491
1546
 
1547
+ /**
1548
+ * @public
1549
+ */
1550
+ export declare type MenuItemProps<E extends ElementType = 'button'> = Props<MenuItemOwnProps, E>
1551
+
1492
1552
  /**
1493
1553
  * @public
1494
1554
  */
@@ -1557,7 +1617,7 @@ export declare type Placement =
1557
1617
  */
1558
1618
  export declare const Popover: ForwardRefExoticComponent<
1559
1619
  Omit<
1560
- PopoverProps & Omit<HTMLProps<HTMLDivElement>, 'content' | 'width' | 'children' | 'as'>,
1620
+ PopoverProps & Omit<HTMLProps<HTMLDivElement>, 'content' | 'width' | 'as' | 'children'>,
1561
1621
  'ref'
1562
1622
  > &
1563
1623
  RefAttributes<HTMLDivElement>
@@ -1709,6 +1769,19 @@ export declare interface PortalProviderProps {
1709
1769
  __unstable_elements?: Record<string, HTMLElement | null | undefined>
1710
1770
  }
1711
1771
 
1772
+ /**
1773
+ * Resolves the props of a polymorphic component: the props of the element/component passed to `as`
1774
+ * (defaulting to the component's own element), with the component's own props assigned on top.
1775
+ *
1776
+ * @public
1777
+ */
1778
+ export declare type Props<P extends EmptyProps, E extends ElementType<P>> = Assign<
1779
+ E extends TagType ? React.JSX.IntrinsicElements[E] : React.ComponentProps<E>,
1780
+ P & {
1781
+ as?: E
1782
+ }
1783
+ >
1784
+
1712
1785
  /**
1713
1786
  * The `Radio` component allows the user to select one option from a set.
1714
1787
  *
@@ -2065,7 +2138,9 @@ export declare const Skeleton: ForwardRefExoticComponent<
2065
2138
  * This API might change. DO NOT USE IN PRODUCTION.
2066
2139
  * @beta
2067
2140
  */
2068
- export declare interface SkeletonProps extends ResponsiveRadiusProps, Omit<BoxProps, 'children'> {
2141
+ export declare interface SkeletonProps
2142
+ extends ResponsiveRadiusProps,
2143
+ Omit<BoxOwnProps, 'children'> {
2069
2144
  animated?: boolean
2070
2145
  delay?: number
2071
2146
  }
@@ -2092,7 +2167,7 @@ export declare interface SpinnerProps {
2092
2167
  * @public
2093
2168
  */
2094
2169
  export declare const SrOnly: ForwardRefExoticComponent<
2095
- Omit<SrOnlyProps & Omit<HTMLProps<HTMLDivElement>, 'aria-hidden' | 'as'>, 'ref'> &
2170
+ Omit<SrOnlyProps & Omit<HTMLProps<HTMLDivElement>, 'as' | 'aria-hidden'>, 'ref'> &
2096
2171
  RefAttributes<HTMLDivElement>
2097
2172
  >
2098
2173
 
@@ -2109,15 +2184,14 @@ export declare interface SrOnlyProps {
2109
2184
  *
2110
2185
  * @public
2111
2186
  */
2112
- export declare const Stack: ForwardRefExoticComponent<
2113
- StackProps & Omit<HTMLProps<HTMLDivElement>, 'ref' | 'as'> & RefAttributes<HTMLDivElement>
2114
- >
2187
+ export declare const Stack: <E extends ElementType = 'div'>(
2188
+ props: StackProps<E>,
2189
+ ) => React.JSX.Element
2115
2190
 
2116
2191
  /**
2117
2192
  * @public
2118
2193
  */
2119
- export declare interface StackProps extends BoxProps {
2120
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
2194
+ export declare interface StackOwnProps extends BoxOwnProps {
2121
2195
  gap?: number | number[]
2122
2196
  /**
2123
2197
  * @deprecated Use `gap` instead. `space` will be removed in v4.
@@ -2125,6 +2199,11 @@ export declare interface StackProps extends BoxProps {
2125
2199
  space?: number | number[]
2126
2200
  }
2127
2201
 
2202
+ /**
2203
+ * @public
2204
+ */
2205
+ export declare type StackProps<E extends ElementType = 'div'> = Props<StackOwnProps, E>
2206
+
2128
2207
  /**
2129
2208
  * @public
2130
2209
  * @deprecated Use `buildTheme` from `@sanity/ui/theme` instead.
@@ -2164,7 +2243,7 @@ export declare const Tab: ForwardRefExoticComponent<
2164
2243
  TabProps &
2165
2244
  Omit<
2166
2245
  HTMLProps<HTMLButtonElement>,
2167
- 'label' | 'id' | 'type' | 'width' | 'aria-controls' | 'as'
2246
+ 'width' | 'label' | 'id' | 'type' | 'as' | 'aria-controls'
2168
2247
  >,
2169
2248
  'ref'
2170
2249
  > &
@@ -2182,7 +2261,7 @@ export declare const TabList: ForwardRefExoticComponent<
2182
2261
  /**
2183
2262
  * @public
2184
2263
  */
2185
- export declare interface TabListProps extends Omit<InlineProps, 'as' | 'height'> {
2264
+ export declare interface TabListProps extends Omit<InlineOwnProps, 'height'> {
2186
2265
  children: Array<React.JSX.Element | null | undefined | false>
2187
2266
  }
2188
2267
 
@@ -2191,7 +2270,7 @@ export declare interface TabListProps extends Omit<InlineProps, 'as' | 'height'>
2191
2270
  */
2192
2271
  export declare const TabPanel: ForwardRefExoticComponent<
2193
2272
  Omit<
2194
- TabPanelProps & Omit<HTMLProps<HTMLDivElement>, 'id' | 'role' | 'aria-labelledby' | 'as'>,
2273
+ TabPanelProps & Omit<HTMLProps<HTMLDivElement>, 'id' | 'as' | 'role' | 'aria-labelledby'>,
2195
2274
  'ref'
2196
2275
  > &
2197
2276
  RefAttributes<HTMLDivElement>
@@ -2200,7 +2279,7 @@ export declare const TabPanel: ForwardRefExoticComponent<
2200
2279
  /**
2201
2280
  * @public
2202
2281
  */
2203
- export declare interface TabPanelProps extends BoxProps {
2282
+ export declare interface TabPanelProps extends BoxOwnProps {
2204
2283
  /**
2205
2284
  * The `id` of the correlating `Tab` component.
2206
2285
  */
@@ -2226,15 +2305,15 @@ export declare interface TabProps {
2226
2305
  'tone'?: ButtonTone
2227
2306
  }
2228
2307
 
2308
+ /** @public */
2309
+ export declare type TagType = keyof React.JSX.IntrinsicElements
2310
+
2229
2311
  /**
2230
2312
  * The `Text` component is an agile, themed typographic element.
2231
2313
  *
2232
2314
  * @public
2233
2315
  */
2234
- declare const Text_2: ForwardRefExoticComponent<
2235
- Omit<TextProps & Omit<HTMLProps<HTMLDivElement>, 'size' | 'as'>, 'ref'> &
2236
- RefAttributes<HTMLDivElement>
2237
- >
2316
+ declare const Text_2: <E extends ElementType = 'div'>(props: TextProps<E>) => React.JSX.Element
2238
2317
  export {Text_2 as Text}
2239
2318
 
2240
2319
  /**
@@ -2274,14 +2353,14 @@ export declare interface TextAreaProps extends ResponsiveRadiusProps {
2274
2353
  * @public
2275
2354
  */
2276
2355
  export declare const TextInput: ForwardRefExoticComponent<
2277
- Omit<TextInputProps & Omit<HTMLProps<HTMLInputElement>, 'type' | 'prefix' | 'as'>, 'ref'> &
2356
+ Omit<TextInputProps & Omit<HTMLProps<HTMLInputElement>, 'type' | 'as' | 'prefix'>, 'ref'> &
2278
2357
  RefAttributes<HTMLInputElement>
2279
2358
  >
2280
2359
 
2281
2360
  /**
2282
2361
  * @public
2283
2362
  */
2284
- export declare type TextInputClearButtonProps = Omit<ButtonProps, 'as'> &
2363
+ export declare type TextInputClearButtonProps = ButtonOwnProps &
2285
2364
  Omit<React.HTMLProps<HTMLButtonElement>, 'as' | 'onClick' | 'onMouseDown' | 'ref'>
2286
2365
 
2287
2366
  /**
@@ -2339,10 +2418,9 @@ export declare type TextInputType =
2339
2418
  /**
2340
2419
  * @public
2341
2420
  */
2342
- export declare interface TextProps {
2421
+ export declare interface TextOwnProps {
2343
2422
  accent?: boolean
2344
2423
  align?: TextAlign | TextAlign[]
2345
- as?: React.ElementType | keyof React.JSX.IntrinsicElements
2346
2424
  /** When `true` the text color will be muted. */
2347
2425
  muted?: boolean
2348
2426
  size?: number | number[]
@@ -2355,13 +2433,18 @@ export declare interface TextProps {
2355
2433
  weight?: ThemeFontWeightKey_2
2356
2434
  }
2357
2435
 
2436
+ /**
2437
+ * @public
2438
+ */
2439
+ export declare type TextProps<E extends ElementType = 'div'> = Props<TextOwnProps, E>
2440
+
2358
2441
  /**
2359
2442
  * This API might change. DO NOT USE IN PRODUCTION.
2360
2443
  * @beta
2361
2444
  */
2362
2445
  export declare const TextSkeleton: ForwardRefExoticComponent<
2363
2446
  Omit<
2364
- TextSkeletonProps & Omit<HTMLProps<HTMLDivElement>, 'height' | 'size' | 'children' | 'as'>,
2447
+ TextSkeletonProps & Omit<HTMLProps<HTMLDivElement>, 'size' | 'height' | 'as' | 'children'>,
2365
2448
  'ref'
2366
2449
  > &
2367
2450
  RefAttributes<HTMLDivElement>
@@ -2659,7 +2742,7 @@ export declare interface ToastProviderProps extends Omit<ToastLayerProps, 'child
2659
2742
  * @public
2660
2743
  */
2661
2744
  export declare const Tooltip: ForwardRefExoticComponent<
2662
- Omit<TooltipProps & Omit<HTMLProps<HTMLDivElement>, 'content' | 'children' | 'as'>, 'ref'> &
2745
+ Omit<TooltipProps & Omit<HTMLProps<HTMLDivElement>, 'content' | 'as' | 'children'>, 'ref'> &
2663
2746
  RefAttributes<HTMLDivElement>
2664
2747
  >
2665
2748
 
@@ -2754,8 +2837,8 @@ export declare interface TooltipProps extends Omit<LayerProps, 'as'> {
2754
2837
  */
2755
2838
  export declare const Tree: ForwardRefExoticComponent<
2756
2839
  TreeProps &
2757
- Omit<HTMLProps<HTMLDivElement>, 'height' | 'wrap' | 'ref' | 'role' | 'as' | 'align'> &
2758
- RefAttributes<HTMLDivElement>
2840
+ Omit<HTMLProps<HTMLUListElement>, 'wrap' | 'height' | 'as' | 'ref' | 'align' | 'role'> &
2841
+ RefAttributes<HTMLUListElement>
2759
2842
  >
2760
2843
 
2761
2844
  /**
@@ -2799,7 +2882,7 @@ export declare interface TreeItemProps {
2799
2882
  /**
2800
2883
  * Allows passing a custom element type to the link component
2801
2884
  */
2802
- linkAs?: BoxProps['as']
2885
+ linkAs?: ElementType
2803
2886
  padding?: number | number[]
2804
2887
  gap?: number | number[]
2805
2888
  /**
@@ -3025,8 +3108,8 @@ export declare function useTree(): TreeContextValue
3025
3108
  */
3026
3109
  export declare const VirtualList: ForwardRefExoticComponent<
3027
3110
  VirtualListProps<any> &
3028
- StackProps &
3029
- Omit<HTMLProps<HTMLDivElement>, 'children' | 'ref' | 'onChange' | 'as'> &
3111
+ StackOwnProps &
3112
+ Omit<HTMLProps<HTMLDivElement>, 'as' | 'children' | 'ref' | 'onChange'> &
3030
3113
  RefAttributes<HTMLDivElement>
3031
3114
  >
3032
3115