@sanity/ui 2.6.7-canary.0 → 2.6.7

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 (59) hide show
  1. package/dist/index.d.mts +15 -51
  2. package/dist/index.d.ts +15 -51
  3. package/dist/index.esm.js +186 -120
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +186 -119
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +186 -120
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/theme.d.mts +14 -14
  10. package/dist/theme.d.ts +14 -14
  11. package/dist/theme.esm.js.map +1 -1
  12. package/dist/theme.js.map +1 -1
  13. package/dist/theme.mjs.map +1 -1
  14. package/package.json +53 -46
  15. package/src/core/__workshop__/constants.ts +36 -36
  16. package/src/core/components/autocomplete/autocomplete.tsx +1 -1
  17. package/src/core/components/breadcrumbs/breadcrumbs.tsx +6 -15
  18. package/src/core/components/dialog/dialog.tsx +21 -12
  19. package/src/core/components/dialog/styles.ts +8 -8
  20. package/src/core/components/menu/menu.tsx +18 -11
  21. package/src/core/components/menu/menuButton.tsx +11 -11
  22. package/src/core/components/menu/menuContext.ts +1 -1
  23. package/src/core/components/menu/useMenuController.ts +17 -11
  24. package/src/core/components/tab/tab.tsx +8 -8
  25. package/src/core/components/tab/tabPanel.tsx +1 -1
  26. package/src/core/components/toast/styles.ts +1 -2
  27. package/src/core/components/toast/useToast.ts +0 -1
  28. package/src/core/components/tree/tree.tsx +0 -1
  29. package/src/core/components/tree/treeItem.tsx +0 -1
  30. package/src/core/helpers/focus.ts +0 -1
  31. package/src/core/helpers/scroll.ts +0 -1
  32. package/src/core/hooks/_internal/index.ts +1 -0
  33. package/src/core/hooks/_internal/useUnique.ts +34 -0
  34. package/src/core/hooks/index.ts +2 -3
  35. package/src/core/hooks/useClickOutside.ts +72 -38
  36. package/src/core/hooks/useElementSize.ts +0 -1
  37. package/src/core/hooks/useMediaIndex/useMediaIndex.ts +10 -2
  38. package/src/core/hooks/usePrefersDark.ts +55 -10
  39. package/src/core/hooks/usePrefersReducedMotion.ts +56 -10
  40. package/src/core/primitives/avatar/styles.ts +42 -42
  41. package/src/core/primitives/badge/styles.ts +2 -2
  42. package/src/core/primitives/button/styles.ts +4 -4
  43. package/src/core/primitives/inline/styles.ts +2 -2
  44. package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +7 -9
  45. package/src/core/primitives/popover/constants.ts +4 -4
  46. package/src/core/primitives/stack/styles.ts +2 -2
  47. package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +7 -9
  48. package/src/core/primitives/tooltip/constants.ts +4 -4
  49. package/src/core/primitives/tooltip/tooltip.tsx +49 -68
  50. package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +0 -1
  51. package/src/core/styles/font/responsiveFont.ts +8 -8
  52. package/src/core/theme/__workshop__/debug/story.tsx +11 -11
  53. package/src/core/utils/layer/layerProvider.tsx +0 -1
  54. package/src/core/utils/portal/__workshop__/named.tsx +8 -10
  55. package/src/core/utils/portal/portalProvider.tsx +13 -7
  56. package/src/theme/build/buildColorTheme.test.ts +13 -13
  57. package/src/theme/config/tokens/color/types.ts +14 -14
  58. package/src/theme/defaults/colorTokens.ts +36 -36
  59. package/src/core/hooks/useMatchMedia.ts +0 -46
package/dist/index.d.mts CHANGED
@@ -628,7 +628,7 @@ export declare interface CheckboxProps {
628
628
  /**
629
629
  * @public
630
630
  */
631
- export declare type ClickOutsideListener = (event: MouseEvent | TouchEvent) => void
631
+ export declare type ClickOutsideListener = (event: MouseEvent) => void
632
632
 
633
633
  /**
634
634
  * @public
@@ -1432,7 +1432,7 @@ export declare interface MenuProps extends ResponsivePaddingProps {
1432
1432
  * @deprecated Use `shouldFocus="last"` instead.
1433
1433
  */
1434
1434
  focusLast?: boolean
1435
- onClickOutside?: (event: MouseEvent | TouchEvent) => void
1435
+ onClickOutside?: (event: MouseEvent) => void
1436
1436
  onEscape?: () => void
1437
1437
  onItemClick?: () => void
1438
1438
  onItemSelect?: (index: number) => void
@@ -2069,7 +2069,7 @@ export declare interface TabPanelProps extends BoxProps {
2069
2069
  * The `id` of the correlating `Tab` component.
2070
2070
  */
2071
2071
  'aria-labelledby': string
2072
- 'id': string
2072
+ id: string
2073
2073
  }
2074
2074
 
2075
2075
  /**
@@ -2080,14 +2080,14 @@ export declare interface TabProps {
2080
2080
  * The `id` of the correlating `TabPanel` component.
2081
2081
  */
2082
2082
  'aria-controls': string
2083
- 'id': string
2084
- 'icon'?: React.ElementType | React.ReactNode
2085
- 'focused'?: boolean
2086
- 'fontSize'?: number | number[]
2087
- 'label'?: React.ReactNode
2088
- 'padding'?: number | number[]
2089
- 'selected'?: boolean
2090
- 'tone'?: ButtonTone
2083
+ id: string
2084
+ icon?: React.ElementType | React.ReactNode
2085
+ focused?: boolean
2086
+ fontSize?: number | number[]
2087
+ label?: React.ReactNode
2088
+ padding?: number | number[]
2089
+ selected?: boolean
2090
+ tone?: ButtonTone
2091
2091
  }
