@sanity/ui 2.6.4-canary.0 → 2.6.4-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +51 -15
- package/dist/index.d.ts +51 -15
- package/dist/index.esm.js +103 -167
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +102 -167
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -167
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +14 -14
- package/dist/theme.d.ts +14 -14
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs.map +1 -1
- package/package.json +28 -27
- package/src/core/__workshop__/constants.ts +36 -36
- package/src/core/components/autocomplete/autocomplete.tsx +1 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +15 -6
- package/src/core/components/dialog/dialog.tsx +12 -21
- package/src/core/components/dialog/styles.ts +8 -8
- package/src/core/components/menu/menu.tsx +11 -18
- package/src/core/components/menu/menuButton.tsx +11 -11
- package/src/core/components/menu/menuContext.ts +1 -1
- package/src/core/components/menu/useMenuController.ts +11 -18
- package/src/core/components/tab/tab.tsx +8 -8
- package/src/core/components/tab/tabPanel.tsx +1 -1
- package/src/core/components/toast/useToast.ts +1 -0
- package/src/core/components/tree/tree.tsx +1 -0
- package/src/core/components/tree/treeItem.tsx +1 -0
- package/src/core/hooks/index.ts +3 -2
- package/src/core/hooks/useClickOutside.ts +37 -74
- package/src/core/hooks/useMatchMedia.ts +46 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +2 -11
- package/src/core/hooks/usePrefersDark.ts +10 -58
- package/src/core/hooks/usePrefersReducedMotion.ts +10 -58
- package/src/core/primitives/avatar/styles.ts +42 -42
- package/src/core/primitives/badge/styles.ts +2 -2
- package/src/core/primitives/button/styles.ts +4 -4
- package/src/core/primitives/inline/styles.ts +2 -2
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +9 -7
- package/src/core/primitives/popover/constants.ts +4 -4
- package/src/core/primitives/stack/styles.ts +2 -2
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +9 -7
- package/src/core/primitives/tooltip/constants.ts +4 -4
- package/src/core/primitives/tooltip/tooltip.tsx +45 -27
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +1 -0
- package/src/core/styles/font/responsiveFont.ts +8 -8
- package/src/core/theme/__workshop__/debug/story.tsx +11 -11
- package/src/core/utils/layer/layerProvider.tsx +1 -0
- package/src/core/utils/portal/__workshop__/named.tsx +10 -8
- package/src/core/utils/portal/portalProvider.tsx +7 -14
- package/src/theme/build/buildColorTheme.test.ts +13 -13
- package/src/theme/config/tokens/color/types.ts +14 -14
- package/src/theme/defaults/colorTokens.ts +36 -36
- package/src/core/hooks/_internal/index.ts +0 -1
- package/src/core/hooks/_internal/useUnique.ts +0 -34
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) => void
|
|
631
|
+
export declare type ClickOutsideListener = (event: MouseEvent | TouchEvent) => 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) => void
|
|
1435
|
+
onClickOutside?: (event: MouseEvent | TouchEvent) => 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,13 +2649,22 @@ 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
|
+
*
|
|
2652
2659
|
* @public
|
|
2653
2660
|
*/
|
|
2654
2661
|
export declare function useClickOutside(
|
|
2655
2662
|
listener: ClickOutsideListener,
|
|
2656
|
-
elementsArg?:
|
|
2663
|
+
elementsArg?:
|
|
2664
|
+
| Array<HTMLElement | HTMLElement[] | null>
|
|
2665
|
+
| (() => Array<HTMLElement | HTMLElement[] | null>),
|
|
2657
2666
|
boundaryElement?: HTMLElement | null,
|
|
2658
|
-
):
|
|
2667
|
+
): void
|
|
2659
2668
|
|
|
2660
2669
|
/**
|
|
2661
2670
|
* @beta
|
|
@@ -2713,6 +2722,18 @@ export declare function useGlobalKeyDown(onKeyDown: (event: KeyboardEvent) => vo
|
|
|
2713
2722
|
*/
|
|
2714
2723
|
export declare function useLayer(): LayerContextValue
|
|
2715
2724
|
|
|
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
|
+
|
|
2716
2737
|
/**
|
|
2717
2738
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
2718
2739
|
* @beta
|
|
@@ -2725,15 +2746,30 @@ export declare function useMediaIndex(): number
|
|
|
2725
2746
|
export declare function usePortal(): PortalContextValue
|
|
2726
2747
|
|
|
2727
2748
|
/**
|
|
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
|
+
*
|
|
2728
2757
|
* @public
|
|
2729
2758
|
*/
|
|
2730
|
-
export declare function usePrefersDark(): boolean
|
|
2759
|
+
export declare function usePrefersDark(getServerSnapshot?: () => boolean): boolean
|
|
2731
2760
|
|
|
2732
2761
|
/**
|
|
2733
2762
|
* 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
|
+
*
|
|
2734
2770
|
* @public
|
|
2735
2771
|
*/
|
|
2736
|
-
export declare function usePrefersReducedMotion(): boolean
|
|
2772
|
+
export declare function usePrefersReducedMotion(getServerSnapshot?: () => boolean): boolean
|
|
2737
2773
|
|
|
2738
2774
|
/**
|
|
2739
2775
|
* @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) => void
|
|
631
|
+
export declare type ClickOutsideListener = (event: MouseEvent | TouchEvent) => 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) => void
|
|
1435
|
+
onClickOutside?: (event: MouseEvent | TouchEvent) => 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,13 +2649,22 @@ 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
|
+
*
|
|
2652
2659
|
* @public
|
|
2653
2660
|
*/
|
|
2654
2661
|
export declare function useClickOutside(
|
|
2655
2662
|
listener: ClickOutsideListener,
|
|
2656
|
-
elementsArg?:
|
|
2663
|
+
elementsArg?:
|
|
2664
|
+
| Array<HTMLElement | HTMLElement[] | null>
|
|
2665
|
+
| (() => Array<HTMLElement | HTMLElement[] | null>),
|
|
2657
2666
|
boundaryElement?: HTMLElement | null,
|
|
2658
|
-
):
|
|
2667
|
+
): void
|
|
2659
2668
|
|
|
2660
2669
|
/**
|
|
2661
2670
|
* @beta
|
|
@@ -2713,6 +2722,18 @@ export declare function useGlobalKeyDown(onKeyDown: (event: KeyboardEvent) => vo
|
|
|
2713
2722
|
*/
|
|
2714
2723
|
export declare function useLayer(): LayerContextValue
|
|
2715
2724
|
|
|
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
|
+
|
|
2716
2737
|
/**
|
|
2717
2738
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
2718
2739
|
* @beta
|
|
@@ -2725,15 +2746,30 @@ export declare function useMediaIndex(): number
|
|
|
2725
2746
|
export declare function usePortal(): PortalContextValue
|
|
2726
2747
|
|
|
2727
2748
|
/**
|
|
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
|
+
*
|
|
2728
2757
|
* @public
|
|
2729
2758
|
*/
|
|
2730
|
-
export declare function usePrefersDark(): boolean
|
|
2759
|
+
export declare function usePrefersDark(getServerSnapshot?: () => boolean): boolean
|
|
2731
2760
|
|
|
2732
2761
|
/**
|
|
2733
2762
|
* 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
|
+
*
|
|
2734
2770
|
* @public
|
|
2735
2771
|
*/
|
|
2736
|
-
export declare function usePrefersReducedMotion(): boolean
|
|
2772
|
+
export declare function usePrefersReducedMotion(getServerSnapshot?: () => boolean): boolean
|
|
2737
2773
|
|
|
2738
2774
|
/**
|
|
2739
2775
|
* @public
|