@pega/cosmos-react-core 4.0.0-dev.24.1 → 4.0.0-dev.25.0
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/components/Backdrop/Backdrop.d.ts +4 -0
- package/lib/components/Backdrop/Backdrop.d.ts.map +1 -1
- package/lib/components/Backdrop/Backdrop.js +12 -8
- package/lib/components/Backdrop/Backdrop.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +2 -3
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts +1 -0
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.styles.js +7 -7
- package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -1
- package/lib/components/Popover/Popover.d.ts +1 -1
- package/lib/components/Popover/Popover.d.ts.map +1 -1
- package/lib/components/Popover/Popover.js +25 -4
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/Popover.styles.d.ts +1 -0
- package/lib/components/Popover/Popover.styles.d.ts.map +1 -1
- package/lib/components/Popover/Popover.styles.js +2 -2
- package/lib/components/Popover/Popover.styles.js.map +1 -1
- package/lib/components/SkipLinks/SkipLinks.d.ts.map +1 -1
- package/lib/components/SkipLinks/SkipLinks.js +1 -1
- package/lib/components/SkipLinks/SkipLinks.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib/components/Tooltip/Tooltip.js +2 -3
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/hooks/useEvent.js +5 -5
- package/lib/hooks/useEvent.js.map +1 -1
- package/lib/hooks/useFocusWithin.d.ts +1 -1
- package/lib/hooks/useFocusWithin.d.ts.map +1 -1
- package/lib/hooks/useFocusWithin.js +5 -3
- package/lib/hooks/useFocusWithin.js.map +1 -1
- package/lib/hooks/useOuterEvent.d.ts.map +1 -1
- package/lib/hooks/useOuterEvent.js +10 -4
- package/lib/hooks/useOuterEvent.js.map +1 -1
- package/lib/utils/getAllPopovers.d.ts +4 -0
- package/lib/utils/getAllPopovers.d.ts.map +1 -0
- package/lib/utils/getAllPopovers.js +19 -0
- package/lib/utils/getAllPopovers.js.map +1 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +2 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/normalizeTargets.d.ts +9 -0
- package/lib/utils/normalizeTargets.d.ts.map +1 -0
- package/lib/utils/normalizeTargets.js +17 -0
- package/lib/utils/normalizeTargets.js.map +1 -0
- package/package.json +1 -1
- package/lib/utils/normalizeElements.d.ts +0 -9
- package/lib/utils/normalizeElements.d.ts.map +0 -1
- package/lib/utils/normalizeElements.js +0 -14
- package/lib/utils/normalizeElements.js.map +0 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { FunctionComponent, ReactNode, Ref, MouseEvent } from 'react';
|
|
2
2
|
import { BaseProps, ForwardProps, ExcludeStrict } from '../../types';
|
|
3
3
|
import { FlexProps } from '../Flex';
|
|
4
|
+
interface BackdropContextValue {
|
|
5
|
+
el: HTMLDivElement | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const BackdropContext: import("react").Context<BackdropContextValue>;
|
|
4
8
|
export interface BackdropProps extends BaseProps {
|
|
5
9
|
/**
|
|
6
10
|
* Opacity of the Backdrop.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Backdrop.d.ts","sourceRoot":"","sources":["../../../src/components/Backdrop/Backdrop.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,SAAS,
|
|
1
|
+
{"version":3,"file":"Backdrop.d.ts","sourceRoot":"","sources":["../../../src/components/Backdrop/Backdrop.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,SAAS,EAOT,GAAG,EACH,UAAU,EAEX,MAAM,OAAO,CAAC;AAKf,OAA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B,CAAC,aAAa,GAAG,YAAY,CA0F5D,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState, useCallback, forwardRef } from 'react';
|
|
2
|
+
import { useEffect, useState, useCallback, useMemo, forwardRef, createContext } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { defaultThemeProp } from '../../theme';
|
|
5
5
|
import { reflow } from '../../utils';
|
|
6
6
|
import Flex from '../Flex';
|
|
7
|
-
import { useConsolidatedRef } from '../../hooks';
|
|
7
|
+
import { useConsolidatedRef, useElement } from '../../hooks';
|
|
8
|
+
export const BackdropContext = createContext({
|
|
9
|
+
el: null
|
|
10
|
+
});
|
|
8
11
|
const transitionSpeedToTheme = {
|
|
9
12
|
slow: 2,
|
|
10
13
|
medium: 1,
|
|
@@ -43,10 +46,10 @@ export const StyledBackdrop = styled.div(props => {
|
|
|
43
46
|
`;
|
|
44
47
|
});
|
|
45
48
|
StyledBackdrop.defaultProps = defaultThemeProp;
|
|
46
|
-
const Backdrop = forwardRef(function Backdrop(
|
|
47
|
-
const { children, container, open = false, variant = 'dark', transitionSpeed = 'medium', alpha = 0.6, position = 'fixed', onBeforeTransitionIn, onAfterTransitionIn, onBeforeTransitionOut, onAfterTransitionOut, ...restProps } = props;
|
|
48
|
-
const cRef = useConsolidatedRef(ref);
|
|
49
|
+
const Backdrop = forwardRef(function Backdrop({ children, container, open = false, variant = 'dark', transitionSpeed = 'medium', alpha = 0.6, position = 'fixed', onBeforeTransitionIn, onAfterTransitionIn, onBeforeTransitionOut, onAfterTransitionOut, ...restProps }, ref) {
|
|
49
50
|
const [state, setState] = useState('closed');
|
|
51
|
+
const [backdropEl, setBackdropEl] = useElement();
|
|
52
|
+
const backdropRef = useConsolidatedRef(ref, setBackdropEl);
|
|
50
53
|
const onTransitionEnd = useCallback((e) => {
|
|
51
54
|
if (e.propertyName !== 'opacity' || e.target !== e.currentTarget)
|
|
52
55
|
return;
|
|
@@ -76,9 +79,9 @@ const Backdrop = forwardRef(function Backdrop(props, ref) {
|
|
|
76
79
|
}, [open]);
|
|
77
80
|
// Using a separate effect instead of combined logic above as it seems more intuitive to mentally manage.
|
|
78
81
|
useEffect(() => {
|
|
79
|
-
if (!
|
|
82
|
+
if (!backdropRef.current)
|
|
80
83
|
return;
|
|
81
|
-
const opacity = window.getComputedStyle(
|
|
84
|
+
const opacity = window.getComputedStyle(backdropRef.current).opacity;
|
|
82
85
|
// If the opacity is already at the destination value, sync the state value.
|
|
83
86
|
if (state === 'closing' && opacity === '0') {
|
|
84
87
|
// Since the transition never ran, we have to pretend it did and call the callback.
|
|
@@ -92,7 +95,8 @@ const Backdrop = forwardRef(function Backdrop(props, ref) {
|
|
|
92
95
|
setState('open');
|
|
93
96
|
}
|
|
94
97
|
}, [state]);
|
|
95
|
-
|
|
98
|
+
const ctxValue = useMemo(() => ({ el: backdropEl }), [backdropEl]);
|
|
99
|
+
return !open && state === 'closed' ? null : (_jsx(BackdropContext.Provider, { value: ctxValue, children: _jsx(Flex, { container: { justify: 'center', alignItems: 'center', ...container }, as: StyledBackdrop, transitionSpeed: transitionSpeed, opacity: state === 'opening' || state === 'open' ? 1 : 0, alpha: alpha, variant: variant, position: position, onTransitionEnd: onTransitionEnd, ref: backdropRef, ...restProps, children: children }) }));
|
|
96
100
|
});
|
|
97
101
|
export default Backdrop;
|
|
98
102
|
//# sourceMappingURL=Backdrop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Backdrop.js","sourceRoot":"","sources":["../../../src/components/Backdrop/Backdrop.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EAIX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EA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useEffect,\n useState,\n useCallback,\n forwardRef,\n Ref,\n MouseEvent,\n PropsWithoutRef\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { reflow } from '../../utils';\nimport { BaseProps, PropsWithDefaults, ForwardProps, ExcludeStrict } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport { useConsolidatedRef } from '../../hooks';\n\nexport interface BackdropProps extends BaseProps {\n /**\n * Opacity of the Backdrop.\n * @default 0.4\n */\n alpha?: number;\n /** Any React Node to be rendered on top of the Backdrop component. */\n children?: ReactNode;\n /** Props passed to Flex container. */\n container?: ExcludeStrict<FlexProps['container'], true>;\n /**\n * Toggles visibility of Backdrop.\n * @default false\n */\n open?: boolean;\n /**\n * Determines the color of the Backdrop.\n * @default 'dark'\n */\n variant?: 'dark' | 'light';\n /**\n * Transition speed of Backdrop animation.\n * @default 'medium'\n */\n transitionSpeed?: 'slow' | 'medium' | 'fast' | 'none';\n /**\n * The position of the Backdrop.\n * @default 'fixed'\n */\n position?: 'absolute' | 'fixed';\n /** Accepts a callback function for click event on Backdrop. */\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n /** Accepts a callback that gets invoked before opening Backdrop. */\n onBeforeTransitionIn?: () => void;\n /** Accepts a callback that gets invoked after opening Backdrop. */\n onAfterTransitionIn?: () => void;\n /** Accepts a callback that gets invoked before closing Backdrop. */\n onBeforeTransitionOut?: () => void;\n /** Accepts a callback that gets invoked after closing Backdrop */\n onAfterTransitionOut?: () => void;\n /** Ref for a Backdrop's root div element. */\n ref?: Ref<HTMLDivElement>;\n}\n\ntype BackdropPropsWithDefaults = PropsWithDefaults<\n BackdropProps,\n 'open' | 'transitionSpeed' | 'alpha' | 'position'\n>;\n\nconst transitionSpeedToTheme = {\n slow: 2,\n medium: 1,\n fast: 0.5,\n none: 0\n} as const;\n\nexport const StyledBackdrop = styled.div<BackdropPropsWithDefaults & { opacity: 0 | 1 }>(props => {\n const {\n theme: { base }\n } = props;\n const { opacity, alpha, variant, position } = props;\n const transitionDuration = `max(calc(${transitionSpeedToTheme[props.transitionSpeed]} * ${\n base.animation.speed\n }), 1ms)`;\n\n return css`\n position: ${position};\n z-index: ${position === 'fixed' ? base['z-index'].backdrop : base['z-index'].popover + 1};\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n border-radius: inherit;\n opacity: ${opacity};\n transition-property: opacity;\n transition-timing-function: ${props.theme.base.animation.timing.ease};\n /* stylelint-disable declaration-block-no-duplicate-properties */\n transition-duration: 1ms;\n transition-duration: ${transitionDuration};\n /* stylelint-enable declaration-block-no-duplicate-properties */\n\n ${variant === 'dark' &&\n css`\n background: rgba(0, 0, 0, ${alpha});\n `}\n\n ${variant === 'light' &&\n css`\n background: rgba(255, 255, 255, ${alpha});\n `}\n `;\n});\n\nStyledBackdrop.defaultProps = defaultThemeProp;\n\ntype State = 'closed' | 'opening' | 'open' | 'closing';\n\nconst Backdrop: FunctionComponent<BackdropProps & ForwardProps> = forwardRef(function Backdrop(\n props: PropsWithoutRef<BackdropProps>,\n ref: BackdropProps['ref']\n) {\n const {\n children,\n container,\n open = false,\n variant = 'dark',\n transitionSpeed = 'medium',\n alpha = 0.6,\n position = 'fixed',\n onBeforeTransitionIn,\n onAfterTransitionIn,\n onBeforeTransitionOut,\n onAfterTransitionOut,\n ...restProps\n } = props;\n\n const cRef = useConsolidatedRef(ref);\n\n const [state, setState] = useState<State>('closed');\n\n const onTransitionEnd = useCallback(\n (e: TransitionEvent) => {\n if (e.propertyName !== 'opacity' || e.target !== e.currentTarget) return;\n let nextState: State;\n\n if (state === 'closing') {\n nextState = 'closed';\n onAfterTransitionOut?.();\n } else {\n nextState = 'open';\n onAfterTransitionIn?.();\n }\n\n setState(nextState);\n },\n [state, onAfterTransitionOut, onAfterTransitionIn]\n );\n\n useEffect(() => {\n if (open) {\n if (state === 'closed' || state === 'closing') {\n onBeforeTransitionIn?.();\n reflow();\n setState('opening');\n }\n } else if (state === 'open' || state === 'opening') {\n onBeforeTransitionOut?.();\n setState('closing');\n }\n }, [open]);\n\n // Using a separate effect instead of combined logic above as it seems more intuitive to mentally manage.\n useEffect(() => {\n if (!cRef.current) return;\n const opacity = window.getComputedStyle(cRef.current).opacity;\n // If the opacity is already at the destination value, sync the state value.\n if (state === 'closing' && opacity === '0') {\n // Since the transition never ran, we have to pretend it did and call the callback.\n // TODO: This maybe can be fixed with the animation api\n onAfterTransitionOut?.();\n setState('closed');\n }\n if (state === 'opening' && opacity === '1') {\n // ditto, see above...\n onAfterTransitionIn?.();\n setState('open');\n }\n }, [state]);\n\n return !open && state === 'closed' ? null : (\n <Flex\n container={{ justify: 'center', alignItems: 'center', ...container }}\n as={StyledBackdrop}\n transitionSpeed={transitionSpeed}\n opacity={state === 'opening' || state === 'open' ? 1 : 0}\n alpha={alpha}\n variant={variant}\n position={position}\n onTransitionEnd={onTransitionEnd}\n ref={cRef}\n {...restProps}\n >\n {children}\n </Flex>\n );\n});\n\nexport default Backdrop;\n"]}
|
|
1
|
+
{"version":3,"file":"Backdrop.js","sourceRoot":"","sources":["../../../src/components/Backdrop/Backdrop.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,OAAO,EACP,UAAU,EACV,aAAa,EAId,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,IAAmB,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM7D,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAuB;IACjE,EAAE,EAAE,IAAI;CACT,CAAC,CAAC;AAmDH,MAAM,sBAAsB,GAAG;IAC7B,IAAI,EAAE,CAAC;IACP,MAAM,EA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,\n ReactNode,\n useEffect,\n useState,\n useCallback,\n useMemo,\n forwardRef,\n createContext,\n Ref,\n MouseEvent,\n PropsWithoutRef\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { reflow } from '../../utils';\nimport { BaseProps, PropsWithDefaults, ForwardProps, ExcludeStrict } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport { useConsolidatedRef, useElement } from '../../hooks';\n\ninterface BackdropContextValue {\n el: HTMLDivElement | null;\n}\n\nexport const BackdropContext = createContext<BackdropContextValue>({\n el: null\n});\n\nexport interface BackdropProps extends BaseProps {\n /**\n * Opacity of the Backdrop.\n * @default 0.4\n */\n alpha?: number;\n /** Any React Node to be rendered on top of the Backdrop component. */\n children?: ReactNode;\n /** Props passed to Flex container. */\n container?: ExcludeStrict<FlexProps['container'], true>;\n /**\n * Toggles visibility of Backdrop.\n * @default false\n */\n open?: boolean;\n /**\n * Determines the color of the Backdrop.\n * @default 'dark'\n */\n variant?: 'dark' | 'light';\n /**\n * Transition speed of Backdrop animation.\n * @default 'medium'\n */\n transitionSpeed?: 'slow' | 'medium' | 'fast' | 'none';\n /**\n * The position of the Backdrop.\n * @default 'fixed'\n */\n position?: 'absolute' | 'fixed';\n /** Accepts a callback function for click event on Backdrop. */\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n /** Accepts a callback that gets invoked before opening Backdrop. */\n onBeforeTransitionIn?: () => void;\n /** Accepts a callback that gets invoked after opening Backdrop. */\n onAfterTransitionIn?: () => void;\n /** Accepts a callback that gets invoked before closing Backdrop. */\n onBeforeTransitionOut?: () => void;\n /** Accepts a callback that gets invoked after closing Backdrop */\n onAfterTransitionOut?: () => void;\n /** Ref for a Backdrop's root div element. */\n ref?: Ref<HTMLDivElement>;\n}\n\ntype BackdropPropsWithDefaults = PropsWithDefaults<\n BackdropProps,\n 'open' | 'transitionSpeed' | 'alpha' | 'position'\n>;\n\nconst transitionSpeedToTheme = {\n slow: 2,\n medium: 1,\n fast: 0.5,\n none: 0\n} as const;\n\nexport const StyledBackdrop = styled.div<BackdropPropsWithDefaults & { opacity: 0 | 1 }>(props => {\n const {\n theme: { base }\n } = props;\n const { opacity, alpha, variant, position } = props;\n const transitionDuration = `max(calc(${transitionSpeedToTheme[props.transitionSpeed]} * ${\n base.animation.speed\n }), 1ms)`;\n\n return css`\n position: ${position};\n z-index: ${position === 'fixed' ? base['z-index'].backdrop : base['z-index'].popover + 1};\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n border-radius: inherit;\n opacity: ${opacity};\n transition-property: opacity;\n transition-timing-function: ${props.theme.base.animation.timing.ease};\n /* stylelint-disable declaration-block-no-duplicate-properties */\n transition-duration: 1ms;\n transition-duration: ${transitionDuration};\n /* stylelint-enable declaration-block-no-duplicate-properties */\n\n ${variant === 'dark' &&\n css`\n background: rgba(0, 0, 0, ${alpha});\n `}\n\n ${variant === 'light' &&\n css`\n background: rgba(255, 255, 255, ${alpha});\n `}\n `;\n});\n\nStyledBackdrop.defaultProps = defaultThemeProp;\n\ntype State = 'closed' | 'opening' | 'open' | 'closing';\n\nconst Backdrop: FunctionComponent<BackdropProps & ForwardProps> = forwardRef(function Backdrop(\n {\n children,\n container,\n open = false,\n variant = 'dark',\n transitionSpeed = 'medium',\n alpha = 0.6,\n position = 'fixed',\n onBeforeTransitionIn,\n onAfterTransitionIn,\n onBeforeTransitionOut,\n onAfterTransitionOut,\n ...restProps\n }: PropsWithoutRef<BackdropProps>,\n ref: BackdropProps['ref']\n) {\n const [state, setState] = useState<State>('closed');\n const [backdropEl, setBackdropEl] = useElement<HTMLDivElement>();\n const backdropRef = useConsolidatedRef(ref, setBackdropEl);\n\n const onTransitionEnd = useCallback(\n (e: TransitionEvent) => {\n if (e.propertyName !== 'opacity' || e.target !== e.currentTarget) return;\n let nextState: State;\n\n if (state === 'closing') {\n nextState = 'closed';\n onAfterTransitionOut?.();\n } else {\n nextState = 'open';\n onAfterTransitionIn?.();\n }\n\n setState(nextState);\n },\n [state, onAfterTransitionOut, onAfterTransitionIn]\n );\n\n useEffect(() => {\n if (open) {\n if (state === 'closed' || state === 'closing') {\n onBeforeTransitionIn?.();\n reflow();\n setState('opening');\n }\n } else if (state === 'open' || state === 'opening') {\n onBeforeTransitionOut?.();\n setState('closing');\n }\n }, [open]);\n\n // Using a separate effect instead of combined logic above as it seems more intuitive to mentally manage.\n useEffect(() => {\n if (!backdropRef.current) return;\n const opacity = window.getComputedStyle(backdropRef.current).opacity;\n // If the opacity is already at the destination value, sync the state value.\n if (state === 'closing' && opacity === '0') {\n // Since the transition never ran, we have to pretend it did and call the callback.\n // TODO: This maybe can be fixed with the animation api\n onAfterTransitionOut?.();\n setState('closed');\n }\n if (state === 'opening' && opacity === '1') {\n // ditto, see above...\n onAfterTransitionIn?.();\n setState('open');\n }\n }, [state]);\n\n const ctxValue = useMemo(() => ({ el: backdropEl }), [backdropEl]);\n\n return !open && state === 'closed' ? null : (\n <BackdropContext.Provider value={ctxValue}>\n <Flex\n container={{ justify: 'center', alignItems: 'center', ...container }}\n as={StyledBackdrop}\n transitionSpeed={transitionSpeed}\n opacity={state === 'opening' || state === 'open' ? 1 : 0}\n alpha={alpha}\n variant={variant}\n position={position}\n onTransitionEnd={onTransitionEnd}\n ref={backdropRef}\n {...restProps}\n >\n {children}\n </Flex>\n </BackdropContext.Provider>\n );\n});\n\nexport default Backdrop;\n"]}
|
|
@@ -12,12 +12,11 @@ import * as rowIcon from '../Icon/icons/row.icon';
|
|
|
12
12
|
import * as plusIcon from '../Icon/icons/plus.icon';
|
|
13
13
|
import * as moreIcon from '../Icon/icons/more.icon';
|
|
14
14
|
import { hasProp, withTestIds } from '../../utils';
|
|
15
|
-
import FormDialog from '../Dialog/FormDialog';
|
|
16
15
|
import { formatNumber } from '../Number';
|
|
17
16
|
import MenuButton from '../MenuButton';
|
|
18
17
|
import Avatar from '../Avatar';
|
|
19
18
|
import PresetMenuPopover from './PresetMenuPopover';
|
|
20
|
-
import { StyledViewSelector, StyledSearchForm, StyledListToolbar, StyledHeadingText, StyledCountMeta, StyledContainer, StyledListToolbarContent } from './ListToolbar.styles';
|
|
19
|
+
import { StyledViewSelector, StyledSearchForm, StyledListToolbar, StyledHeadingText, StyledCountMeta, StyledContainer, StyledListToolbarContent, StyledListToolbarDialog } from './ListToolbar.styles';
|
|
21
20
|
import helpers from './helpers';
|
|
22
21
|
import { getListToolbarTestIds } from './ListToolbar.test-ids';
|
|
23
22
|
registerIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);
|
|
@@ -99,7 +98,7 @@ const ListToolbar = forwardRef(function ListToolbar({ testId, name, headingTag =
|
|
|
99
98
|
if (queryOptionProps &&
|
|
100
99
|
hasProp(queryOptionProps, 'renderer') &&
|
|
101
100
|
queryOptionPopoverTarget.current) {
|
|
102
|
-
queryOptionPopover = (_jsx(
|
|
101
|
+
queryOptionPopover = (_jsx(StyledListToolbarDialog, { target: queryOptionPopoverTarget.current, heading: t(currentQueryOptionId), placement: 'bottom-end', onCancel: () => {
|
|
103
102
|
if (queryOptionProps.onCancel() === false)
|
|
104
103
|
return;
|
|
105
104
|
setCurrentQueryOptionId(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListToolbar.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAIV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EAET,MAAM,OAAO,CAAC;AAEf,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,IAAI,EAAE,EAAE,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AS;wCAC/C,GAAG,eAAe;qCACnB,CAAC,CAAC,EACH,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,4BAA4B,GACjC,GACG,CACR,IACI,CACR,IACwB,EAE1B,kBAAkB,EAEnB,KAAC,iBAAiB,IAChB,SAAS,EAAE,4BAA4B,EACvC,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAC1C,IAAI,EAAE,wBAAwB,EAAE,IAAI,EACpC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAC7C,IACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n KeyboardEvent,\n PropsWithoutRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n MouseEvent\n} from 'react';\n\nimport Actions from '../Actions';\nimport Button from '../Button';\nimport { Action, ForwardProps } from '../../types';\nimport {\n useBreakpoint,\n useConfiguration,\n useConsolidatedRef,\n useEscape,\n useI18n,\n useTestIds\n} from '../../hooks';\nimport Flex from '../Flex';\nimport SearchInput from '../SearchInput';\nimport Icon, { registerIcon } from '../Icon';\nimport * as filterIcon from '../Icon/icons/filter.icon';\nimport * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';\nimport * as rowIcon from '../Icon/icons/row.icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport * as moreIcon from '../Icon/icons/more.icon';\nimport { hasProp, withTestIds } from '../../utils';\nimport FormDialog from '../Dialog/FormDialog';\nimport { formatNumber } from '../Number';\nimport MenuButton from '../MenuButton';\nimport Avatar from '../Avatar';\n\nimport PresetMenuPopover, { PresetMenuPopoverProps } from './PresetMenuPopover';\nimport {\n StyledViewSelector,\n StyledSearchForm,\n StyledListToolbar,\n StyledHeadingText,\n StyledCountMeta,\n StyledContainer,\n StyledListToolbarContent\n} from './ListToolbar.styles';\nimport type {\n ListToolbarProps,\n PresetMenuProps,\n QueryOptionDialogProps,\n QueryOptionId,\n ViewProps,\n ViewSelectorProps\n} from './ListToolbar.types';\nimport helpers from './helpers';\nimport { getListToolbarTestIds } from './ListToolbar.test-ids';\n\nregisterIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);\n\nconst CountMeta = ({\n count,\n ...restProps\n}: { count: NonNullable<ListToolbarProps['count']> } & ForwardProps) => {\n const { locale } = useConfiguration();\n const t = useI18n();\n const totalFormattedValue = formatNumber(count.total ?? 0, {\n locale,\n options: {\n useGrouping: true\n }\n });\n return (\n <StyledCountMeta variant='secondary' {...restProps}>\n {count.selected\n ? t(\n 'selected_count',\n [formatNumber(count.selected, { locale, options: { useGrouping: true } })],\n { count: count.selected }\n )\n : count.total !== undefined &&\n t(\n 'results_count',\n [count.totalHasMore ? `${totalFormattedValue}+` : totalFormattedValue],\n {\n count: count.total\n }\n )}\n </StyledCountMeta>\n );\n};\n\nconst generateViewName = (\n view: ViewProps,\n texts: { default: string; appDefault: string },\n options: {\n defaultId?: ViewSelectorProps['defaultId'];\n appDefaultId?: ViewSelectorProps['appDefaultId'];\n }\n) => {\n return `${view.text} ${view.id === options.defaultId ? `(${texts.default})` : ''} ${\n view.id === options.appDefaultId ? `(${texts.appDefault})` : ''\n }`;\n};\n\nconst ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps> = forwardRef(\n function ListToolbar(\n {\n testId,\n name,\n headingTag = 'h3',\n viewSelector,\n formControlProps,\n createNew,\n search,\n count,\n additionalActions,\n filter,\n sort,\n group,\n actions,\n actionsButtonRef,\n ...restProps\n }: PropsWithoutRef<ListToolbarProps>,\n ref: ListToolbarProps['ref']\n ) {\n const t = useI18n();\n const testIds = useTestIds(testId, getListToolbarTestIds);\n\n const isSmallOrAbove = useBreakpoint('sm');\n const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);\n const toolbarContentRef = useRef<HTMLDivElement>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const searchWrapperRef = useRef<HTMLDivElement>(null);\n const searchButtonRef = useRef<HTMLButtonElement>(null);\n const [isSearchOpen, setIsSearchOpen] = useState(!!search?.value);\n\n const onSearchEscape = useCallback(() => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n setTimeout(() => searchButtonRef.current?.focus());\n }, [search?.value]);\n\n useEffect(() => {\n if (search?.value) {\n setIsSearchOpen(true);\n }\n }, [search?.value]);\n\n const [currentQueryOptionId, setCurrentQueryOptionId] = useState<QueryOptionId | null>(null);\n const queryOptionPopoverTarget = useRef<HTMLButtonElement>();\n\n const [actionsQueryOptionPreset, setActionsQueryOptionPreset] =\n useState<Pick<PresetMenuPopoverProps, 'heading' | 'menu'>>();\n const [optionPresetMenuOpen, setOptionPresetMenuOpen] = useState(false);\n\n const createNewButton = useMemo(() => {\n if (!createNew?.onClick) return null;\n const text = createNew.label ?? t('create_new');\n\n return (\n <Button variant='simple' icon label={text} aria-label={text} onClick={createNew.onClick}>\n <Icon name='plus' />\n </Button>\n );\n }, [t, createNew, isSmallOrAbove]);\n\n useEscape(onSearchEscape, searchButtonRef);\n const searchInputWrapper = useMemo(\n () => (\n <div role='dialog' ref={searchWrapperRef}>\n <SearchInput\n {...search}\n onSearchSubmit={(value: string) => {\n search?.onSearchSubmit?.(value);\n onSearchEscape();\n }}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n e.preventDefault();\n }}\n ref={searchInputRef}\n />\n </div>\n ),\n [search, onSearchEscape]\n );\n\n const searchLabel = t('search');\n const searchButton = useMemo(() => {\n return (\n <Button\n as='div'\n role='button'\n variant='simple'\n icon\n label={!isSearchOpen ? searchLabel : undefined}\n aria-label={searchLabel}\n onClick={() => {\n setIsSearchOpen(true);\n setTimeout(() => searchInputRef.current?.focus());\n }}\n onKeyDown={(e: KeyboardEvent<HTMLElement>) => {\n if (e.target !== searchInputRef.current && (e.key === 'Enter' || e.key === ' ')) {\n setIsSearchOpen(true);\n setTimeout(() => {\n searchInputRef.current?.focus();\n searchInputRef.current?.select();\n });\n }\n }}\n tabIndex={0}\n ref={searchButtonRef}\n >\n {isSearchOpen ? searchInputWrapper : <Icon name='search' />}\n </Button>\n );\n }, [searchLabel, setIsSearchOpen, isSearchOpen, searchInputWrapper]);\n\n let queryOptionPopover = null;\n if (currentQueryOptionId) {\n const queryOptionProps = { filter, sort, group }[currentQueryOptionId];\n if (\n queryOptionProps &&\n hasProp(queryOptionProps, 'renderer') &&\n queryOptionPopoverTarget.current\n ) {\n queryOptionPopover = (\n <FormDialog\n target={queryOptionPopoverTarget.current}\n heading={t(currentQueryOptionId)}\n placement='bottom-end'\n onCancel={() => {\n if (queryOptionProps.onCancel() === false) return;\n setCurrentQueryOptionId(null);\n }}\n onSubmit={() => {\n if (queryOptionProps.onSubmit() === false) return;\n setCurrentQueryOptionId(null);\n }}\n >\n <queryOptionProps.renderer />\n </FormDialog>\n );\n }\n }\n\n const getQueryOptionAction = useCallback(\n (\n id: 'sort' | 'group' | 'filter',\n icon: string,\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps\n ) => {\n return {\n text: t(id),\n id,\n icon,\n count: queryOptionProps.count,\n onClick: () => {\n if (hasProp(queryOptionProps, 'renderer')) {\n setCurrentQueryOptionId(id);\n queryOptionPopoverTarget.current = consolidatedActionsButtonRef.current ?? undefined;\n }\n if (hasProp(queryOptionProps, 'items')) {\n setActionsQueryOptionPreset({\n heading: t(id),\n menu: {\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }\n });\n setOptionPresetMenuOpen(true);\n }\n }\n };\n },\n []\n );\n\n const basicModeActions = useMemo(() => {\n let basicActions: Action[] = [];\n if (filter) {\n const filterAction: Action = getQueryOptionAction('filter', 'filter', filter);\n basicActions.push(filterAction);\n }\n if (sort) {\n const sortAction: Action = getQueryOptionAction('sort', 'arrow-up-down', sort);\n basicActions.push(sortAction);\n }\n if (group) {\n const groupAction: Action = getQueryOptionAction('group', 'row', group);\n basicActions.push(groupAction);\n }\n if (actions) {\n basicActions = basicActions.concat(actions);\n }\n\n return basicActions.length ? basicActions : undefined;\n }, [actions, filter, sort, group, getQueryOptionAction]);\n\n let selectedViewName: string | undefined;\n if (viewSelector) {\n selectedViewName = helpers.getSelectedView(viewSelector.views)?.text;\n selectedViewName ??= helpers.getViews(viewSelector.views)[0].text;\n }\n\n const labelText =\n viewSelector && viewSelector.views.length > 1 ? `${name}: ${selectedViewName}` : name;\n\n return (\n <Flex data-testid={testIds.root} container {...restProps} as={StyledListToolbar} ref={ref}>\n <StyledListToolbarContent\n container={{ direction: 'column', gap: 0.5 }}\n ref={toolbarContentRef}\n item={{ grow: 1 }}\n >\n <Flex container={{ alignItems: 'start', justify: 'between', gap: 2 }}>\n <StyledContainer\n container={{\n alignItems: 'baseline',\n gap: 1,\n wrap: 'wrap'\n }}\n >\n <StyledHeadingText\n data-testid={testIds.heading}\n variant={headingTag}\n required={viewSelector?.views?.length && formControlProps?.required}\n >\n {!viewSelector || viewSelector.views.length <= 1 ? (\n labelText\n ) : (\n <MenuButton\n variant='text'\n text={labelText}\n as={StyledViewSelector}\n menu={{\n mode: 'single-select',\n items: viewSelector.views.map(view => {\n if (hasProp(view, 'items')) {\n return {\n id: view.text,\n label: view.text,\n items: view.items.map(groupedView => {\n return {\n ...groupedView,\n primary: generateViewName(\n groupedView,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: groupedView.visual ? (\n <Avatar {...groupedView.visual} />\n ) : undefined\n };\n })\n };\n }\n\n return {\n ...view,\n primary: generateViewName(\n view,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: view.visual ? <Avatar {...view.visual} /> : undefined\n };\n }),\n onItemClick: viewSelector.onViewSelect\n }}\n testId={testIds.viewSelector}\n />\n )}\n </StyledHeadingText>\n {isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </StyledContainer>\n <Flex container={{ alignItems: 'center', gap: 1 }} item={{ shrink: 0 }}>\n {isSmallOrAbove && additionalActions}\n {search && isSmallOrAbove && searchButton}\n {isSmallOrAbove && createNewButton}\n {isSmallOrAbove && basicModeActions && (\n <span>\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n visual: icon ? <Icon name={icon} /> : undefined,\n ...restActionProps\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n </span>\n )}\n {!isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </Flex>\n </Flex>\n {!isSmallOrAbove && (\n <Flex container={{ alignItems: 'start', justify: 'between', gap: 1 }}>\n {additionalActions}\n <Flex\n as={StyledSearchForm}\n container={{ alignItems: 'center', wrap: 'wrap', gap: 1 }}\n item={{ grow: 1 }}\n >\n {search && searchInputWrapper}\n </Flex>\n {createNewButton}\n {basicModeActions && (\n <span>\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n visual: icon ? <Icon name={icon} /> : undefined,\n ...restActionProps\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n </span>\n )}\n </Flex>\n )}\n </StyledListToolbarContent>\n\n {queryOptionPopover}\n\n <PresetMenuPopover\n buttonRef={consolidatedActionsButtonRef}\n heading={actionsQueryOptionPreset?.heading}\n menu={actionsQueryOptionPreset?.menu}\n isOpen={optionPresetMenuOpen}\n onClose={() => setOptionPresetMenuOpen(false)}\n />\n </Flex>\n );\n }\n);\n\nexport default withTestIds(ListToolbar, getListToolbarTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"ListToolbar.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAIV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EAET,MAAM,OA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ACxB,EACN,eAAe,EACf,gBAAgB,IAAI,CACnB,yBACE,KAAC,OAAO,IACN,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;wCAC7D,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC,CAAC,SAAS;wCAC/C,GAAG,eAAe;qCACnB,CAAC,CAAC,EACH,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,4BAA4B,GACjC,GACG,CACR,IACI,CACR,IACwB,EAE1B,kBAAkB,EAEnB,KAAC,iBAAiB,IAChB,SAAS,EAAE,4BAA4B,EACvC,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAC1C,IAAI,EAAE,wBAAwB,EAAE,IAAI,EACpC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAC7C,IACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n KeyboardEvent,\n PropsWithoutRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n MouseEvent\n} from 'react';\n\nimport Actions from '../Actions';\nimport Button from '../Button';\nimport { Action, ForwardProps } from '../../types';\nimport {\n useBreakpoint,\n useConfiguration,\n useConsolidatedRef,\n useEscape,\n useI18n,\n useTestIds\n} from '../../hooks';\nimport Flex from '../Flex';\nimport SearchInput from '../SearchInput';\nimport Icon, { registerIcon } from '../Icon';\nimport * as filterIcon from '../Icon/icons/filter.icon';\nimport * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';\nimport * as rowIcon from '../Icon/icons/row.icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport * as moreIcon from '../Icon/icons/more.icon';\nimport { hasProp, withTestIds } from '../../utils';\nimport { formatNumber } from '../Number';\nimport MenuButton from '../MenuButton';\nimport Avatar from '../Avatar';\n\nimport PresetMenuPopover, { PresetMenuPopoverProps } from './PresetMenuPopover';\nimport {\n StyledViewSelector,\n StyledSearchForm,\n StyledListToolbar,\n StyledHeadingText,\n StyledCountMeta,\n StyledContainer,\n StyledListToolbarContent,\n StyledListToolbarDialog\n} from './ListToolbar.styles';\nimport type {\n ListToolbarProps,\n PresetMenuProps,\n QueryOptionDialogProps,\n QueryOptionId,\n ViewProps,\n ViewSelectorProps\n} from './ListToolbar.types';\nimport helpers from './helpers';\nimport { getListToolbarTestIds } from './ListToolbar.test-ids';\n\nregisterIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);\n\nconst CountMeta = ({\n count,\n ...restProps\n}: { count: NonNullable<ListToolbarProps['count']> } & ForwardProps) => {\n const { locale } = useConfiguration();\n const t = useI18n();\n const totalFormattedValue = formatNumber(count.total ?? 0, {\n locale,\n options: {\n useGrouping: true\n }\n });\n return (\n <StyledCountMeta variant='secondary' {...restProps}>\n {count.selected\n ? t(\n 'selected_count',\n [formatNumber(count.selected, { locale, options: { useGrouping: true } })],\n { count: count.selected }\n )\n : count.total !== undefined &&\n t(\n 'results_count',\n [count.totalHasMore ? `${totalFormattedValue}+` : totalFormattedValue],\n {\n count: count.total\n }\n )}\n </StyledCountMeta>\n );\n};\n\nconst generateViewName = (\n view: ViewProps,\n texts: { default: string; appDefault: string },\n options: {\n defaultId?: ViewSelectorProps['defaultId'];\n appDefaultId?: ViewSelectorProps['appDefaultId'];\n }\n) => {\n return `${view.text} ${view.id === options.defaultId ? `(${texts.default})` : ''} ${\n view.id === options.appDefaultId ? `(${texts.appDefault})` : ''\n }`;\n};\n\nconst ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps> = forwardRef(\n function ListToolbar(\n {\n testId,\n name,\n headingTag = 'h3',\n viewSelector,\n formControlProps,\n createNew,\n search,\n count,\n additionalActions,\n filter,\n sort,\n group,\n actions,\n actionsButtonRef,\n ...restProps\n }: PropsWithoutRef<ListToolbarProps>,\n ref: ListToolbarProps['ref']\n ) {\n const t = useI18n();\n const testIds = useTestIds(testId, getListToolbarTestIds);\n\n const isSmallOrAbove = useBreakpoint('sm');\n const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);\n const toolbarContentRef = useRef<HTMLDivElement>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const searchWrapperRef = useRef<HTMLDivElement>(null);\n const searchButtonRef = useRef<HTMLButtonElement>(null);\n const [isSearchOpen, setIsSearchOpen] = useState(!!search?.value);\n\n const onSearchEscape = useCallback(() => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n setTimeout(() => searchButtonRef.current?.focus());\n }, [search?.value]);\n\n useEffect(() => {\n if (search?.value) {\n setIsSearchOpen(true);\n }\n }, [search?.value]);\n\n const [currentQueryOptionId, setCurrentQueryOptionId] = useState<QueryOptionId | null>(null);\n const queryOptionPopoverTarget = useRef<HTMLButtonElement>();\n\n const [actionsQueryOptionPreset, setActionsQueryOptionPreset] =\n useState<Pick<PresetMenuPopoverProps, 'heading' | 'menu'>>();\n const [optionPresetMenuOpen, setOptionPresetMenuOpen] = useState(false);\n\n const createNewButton = useMemo(() => {\n if (!createNew?.onClick) return null;\n const text = createNew.label ?? t('create_new');\n\n return (\n <Button variant='simple' icon label={text} aria-label={text} onClick={createNew.onClick}>\n <Icon name='plus' />\n </Button>\n );\n }, [t, createNew, isSmallOrAbove]);\n\n useEscape(onSearchEscape, searchButtonRef);\n const searchInputWrapper = useMemo(\n () => (\n <div role='dialog' ref={searchWrapperRef}>\n <SearchInput\n {...search}\n onSearchSubmit={(value: string) => {\n search?.onSearchSubmit?.(value);\n onSearchEscape();\n }}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n e.preventDefault();\n }}\n ref={searchInputRef}\n />\n </div>\n ),\n [search, onSearchEscape]\n );\n\n const searchLabel = t('search');\n const searchButton = useMemo(() => {\n return (\n <Button\n as='div'\n role='button'\n variant='simple'\n icon\n label={!isSearchOpen ? searchLabel : undefined}\n aria-label={searchLabel}\n onClick={() => {\n setIsSearchOpen(true);\n setTimeout(() => searchInputRef.current?.focus());\n }}\n onKeyDown={(e: KeyboardEvent<HTMLElement>) => {\n if (e.target !== searchInputRef.current && (e.key === 'Enter' || e.key === ' ')) {\n setIsSearchOpen(true);\n setTimeout(() => {\n searchInputRef.current?.focus();\n searchInputRef.current?.select();\n });\n }\n }}\n tabIndex={0}\n ref={searchButtonRef}\n >\n {isSearchOpen ? searchInputWrapper : <Icon name='search' />}\n </Button>\n );\n }, [searchLabel, setIsSearchOpen, isSearchOpen, searchInputWrapper]);\n\n let queryOptionPopover = null;\n if (currentQueryOptionId) {\n const queryOptionProps = { filter, sort, group }[currentQueryOptionId];\n if (\n queryOptionProps &&\n hasProp(queryOptionProps, 'renderer') &&\n queryOptionPopoverTarget.current\n ) {\n queryOptionPopover = (\n <StyledListToolbarDialog\n target={queryOptionPopoverTarget.current}\n heading={t(currentQueryOptionId)}\n placement='bottom-end'\n onCancel={() => {\n if (queryOptionProps.onCancel() === false) return;\n setCurrentQueryOptionId(null);\n }}\n onSubmit={() => {\n if (queryOptionProps.onSubmit() === false) return;\n setCurrentQueryOptionId(null);\n }}\n >\n <queryOptionProps.renderer />\n </StyledListToolbarDialog>\n );\n }\n }\n\n const getQueryOptionAction = useCallback(\n (\n id: 'sort' | 'group' | 'filter',\n icon: string,\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps\n ) => {\n return {\n text: t(id),\n id,\n icon,\n count: queryOptionProps.count,\n onClick: () => {\n if (hasProp(queryOptionProps, 'renderer')) {\n setCurrentQueryOptionId(id);\n queryOptionPopoverTarget.current = consolidatedActionsButtonRef.current ?? undefined;\n }\n if (hasProp(queryOptionProps, 'items')) {\n setActionsQueryOptionPreset({\n heading: t(id),\n menu: {\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }\n });\n setOptionPresetMenuOpen(true);\n }\n }\n };\n },\n []\n );\n\n const basicModeActions = useMemo(() => {\n let basicActions: Action[] = [];\n if (filter) {\n const filterAction: Action = getQueryOptionAction('filter', 'filter', filter);\n basicActions.push(filterAction);\n }\n if (sort) {\n const sortAction: Action = getQueryOptionAction('sort', 'arrow-up-down', sort);\n basicActions.push(sortAction);\n }\n if (group) {\n const groupAction: Action = getQueryOptionAction('group', 'row', group);\n basicActions.push(groupAction);\n }\n if (actions) {\n basicActions = basicActions.concat(actions);\n }\n\n return basicActions.length ? basicActions : undefined;\n }, [actions, filter, sort, group, getQueryOptionAction]);\n\n let selectedViewName: string | undefined;\n if (viewSelector) {\n selectedViewName = helpers.getSelectedView(viewSelector.views)?.text;\n selectedViewName ??= helpers.getViews(viewSelector.views)[0].text;\n }\n\n const labelText =\n viewSelector && viewSelector.views.length > 1 ? `${name}: ${selectedViewName}` : name;\n\n return (\n <Flex data-testid={testIds.root} container {...restProps} as={StyledListToolbar} ref={ref}>\n <StyledListToolbarContent\n container={{ direction: 'column', gap: 0.5 }}\n ref={toolbarContentRef}\n item={{ grow: 1 }}\n >\n <Flex container={{ alignItems: 'start', justify: 'between', gap: 2 }}>\n <StyledContainer\n container={{\n alignItems: 'baseline',\n gap: 1,\n wrap: 'wrap'\n }}\n >\n <StyledHeadingText\n data-testid={testIds.heading}\n variant={headingTag}\n required={viewSelector?.views?.length && formControlProps?.required}\n >\n {!viewSelector || viewSelector.views.length <= 1 ? (\n labelText\n ) : (\n <MenuButton\n variant='text'\n text={labelText}\n as={StyledViewSelector}\n menu={{\n mode: 'single-select',\n items: viewSelector.views.map(view => {\n if (hasProp(view, 'items')) {\n return {\n id: view.text,\n label: view.text,\n items: view.items.map(groupedView => {\n return {\n ...groupedView,\n primary: generateViewName(\n groupedView,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: groupedView.visual ? (\n <Avatar {...groupedView.visual} />\n ) : undefined\n };\n })\n };\n }\n\n return {\n ...view,\n primary: generateViewName(\n view,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: view.visual ? <Avatar {...view.visual} /> : undefined\n };\n }),\n onItemClick: viewSelector.onViewSelect\n }}\n testId={testIds.viewSelector}\n />\n )}\n </StyledHeadingText>\n {isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </StyledContainer>\n <Flex container={{ alignItems: 'center', gap: 1 }} item={{ shrink: 0 }}>\n {isSmallOrAbove && additionalActions}\n {search && isSmallOrAbove && searchButton}\n {isSmallOrAbove && createNewButton}\n {isSmallOrAbove && basicModeActions && (\n <span>\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n visual: icon ? <Icon name={icon} /> : undefined,\n ...restActionProps\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n </span>\n )}\n {!isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </Flex>\n </Flex>\n {!isSmallOrAbove && (\n <Flex container={{ alignItems: 'start', justify: 'between', gap: 1 }}>\n {additionalActions}\n <Flex\n as={StyledSearchForm}\n container={{ alignItems: 'center', wrap: 'wrap', gap: 1 }}\n item={{ grow: 1 }}\n >\n {search && searchInputWrapper}\n </Flex>\n {createNewButton}\n {basicModeActions && (\n <span>\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n visual: icon ? <Icon name={icon} /> : undefined,\n ...restActionProps\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n </span>\n )}\n </Flex>\n )}\n </StyledListToolbarContent>\n\n {queryOptionPopover}\n\n <PresetMenuPopover\n buttonRef={consolidatedActionsButtonRef}\n heading={actionsQueryOptionPreset?.heading}\n menu={actionsQueryOptionPreset?.menu}\n isOpen={optionPresetMenuOpen}\n onClose={() => setOptionPresetMenuOpen(false)}\n />\n </Flex>\n );\n }\n);\n\nexport default withTestIds(ListToolbar, getListToolbarTestIds);\n"]}
|
|
@@ -3,6 +3,7 @@ export declare const StyledViewSelector: import("styled-components").StyledCompo
|
|
|
3
3
|
required: boolean;
|
|
4
4
|
}, never>;
|
|
5
5
|
export declare const StyledListToolbar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
6
|
+
export declare const StyledListToolbarDialog: import("styled-components").StyledComponent<import("react").FC<import("../Dialog").FormDialogProps & Pick<import("react").HTMLAttributes<HTMLDivElement>, "hidden" | "color" | "style" | "translate" | "prefix" | "slot" | "title" | "children" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture">>, import("styled-components").DefaultTheme, {}, never>;
|
|
6
7
|
export declare const StyledListToolbarContent: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Flex").FlexProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
7
8
|
export declare const StyledHeadingText: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Text").TextProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {
|
|
8
9
|
required?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListToolbar.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,gBAAgB,yGAK5B,CAAC;AAEF,eAAO,MAAM,kBAAkB;cAA6B,OAAO;SA0BjE,CAAC;AAIH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ListToolbar.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,gBAAgB,yGAK5B,CAAC;AAEF,eAAO,MAAM,kBAAkB;cAA6B,OAAO;SA0BjE,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAI9C,eAAO,MAAM,uBAAuB,mrJAKlC,CAAC;AAIH,eAAO,MAAM,wBAAwB,iMAOnC,CAAC;AAIH,eAAO,MAAM,iBAAiB;;SA0B5B,CAAC;AAIH,eAAO,MAAM,eAAe,iMAW1B,CAAC;AAIH,eAAO,MAAM,eAAe,iMAU3B,CAAC"}
|
|
@@ -5,7 +5,7 @@ import Text, { StyledText } from '../Text';
|
|
|
5
5
|
import { defaultThemeProp } from '../../theme';
|
|
6
6
|
import { calculateFontSize } from '../../styles';
|
|
7
7
|
import { StyledButton } from '../Button';
|
|
8
|
-
import
|
|
8
|
+
import FormDialog from '../Dialog/FormDialog';
|
|
9
9
|
export const StyledSearchForm = styled.div `
|
|
10
10
|
${StyledSearchInput} {
|
|
11
11
|
flex-grow: 1;
|
|
@@ -39,15 +39,15 @@ export const StyledViewSelector = styled.button(({ theme, required }) => {
|
|
|
39
39
|
`;
|
|
40
40
|
});
|
|
41
41
|
StyledViewSelector.defaultProps = defaultThemeProp;
|
|
42
|
-
export const StyledListToolbar = styled.div
|
|
42
|
+
export const StyledListToolbar = styled.div ``;
|
|
43
|
+
StyledListToolbar.defaultProps = defaultThemeProp;
|
|
44
|
+
export const StyledListToolbarDialog = styled(FormDialog)(({ theme }) => {
|
|
43
45
|
return css `
|
|
44
|
-
${
|
|
45
|
-
|
|
46
|
-
max-width: calc(100vw - 4 * ${theme.base.spacing});
|
|
47
|
-
}
|
|
46
|
+
min-width: min(${theme.base['content-width'].lg}, calc(100% - 2rem));
|
|
47
|
+
max-width: calc(100vw - 4 * ${theme.base.spacing});
|
|
48
48
|
`;
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
StyledListToolbarDialog.defaultProps = defaultThemeProp;
|
|
51
51
|
export const StyledListToolbarContent = styled(Flex)(({ theme }) => {
|
|
52
52
|
return css `
|
|
53
53
|
${StyledButton} + ${StyledButton} {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListToolbar.styles.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"ListToolbar.styles.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE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AY,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;IAE3D,OAAO,GAAG,CAAA;mBACO,YAAY;;;qBAGV,aAAa;;GAE/B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEhD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;MAIrC,iBAAiB,KAAK,kBAAkB,IAAI,UAAU;;;;;;CAM3D,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport Flex from '../Flex';\nimport { StyledSearchInput } from '../SearchInput';\nimport Text, { StyledText } from '../Text';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { StyledButton } from '../Button';\nimport FormDialog from '../Dialog/FormDialog';\n\nexport const StyledSearchForm = styled.div`\n ${StyledSearchInput} {\n flex-grow: 1;\n max-width: min(100%, 40ch);\n }\n`;\n\nexport const StyledViewSelector = styled.button<{ required: boolean }>(({ theme, required }) => {\n const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n const { urgent } = theme.base.palette;\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n flex-shrink: initial;\n white-space: initial;\n ${StyledText} {\n font-size: ${fontSizes[theme.components.text.h3['font-size'] as FontSize]};\n font-weight: ${theme.components.text.h3['font-weight']};\n line-height: ${hitAreaMouse};\n word-break: break-word;\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n }\n\n ${StyledText}::after {\n display: ${required ? 'inline-block' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nStyledViewSelector.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbar = styled.div``;\n\nStyledListToolbar.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarDialog = styled(FormDialog)(({ theme }) => {\n return css`\n min-width: min(${theme.base['content-width'].lg}, calc(100% - 2rem));\n max-width: calc(100vw - 4 * ${theme.base.spacing});\n `;\n});\n\nStyledListToolbarDialog.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarContent = styled(Flex)(({ theme }) => {\n return css`\n ${StyledButton} + ${StyledButton} {\n margin-inline-start: 0;\n }\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n `;\n});\n\nStyledListToolbarContent.defaultProps = defaultThemeProp;\n\nexport const StyledHeadingText = styled(Text)<{ required?: boolean }>(({ theme, required }) => {\n const { urgent } = theme.base.palette;\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n position: relative;\n line-height: ${hitAreaMouse};\n word-break: break-word;\n ${required &&\n css`\n padding-inline-end: calc(1.5 * ${theme.base.spacing});\n `}\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n &::after {\n display: ${required ? 'inline' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n position: absolute;\n inset-inline-end: 0;\n inset-block-start: 0;\n }\n `;\n});\n\nStyledHeadingText.defaultProps = defaultThemeProp;\n\nexport const StyledCountMeta = styled(Text)(({ theme }) => {\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n line-height: ${hitAreaMouse};\n\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n `;\n});\n\nStyledCountMeta.defaultProps = defaultThemeProp;\n\nexport const StyledContainer = styled(Flex)`\n @media (pointer: coarse) {\n overflow: hidden;\n\n ${StyledHeadingText}, ${StyledViewSelector} ${StyledText} {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n`;\n"]}
|
|
@@ -14,7 +14,7 @@ export interface PopoverProps<Modifiers extends string = string> extends BasePro
|
|
|
14
14
|
show?: boolean;
|
|
15
15
|
/**
|
|
16
16
|
* If true, the Popover will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).
|
|
17
|
-
* @default
|
|
17
|
+
* @default true
|
|
18
18
|
*/
|
|
19
19
|
portal?: boolean | ConfigurationProps['portalTarget'];
|
|
20
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,GAAG,EAEH,YAAY,EAEZ,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAa,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAStD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,GAAG,EAEH,YAAY,EAEZ,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAa,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAStD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAOtD,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAC9C,MAAM,WAAW,YAAY,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,SAAS;IAChF,2IAA2I;IAC3I,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACtD;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;IAC9C;;;OAGG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC;IAChD;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yGAAyG;IACzG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,kCAAkC;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,uCAAuC;IACvC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAQD,QAAA,MAAM,OAAO,EAAE,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,EAC/C,KAAK,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,YAAY,KAC1C,YAAY,GAAG,IAkPlB,CAAC;AAEH,eAAe,OAAO,CAAC"}
|
|
@@ -3,7 +3,8 @@ import { forwardRef, useContext, useRef, useEffect, useMemo, useState, useLayout
|
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { usePopper } from 'react-popper';
|
|
5
5
|
import { useAfterInitialEffect, useConfiguration, useConsolidatedRef, useElement, useUID } from '../../hooks';
|
|
6
|
-
import { getRelativeOffset, windowIsAvailable } from '../../utils';
|
|
6
|
+
import { getRelativeOffset, popoverMap, windowIsAvailable } from '../../utils';
|
|
7
|
+
import { BackdropContext } from '../Backdrop/Backdrop';
|
|
7
8
|
import { PopoverManagerContext } from './PopoverContext';
|
|
8
9
|
import { StyledPopover, StyledPopoverArrow } from './Popover.styles';
|
|
9
10
|
import { placeAndContain } from './modifiers';
|
|
@@ -12,8 +13,9 @@ const delays = {
|
|
|
12
13
|
short: 500,
|
|
13
14
|
long: 1000
|
|
14
15
|
};
|
|
15
|
-
const Popover = forwardRef(function Popover({ show = true, portal =
|
|
16
|
+
const Popover = forwardRef(function Popover({ show = true, portal = true, target, placement = 'bottom', strategy = 'fixed', style, modifiers = [], arrow = false, groupId, showDelay = 'none', hideDelay = 'none', hideOnTargetHidden = false, children, onHide, ...restProps }, ref) {
|
|
16
17
|
const { portalTarget: configurationPortal } = useConfiguration();
|
|
18
|
+
const { el: backdropPortal } = useContext(BackdropContext);
|
|
17
19
|
const { checkActive, setActive, popovers } = useContext(PopoverManagerContext);
|
|
18
20
|
const [popperEl, setPopperEl] = useElement();
|
|
19
21
|
const popperRef = useConsolidatedRef(ref, setPopperEl);
|
|
@@ -23,8 +25,9 @@ const Popover = forwardRef(function Popover({ show = true, portal = false, targe
|
|
|
23
25
|
const [showPopover, setShowPopover] = useState(show);
|
|
24
26
|
const timeout = useRef();
|
|
25
27
|
const uid = useUID();
|
|
28
|
+
const pointerId = useUID();
|
|
26
29
|
const resolvedTarget = target instanceof Element ? target : target?.contextElement;
|
|
27
|
-
const portalTarget = typeof portal === 'boolean' ? configurationPortal : portal;
|
|
30
|
+
const portalTarget = typeof portal === 'boolean' ? backdropPortal ?? configurationPortal : portal;
|
|
28
31
|
const memoedModifiers = useMemo(() => {
|
|
29
32
|
const flipEnabled = !!modifiers
|
|
30
33
|
.slice()
|
|
@@ -170,7 +173,25 @@ const Popover = forwardRef(function Popover({ show = true, portal = false, targe
|
|
|
170
173
|
setShowPopover(false);
|
|
171
174
|
}
|
|
172
175
|
}, [groupId ? popovers[groupId] : undefined]);
|
|
173
|
-
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (!portal || !resolvedTarget)
|
|
178
|
+
return;
|
|
179
|
+
if (!popoverMap.has(resolvedTarget)) {
|
|
180
|
+
popoverMap.set(resolvedTarget, new Set());
|
|
181
|
+
}
|
|
182
|
+
resolvedTarget.toggleAttribute('data-popover-target', true);
|
|
183
|
+
popoverMap.get(resolvedTarget).add(pointerId);
|
|
184
|
+
return () => {
|
|
185
|
+
if (!popoverMap.has(resolvedTarget))
|
|
186
|
+
return;
|
|
187
|
+
popoverMap.get(resolvedTarget).delete(pointerId);
|
|
188
|
+
if (popoverMap.get(resolvedTarget).size === 0) {
|
|
189
|
+
popoverMap.delete(resolvedTarget);
|
|
190
|
+
resolvedTarget.removeAttribute('data-popover-target');
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}, [portal, resolvedTarget, pointerId]);
|
|
194
|
+
const content = (_jsxs(StyledPopover, { ...restProps, "data-popover-id": pointerId, portal: !!(portal && portalTarget), offset: offset, ref: popperRef, style: { ...style, ...styles.popper }, ...attributes.popper, children: [arrow && _jsx(StyledPopoverArrow, { ref: arrowRef, style: { ...styles.arrow } }), children] }));
|
|
174
195
|
if (!target || !showPopover || (groupId && !checkActive(uid, groupId)))
|
|
175
196
|
return null;
|
|
176
197
|
return portal && portalTarget ? createPortal(content, portalTarget) : content;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAKV,MAAM,EAEN,SAAS,EACT,OAAO,EACP,QAAQ,EACR,eAAe,EAChB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAKtD,OAAO,EACL,qB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AAO,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpF,OAAO,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChF,CAAC,CAAC,CAAC;AAEH,eAAe,OAAO,CAAC","sourcesContent":["import {\n forwardRef,\n useContext,\n PropsWithoutRef,\n Ref,\n CSSProperties,\n ReactElement,\n useRef,\n ReactNode,\n useEffect,\n useMemo,\n useState,\n useLayoutEffect\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper, PopperProps } from 'react-popper';\nimport { VirtualElement } from '@popperjs/core';\nimport { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport {\n useAfterInitialEffect,\n useConfiguration,\n useConsolidatedRef,\n useElement,\n useUID\n} from '../../hooks';\nimport { getRelativeOffset, windowIsAvailable } from '../../utils';\nimport { ConfigurationProps } from '../Configuration';\n\nimport { PopoverManagerContext } from './PopoverContext';\nimport { StyledPopover, StyledPopoverArrow } from './Popover.styles';\nimport { placeAndContain } from './modifiers';\n\nexport type Delay = 'none' | 'short' | 'long';\nexport interface PopoverProps<Modifiers extends string = string> extends BaseProps {\n /** The DOM element or [virtual element](https://popper.js.org/docs/v2/virtual-elements) that the Popover is positioned in reference to. */\n target: Element | VirtualElement | null;\n /**\n * If true, the Popover will be visible.\n * @default true\n */\n show?: boolean;\n /**\n * If true, the Popover will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default false\n */\n portal?: boolean | ConfigurationProps['portalTarget'];\n /**\n * Delay on showing the Popover.\n * @default 'none'\n */\n showDelay?: Delay;\n /**\n * Delay on hiding the Popover.\n * @default 'none'\n */\n hideDelay?: Delay;\n /**\n * [React Popper Placement](https://popper.js.org/react-popper/v2/render-props/#placement)\n * @default 'bottom'\n */\n placement?: PopperProps<Modifiers>['placement'];\n /**\n * [React Popper Strategy](https://popper.js.org/react-popper/v2/render-props/#strategy)\n * @default 'absolute'\n */\n strategy?: PopperProps<Modifiers>['strategy'];\n /**\n * [React Popper Modifiers](https://popper.js.org/react-popper/v2/render-props/#modifiers)\n * @default []\n */\n modifiers?: PopperProps<Modifiers>['modifiers'];\n /**\n * If true, an arrow will visually identify from which element the Popover is rendered.\n * @default false\n */\n arrow?: boolean;\n /** The group that the Popover belongs to. Popovers in the same group will be closed when others open. */\n groupId?: string;\n /**\n * If true, the Popover will be visibly hidden when its target leaves the viewport.\n * @default false\n */\n hideOnTargetHidden?: boolean;\n /** Callback that runs when the popover is hidden */\n onHide?: () => void;\n /** The content of the Popover. */\n children: ReactNode;\n /** The ref of the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst delays = {\n none: 0,\n short: 500,\n long: 1000\n};\n\nconst Popover: <Modifiers extends string = string>(\n props: PopoverProps<Modifiers> & ForwardProps\n) => ReactElement | null = forwardRef(function Popover(\n {\n show = true,\n portal = false,\n target,\n placement = 'bottom',\n strategy = 'fixed',\n style,\n modifiers = [],\n arrow = false,\n groupId,\n showDelay = 'none',\n hideDelay = 'none',\n hideOnTargetHidden = false,\n children,\n onHide,\n ...restProps\n }: PropsWithoutRef<PopoverProps> & { style?: CSSProperties },\n ref: PopoverProps['ref']\n) {\n const { portalTarget: configurationPortal } = useConfiguration();\n const { checkActive, setActive, popovers } = useContext(PopoverManagerContext);\n const [popperEl, setPopperEl] = useElement<HTMLDivElement>();\n const popperRef = useConsolidatedRef<HTMLDivElement>(ref, setPopperEl);\n const arrowRef = useRef<HTMLDivElement>(null);\n const forceUpdateRef = useRef<() => void>();\n const initialOffset = useRef<Pick<DOMRect, 'x' | 'y'> | null>(null);\n const [showPopover, setShowPopover] = useState(show);\n const timeout = useRef<number>();\n const uid = useUID();\n\n const resolvedTarget = target instanceof Element ? target : target?.contextElement;\n const portalTarget = typeof portal === 'boolean' ? configurationPortal : portal;\n\n const memoedModifiers = useMemo(() => {\n const flipEnabled = !!modifiers\n .slice()\n .reverse()\n .find(modifier => modifier.name === 'flip' && modifier.enabled !== undefined)?.enabled;\n\n return [\n {\n name: 'computeStyles',\n options: {\n gpuAcceleration: false\n }\n },\n {\n name: 'offset',\n options: {\n offset: [0, arrow ? 5.5 : 2]\n }\n },\n { name: 'hide', enabled: hideOnTargetHidden },\n { name: 'arrow', enabled: arrow, options: { element: arrowRef.current } },\n {\n name: 'preventOverflow',\n options: {\n tether: !modifiers.find(m => m.name === 'sameWidth'),\n padding: 16\n }\n },\n {\n ...placeAndContain,\n enabled: !flipEnabled\n },\n ...modifiers\n ];\n }, [arrow, hideOnTargetHidden, modifiers]);\n\n const offset = useMemo(() => {\n const offsetModifier = [...memoedModifiers]\n .reverse()\n .find(m => m.name === 'offset' && m.enabled !== false) as OffsetModifier | undefined;\n return Array.isArray(offsetModifier?.options?.offset)\n ? offsetModifier?.options?.offset[1] ?? 0\n : 0;\n }, [memoedModifiers]);\n\n const { styles, attributes, forceUpdate } = usePopper(target, popperEl, {\n placement,\n strategy,\n modifiers: memoedModifiers\n });\n\n if (forceUpdate) forceUpdateRef.current = forceUpdate;\n\n // Setter-less useState to avoid re-running these constructors on every render with useRef.\n const [ac] = useState(() => new AbortController());\n const [observedSet] = useState(() => new WeakSet<Element>());\n const [ro] = useState(\n () =>\n new ResizeObserver(entries => {\n let updateQueued = false;\n\n for (const { target: resizeTarget } of entries) {\n // Ignore the first ResizeObserver event for each element since ResizeObserver always fires once when calling .observe().\n if (!observedSet.has(resizeTarget)) {\n observedSet.add(resizeTarget);\n } else if (!updateQueued) {\n updateQueued = true;\n\n if (!ac.signal.aborted) {\n forceUpdateRef.current?.();\n }\n }\n }\n })\n );\n\n useEffect(() => {\n return () => {\n ac.abort();\n ro.disconnect();\n };\n }, []);\n\n useEffect(() => {\n if (!popperEl) return;\n\n ro.observe(popperEl);\n\n return () => {\n ro.unobserve(popperEl);\n };\n }, [popperEl]);\n\n useEffect(() => {\n if (!resolvedTarget) return;\n\n ro.observe(resolvedTarget);\n\n return () => {\n ro.unobserve(resolvedTarget);\n };\n }, [resolvedTarget]);\n\n useLayoutEffect(() => {\n if (resolvedTarget) {\n initialOffset.current = getRelativeOffset(resolvedTarget, document.documentElement);\n } else {\n initialOffset.current = null;\n }\n }, [resolvedTarget]);\n\n useEffect(() => {\n if (!showPopover || !resolvedTarget) return;\n\n let rafId: ReturnType<typeof requestAnimationFrame>;\n\n const checkCoords = () => {\n if (resolvedTarget && initialOffset.current) {\n const newOffset = getRelativeOffset(resolvedTarget, document.documentElement);\n\n if (initialOffset.current.x !== newOffset.x || initialOffset.current.y !== newOffset.y) {\n initialOffset.current = newOffset;\n forceUpdateRef.current?.();\n } else {\n rafId = requestAnimationFrame(checkCoords);\n }\n }\n };\n\n rafId = requestAnimationFrame(checkCoords);\n\n return () => {\n cancelAnimationFrame(rafId);\n };\n }, [showPopover, resolvedTarget]);\n\n useEffect(() => {\n if (groupId && show) setActive(uid, groupId);\n\n if (windowIsAvailable) {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n setShowPopover(show);\n }, delays[show ? showDelay : hideDelay]);\n } else {\n setShowPopover(show);\n }\n }, [show]);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n useAfterInitialEffect(() => {\n if (!showPopover) {\n onHide?.();\n }\n }, [showPopover]);\n\n useEffect(() => {\n if (groupId && popovers[groupId] && popovers[groupId] !== uid) {\n setShowPopover(false);\n }\n }, [groupId ? popovers[groupId] : undefined]);\n\n const content = (\n <StyledPopover\n {...restProps}\n offset={offset}\n ref={popperRef}\n style={{ ...style, ...styles.popper }}\n {...attributes.popper}\n >\n {arrow && <StyledPopoverArrow ref={arrowRef} style={{ ...styles.arrow }} />}\n {children}\n </StyledPopover>\n );\n\n if (!target || !showPopover || (groupId && !checkActive(uid, groupId))) return null;\n\n return portal && portalTarget ? createPortal(content, portalTarget) : content;\n});\n\nexport default Popover;\n"]}
|
|
1
|
+
{"version":3,"file":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K,EAAE,GAAI,EAC1E,QAAQ,IACK,CACjB,CAAC;IAEF,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpF,OAAO,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChF,CAAC,CAAC,CAAC;AAEH,eAAe,OAAO,CAAC","sourcesContent":["import {\n forwardRef,\n useContext,\n PropsWithoutRef,\n Ref,\n CSSProperties,\n ReactElement,\n useRef,\n ReactNode,\n useEffect,\n useMemo,\n useState,\n useLayoutEffect\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper, PopperProps } from 'react-popper';\nimport { VirtualElement } from '@popperjs/core';\nimport { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport {\n useAfterInitialEffect,\n useConfiguration,\n useConsolidatedRef,\n useElement,\n useUID\n} from '../../hooks';\nimport { getRelativeOffset, popoverMap, windowIsAvailable } from '../../utils';\nimport { ConfigurationProps } from '../Configuration';\nimport { BackdropContext } from '../Backdrop/Backdrop';\n\nimport { PopoverManagerContext } from './PopoverContext';\nimport { StyledPopover, StyledPopoverArrow } from './Popover.styles';\nimport { placeAndContain } from './modifiers';\n\nexport type Delay = 'none' | 'short' | 'long';\nexport interface PopoverProps<Modifiers extends string = string> extends BaseProps {\n /** The DOM element or [virtual element](https://popper.js.org/docs/v2/virtual-elements) that the Popover is positioned in reference to. */\n target: Element | VirtualElement | null;\n /**\n * If true, the Popover will be visible.\n * @default true\n */\n show?: boolean;\n /**\n * If true, the Popover will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default true\n */\n portal?: boolean | ConfigurationProps['portalTarget'];\n /**\n * Delay on showing the Popover.\n * @default 'none'\n */\n showDelay?: Delay;\n /**\n * Delay on hiding the Popover.\n * @default 'none'\n */\n hideDelay?: Delay;\n /**\n * [React Popper Placement](https://popper.js.org/react-popper/v2/render-props/#placement)\n * @default 'bottom'\n */\n placement?: PopperProps<Modifiers>['placement'];\n /**\n * [React Popper Strategy](https://popper.js.org/react-popper/v2/render-props/#strategy)\n * @default 'absolute'\n */\n strategy?: PopperProps<Modifiers>['strategy'];\n /**\n * [React Popper Modifiers](https://popper.js.org/react-popper/v2/render-props/#modifiers)\n * @default []\n */\n modifiers?: PopperProps<Modifiers>['modifiers'];\n /**\n * If true, an arrow will visually identify from which element the Popover is rendered.\n * @default false\n */\n arrow?: boolean;\n /** The group that the Popover belongs to. Popovers in the same group will be closed when others open. */\n groupId?: string;\n /**\n * If true, the Popover will be visibly hidden when its target leaves the viewport.\n * @default false\n */\n hideOnTargetHidden?: boolean;\n /** Callback that runs when the popover is hidden */\n onHide?: () => void;\n /** The content of the Popover. */\n children: ReactNode;\n /** The ref of the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst delays = {\n none: 0,\n short: 500,\n long: 1000\n};\n\nconst Popover: <Modifiers extends string = string>(\n props: PopoverProps<Modifiers> & ForwardProps\n) => ReactElement | null = forwardRef(function Popover(\n {\n show = true,\n portal = true,\n target,\n placement = 'bottom',\n strategy = 'fixed',\n style,\n modifiers = [],\n arrow = false,\n groupId,\n showDelay = 'none',\n hideDelay = 'none',\n hideOnTargetHidden = false,\n children,\n onHide,\n ...restProps\n }: PropsWithoutRef<PopoverProps> & { style?: CSSProperties },\n ref: PopoverProps['ref']\n) {\n const { portalTarget: configurationPortal } = useConfiguration();\n const { el: backdropPortal } = useContext(BackdropContext);\n const { checkActive, setActive, popovers } = useContext(PopoverManagerContext);\n const [popperEl, setPopperEl] = useElement<HTMLDivElement>();\n const popperRef = useConsolidatedRef<HTMLDivElement>(ref, setPopperEl);\n const arrowRef = useRef<HTMLDivElement>(null);\n const forceUpdateRef = useRef<() => void>();\n const initialOffset = useRef<Pick<DOMRect, 'x' | 'y'> | null>(null);\n const [showPopover, setShowPopover] = useState(show);\n const timeout = useRef<number>();\n const uid = useUID();\n const pointerId = useUID();\n\n const resolvedTarget = target instanceof Element ? target : target?.contextElement;\n const portalTarget = typeof portal === 'boolean' ? backdropPortal ?? configurationPortal : portal;\n\n const memoedModifiers = useMemo(() => {\n const flipEnabled = !!modifiers\n .slice()\n .reverse()\n .find(modifier => modifier.name === 'flip' && modifier.enabled !== undefined)?.enabled;\n\n return [\n {\n name: 'computeStyles',\n options: {\n gpuAcceleration: false\n }\n },\n {\n name: 'offset',\n options: {\n offset: [0, arrow ? 5.5 : 2]\n }\n },\n { name: 'hide', enabled: hideOnTargetHidden },\n { name: 'arrow', enabled: arrow, options: { element: arrowRef.current } },\n {\n name: 'preventOverflow',\n options: {\n tether: !modifiers.find(m => m.name === 'sameWidth'),\n padding: 16\n }\n },\n {\n ...placeAndContain,\n enabled: !flipEnabled\n },\n ...modifiers\n ];\n }, [arrow, hideOnTargetHidden, modifiers]);\n\n const offset = useMemo(() => {\n const offsetModifier = [...memoedModifiers]\n .reverse()\n .find(m => m.name === 'offset' && m.enabled !== false) as OffsetModifier | undefined;\n return Array.isArray(offsetModifier?.options?.offset)\n ? offsetModifier?.options?.offset[1] ?? 0\n : 0;\n }, [memoedModifiers]);\n\n const { styles, attributes, forceUpdate } = usePopper(target, popperEl, {\n placement,\n strategy,\n modifiers: memoedModifiers\n });\n\n if (forceUpdate) forceUpdateRef.current = forceUpdate;\n\n // Setter-less useState to avoid re-running these constructors on every render with useRef.\n const [ac] = useState(() => new AbortController());\n const [observedSet] = useState(() => new WeakSet<Element>());\n const [ro] = useState(\n () =>\n new ResizeObserver(entries => {\n let updateQueued = false;\n\n for (const { target: resizeTarget } of entries) {\n // Ignore the first ResizeObserver event for each element since ResizeObserver always fires once when calling .observe().\n if (!observedSet.has(resizeTarget)) {\n observedSet.add(resizeTarget);\n } else if (!updateQueued) {\n updateQueued = true;\n\n if (!ac.signal.aborted) {\n forceUpdateRef.current?.();\n }\n }\n }\n })\n );\n\n useEffect(() => {\n return () => {\n ac.abort();\n ro.disconnect();\n };\n }, []);\n\n useEffect(() => {\n if (!popperEl) return;\n\n ro.observe(popperEl);\n\n return () => {\n ro.unobserve(popperEl);\n };\n }, [popperEl]);\n\n useEffect(() => {\n if (!resolvedTarget) return;\n\n ro.observe(resolvedTarget);\n\n return () => {\n ro.unobserve(resolvedTarget);\n };\n }, [resolvedTarget]);\n\n useLayoutEffect(() => {\n if (resolvedTarget) {\n initialOffset.current = getRelativeOffset(resolvedTarget, document.documentElement);\n } else {\n initialOffset.current = null;\n }\n }, [resolvedTarget]);\n\n useEffect(() => {\n if (!showPopover || !resolvedTarget) return;\n\n let rafId: ReturnType<typeof requestAnimationFrame>;\n\n const checkCoords = () => {\n if (resolvedTarget && initialOffset.current) {\n const newOffset = getRelativeOffset(resolvedTarget, document.documentElement);\n\n if (initialOffset.current.x !== newOffset.x || initialOffset.current.y !== newOffset.y) {\n initialOffset.current = newOffset;\n forceUpdateRef.current?.();\n } else {\n rafId = requestAnimationFrame(checkCoords);\n }\n }\n };\n\n rafId = requestAnimationFrame(checkCoords);\n\n return () => {\n cancelAnimationFrame(rafId);\n };\n }, [showPopover, resolvedTarget]);\n\n useEffect(() => {\n if (groupId && show) setActive(uid, groupId);\n\n if (windowIsAvailable) {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n setShowPopover(show);\n }, delays[show ? showDelay : hideDelay]);\n } else {\n setShowPopover(show);\n }\n }, [show]);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n useAfterInitialEffect(() => {\n if (!showPopover) {\n onHide?.();\n }\n }, [showPopover]);\n\n useEffect(() => {\n if (groupId && popovers[groupId] && popovers[groupId] !== uid) {\n setShowPopover(false);\n }\n }, [groupId ? popovers[groupId] : undefined]);\n\n useEffect(() => {\n if (!portal || !resolvedTarget) return;\n\n if (!popoverMap.has(resolvedTarget)) {\n popoverMap.set(resolvedTarget, new Set());\n }\n\n resolvedTarget.toggleAttribute('data-popover-target', true);\n\n popoverMap.get(resolvedTarget)!.add(pointerId);\n\n return () => {\n if (!popoverMap.has(resolvedTarget)) return;\n\n popoverMap.get(resolvedTarget)!.delete(pointerId);\n\n if (popoverMap.get(resolvedTarget)!.size === 0) {\n popoverMap.delete(resolvedTarget);\n resolvedTarget.removeAttribute('data-popover-target');\n }\n };\n }, [portal, resolvedTarget, pointerId]);\n\n const content = (\n <StyledPopover\n {...restProps}\n data-popover-id={pointerId}\n portal={!!(portal && portalTarget)}\n offset={offset}\n ref={popperRef}\n style={{ ...style, ...styles.popper }}\n {...attributes.popper}\n >\n {arrow && <StyledPopoverArrow ref={arrowRef} style={{ ...styles.arrow }} />}\n {children}\n </StyledPopover>\n );\n\n if (!target || !showPopover || (groupId && !checkActive(uid, groupId))) return null;\n\n return portal && portalTarget ? createPortal(content, portalTarget) : content;\n});\n\nexport default Popover;\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const StyledPopoverArrow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
2
|
export declare const StyledPopover: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
3
3
|
offset?: number | undefined;
|
|
4
|
+
portal?: boolean | undefined;
|
|
4
5
|
}, never>;
|
|
5
6
|
//# sourceMappingURL=Popover.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,yGAW9B,CAAC;AAIF,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"Popover.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,yGAW9B,CAAC;AAIF,eAAO,MAAM,aAAa;;;SA6GzB,CAAC"}
|
|
@@ -13,14 +13,14 @@ export const StyledPopoverArrow = styled.div `
|
|
|
13
13
|
}
|
|
14
14
|
`;
|
|
15
15
|
StyledPopoverArrow.defaultProps = defaultThemeProp;
|
|
16
|
-
export const StyledPopover = styled.div(({ theme: { base: { 'border-radius': borderRadius, 'z-index': { popover:
|
|
16
|
+
export const StyledPopover = styled.div(({ theme: { base: { 'border-radius': borderRadius, 'z-index': { popover: popoverZIndex, backdrop: backdropZIndex }, shadow: { high } }, components: { card: { background }, 'form-control': { 'border-radius': formControlBorderRadius } } }, portal, offset }) => {
|
|
17
17
|
return css `
|
|
18
18
|
/*
|
|
19
19
|
Margin should never be used with Popper.
|
|
20
20
|
https://popper.js.org/docs/v2/migration-guide/#4-remove-all-css-margins
|
|
21
21
|
*/
|
|
22
22
|
margin: 0 !important;
|
|
23
|
-
z-index: ${
|
|
23
|
+
z-index: ${portal ? backdropZIndex - 1 : popoverZIndex};
|
|
24
24
|
background-color: ${background};
|
|
25
25
|
border-radius: calc(${formControlBorderRadius} * ${borderRadius});
|
|
26
26
|
box-shadow: ${high};
|