2092
2092
 
2093
2093
  /**
@@ -2649,22 +2649,13 @@ export declare function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPri
2649
2649
  export declare function useBoundaryElement(): BoundaryElementContextValue
2650
2650
 
2651
2651
  /**
2652
- * Use the callback version of `elementsArg` if you're using `useRef` to handle elements:
2653
- * ```tsx
2654
- * useClickOutside(
2655
- * () => {},
2656
- * () => [ref.current],
2657
- * )
2658
- *
2659
2652
  * @public
2660
2653
  */
2661
2654
  export declare function useClickOutside(
2662
2655
  listener: ClickOutsideListener,
2663
- elementsArg?:
2664
- | Array<HTMLElement | HTMLElement[] | null>
2665
- | (() => Array<HTMLElement | HTMLElement[] | null>),
2656
+ elementsArg?: Array<HTMLElement | HTMLElement[] | null>,
2666
2657
  boundaryElement?: HTMLElement | null,
2667
- ): void
2658
+ ): (el: HTMLElement | null) => void
2668
2659
 
2669
2660
  /**
2670
2661
  * @beta
@@ -2722,18 +2713,6 @@ export declare function useGlobalKeyDown(onKeyDown: (event: KeyboardEvent) => vo
2722
2713
  */
2723
2714
  export declare function useLayer(): LayerContextValue
2724
2715
 
2725
- /**
2726
- * Efficiently subscribes to `window.matchMedia` queries
2727
- *
2728
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Required if the hook is called during SSR (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
2729
- *
2730
- * @public
2731
- */
2732
- export declare function useMatchMedia(
2733
- mediaQueryString: `(${string})`,
2734
- getServerSnapshot?: () => boolean,
2735
- ): boolean
2736
-
2737
2716
  /**
2738
2717
  * This API might change. DO NOT USE IN PRODUCTION.
2739
2718
  * @beta
@@ -2746,30 +2725,15 @@ export declare function useMediaIndex(): number
2746
2725
  export declare function usePortal(): PortalContextValue
2747
2726
 
2748
2727
  /**
2749
- * Returns true if a dark color scheme is preferred, false if a light color scheme is preferred or the preference is not known.
2750
- *
2751
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-color-scheme: light)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
2752
- *
2753
- * If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
2754
- * Chrome supports reading the `prefers-color-scheme` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Color-Scheme
2755
- * @example https://gist.github.com/stipsan/13c0cccf8dfc34f4b44bb1b984baf7df
2756
- *
2757
2728
  * @public
2758
2729
  */
2759
- export declare function usePrefersDark(getServerSnapshot?: () => boolean): boolean
2730
+ export declare function usePrefersDark(): boolean
2760
2731
 
2761
2732
  /**
2762
2733
  * Returns true if motion should be reduced
2763
- *
2764
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-reduced-motion: no-preference)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
2765
- *
2766
- * If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
2767
- * Chrome supports reading the `prefers-reduced-motion` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Reduced-Motion
2768
- * @example https://gist.github.com/stipsan/0c0f839a27842249cada893e9fb7767b
2769
- *
2770
2734
  * @public
2771
2735
  */
2772
- export declare function usePrefersReducedMotion(getServerSnapshot?: () => boolean): boolean
2736
+ export declare function usePrefersReducedMotion(): boolean
2773
2737
 
2774
2738
  /**
2775
2739
  * @public
package/dist/index.d.ts CHANGED
@@ -628,7 +628,7 @@ export declare interface CheckboxProps {
628
628
  /**
629
629
  * @public
630
630
  */
631
- export declare type ClickOutsideListener = (event: MouseEvent | TouchEvent) => void
631
+ export declare type ClickOutsideListener = (event: MouseEvent) => void
632
632
 
633
633
  /**
634
634
  * @public
@@ -1432,7 +1432,7 @@ export declare interface MenuProps extends ResponsivePaddingProps {
1432
1432
  * @deprecated Use `shouldFocus="last"` instead.
1433
1433
  */
