@sanity/ui 0.36.13-next.12 → 0.36.15
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 +5 -1
- package/lib/cjs/components/dialog/dialog.js.map +2 -2
- package/lib/cjs/components/menu/menuButton.d.ts +12 -9
- package/lib/cjs/components/menu/menuButton.d.ts.map +1 -1
- package/lib/cjs/components/menu/menuButton.js +17 -2
- package/lib/cjs/components/menu/menuButton.js.map +2 -2
- package/lib/cjs/components/menu/menuItem.d.ts.map +1 -1
- package/lib/cjs/components/menu/menuItem.js +1 -0
- package/lib/cjs/components/menu/menuItem.js.map +2 -2
- 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 +3 -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.map +1 -1
- package/lib/cjs/utils/portal/portal.js +2 -1
- package/lib/cjs/utils/portal/portal.js.map +2 -2
- 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 +5 -1
- package/lib/esm/components/dialog/dialog.js.map +2 -2
- package/lib/esm/components/menu/menuButton.d.ts +12 -9
- package/lib/esm/components/menu/menuButton.d.ts.map +1 -1
- package/lib/esm/components/menu/menuButton.js +26 -3
- package/lib/esm/components/menu/menuButton.js.map +2 -2
- package/lib/esm/components/menu/menuItem.d.ts.map +1 -1
- package/lib/esm/components/menu/menuItem.js +1 -0
- package/lib/esm/components/menu/menuItem.js.map +2 -2
- 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 +3 -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.map +1 -1
- package/lib/esm/utils/portal/portal.js +2 -1
- package/lib/esm/utils/portal/portal.js.map +2 -2
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -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 // 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 && <Portal
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAiBA,MAAM,OAAO,OAAO;AAAA;AAAA;AAOb,MAAM,UAAU,WAAW,kBAChC,OACA,KACA;AA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AACd,QAAI,CAAC;AAAQ;AAEb,mCAA+B,OAAmB;AAChD,UAAI,CAAC;AAAkB;AAEvB,YAAM,sBACJ,qBAAqB,MAAM,UAC1B,MAAM,kBAAkB,QAAQ,iBAAiB,SAAS,MAAM;AAEnE,UAAI,CAAC,qBAAqB;AACxB,kBAAU;AACV,eAAO,oBAAoB,aAAa;AAAA;AAAA;AAI5C,WAAO,iBAAiB,aAAa;AAErC,WAAO,MAAM;AACX,aAAO,oBAAoB,aAAa;AAAA;AAAA,KAEzC,CAAC,QAAQ;AAEZ,YAAU,MAAM;AACd,QAAI;AAAa;AAAA,KAChB,CAAC,aAAa;AAGjB,YAAU,MAAM;AACd,QAAI;AAAU,gBAAU;AAAA,KACvB,CAAC;AAGJ,YAAU,MAAM;AACd,QAAI,CAAC;AAAS,gBAAU;AAAA,KACvB,CAAC;AAEJ,QAAM,SAAS,CAAC,OAA8B;AAC5C,qBAAiB;AACjB,iBAAa,UAAU;AAAA;AAGzB,MAAI,CAAC;AAAU,WAAO;AAEtB,MAAI;AAAU,WAAO;AAErB,QAAM,iBAAiB;AAAA,IACrB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,cAAc;AAAA,IACd,cAAc;AAAA,IACd,KAAK;AAAA;AAGP,QAAM,gBAAgB,aAAa,UAAU;AAE7C,QAAM,aACJ,oCAAC,MAAD;AAAA,IACE,WAAQ;AAAA,KACJ,YACA,OAAO,WAAW,SAHxB;AAAA,IAIE,KAAK;AAAA,IACL,OAAO,OAAO,OAAO;AAAA,IACrB;AAAA,MAEA,oCAAC,MAAD;AAAA,IAAM,QAAQ;AAAA,IAAG;AAAA,IAAgB,QAAQ;AAAA,KACtC,SACD,oCAAC,cAAD;AAAA,IAAc,KAAK;AAAA,IAAiB,OAAO,OAAO,OAAO;AAAA;AAK/D,SACE,0DACG,eAEA,UACC,0DACG,
|
|
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 {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;AAAA,IAAG;AAAA,IAAgB,QAAQ;AAAA,KACtC,SACD,oCAAC,cAAD;AAAA,IAAc,KAAK;AAAA,IAAiB,OAAO,OAAO,OAAO;AAAA;AAK/D,SACE,0DACG,eAEA,UACC,0DACG,UACC,oCAAC,QAAD;AAAA,IAAQ,iBAAiB,OAAO,WAAW,WAAW,SAAS;AAAA,KAC5D,aAIJ,CAAC,UAAU;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;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;AAC5C,QAAM,iBAAiB,KAAK,MAAO,YAAW,QAAS,KAAK,IAAI;AAChE,QAAM,mBAAoB,aAAY,kBAAkB;AAExD,SAAO;AAAA,IACL,UAAU,IAAI;AAAA,IACd,YAAY,QAAQ,gBAAgB;AAAA,IACpC,eAAe,IAAI;AAAA,IACnB,WAAW,cAAc,IAAI;AAAA,IAE7B,YAAY;AAAA,MACV,WAAW,QAAQ,IAAI,IAAI;AAAA;AAAA,IAG7B,WAAW;AAAA,MACT,cAAc;AAAA;AAAA,IAGhB,sBAAsB;AAAA,MACpB,QAAQ,mBAAmB,UAAU,IAAI,IAAI,mBAAmB,sBAAqB;AAAA;AAAA,IAGvF,iCAAiC;AAAA,MAC/B,UAAU,QAAQ;AAAA,MAClB,QAAQ;AAAA,QAEN,IAAI;AAAA,QAEJ,mBACI,QAAQ,IAAI,uBAAuB,IAAI,mBAAmB,gBAC1D,IAAI;AAAA,QACR,KAAK;AAAA;AAAA,IAGT,wBAAwB;AAAA,MACtB,UAAU,QAAQ;AAAA,MAClB,QAAQ;AAAA,QAEN,IAAI;AAAA,QAEJ,mBACI,QAAQ,IAAI,iBAAiB,IAAI,mBAAmB,gBACpD,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;IACzB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,KAAK,CAAC,WAAW,GAAG,IAAI,
|
|
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,9 +1,10 @@
|
|
|
1
1
|
import ReactDOM from "react-dom";
|
|
2
2
|
import { usePortal } from "./usePortal";
|
|
3
3
|
function Portal(props) {
|
|
4
|
+
var _a;
|
|
4
5
|
const { children, __unstable_name: name } = props;
|
|
5
6
|
const portal = usePortal();
|
|
6
|
-
const portalElement = name ? portal.elements && portal.elements[name] : portal.element;
|
|
7
|
+
const portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || ((_a = portal.elements) == null ? void 0 : _a.default);
|
|
7
8
|
if (!portalElement) {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
@@ -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 * @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
|
|
5
|
-
"mappings": "AACA;AACA;AAgBO,gBAAgB,OAA8C;
|
|
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
|
}
|