@sanity/ui 0.36.11 → 0.36.13
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/lib/cjs/components/autocomplete/autocomplete.styles.d.ts +1 -1
- package/lib/cjs/components/autocomplete/autocomplete.styles.d.ts.map +1 -1
- package/lib/cjs/components/dialog/dialog.d.ts +1 -0
- package/lib/cjs/components/dialog/dialog.d.ts.map +1 -1
- package/lib/cjs/components/dialog/dialog.js +11 -9
- package/lib/cjs/components/dialog/dialog.js.map +2 -2
- package/lib/cjs/components/menu/menuButton.d.ts +6 -6
- package/lib/cjs/components/menu/menuButton.js.map +1 -1
- package/lib/cjs/hooks/_internal/index.d.ts +2 -0
- package/lib/cjs/hooks/_internal/index.d.ts.map +1 -0
- package/lib/cjs/hooks/_internal/index.js +20 -0
- package/lib/cjs/hooks/_internal/index.js.map +7 -0
- package/lib/cjs/hooks/_internal/useUnique.d.ts +8 -0
- package/lib/cjs/hooks/_internal/useUnique.d.ts.map +1 -0
- package/lib/cjs/hooks/_internal/useUnique.js +35 -0
- package/lib/cjs/hooks/_internal/useUnique.js.map +7 -0
- package/lib/cjs/primitives/popover/popover.d.ts +1 -1
- package/lib/cjs/primitives/popover/popover.d.ts.map +1 -1
- package/lib/cjs/primitives/popover/popover.js +3 -1
- package/lib/cjs/primitives/popover/popover.js.map +2 -2
- package/lib/cjs/primitives/tooltip/tooltip.d.ts +1 -1
- package/lib/cjs/primitives/tooltip/tooltip.d.ts.map +1 -1
- package/lib/cjs/primitives/tooltip/tooltip.js +20 -1
- package/lib/cjs/primitives/tooltip/tooltip.js.map +2 -2
- package/lib/cjs/styles/font/responsiveFont.d.ts.map +1 -1
- package/lib/cjs/styles/font/responsiveFont.js +9 -0
- package/lib/cjs/styles/font/responsiveFont.js.map +2 -2
- package/lib/cjs/utils/portal/portal.d.ts +4 -0
- package/lib/cjs/utils/portal/portal.d.ts.map +1 -1
- package/lib/cjs/utils/portal/portal.js +5 -2
- package/lib/cjs/utils/portal/portal.js.map +2 -2
- package/lib/cjs/utils/portal/portalProvider.d.ts +5 -1
- package/lib/cjs/utils/portal/portalProvider.d.ts.map +1 -1
- package/lib/cjs/utils/portal/portalProvider.js +6 -3
- package/lib/cjs/utils/portal/portalProvider.js.map +2 -2
- package/lib/cjs/utils/portal/types.d.ts +1 -0
- package/lib/cjs/utils/portal/types.d.ts.map +1 -1
- package/lib/cjs/utils/portal/types.js.map +1 -1
- package/lib/esm/components/autocomplete/autocomplete.styles.d.ts +1 -1
- package/lib/esm/components/autocomplete/autocomplete.styles.d.ts.map +1 -1
- package/lib/esm/components/dialog/dialog.d.ts +1 -0
- package/lib/esm/components/dialog/dialog.d.ts.map +1 -1
- package/lib/esm/components/dialog/dialog.js +12 -10
- package/lib/esm/components/dialog/dialog.js.map +2 -2
- package/lib/esm/components/menu/menuButton.d.ts +6 -6
- package/lib/esm/components/menu/menuButton.js.map +1 -1
- package/lib/esm/hooks/_internal/index.d.ts +2 -0
- package/lib/esm/hooks/_internal/index.d.ts.map +1 -0
- package/lib/esm/hooks/_internal/index.js +1 -0
- package/lib/esm/hooks/_internal/index.js.map +7 -0
- package/lib/esm/hooks/_internal/useUnique.d.ts +8 -0
- package/lib/esm/hooks/_internal/useUnique.d.ts.map +1 -0
- package/lib/esm/hooks/_internal/useUnique.js +12 -0
- package/lib/esm/hooks/_internal/useUnique.js.map +7 -0
- package/lib/esm/primitives/popover/popover.d.ts +1 -1
- package/lib/esm/primitives/popover/popover.d.ts.map +1 -1
- package/lib/esm/primitives/popover/popover.js +3 -1
- package/lib/esm/primitives/popover/popover.js.map +2 -2
- package/lib/esm/primitives/tooltip/tooltip.d.ts +1 -1
- package/lib/esm/primitives/tooltip/tooltip.d.ts.map +1 -1
- package/lib/esm/primitives/tooltip/tooltip.js +20 -1
- package/lib/esm/primitives/tooltip/tooltip.js.map +2 -2
- package/lib/esm/styles/font/responsiveFont.d.ts.map +1 -1
- package/lib/esm/styles/font/responsiveFont.js +9 -0
- package/lib/esm/styles/font/responsiveFont.js.map +2 -2
- package/lib/esm/utils/portal/portal.d.ts +4 -0
- package/lib/esm/utils/portal/portal.d.ts.map +1 -1
- package/lib/esm/utils/portal/portal.js +5 -2
- package/lib/esm/utils/portal/portal.js.map +2 -2
- package/lib/esm/utils/portal/portalProvider.d.ts +5 -1
- package/lib/esm/utils/portal/portalProvider.d.ts.map +1 -1
- package/lib/esm/utils/portal/portalProvider.js +6 -3
- package/lib/esm/utils/portal/portalProvider.js.map +2 -2
- package/lib/esm/utils/portal/types.d.ts +1 -0
- package/lib/esm/utils/portal/types.d.ts.map +1 -1
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +9 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/primitives/popover/popover.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, {cloneElement, forwardRef, useCallback, useEffect, useMemo, useState} from 'react'\nimport {usePopper} from 'react-popper'\nimport styled, {css} from 'styled-components'\nimport {EMPTY_RECORD} from '../../constants'\nimport {useForwardedRef} from '../../hooks'\nimport {ThemeColorSchemeKey, useTheme} from '../../theme'\nimport {CardTone, Placement, PopoverMargins} from '../../types'\nimport {Layer, LayerProps, Portal, useBoundaryElement, usePortal} from '../../utils'\nimport {Card} from '../card'\nimport {ResponsiveWidthStyleProps} from '../container'\nimport {responsiveContainerWidthStyle} from '../container/styles'\nimport {ResponsiveRadiusProps, ResponsiveShadowProps, ResponsiveWidthProps} from '../types'\nimport {PopoverArrow} from './arrow'\nimport {usePopoverModifiers} from './modifiers'\n\n/**\n * @public\n */\nexport interface PopoverProps\n extends Omit<LayerProps, 'as'>,\n ResponsiveRadiusProps,\n ResponsiveShadowProps,\n ResponsiveWidthProps {\n /**\n * @beta\n */\n __unstable_margins?: PopoverMargins\n allowedAutoPlacements?: Placement[]\n arrow?: boolean\n boundaryElement?: HTMLElement | null\n children?: React.ReactElement\n constrainSize?: boolean\n content?: React.ReactNode\n disabled?: boolean\n fallbackPlacements?: Placement[]\n open?: boolean\n padding?: number | number[]\n placement?: Placement\n portal?: boolean\n preventOverflow?: boolean\n referenceElement?: HTMLElement | null\n matchReferenceWidth?: boolean\n scheme?: ThemeColorSchemeKey\n tether?: boolean\n tetherOffset?: number | ((...args: any[]) => number)\n tone?: CardTone\n}\n\nconst Root = styled(Layer)<{$preventOverflow?: boolean}>(\n ({$preventOverflow}) => css`\n pointer-events: none;\n display: flex;\n flex-direction: column;\n max-width: calc(100% - 16px);\n\n & > * {\n min-height: 0;\n }\n\n /* Hide the popover when the reference element is out of bounds */\n ${$preventOverflow &&\n css`\n &[data-popper-reference-hidden='true'] {\n display: none;\n }\n `}\n `\n)\n\nconst PopoverCard = styled(Card)<\n ResponsiveWidthStyleProps & {\n $constrainSize?: boolean\n $preventOverflow?: boolean\n }\n>(\n ({$constrainSize}) => css`\n flex: 1;\n max-height: ${$constrainSize && '100%'};\n pointer-events: all;\n\n && {\n display: flex;\n }\n\n flex-direction: column;\n\n & > * {\n min-height: 0;\n }\n\n ${responsiveContainerWidthStyle}\n `\n)\n\n/**\n * @public\n */\nexport const Popover = forwardRef(function Popover(\n props: PopoverProps &\n Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'width'>,\n ref: React.ForwardedRef<HTMLDivElement>\n) {\n const boundaryElementContext = useBoundaryElement()\n const theme = useTheme()\n const {\n __unstable_margins: margins,\n allowedAutoPlacements,\n arrow = true,\n boundaryElement: boundaryElementProp = boundaryElementContext.element,\n children: child,\n content,\n constrainSize,\n disabled,\n fallbackPlacements,\n open = false,\n padding,\n placement = 'bottom',\n portal: portalProp = false,\n preventOverflow,\n radius = 3,\n referenceElement: referenceElementProp,\n matchReferenceWidth,\n shadow = 3,\n scheme,\n style = EMPTY_RECORD,\n tether,\n tetherOffset,\n tone = 'inherit',\n width = 0,\n zOffset = theme.sanity.layer?.popover.zOffset,\n ...restProps\n } = props\n const forwardedRef = useForwardedRef(ref)\n const portal = usePortal()\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)\n const [popperElement, setPopperElement] = useState<HTMLElement | null>(null)\n const [arrowElement, setArrowElement] = useState<HTMLElement | null>(null)\n const popperReferenceElement = referenceElementProp || referenceElement\n\n const modifiers = usePopoverModifiers({\n allowedAutoPlacements,\n arrow,\n arrowElement,\n boundaryElement: boundaryElementProp || portal.boundaryElement,\n constrainSize,\n distance: arrow ? 4 : 0,\n fallbackPlacements,\n margins,\n matchReferenceWidth,\n open,\n preventOverflow,\n skidding: 0,\n tether,\n tetherOffset,\n })\n\n const popper = usePopper(popperReferenceElement, popperElement, {\n placement,\n modifiers,\n })\n\n const {attributes, forceUpdate, styles} = popper\n\n const setRef = useCallback(\n (el: HTMLElement | null) => {\n const childRef = (child as any).ref\n\n setReferenceElement(el)\n\n if (typeof childRef === 'function') {\n childRef(el)\n } else if (childRef) {\n childRef.current = el\n }\n },\n [child]\n )\n\n const setRootRef = useCallback(\n (el: HTMLDivElement | null) => {\n setPopperElement(el)\n forwardedRef.current = el\n },\n [forwardedRef]\n )\n\n const popoverStyle = useMemo(() => ({...style, ...styles.popper}), [style, styles])\n\n useEffect(() => {\n if (forceUpdate) {\n try {\n forceUpdate()\n } catch (_) {\n // ignore caught error\n }\n }\n }, [content, forceUpdate, open, popperReferenceElement])\n\n if (disabled) {\n return child || <></>\n }\n\n const node = (\n <Root\n data-ui=\"Popover\"\n {...restProps}\n $preventOverflow={preventOverflow}\n ref={setRootRef}\n style={popoverStyle}\n zOffset={zOffset}\n {...attributes.popper}\n >\n <PopoverCard\n $constrainSize={constrainSize}\n data-ui=\"PopoverCard\"\n padding={padding}\n radius={radius}\n scheme={scheme}\n shadow={shadow}\n tone={tone}\n width={width as any}\n >\n {arrow && <PopoverArrow ref={setArrowElement} style={styles.arrow} />}\n {content}\n </PopoverCard>\n </Root>\n )\n\n return (\n <>\n {child && !referenceElementProp ? cloneElement(child, {ref: setRef}) : child || <></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KAAK;AAAA,IACL,OAAO;AAAA,IACP;AAAA,MACI,WAAW,SAEf,oCAAC,aAAD;AAAA,IACE,gBAAgB;AAAA,IAChB,WAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEC,SAAS,oCAAC,cAAD;AAAA,IAAc,KAAK;AAAA,IAAiB,OAAO,OAAO;AAAA,MAC3D;AAKP,SACE,0DACG,SAAS,CAAC,uBAAuB,aAAa,OAAO,EAAC,KAAK,YAAW,SAAS,2DAE/E,QACC,0DACG,
|
|
4
|
+
"sourcesContent": ["import React, {cloneElement, forwardRef, useCallback, useEffect, useMemo, useState} from 'react'\nimport {usePopper} from 'react-popper'\nimport styled, {css} from 'styled-components'\nimport {EMPTY_RECORD} from '../../constants'\nimport {useForwardedRef} from '../../hooks'\nimport {ThemeColorSchemeKey, useTheme} from '../../theme'\nimport {CardTone, Placement, PopoverMargins} from '../../types'\nimport {Layer, LayerProps, Portal, useBoundaryElement, usePortal} from '../../utils'\nimport {Card} from '../card'\nimport {ResponsiveWidthStyleProps} from '../container'\nimport {responsiveContainerWidthStyle} from '../container/styles'\nimport {ResponsiveRadiusProps, ResponsiveShadowProps, ResponsiveWidthProps} from '../types'\nimport {PopoverArrow} from './arrow'\nimport {usePopoverModifiers} from './modifiers'\n\n/**\n * @public\n */\nexport interface PopoverProps\n extends Omit<LayerProps, 'as'>,\n ResponsiveRadiusProps,\n ResponsiveShadowProps,\n ResponsiveWidthProps {\n /**\n * @beta\n */\n __unstable_margins?: PopoverMargins\n allowedAutoPlacements?: Placement[]\n arrow?: boolean\n boundaryElement?: HTMLElement | null\n children?: React.ReactElement\n constrainSize?: boolean\n content?: React.ReactNode\n disabled?: boolean\n fallbackPlacements?: Placement[]\n open?: boolean\n padding?: number | number[]\n placement?: Placement\n portal?: boolean | string\n preventOverflow?: boolean\n referenceElement?: HTMLElement | null\n matchReferenceWidth?: boolean\n scheme?: ThemeColorSchemeKey\n tether?: boolean\n tetherOffset?: number | ((...args: any[]) => number)\n tone?: CardTone\n}\n\nconst Root = styled(Layer)<{$preventOverflow?: boolean}>(\n ({$preventOverflow}) => css`\n pointer-events: none;\n display: flex;\n flex-direction: column;\n max-width: calc(100% - 16px);\n\n & > * {\n min-height: 0;\n }\n\n /* Hide the popover when the reference element is out of bounds */\n ${$preventOverflow &&\n css`\n &[data-popper-reference-hidden='true'] {\n display: none;\n }\n `}\n `\n)\n\nconst PopoverCard = styled(Card)<\n ResponsiveWidthStyleProps & {\n $constrainSize?: boolean\n $preventOverflow?: boolean\n }\n>(\n ({$constrainSize}) => css`\n flex: 1;\n max-height: ${$constrainSize && '100%'};\n pointer-events: all;\n\n && {\n display: flex;\n }\n\n flex-direction: column;\n\n & > * {\n min-height: 0;\n }\n\n ${responsiveContainerWidthStyle}\n `\n)\n\n/**\n * @public\n */\nexport const Popover = forwardRef(function Popover(\n props: PopoverProps &\n Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'width'>,\n ref: React.ForwardedRef<HTMLDivElement>\n) {\n const boundaryElementContext = useBoundaryElement()\n const theme = useTheme()\n const {\n __unstable_margins: margins,\n allowedAutoPlacements,\n arrow = true,\n boundaryElement: boundaryElementProp = boundaryElementContext.element,\n children: child,\n content,\n constrainSize,\n disabled,\n fallbackPlacements,\n open = false,\n padding,\n placement = 'bottom',\n portal: portalProp = false,\n preventOverflow,\n radius = 3,\n referenceElement: referenceElementProp,\n matchReferenceWidth,\n shadow = 3,\n scheme,\n style = EMPTY_RECORD,\n tether,\n tetherOffset,\n tone = 'inherit',\n width = 0,\n zOffset = theme.sanity.layer?.popover.zOffset,\n ...restProps\n } = props\n const forwardedRef = useForwardedRef(ref)\n const portal = usePortal()\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)\n const [popperElement, setPopperElement] = useState<HTMLElement | null>(null)\n const [arrowElement, setArrowElement] = useState<HTMLElement | null>(null)\n const popperReferenceElement = referenceElementProp || referenceElement\n\n const modifiers = usePopoverModifiers({\n allowedAutoPlacements,\n arrow,\n arrowElement,\n boundaryElement: boundaryElementProp || portal.boundaryElement,\n constrainSize,\n distance: arrow ? 4 : 0,\n fallbackPlacements,\n margins,\n matchReferenceWidth,\n open,\n preventOverflow,\n skidding: 0,\n tether,\n tetherOffset,\n })\n\n const popper = usePopper(popperReferenceElement, popperElement, {\n placement,\n modifiers,\n })\n\n const {attributes, forceUpdate, styles} = popper\n\n const setRef = useCallback(\n (el: HTMLElement | null) => {\n const childRef = (child as any).ref\n\n setReferenceElement(el)\n\n if (typeof childRef === 'function') {\n childRef(el)\n } else if (childRef) {\n childRef.current = el\n }\n },\n [child]\n )\n\n const setRootRef = useCallback(\n (el: HTMLDivElement | null) => {\n setPopperElement(el)\n forwardedRef.current = el\n },\n [forwardedRef]\n )\n\n const popoverStyle = useMemo(() => ({...style, ...styles.popper}), [style, styles])\n\n useEffect(() => {\n if (forceUpdate) {\n try {\n forceUpdate()\n } catch (_) {\n // ignore caught error\n }\n }\n }, [content, forceUpdate, open, popperReferenceElement])\n\n if (disabled) {\n return child || <></>\n }\n\n const node = (\n <Root\n data-ui=\"Popover\"\n {...restProps}\n $preventOverflow={preventOverflow}\n ref={setRootRef}\n style={popoverStyle}\n zOffset={zOffset}\n {...attributes.popper}\n >\n <PopoverCard\n $constrainSize={constrainSize}\n data-ui=\"PopoverCard\"\n padding={padding}\n radius={radius}\n scheme={scheme}\n shadow={shadow}\n tone={tone}\n width={width as any}\n >\n {arrow && <PopoverArrow ref={setArrowElement} style={styles.arrow} />}\n {content}\n </PopoverCard>\n </Root>\n )\n\n return (\n <>\n {child && !referenceElementProp ? cloneElement(child, {ref: setRef}) : child || <></>}\n\n {open && (\n <>\n {portalProp && (\n <Portal __unstable_name={typeof portalProp === 'string' ? portalProp : undefined}>\n {node}\n </Portal>\n )}\n\n {!portalProp && node}\n </>\n )}\n </>\n )\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;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AAgB;AAAA,IAChB,WAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEC,SAAS,oCAAC,cAAD;AAAA,IAAc,KAAK;AAAA,IAAiB,OAAO,OAAO;AAAA,MAC3D;AAKP,SACE,0DACG,SAAS,CAAC,uBAAuB,aAAa,OAAO,EAAC,KAAK,YAAW,SAAS,2DAE/E,QACC,0DACG,cACC,oCAAC,QAAD;AAAA,IAAQ,iBAAiB,OAAO,eAAe,WAAW,aAAa;AAAA,KACpE,OAIJ,CAAC,cAAc;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../../src/primitives/tooltip/tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAA;AAIvF,OAAO,EAAC,mBAAmB,EAAW,MAAM,aAAa,CAAA;AACzD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAQ,UAAU,EAA6B,MAAM,aAAa,CAAA;AAIzE;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC;IAC1D,qBAAqB,CAAC,EAAE,SAAS,EAAE,CAAA;IACnC,eAAe,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IACpC,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAA;IAC7B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,kBAAkB,CAAC,EAAE,SAAS,EAAE,CAAA;IAChC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../../src/primitives/tooltip/tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAA;AAIvF,OAAO,EAAC,mBAAmB,EAAW,MAAM,aAAa,CAAA;AACzD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAQ,UAAU,EAA6B,MAAM,aAAa,CAAA;AAIzE;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC;IAC1D,qBAAqB,CAAC,EAAE,SAAS,EAAE,CAAA;IACnC,eAAe,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IACpC,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAA;IAC7B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,kBAAkB,CAAC,EAAE,SAAS,EAAE,CAAA;IAChC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACzB,MAAM,CAAC,EAAE,mBAAmB,CAAA;CAC7B;AAMD;;GAEG;AACH,eAAO,MAAM,OAAO,w2LAyJlB,CAAA"}
|
|
@@ -108,6 +108,23 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
108
108
|
const handleFocus = useCallback(() => setIsOpen(true), []);
|
|
109
109
|
const handleMouseEnter = useCallback(() => setIsOpen(true), []);
|
|
110
110
|
const handleMouseLeave = useCallback(() => setIsOpen(false), []);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (!isOpen)
|
|
113
|
+
return;
|
|
114
|
+
function handleWindowMouseMove(event) {
|
|
115
|
+
if (!referenceElement)
|
|
116
|
+
return;
|
|
117
|
+
const isHoveringReference = referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target);
|
|
118
|
+
if (!isHoveringReference) {
|
|
119
|
+
setIsOpen(false);
|
|
120
|
+
window.removeEventListener("mousemove", handleWindowMouseMove);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
window.addEventListener("mousemove", handleWindowMouseMove);
|
|
124
|
+
return () => {
|
|
125
|
+
window.removeEventListener("mousemove", handleWindowMouseMove);
|
|
126
|
+
};
|
|
127
|
+
}, [isOpen, referenceElement]);
|
|
111
128
|
useEffect(() => {
|
|
112
129
|
if (forceUpdate)
|
|
113
130
|
forceUpdate();
|
|
@@ -150,7 +167,9 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
150
167
|
ref: setArrowElement,
|
|
151
168
|
style: popper.styles.arrow
|
|
152
169
|
})));
|
|
153
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, referenceNode, isOpen && /* @__PURE__ */ React.createElement(React.Fragment, null, portal && /* @__PURE__ */ React.createElement(Portal,
|
|
170
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, referenceNode, isOpen && /* @__PURE__ */ React.createElement(React.Fragment, null, portal && /* @__PURE__ */ React.createElement(Portal, {
|
|
171
|
+
__unstable_name: typeof portal === "string" ? portal : void 0
|
|
172
|
+
}, popperNode), !portal && popperNode));
|
|
154
173
|
});
|
|
155
174
|
export {
|
|
156
175
|
Tooltip
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/primitives/tooltip/tooltip.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, {cloneElement, forwardRef, useCallback, useEffect, useState} from 'react'\nimport {usePopper} from 'react-popper'\nimport styled from 'styled-components'\nimport {useForwardedRef} from '../../hooks'\nimport {ThemeColorSchemeKey, useTheme} from '../../theme'\nimport {Placement} from '../../types'\nimport {Layer, LayerProps, Portal, useBoundaryElement} from '../../utils'\nimport {Card} from '../card'\nimport {TooltipArrow} from './tooltipArrow'\n\n/**\n * @public\n */\nexport interface TooltipProps extends Omit<LayerProps, 'as'> {\n allowedAutoPlacements?: Placement[]\n boundaryElement?: HTMLElement | null\n children?: React.ReactElement\n content?: React.ReactNode\n disabled?: boolean\n fallbackPlacements?: Placement[]\n placement?: Placement\n portal?: boolean\n scheme?: ThemeColorSchemeKey\n}\n\nconst Root = styled(Layer)`\n pointer-events: none;\n`\n\n/**\n * @public\n */\nexport const Tooltip = forwardRef(function Tooltip(\n props: TooltipProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content'>,\n ref: React.ForwardedRef<HTMLDivElement>\n) {\n const boundaryElementContext = useBoundaryElement()\n const theme = useTheme()\n const {\n allowedAutoPlacements,\n boundaryElement = boundaryElementContext?.element,\n children,\n content,\n disabled,\n fallbackPlacements,\n placement = 'bottom',\n portal,\n scheme,\n zOffset = theme.sanity.layer?.tooltip.zOffset,\n ...restProps\n } = props\n const forwardedRef = useForwardedRef(ref)\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null)\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null)\n const popper = usePopper(referenceElement, popperElement, {\n placement,\n modifiers: [\n {\n name: 'arrow',\n options: {\n element: arrowElement,\n padding: 4,\n },\n },\n {\n name: 'preventOverflow',\n options: {\n altAxis: true,\n boundary: boundaryElement || undefined,\n padding: 4,\n },\n },\n {\n name: 'offset',\n options: {offset: [0, 3]},\n },\n {\n name: 'flip',\n options: {\n allowedAutoPlacements,\n fallbackPlacements,\n },\n },\n ],\n })\n const {forceUpdate} = popper\n const [isOpen, setIsOpen] = useState(false)\n const handleBlur = useCallback(() => setIsOpen(false), [])\n const handleFocus = useCallback(() => setIsOpen(true), [])\n const handleMouseEnter = useCallback(() => setIsOpen(true), [])\n const handleMouseLeave = useCallback(() => setIsOpen(false), [])\n\n useEffect(() => {\n if (forceUpdate) forceUpdate()\n }, [forceUpdate, content])\n\n // Close when `disabled` changes to `true`\n useEffect(() => {\n if (disabled) setIsOpen(false)\n }, [disabled])\n\n // Close when `content` changes to falsy\n useEffect(() => {\n if (!content) setIsOpen(false)\n }, [content])\n\n const setRef = (el: HTMLDivElement | null) => {\n setPopperElement(el)\n forwardedRef.current = el\n }\n\n if (!children) return <></>\n\n if (disabled) return children\n\n const referenceProps = {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n ref: setReferenceElement,\n }\n\n const referenceNode = cloneElement(children, referenceProps)\n\n const popperNode = (\n <Root\n data-ui=\"Tooltip\"\n {...restProps}\n {...popper.attributes.popper}\n ref={setRef}\n style={popper.styles.popper}\n zOffset={zOffset}\n >\n <Card radius={2} scheme={scheme} shadow={3}>\n {content}\n <TooltipArrow ref={setArrowElement} style={popper.styles.arrow} />\n </Card>\n </Root>\n )\n\n return (\n <>\n {referenceNode}\n\n {isOpen && (\n <>\n {portal && <Portal
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAiBA,MAAM,OAAO,OAAO;AAAA;AAAA;AAOb,MAAM,UAAU,WAAW,kBAChC,OACA,KACA;AAnCF;AAoCE,QAAM,yBAAyB;AAC/B,QAAM,QAAQ;AACd,QAYI,YAXF;AAAA;AAAA,IACA,kBAAkB,iEAAwB;AAAA,IAC1C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,UAAU,YAAM,OAAO,UAAb,mBAAoB,QAAQ;AAAA,MAEpC,IADC,sBACD,IADC;AAAA,IAVH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGF,QAAM,eAAe,gBAAgB;AACrC,QAAM,CAAC,kBAAkB,uBAAuB,SAA6B;AAC7E,QAAM,CAAC,eAAe,oBAAoB,SAAgC;AAC1E,QAAM,CAAC,cAAc,mBAAmB,SAAgC;AACxE,QAAM,SAAS,UAAU,kBAAkB,eAAe;AAAA,IACxD;AAAA,IACA,WAAW;AAAA,MACT;AAAA,QACE,MAAM;AAAA,QACN,SAAS;AAAA,UACP,SAAS;AAAA,UACT,SAAS;AAAA;AAAA;AAAA,MAGb;AAAA,QACE,MAAM;AAAA,QACN,SAAS;AAAA,UACP,SAAS;AAAA,UACT,UAAU,mBAAmB;AAAA,UAC7B,SAAS;AAAA;AAAA;AAAA,MAGb;AAAA,QACE,MAAM;AAAA,QACN,SAAS,EAAC,QAAQ,CAAC,GAAG;AAAA;AAAA,MAExB;AAAA,QACE,MAAM;AAAA,QACN,SAAS;AAAA,UACP;AAAA,UACA;AAAA;AAAA;AAAA;AAAA;AAKR,QAAM,EAAC,gBAAe;AACtB,QAAM,CAAC,QAAQ,aAAa,SAAS;AACrC,QAAM,aAAa,YAAY,MAAM,UAAU,QAAQ;AACvD,QAAM,cAAc,YAAY,MAAM,UAAU,OAAO;AACvD,QAAM,mBAAmB,YAAY,MAAM,UAAU,OAAO;AAC5D,QAAM,mBAAmB,YAAY,MAAM,UAAU,QAAQ;
|
|
4
|
+
"sourcesContent": ["import React, {cloneElement, forwardRef, useCallback, useEffect, useState} from 'react'\nimport {usePopper} from 'react-popper'\nimport styled from 'styled-components'\nimport {useForwardedRef} from '../../hooks'\nimport {ThemeColorSchemeKey, useTheme} from '../../theme'\nimport {Placement} from '../../types'\nimport {Layer, LayerProps, Portal, useBoundaryElement} from '../../utils'\nimport {Card} from '../card'\nimport {TooltipArrow} from './tooltipArrow'\n\n/**\n * @public\n */\nexport interface TooltipProps extends Omit<LayerProps, 'as'> {\n allowedAutoPlacements?: Placement[]\n boundaryElement?: HTMLElement | null\n children?: React.ReactElement\n content?: React.ReactNode\n disabled?: boolean\n fallbackPlacements?: Placement[]\n placement?: Placement\n portal?: boolean | string\n scheme?: ThemeColorSchemeKey\n}\n\nconst Root = styled(Layer)`\n pointer-events: none;\n`\n\n/**\n * @public\n */\nexport const Tooltip = forwardRef(function Tooltip(\n props: TooltipProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content'>,\n ref: React.ForwardedRef<HTMLDivElement>\n) {\n const boundaryElementContext = useBoundaryElement()\n const theme = useTheme()\n const {\n allowedAutoPlacements,\n boundaryElement = boundaryElementContext?.element,\n children,\n content,\n disabled,\n fallbackPlacements,\n placement = 'bottom',\n portal,\n scheme,\n zOffset = theme.sanity.layer?.tooltip.zOffset,\n ...restProps\n } = props\n const forwardedRef = useForwardedRef(ref)\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null)\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null)\n const popper = usePopper(referenceElement, popperElement, {\n placement,\n modifiers: [\n {\n name: 'arrow',\n options: {\n element: arrowElement,\n padding: 4,\n },\n },\n {\n name: 'preventOverflow',\n options: {\n altAxis: true,\n boundary: boundaryElement || undefined,\n padding: 4,\n },\n },\n {\n name: 'offset',\n options: {offset: [0, 3]},\n },\n {\n name: 'flip',\n options: {\n allowedAutoPlacements,\n fallbackPlacements,\n },\n },\n ],\n })\n const {forceUpdate} = popper\n const [isOpen, setIsOpen] = useState(false)\n const handleBlur = useCallback(() => setIsOpen(false), [])\n const handleFocus = useCallback(() => setIsOpen(true), [])\n const handleMouseEnter = useCallback(() => setIsOpen(true), [])\n const handleMouseLeave = useCallback(() => setIsOpen(false), [])\n\n // Detect whether the mouse is moving outside of the reference element. This is sometimes\n // necessary, because the tooltip might not always close as it should (e.g. when clicking\n // the reference element triggers a CPU-heavy operation.)\n useEffect(() => {\n if (!isOpen) return\n\n function handleWindowMouseMove(event: MouseEvent) {\n if (!referenceElement) return\n\n const isHoveringReference =\n referenceElement === event.target ||\n (event.target instanceof Node && referenceElement.contains(event.target))\n\n if (!isHoveringReference) {\n setIsOpen(false)\n window.removeEventListener('mousemove', handleWindowMouseMove)\n }\n }\n\n window.addEventListener('mousemove', handleWindowMouseMove)\n\n return () => {\n window.removeEventListener('mousemove', handleWindowMouseMove)\n }\n }, [isOpen, referenceElement])\n\n useEffect(() => {\n if (forceUpdate) forceUpdate()\n }, [forceUpdate, content])\n\n // Close when `disabled` changes to `true`\n useEffect(() => {\n if (disabled) setIsOpen(false)\n }, [disabled])\n\n // Close when `content` changes to falsy\n useEffect(() => {\n if (!content) setIsOpen(false)\n }, [content])\n\n const setRef = (el: HTMLDivElement | null) => {\n setPopperElement(el)\n forwardedRef.current = el\n }\n\n if (!children) return <></>\n\n if (disabled) return children\n\n const referenceProps = {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n ref: setReferenceElement,\n }\n\n const referenceNode = cloneElement(children, referenceProps)\n\n const popperNode = (\n <Root\n data-ui=\"Tooltip\"\n {...restProps}\n {...popper.attributes.popper}\n ref={setRef}\n style={popper.styles.popper}\n zOffset={zOffset}\n >\n <Card radius={2} scheme={scheme} shadow={3}>\n {content}\n <TooltipArrow ref={setArrowElement} style={popper.styles.arrow} />\n </Card>\n </Root>\n )\n\n return (\n <>\n {referenceNode}\n\n {isOpen && (\n <>\n {portal && (\n <Portal __unstable_name={typeof portal === 'string' ? portal : undefined}>\n {popperNode}\n </Portal>\n )}\n\n {!portal && popperNode}\n </>\n )}\n </>\n )\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAiBA,MAAM,OAAO,OAAO;AAAA;AAAA;AAOb,MAAM,UAAU,WAAW,kBAChC,OACA,KACA;AAnCF;AAoCE,QAAM,yBAAyB;AAC/B,QAAM,QAAQ;AACd,QAYI,YAXF;AAAA;AAAA,IACA,kBAAkB,iEAAwB;AAAA,IAC1C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,UAAU,YAAM,OAAO,UAAb,mBAAoB,QAAQ;AAAA,MAEpC,IADC,sBACD,IADC;AA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aAAa,CAAA;AAEvD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,wBAAwB,GAAG,UAAU,GAC3C,SAAS,EAAE,CA0Cb;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"responsiveFont.d.ts","sourceRoot":"","sources":["../../../../src/styles/font/responsiveFont.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,aAAa,CAAA;AAEvD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,wBAAwB,GAAG,UAAU,GAC3C,SAAS,EAAE,CA0Cb;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAkDlF"}
|
|
@@ -36,6 +36,8 @@ function fontSize(size, horizontalOffset) {
|
|
|
36
36
|
const negHeight = ascenderHeight + descenderHeight;
|
|
37
37
|
const capHeight = lineHeight - negHeight;
|
|
38
38
|
const iconOffset = (capHeight - iconSize) / 2;
|
|
39
|
+
const customIconSize = Math.floor(fontSize2 * 1.125 / 2) * 2 + 1;
|
|
40
|
+
const customIconOffset = (capHeight - customIconSize) / 2;
|
|
39
41
|
return {
|
|
40
42
|
fontSize: rem(fontSize2),
|
|
41
43
|
lineHeight: `calc(${lineHeight} / ${fontSize2})`,
|
|
@@ -50,6 +52,13 @@ function fontSize(size, horizontalOffset) {
|
|
|
50
52
|
"& > code, & > span": {
|
|
51
53
|
margin: horizontalOffset ? `0 calc(${rem(0 - horizontalOffset * fontSize2)} - 1px)` : "0 -1px"
|
|
52
54
|
},
|
|
55
|
+
"& svg:not([data-sanity-icon])": {
|
|
56
|
+
fontSize: `calc(${customIconSize} / 16 * 1rem)`,
|
|
57
|
+
margin: [
|
|
58
|
+
rem(customIconOffset),
|
|
59
|
+
horizontalOffset ? `calc(${rem(customIconOffset)} + ${rem(horizontalOffset * fontSize2)})` : rem(customIconOffset)
|
|
60
|
+
].join(" ")
|
|
61
|
+
},
|
|
53
62
|
"& [data-sanity-icon]": {
|
|
54
63
|
fontSize: `calc(${iconSize} / 16 * 1rem)`,
|
|
55
64
|
margin: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/styles/font/responsiveFont.ts"],
|
|
4
|
-
"sourcesContent": ["import {CSSObject} from 'styled-components'\nimport {ThemeFontSize, ThemeFontKey} from '../../theme'\nimport {getResponsiveProp, rem, responsive} from '../helpers'\nimport {ThemeProps} from '../types'\nimport {ResponsiveFontStyleProps} from './types'\n\n/**\n * A utility function getting responsive font styles.\n * @internal\n */\nexport function responsiveFont(\n fontKey: ThemeFontKey,\n props: ResponsiveFontStyleProps & ThemeProps\n): CSSObject[] {\n const {$size, $weight, theme} = props\n const {fonts, media} = theme.sanity\n const {family, sizes, weights, horizontalOffset} = fonts[fontKey]\n const fontWeight = ($weight && weights[$weight]) || weights.regular\n\n // @todo: make this configurable\n const defaultSize = sizes[2]\n\n const base: CSSObject = {\n position: 'relative',\n fontFamily: family,\n fontWeight,\n padding: '1px',\n margin: 0,\n\n '&:before': {\n content: '\"\"',\n display: 'block',\n height: 0,\n },\n\n '&:after': {\n content: '\"\"',\n display: 'block',\n height: 0,\n },\n\n '& > code, & > span': {\n display: 'block',\n },\n\n '&:not([hidden])': {\n display: 'block',\n },\n }\n\n const resp = responsive(media, getResponsiveProp($size), (sizeIndex) =>\n fontSize(sizes[sizeIndex] || defaultSize, horizontalOffset)\n )\n\n return [base, ...resp]\n}\n\nexport function fontSize(size: ThemeFontSize, horizontalOffset?: number): CSSObject {\n const {ascenderHeight, descenderHeight, fontSize, iconSize, letterSpacing, lineHeight} = size\n const negHeight = ascenderHeight + descenderHeight\n const capHeight = lineHeight - negHeight\n const iconOffset = (capHeight - iconSize) / 2\n\n return {\n fontSize: rem(fontSize),\n lineHeight: `calc(${lineHeight} / ${fontSize})`,\n letterSpacing: rem(letterSpacing),\n transform: `translateY(${rem(descenderHeight)})`,\n\n '&:before': {\n marginTop: `calc(${rem(0 - negHeight)} - 1px)`,\n },\n\n '&:after': {\n marginBottom: '-1px',\n },\n\n '& > code, & > span': {\n margin: horizontalOffset ? `0 calc(${rem(0 - horizontalOffset * fontSize)} - 1px)` : '0 -1px',\n },\n\n '& [data-sanity-icon]': {\n fontSize: `calc(${iconSize} / 16 * 1rem)`,\n margin: [\n // top & bottom\n rem(iconOffset),\n // left & right\n horizontalOffset\n ? `calc(${rem(iconOffset)} + ${rem(horizontalOffset * fontSize)})`\n : rem(iconOffset),\n ].join(' '),\n },\n }\n}\n"],
|
|
5
|
-
"mappings": "AAEA;AAQO,wBACL,SACA,OACa;AACb,QAAM,EAAC,OAAO,SAAS,UAAS;AAChC,QAAM,EAAC,OAAO,UAAS,MAAM;AAC7B,QAAM,EAAC,QAAQ,OAAO,SAAS,qBAAoB,MAAM;AACzD,QAAM,aAAc,WAAW,QAAQ,YAAa,QAAQ;AAG5D,QAAM,cAAc,MAAM;AAE1B,QAAM,OAAkB;AAAA,IACtB,UAAU;AAAA,IACV,YAAY;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,IACT,QAAQ;AAAA,IAER,YAAY;AAAA,MACV,SAAS;AAAA,MACT,SAAS;AAAA,MACT,QAAQ;AAAA;AAAA,IAGV,WAAW;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,QAAQ;AAAA;AAAA,IAGV,sBAAsB;AAAA,MACpB,SAAS;AAAA;AAAA,IAGX,mBAAmB;AAAA,MACjB,SAAS;AAAA;AAAA;AAIb,QAAM,OAAO,WAAW,OAAO,kBAAkB,QAAQ,CAAC,cACxD,SAAS,MAAM,cAAc,aAAa;AAG5C,SAAO,CAAC,MAAM,GAAG;AAAA;AAGZ,kBAAkB,MAAqB,kBAAsC;AAClF,QAAM,EAAC,gBAAgB,iBAAiB,qBAAU,UAAU,eAAe,eAAc;AACzF,QAAM,YAAY,iBAAiB;AACnC,QAAM,YAAY,aAAa;AAC/B,QAAM,aAAc,aAAY,YAAY;
|
|
4
|
+
"sourcesContent": ["import {CSSObject} from 'styled-components'\nimport {ThemeFontSize, ThemeFontKey} from '../../theme'\nimport {getResponsiveProp, rem, responsive} from '../helpers'\nimport {ThemeProps} from '../types'\nimport {ResponsiveFontStyleProps} from './types'\n\n/**\n * A utility function getting responsive font styles.\n * @internal\n */\nexport function responsiveFont(\n fontKey: ThemeFontKey,\n props: ResponsiveFontStyleProps & ThemeProps\n): CSSObject[] {\n const {$size, $weight, theme} = props\n const {fonts, media} = theme.sanity\n const {family, sizes, weights, horizontalOffset} = fonts[fontKey]\n const fontWeight = ($weight && weights[$weight]) || weights.regular\n\n // @todo: make this configurable\n const defaultSize = sizes[2]\n\n const base: CSSObject = {\n position: 'relative',\n fontFamily: family,\n fontWeight,\n padding: '1px',\n margin: 0,\n\n '&:before': {\n content: '\"\"',\n display: 'block',\n height: 0,\n },\n\n '&:after': {\n content: '\"\"',\n display: 'block',\n height: 0,\n },\n\n '& > code, & > span': {\n display: 'block',\n },\n\n '&:not([hidden])': {\n display: 'block',\n },\n }\n\n const resp = responsive(media, getResponsiveProp($size), (sizeIndex) =>\n fontSize(sizes[sizeIndex] || defaultSize, horizontalOffset)\n )\n\n return [base, ...resp]\n}\n\nexport function fontSize(size: ThemeFontSize, horizontalOffset?: number): CSSObject {\n const {ascenderHeight, descenderHeight, fontSize, iconSize, letterSpacing, lineHeight} = size\n const negHeight = ascenderHeight + descenderHeight\n const capHeight = lineHeight - negHeight\n const iconOffset = (capHeight - iconSize) / 2\n const customIconSize = Math.floor((fontSize * 1.125) / 2) * 2 + 1\n const customIconOffset = (capHeight - customIconSize) / 2\n\n return {\n fontSize: rem(fontSize),\n lineHeight: `calc(${lineHeight} / ${fontSize})`,\n letterSpacing: rem(letterSpacing),\n transform: `translateY(${rem(descenderHeight)})`,\n\n '&:before': {\n marginTop: `calc(${rem(0 - negHeight)} - 1px)`,\n },\n\n '&:after': {\n marginBottom: '-1px',\n },\n\n '& > code, & > span': {\n margin: horizontalOffset ? `0 calc(${rem(0 - horizontalOffset * fontSize)} - 1px)` : '0 -1px',\n },\n\n '& svg:not([data-sanity-icon])': {\n fontSize: `calc(${customIconSize} / 16 * 1rem)`,\n margin: [\n // top & bottom\n rem(customIconOffset),\n // left & right\n horizontalOffset\n ? `calc(${rem(customIconOffset)} + ${rem(horizontalOffset * fontSize)})`\n : rem(customIconOffset),\n ].join(' '),\n },\n\n '& [data-sanity-icon]': {\n fontSize: `calc(${iconSize} / 16 * 1rem)`,\n margin: [\n // top & bottom\n rem(iconOffset),\n // left & right\n horizontalOffset\n ? `calc(${rem(iconOffset)} + ${rem(horizontalOffset * fontSize)})`\n : rem(iconOffset),\n ].join(' '),\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEA;AAQO,wBACL,SACA,OACa;AACb,QAAM,EAAC,OAAO,SAAS,UAAS;AAChC,QAAM,EAAC,OAAO,UAAS,MAAM;AAC7B,QAAM,EAAC,QAAQ,OAAO,SAAS,qBAAoB,MAAM;AACzD,QAAM,aAAc,WAAW,QAAQ,YAAa,QAAQ;AAG5D,QAAM,cAAc,MAAM;AAE1B,QAAM,OAAkB;AAAA,IACtB,UAAU;AAAA,IACV,YAAY;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,IACT,QAAQ;AAAA,IAER,YAAY;AAAA,MACV,SAAS;AA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,IAAI;AAAA,QACR,KAAK;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../../../src/utils/portal/portal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../../../src/utils/portal/portal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,KAAK,CAAC,WAAW,GAAG,IAAI,CAWnE"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import ReactDOM from "react-dom";
|
|
2
2
|
import { usePortal } from "./usePortal";
|
|
3
3
|
function Portal(props) {
|
|
4
|
+
var _a;
|
|
5
|
+
const { children, __unstable_name: name } = props;
|
|
4
6
|
const portal = usePortal();
|
|
5
|
-
|
|
7
|
+
const portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || ((_a = portal.elements) == null ? void 0 : _a.default);
|
|
8
|
+
if (!portalElement) {
|
|
6
9
|
return null;
|
|
7
10
|
}
|
|
8
|
-
return ReactDOM.createPortal(
|
|
11
|
+
return ReactDOM.createPortal(children, portalElement);
|
|
9
12
|
}
|
|
10
13
|
export {
|
|
11
14
|
Portal
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/utils/portal/portal.ts"],
|
|
4
|
-
"sourcesContent": ["import React from 'react'\nimport ReactDOM from 'react-dom'\nimport {usePortal} from './usePortal'\n\n/**\n * @public\n */\nexport interface PortalProps {\n children: React.ReactNode\n}\n\n/**\n * @public\n */\nexport function Portal(props: PortalProps): React.ReactPortal | null {\n const portal = usePortal()\n\n if (!
|
|
5
|
-
"mappings": "AACA;AACA;
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport ReactDOM from 'react-dom'\nimport {usePortal} from './usePortal'\n\n/**\n * @public\n */\nexport interface PortalProps {\n children: React.ReactNode\n /**\n * @beta This API might change. DO NOT USE IN PRODUCTION.\n */\n __unstable_name?: string\n}\n\n/**\n * @public\n */\nexport function Portal(props: PortalProps): React.ReactPortal | null {\n const {children, __unstable_name: name} = props\n const portal = usePortal()\n const portalElement =\n (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default\n\n if (!portalElement) {\n return null\n }\n\n return ReactDOM.createPortal(children, portalElement)\n}\n"],
|
|
5
|
+
"mappings": "AACA;AACA;AAgBO,gBAAgB,OAA8C;AAlBrE;AAmBE,QAAM,EAAC,UAAU,iBAAiB,SAAQ;AAC1C,QAAM,SAAS;AACf,QAAM,gBACH,QAAO,OAAO,YAAY,OAAO,SAAS,QAAQ,OAAO,YAAY,cAAO,aAAP,mBAAiB;AAEzF,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA;AAGT,SAAO,SAAS,aAAa,UAAU;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,7 +8,11 @@ export interface PortalProviderProps {
|
|
|
8
8
|
*/
|
|
9
9
|
boundaryElement?: HTMLElement | null;
|
|
10
10
|
children: React.ReactNode;
|
|
11
|
-
element
|
|
11
|
+
element?: HTMLElement | null;
|
|
12
|
+
/**
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
__unstable_elements?: Record<string, HTMLElement | null | undefined>;
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
14
18
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portalProvider.d.ts","sourceRoot":"","sources":["../../../../src/utils/portal/portalProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"portalProvider.d.ts","sourceRoot":"","sources":["../../../../src/utils/portal/portalProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgB,MAAM,OAAO,CAAA;AAKpC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,eAAe,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;CACrE;AAID;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CAc7E"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
|
+
import { useUnique } from "../../hooks/_internal";
|
|
2
3
|
import { PortalContext } from "./portalContext";
|
|
3
4
|
const __BROWSER__ = typeof window !== "undefined";
|
|
4
5
|
function PortalProvider(props) {
|
|
5
|
-
const { boundaryElement, children, element } = props;
|
|
6
|
+
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props;
|
|
7
|
+
const elements = useUnique(elementsProp);
|
|
6
8
|
const value = useMemo(() => {
|
|
7
9
|
return {
|
|
8
10
|
version: 0,
|
|
9
11
|
boundaryElement: boundaryElement || null,
|
|
10
|
-
element: element || __BROWSER__ && document.body || null
|
|
12
|
+
element: element || __BROWSER__ && document.body || null,
|
|
13
|
+
elements
|
|
11
14
|
};
|
|
12
|
-
}, [boundaryElement, element]);
|
|
15
|
+
}, [boundaryElement, element, elements]);
|
|
13
16
|
return /* @__PURE__ */ React.createElement(PortalContext.Provider, {
|
|
14
17
|
value
|
|
15
18
|
}, children);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/utils/portal/portalProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, {useMemo} from 'react'\nimport {PortalContext} from './portalContext'\nimport {PortalContextValue} from './types'\n\n/**\n * @public\n */\nexport interface PortalProviderProps {\n /**\n * @deprecated Use `<BoundaryElementProvider element={...} />` instead\n */\n boundaryElement?: HTMLElement | null\n children: React.ReactNode\n element
|
|
5
|
-
"mappings": "AAAA;AACA;
|
|
4
|
+
"sourcesContent": ["import React, {useMemo} from 'react'\nimport {useUnique} from '../../hooks/_internal'\nimport {PortalContext} from './portalContext'\nimport {PortalContextValue} from './types'\n\n/**\n * @public\n */\nexport interface PortalProviderProps {\n /**\n * @deprecated Use `<BoundaryElementProvider element={...} />` instead\n */\n boundaryElement?: HTMLElement | null\n children: React.ReactNode\n element?: HTMLElement | null\n /**\n * @beta\n */\n __unstable_elements?: Record<string, HTMLElement | null | undefined>\n}\n\nconst __BROWSER__ = typeof window !== 'undefined'\n\n/**\n * @public\n */\nexport function PortalProvider(props: PortalProviderProps): React.ReactElement {\n const {boundaryElement, children, element, __unstable_elements: elementsProp} = props\n const elements = useUnique(elementsProp)\n\n const value: PortalContextValue = useMemo(() => {\n return {\n version: 0.0,\n boundaryElement: boundaryElement || null,\n element: element || (__BROWSER__ && document.body) || null,\n elements,\n }\n }, [boundaryElement, element, elements])\n\n return <PortalContext.Provider value={value}>{children}</PortalContext.Provider>\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AACA;AACA;AAmBA,MAAM,cAAc,OAAO,WAAW;AAK/B,wBAAwB,OAAgD;AAC7E,QAAM,EAAC,iBAAiB,UAAU,SAAS,qBAAqB,iBAAgB;AAChF,QAAM,WAAW,UAAU;AAE3B,QAAM,QAA4B,QAAQ,MAAM;AAC9C,WAAO;AAAA,MACL,SAAS;AAAA,MACT,iBAAiB,mBAAmB;AAAA,MACpC,SAAS,WAAY,eAAe,SAAS,QAAS;AAAA,MACtD;AAAA;AAAA,KAED,CAAC,iBAAiB,SAAS;AAE9B,SAAO,oCAAC,cAAc,UAAf;AAAA,IAAwB;AAAA,KAAe;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/utils/portal/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,GAAG,CAAA;IACZ,eAAe,EAAE,WAAW,GAAG,IAAI,CAAA;IACnC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/utils/portal/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,GAAG,CAAA;IACZ,eAAe,EAAE,WAAW,GAAG,IAAI,CAAA;IACnC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;CAC1D"}
|