1434
1434
  focusLast?: boolean
1435
- onClickOutside?: (event: MouseEvent | TouchEvent) => void
1435
+ onClickOutside?: (event: MouseEvent) => void
1436
1436
  onEscape?: () => void
1437
1437
  onItemClick?: () => void
1438
1438
  onItemSelect?: (index: number) => void
@@ -2069,7 +2069,7 @@ export declare interface TabPanelProps extends BoxProps {
2069
2069
  * The `id` of the correlating `Tab` component.
2070
2070
  */
2071
2071
  'aria-labelledby': string
2072
- 'id': string
2072
+ id: string
2073
2073
  }
2074
2074
 
2075
2075
  /**
@@ -2080,14 +2080,14 @@ export declare interface TabProps {
2080
2080
  * The `id` of the correlating `TabPanel` component.
2081
2081
  */
2082
2082
  'aria-controls': string
2083
- 'id': string
2084
- 'icon'?: React.ElementType | React.ReactNode
2085
- 'focused'?: boolean
2086
- 'fontSize'?: number | number[]
2087
- 'label'?: React.ReactNode
2088
- 'padding'?: number | number[]
2089
- 'selected'?: boolean
2090
- 'tone'?: ButtonTone
2083
+ id: string
2084
+ icon?: React.ElementType | React.ReactNode
2085
+ focused?: boolean
2086
+ fontSize?: number | number[]
2087
+ label?: React.ReactNode
2088
+ padding?: number | number[]
2089
+ selected?: boolean
2090
+ tone?: ButtonTone
2091
2091
  }
2092
2092
 
2093
2093
  /**
@@ -2649,22 +2649,13 @@ export declare function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPri
2649
2649
  export declare function useBoundaryElement(): BoundaryElementContextValue
2650
2650
 
2651
2651
  /**
2652
- * Use the callback version of `elementsArg` if you're using `useRef` to handle elements:
2653
- * ```tsx
2654
- * useClickOutside(
2655
- * () => {},
2656
- * () => [ref.current],
2657
- * )
2658
- *
2659
2652
  * @public
2660
2653
  */
2661
2654
  export declare function useClickOutside(
2662
2655
  listener: ClickOutsideListener,
2663
- elementsArg?:
2664
- | Array<HTMLElement | HTMLElement[] | null>
2665
- | (() => Array<HTMLElement | HTMLElement[] | null>),
2656
+ elementsArg?: Array<HTMLElement | HTMLElement[] | null>,
2666
2657
  boundaryElement?: HTMLElement | null,
2667
- ): void
2658
+ ): (el: HTMLElement | null) => void
2668
2659
 
2669
2660
  /**
2670
2661
  * @beta
@@ -2722,18 +2713,6 @@ export declare function useGlobalKeyDown(onKeyDown: (event: KeyboardEvent) => vo
2722
2713
  */
2723
2714
  export declare function useLayer(): LayerContextValue
2724
2715
 
2725
- /**
2726
- * Efficiently subscribes to `window.matchMedia` queries
2727
- *
2728
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Required if the hook is called during SSR (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
2729
- *
2730
- * @public
2731
- */
2732
- export declare function useMatchMedia(
2733
- mediaQueryString: `(${string})`,
2734
- getServerSnapshot?: () => boolean,
2735
- ): boolean
2736
-
2737
2716
  /**
2738
2717
  * This API might change. DO NOT USE IN PRODUCTION.
2739
2718
  * @beta
@@ -2746,30 +2725,15 @@ export declare function useMediaIndex(): number
2746
2725
  export declare function usePortal(): PortalContextValue
2747
2726
 
2748
2727
  /**
2749
- * Returns true if a dark color scheme is preferred, false if a light color scheme is preferred or the preference is not known.
2750
- *
2751
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-color-scheme: light)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
2752
- *
2753
- * If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
2754
- * Chrome supports reading the `prefers-color-scheme` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Color-Scheme
2755
- * @example https://gist.github.com/stipsan/13c0cccf8dfc34f4b44bb1b984baf7df
2756
- *
2757
2728
  * @public
2758
2729
  */
2759
- export declare function usePrefersDark(getServerSnapshot?: () => boolean): boolean
2730
+ export declare function usePrefersDark(): boolean
2760
2731
 
2761
2732
  /**
2762
2733
  * Returns true if motion should be reduced
2763
- *
2764
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-reduced-motion: no-preference)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
2765
- *
2766
- * If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
2767
- * Chrome supports reading the `prefers-reduced-motion` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Reduced-Motion
2768
- * @example https://gist.github.com/stipsan/0c0f839a27842249cada893e9fb7767b
2769
- *
2770
2734
  * @public
2771
2735
  */
2772
- export declare function usePrefersReducedMotion(getServerSnapshot?: () => boolean): boolean
2736
+ export declare function usePrefersReducedMotion(): boolean
2773
2737
 
2774
2738
  /**
2775
2739
  * @public