@pega/cosmos-react-core 5.0.0-dev.6.2 → 5.0.0-dev.7.1

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.
@@ -1,9 +1,5 @@
1
1
  import type { ExcludeStrict, WithAttributes, TestIdProp } from '../../types';
2
2
  import type { FlexProps } from '../Flex';
3
- interface BackdropContextValue {
4
- el: HTMLDivElement | null;
5
- }
6
- export declare const BackdropContext: import("react").Context<BackdropContextValue>;
7
3
  export type BackdropProps = WithAttributes<'div', TestIdProp & {
8
4
  /**
9
5
  * Opacity of the Backdrop.
@@ -1 +1 @@
1
- {"version":3,"file":"Backdrop.d.ts","sourceRoot":"","sources":["../../../src/components/Backdrop/Backdrop.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,aAAa,EACb,cAAc,EAEd,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,UAAU,oBAAoB;IAC5B,EAAE,EAAE,cAAc,GAAG,IAAI,CAAC;CAC3B;AAED,eAAO,MAAM,eAAe,+CAE1B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,cAAc,CACxC,KAAK,EACL,UAAU,GAAG;IACX;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC;IACxD;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IACtD;;;OAGG;IACH,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IAChC,oEAAoE;IACpE,oBAAoB,CAAC,EAAE,M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CAAC;AAcF,eAAO,MAAM,cAAc;aAAuD,CAAC,GAAG,CAAC;SAqCtF,CAAC;;;;AAMF,wBA6FE"}
@@ -1,14 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useState, useCallback, useMemo, forwardRef, createContext } from 'react';
2
+ import { useEffect, useState, useCallback, forwardRef } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
4
  import { defaultThemeProp } from '../../theme';
5
5
  import { reflow, withTestIds } from '../../utils';
6
+ import Configuration from '../Configuration';
6
7
  import Flex from '../Flex';
7
8
  import { useConsolidatedRef, useElement, useTestIds } from '../../hooks';
8
9
  import { getBackdropTestIds } from './Backdrop.test-ids';
9
- export const BackdropContext = createContext({
10
- el: null
11
- });
12
10
  const transitionSpeedToTheme = {
13
11
  slow: 2,
14
12
  medium: 1,
@@ -97,7 +95,6 @@ export default withTestIds(forwardRef(function Backdrop({ testId, children, cont
97
95
  setState('open');
98
96
  }
99
97
  }, [state]);
100
- const ctxValue = useMemo(() => ({ el: backdropEl }), [backdropEl]);
101
- return !open && state === 'closed' ? null : (_jsx(BackdropContext.Provider, { value: ctxValue, children: _jsx(StyledBackdrop, { "data-testid": testIds.root, container: { justify: 'center', alignItems: 'center', ...container }, transitionSpeed: transitionSpeed, opacity: state === 'opening' || state === 'open' ? 1 : 0, alpha: alpha, variant: variant, position: position, onTransitionEnd: onTransitionEnd, ref: backdropRef, ...restProps, children: children }) }));
98
+ return !open && state === 'closed' ? null : (_jsx(Configuration, { portalTarget: backdropEl ?? undefined, children: _jsx(StyledBackdrop, { "data-testid": testIds.root, container: { justify: 'center', alignItems: 'center', ...container }, transitionSpeed: transitionSpeed, opacity: state === 'opening' || state === 'open' ? 1 : 0, alpha: alpha, variant: variant, position: position, onTransitionEnd: onTransitionEnd, ref: backdropRef, ...restProps, children: children }) }));
102
99
  }), getBackdropTestIds);
103
100
  //# sourceMappingURL=Backdrop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Backd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AE,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEnE,OAAO,CAAC,IAAI,IAAI,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC1C,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YACvC,KAAC,cAAc,mBACA,OAAO,CAAC,IAAI,EACzB,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EACpE,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACxD,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,GAAG,EAAE,WAAW,KACZ,SAAS,YAEZ,QAAQ,GACM,GACQ,CAC5B,CAAC;AACJ,CAAC,CAAC,EACF,kBAAkB,CACnB,CAAC","sourcesContent":["import { useEffect, useState, useCallback, useMemo, forwardRef, createContext } from 'react';\nimport type { PropsWithoutRef, TransitionEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { reflow, withTestIds } from '../../utils';\nimport type {\n PropsWithDefaults,\n ExcludeStrict,\n WithAttributes,\n RefElement,\n TestIdProp\n} from '../../types';\nimport Flex from '../Flex';\nimport type { FlexProps } from '../Flex';\nimport { useConsolidatedRef, useElement, useTestIds } from '../../hooks';\n\nimport { getBackdropTestIds } from './Backdrop.test-ids';\n\ninterface BackdropContextValue {\n el: HTMLDivElement | null;\n}\n\nexport const BackdropContext = createContext<BackdropContextValue>({\n el: null\n});\n\nexport type BackdropProps = WithAttributes<\n 'div',\n TestIdProp & {\n /**\n * Opacity of the Backdrop.\n * @default 0.4\n */\n alpha?: number;\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 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 }\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(Flex)<BackdropPropsWithDefaults & { opacity: 0 | 1 }>(\n 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);\n\nStyledBackdrop.defaultProps = defaultThemeProp;\n\ntype State = 'closed' | 'opening' | 'open' | 'closing';\n\nexport default withTestIds(\n forwardRef<RefElement<BackdropProps>, PropsWithoutRef<BackdropProps>>(function Backdrop(\n {\n testId,\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 },\n ref\n ) {\n const testIds = useTestIds(testId, getBackdropTestIds);\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 <StyledBackdrop\n data-testid={testIds.root}\n container={{ justify: 'center', alignItems: 'center', ...container }}\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 </StyledBackdrop>\n </BackdropContext.Provider>\n );\n }),\n getBackdropTestIds\n);\n"]}
1
+ {"version":3,"file":"Backdrop.js","sourceRoot":"","sources":["../../../src/components/Backdrop/Backdrop.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAErE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQlD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAgDzD,MAAM,sBAAsB,GAAG;IAC7B,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,CAAC;CACC,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CACxC,KAAK,CAAC,EAAE;IACN,MAAM,EACJ,KAAK,EAAE,EAAE,IAAI,EAAE,EAChB,GAAG,KAAK,CAAC;IACV,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAA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B,QAAQ,CAAC,QAAQ,CAAC,CAAC;SACpB;QACD,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,GAAG,EAAE;YAC1C,sBAAsB;YACtB,mBAAmB,EAAE,EAAE,CAAC;YACxB,QAAQ,CAAC,MAAM,CAAC,CAAC;SAClB;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CAAC,IAAI,IAAI,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC1C,KAAC,aAAa,IAAC,YAAY,EAAE,UAAU,IAAI,SAAS,YAClD,KAAC,cAAc,mBACA,OAAO,CAAC,IAAI,EACzB,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EACpE,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACxD,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,GAAG,EAAE,WAAW,KACZ,SAAS,YAEZ,QAAQ,GACM,GACH,CACjB,CAAC;AACJ,CAAC,CAAC,EACF,kBAAkB,CACnB,CAAC","sourcesContent":["import { useEffect, useState, useCallback, forwardRef } from 'react';\nimport type { PropsWithoutRef, TransitionEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { reflow, withTestIds } from '../../utils';\nimport type {\n PropsWithDefaults,\n ExcludeStrict,\n WithAttributes,\n RefElement,\n TestIdProp\n} from '../../types';\nimport Configuration from '../Configuration';\nimport Flex from '../Flex';\nimport type { FlexProps } from '../Flex';\nimport { useConsolidatedRef, useElement, useTestIds } from '../../hooks';\n\nimport { getBackdropTestIds } from './Backdrop.test-ids';\n\nexport type BackdropProps = WithAttributes<\n 'div',\n TestIdProp & {\n /**\n * Opacity of the Backdrop.\n * @default 0.4\n */\n alpha?: number;\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 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 }\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(Flex)<BackdropPropsWithDefaults & { opacity: 0 | 1 }>(\n 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);\n\nStyledBackdrop.defaultProps = defaultThemeProp;\n\ntype State = 'closed' | 'opening' | 'open' | 'closing';\n\nexport default withTestIds(\n forwardRef<RefElement<BackdropProps>, PropsWithoutRef<BackdropProps>>(function Backdrop(\n {\n testId,\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 },\n ref\n ) {\n const testIds = useTestIds(testId, getBackdropTestIds);\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 return !open && state === 'closed' ? null : (\n <Configuration portalTarget={backdropEl ?? undefined}>\n <StyledBackdrop\n data-testid={testIds.root}\n container={{ justify: 'center', alignItems: 'center', ...container }}\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 </StyledBackdrop>\n </Configuration>\n );\n }),\n getBackdropTestIds\n);\n"]}
@@ -6,12 +6,7 @@ export type StatusProps = WithAttributes<'span', TestIdProp & {
6
6
  /** The content of the Badge, transformed to uppercase. */
7
7
  children: ReactText;
8
8
  }>;
9
- export declare const StyledStatus: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, TestIdProp<undefined> & {
10
- /** Determines the color to render the Badge as. This color is derived from the Theme. */
11
- variant: 'success' | 'urgent' | 'warn' | 'pending' | 'info';
12
- /** The content of the Badge, transformed to uppercase. */
13
- children: ReactText;
14
- } & Omit<import("../../types").Attributes<"span">, "children" | "testId" | "variant">, never>;
9
+ export declare const StyledStatus: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, Pick<StatusProps, "variant">, never>;
15
10
  declare const _default: import("react").ForwardRefExoticComponent<Omit<StatusProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>> & {
16
11
  getTestIds: (testIdProp?: string | undefined) => import("../../types").TestIdsRecord<readonly []>;
17
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Status.d.ts","sourceRoot":"","sources":["../../../src/components/Badges/Status.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,OAAO,CAAC;AAMxD,OAAO,KAAK,EAAc,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM1E,MAAM,MAAM,WAAW,GAAG,cAAc,CACtC,MAAM,EACN,UAAU,GAAG;IACX,yFAAyF;IACzF,OAAO,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAC5D,0DAA0D;IAC1D,QAAQ,EAAE,SAAS,CAAC;CACrB,CACF,CAAC;AACF,eAAO,MAAM,YAAY;IANrB,yFAAyF;aAChF,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM;IAC3D,0DAA0D;cAChD,SAAS;6FAwBrB,CAAC;;;;AAIH,wBAaE"}
1
+ {"version":3,"file":"Status.d.ts","sourceRoot":"","sources":["../../../src/components/Badges/Status.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,OAAO,CAAC;AAMxD,OAAO,KAAK,EAAc,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAO1E,MAAM,MAAM,WAAW,GAAG,cAAc,CACtC,MAAM,EACN,UAAU,GAAG;IACX,yFAAyF;IACzF,OAAO,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAC5D,0DAA0D;IAC1D,QAAQ,EAAE,SAAS,CAAC;CACrB,CACF,CAAC;AAEF,eAAO,MAAM,YAAY,oIAwBvB,CAAC;;;;AAIH,wBAeE"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
4
  import { rgba } from 'polished';
@@ -6,6 +6,7 @@ import { calculateFontSize } from '../../styles';
6
6
  import { defaultThemeProp } from '../../theme';
7
7
  import { tryCatch, withTestIds } from '../../utils';
8
8
  import { useTestIds } from '../../hooks';
9
+ import { StyledVisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText';
9
10
  import { getStatusTestIds } from './Badges.test-ids';
10
11
  export const StyledStatus = styled.span(props => {
11
12
  const { spacing } = props.theme.base;
@@ -22,14 +23,17 @@ export const StyledStatus = styled.span(props => {
22
23
  display: inline-block;
23
24
  font-size: ${fontSize.xxs};
24
25
  font-weight: bold;
25
- line-height: calc(${spacing} * 2.5);
26
- padding: 0 ${spacing};
27
- text-transform: uppercase;
26
+ line-height: 1rem;
27
+ padding-inline: calc(${spacing} / 2);
28
+
29
+ & > :first-child {
30
+ text-transform: uppercase;
31
+ }
28
32
  `;
29
33
  });
30
34
  StyledStatus.defaultProps = defaultThemeProp;
31
35
  export default withTestIds(forwardRef(function Status({ testId, variant = 'info', children, ...restProps }, ref) {
32
36
  const testIds = useTestIds(testId, getStatusTestIds);
33
- return (_jsx(StyledStatus, { "data-testid": testIds.root, ...restProps, variant: variant, ref: ref, children: children }));
37
+ return (_jsxs(StyledStatus, { "data-testid": testIds.root, ...restProps, variant: variant, ref: ref, children: [_jsx("span", { "aria-hidden": true, children: children }), _jsx(StyledVisuallyHiddenText, { children: children })] }));
34
38
  }), getStatusTestIds);
35
39
  //# sourceMappingURL=Status.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../src/components/Badges/Status.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAWrD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAc,KAAK,CAAC,EAAE;IAC3D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ef, ReactText } from 'react';\nimport styled, { css } from 'styled-components';\nimport { rgba } from 'polished';\n\nimport { calculateFontSize } from '../../styles';\nimport { defaultThemeProp } from '../../theme';\nimport type { RefElement, WithAttributes, TestIdProp } from '../../types';\nimport { tryCatch, withTestIds } from '../../utils';\nimport { useTestIds } from '../../hooks';\n\nimport { getStatusTestIds } from './Badges.test-ids';\n\nexport type StatusProps = WithAttributes<\n 'span',\n TestIdProp & {\n /** Determines the color to render the Badge as. This color is derived from the Theme. */\n variant: 'success' | 'urgent' | 'warn' | 'pending' | 'info';\n /** The content of the Badge, transformed to uppercase. */\n children: ReactText;\n }\n>;\nexport const StyledStatus = styled.span<StatusProps>(props => {\n const { spacing } = props.theme.base;\n const borderRadius = props.theme.base['border-radius'];\n const { status } = props.theme.components.badges;\n\n const { background, foreground } = status[props.variant];\n const shadow = tryCatch(() => rgba(foreground, 0.1));\n const fontSize = calculateFontSize(props.theme.base['font-size'], props.theme.base['font-scale']);\n\n return css`\n background-color: ${background};\n border-radius: calc(0.25 * ${borderRadius});\n color: ${foreground};\n box-shadow: inset 0 0 0 0.0625rem ${shadow};\n display: inline-block;\n font-size: ${fontSize.xxs};\n font-weight: bold;\n line-height: calc(${spacing} * 2.5);\n padding: 0 ${spacing};\n text-transform: uppercase;\n `;\n});\n\nStyledStatus.defaultProps = defaultThemeProp;\n\nexport default withTestIds(\n forwardRef<RefElement<StatusProps>, PropsWithoutRef<StatusProps>>(function Status(\n { testId, variant = 'info', children, ...restProps },\n ref\n ) {\n const testIds = useTestIds(testId, getStatusTestIds);\n return (\n <StyledStatus data-testid={testIds.root} {...restProps} variant={variant} ref={ref}>\n {children}\n </StyledStatus>\n );\n }),\n getStatusTestIds\n);\n"]}
1
+ {"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../src/components/Badges/Status.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MA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AY,GAAG,gBAAgB,CAAC;AAE7C,eAAe,WAAW,CACxB,UAAU,CAAwD,SAAS,MAAM,CAC/E,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EACpD,GAAG;IAEH,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAErD,OAAO,CACL,MAAC,YAAY,mBAAc,OAAO,CAAC,IAAI,KAAM,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,aAChF,8CAAmB,QAAQ,GAAQ,EACnC,KAAC,wBAAwB,cAAE,QAAQ,GAA4B,IAClD,CAChB,CAAC;AACJ,CAAC,CAAC,EACF,gBAAgB,CACjB,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef, ReactText } from 'react';\nimport styled, { css } from 'styled-components';\nimport { rgba } from 'polished';\n\nimport { calculateFontSize } from '../../styles';\nimport { defaultThemeProp } from '../../theme';\nimport type { RefElement, WithAttributes, TestIdProp } from '../../types';\nimport { tryCatch, withTestIds } from '../../utils';\nimport { useTestIds } from '../../hooks';\nimport { StyledVisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText';\n\nimport { getStatusTestIds } from './Badges.test-ids';\n\nexport type StatusProps = WithAttributes<\n 'span',\n TestIdProp & {\n /** Determines the color to render the Badge as. This color is derived from the Theme. */\n variant: 'success' | 'urgent' | 'warn' | 'pending' | 'info';\n /** The content of the Badge, transformed to uppercase. */\n children: ReactText;\n }\n>;\n\nexport const StyledStatus = styled.span<Pick<StatusProps, 'variant'>>(props => {\n const { spacing } = props.theme.base;\n const borderRadius = props.theme.base['border-radius'];\n const { status } = props.theme.components.badges;\n\n const { background, foreground } = status[props.variant];\n const shadow = tryCatch(() => rgba(foreground, 0.1));\n const fontSize = calculateFontSize(props.theme.base['font-size'], props.theme.base['font-scale']);\n\n return css`\n background-color: ${background};\n border-radius: calc(0.25 * ${borderRadius});\n color: ${foreground};\n box-shadow: inset 0 0 0 0.0625rem ${shadow};\n display: inline-block;\n font-size: ${fontSize.xxs};\n font-weight: bold;\n line-height: 1rem;\n padding-inline: calc(${spacing} / 2);\n\n & > :first-child {\n text-transform: uppercase;\n }\n `;\n});\n\nStyledStatus.defaultProps = defaultThemeProp;\n\nexport default withTestIds(\n forwardRef<RefElement<StatusProps>, PropsWithoutRef<StatusProps>>(function Status(\n { testId, variant = 'info', children, ...restProps },\n ref\n ) {\n const testIds = useTestIds(testId, getStatusTestIds);\n\n return (\n <StyledStatus data-testid={testIds.root} {...restProps} variant={variant} ref={ref}>\n <span aria-hidden>{children}</span>\n <StyledVisuallyHiddenText>{children}</StyledVisuallyHiddenText>\n </StyledStatus>\n );\n }),\n getStatusTestIds\n);\n"]}
@@ -44,7 +44,7 @@ const baseStyles = (theme) => {
44
44
  `;
45
45
  };
46
46
  export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ variant, icon, loading, compact, theme }) => {
47
- const { base: { spacing, 'border-radius': baseBorderRadius, palette: { 'primary-background': backgroundColor }, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger, 'compact-min': hitAreaCompact }, animation: { speed } }, components: { button: { color, 'secondary-color': buttonSecondaryColor, padding, 'border-radius': borderRadius, 'border-width': borderWidth, touch: { padding: touchPadding } } } } = theme;
47
+ const { base: { spacing, 'border-radius': baseBorderRadius, palette: { 'primary-background': backgroundColor }, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger, 'compact-min': hitAreaCompact }, animation: { speed } }, components: { button: { color, 'secondary-color': secondaryColor, padding, 'border-radius': borderRadius, 'border-width': borderWidth, touch: { padding: touchPadding } } } } = theme;
48
48
  const contrastColor = tryCatch(() => readableColor(color));
49
49
  // Base
50
50
  const base = baseStyles(theme);
@@ -114,15 +114,15 @@ export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ va
114
114
  }
115
115
  `;
116
116
  // Secondary
117
- const backgroundUsable = meetsContrastGuidelines(color, buttonSecondaryColor).AA;
118
- const secondaryColor = backgroundUsable ? buttonSecondaryColor : readableColor(color);
119
- const secondaryHoverBackgroundColor = tryCatch(() => mix(0.85, secondaryColor, color));
120
- const secondaryHoverForegroundColor = readableHue(color, secondaryHoverBackgroundColor ?? 'transparent');
117
+ const backgroundUsable = meetsContrastGuidelines(color, secondaryColor).AA;
118
+ const usableColor = backgroundUsable ? color : readableHue(color, secondaryColor);
119
+ const secondaryHoverBackgroundColor = tryCatch(() => mix(0.85, secondaryColor, usableColor));
120
+ const secondaryHoverForegroundColor = readableHue(usableColor, secondaryHoverBackgroundColor ?? 'transparent');
121
121
  const secondary = css `
122
122
  --button-background-color: ${secondaryColor};
123
- color: ${color};
123
+ color: ${usableColor};
124
124
  background-color: ${secondaryColor};
125
- border-color: ${color};
125
+ border-color: ${usableColor};
126
126
 
127
127
  @media (hover: hover) {
128
128
  &:hover {
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAStD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,QAAQ,EAAE,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,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S,CAAC,OAAO,KAAK,QAAQ,CAAC,aAAa,EAAE;wBAC/D,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;qBAC5B;oBAED,OAAQ,SAAS,CAAC,SAA2C,EAAE,CAAC,CAAC,CAAC,CAAC;gBACrE,CAAC,aAEA,YAAY,IAAI,KAAC,QAAQ,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,QAAQ,GAAG,EAC9D,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAC9B,EAEZ,QAAQ,IAAI,KAAK,IAAI,CACpB,KAAC,OAAO,IAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,EAAC,cAAc,EAAE,KAAK,YAC/E,KAAK,GACE,CACX,IACA,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC","sourcesContent":["import { useRef, useEffect, forwardRef } from 'react';\nimport type {\n FunctionComponent,\n ReactNode,\n PropsWithoutRef,\n Ref,\n MouseEvent,\n MouseEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport type { DefaultTheme } from 'styled-components';\nimport { meetsContrastGuidelines, mix, readableColor } from 'polished';\n\nimport type { BaseProps, ForwardProps, PropsWithDefaults, AsProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { getHoverColors, omitProps, readableHue } from '../../styles';\nimport { useElement, useConsolidatedRef } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledIcon } from '../Icon';\nimport { StyledPopover } from '../Popover';\n\nexport interface ButtonProps extends BaseProps, AsProp {\n /** Text or content for the Button. */\n children: ReactNode;\n /**\n * Determines if the Button will be disabled.\n * @default false\n */\n disabled?: boolean;\n /** A location to navigate to. Passing an href will render an anchor styled as a Button. */\n href?: string;\n /**\n * Controls the styling of the Button.\n * @default 'secondary'\n */\n variant?: 'primary' | 'secondary' | 'simple' | 'link' | 'text';\n /**\n * Controls the behavior of a Button within a Form.\n * @default 'button'\n */\n type?: 'button' | 'reset' | 'submit';\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Button. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: boolean;\n /**\n * Used for a smaller sized button.\n * @default false\n */\n compact?: boolean;\n /** The label text will be used inside a Tooltip. */\n label?: string;\n /** The aria label text will be inserted as the aria-label on the Button. */\n 'aria-label'?: string;\n /**\n * Optionally renders an indeterminate progress indicator in a button.\n * @default false\n */\n loading?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\ntype ButtonPropsWithDefaults = PropsWithDefaults<\n ButtonProps,\n 'variant' | 'type' | 'disabled' | 'icon' | 'loading'\n>;\n\nconst baseStyles = (theme: DefaultTheme) => {\n const {\n base: {\n spacing,\n animation: {\n speed,\n timing: { ease }\n },\n 'disabled-opacity': disabledOpacity\n },\n components: {\n button: { 'focus-shadow': focusShadow }\n }\n } = theme;\n\n return css`\n outline: none;\n text-decoration: none;\n transition-property: background-color, color, box-shadow;\n transition-duration: calc(0.5 * ${speed});\n transition-timing-function: ${ease};\n cursor: pointer;\n\n & + & {\n margin-inline-start: ${spacing};\n }\n\n /* Not able to combine with selector above. Stylis bug? */\n & + ${StyledPopover} + & {\n margin-inline-start: ${spacing};\n }\n\n &:disabled,\n &[disabled] {\n opacity: ${disabledOpacity};\n cursor: not-allowed;\n pointer-events: none;\n }\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${focusShadow};\n }\n `;\n};\n\nexport const StyledButton = styled.button.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({ variant, icon, loading, compact, theme }) => {\n const {\n base: {\n spacing,\n 'border-radius': baseBorderRadius,\n palette: { 'primary-background': backgroundColor },\n 'hit-area': {\n 'mouse-min': hitAreaMouse,\n 'finger-min': hitAreaFinger,\n 'compact-min': hitAreaCompact\n },\n animation: { speed }\n },\n components: {\n button: {\n color,\n 'secondary-color': buttonSecondaryColor,\n padding,\n 'border-radius': borderRadius,\n 'border-width': borderWidth,\n touch: { padding: touchPadding }\n }\n }\n } = theme;\n const contrastColor = tryCatch(() => readableColor(color));\n\n // Base\n const base = baseStyles(theme);\n\n // Non-text base\n const nonTextual = css`\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n border: ${borderWidth} solid transparent;\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n -webkit-user-select: none;\n user-select: none;\n\n ${!icon &&\n css`\n padding: ${padding};\n `}\n\n ${icon &&\n css`\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n > svg {\n display: block;\n }\n `}\n\n ${compact &&\n css`\n min-height: ${hitAreaCompact};\n min-width: ${hitAreaCompact};\n `}\n\n @media (pointer: coarse) {\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n ${!compact &&\n css`\n min-height: ${hitAreaFinger};\n min-width: ${hitAreaFinger};\n `}\n\n ${!icon &&\n css`\n padding: ${touchPadding};\n `}\n }\n `;\n\n // Primary\n const hoverColors = getHoverColors(color);\n const hoverPrimaryColor = hoverColors.background;\n const hoverContrastColor = hoverColors.foreground;\n const primary = css`\n --button-background-color: ${color};\n color: ${contrastColor};\n background-color: ${color};\n\n @media (hover: hover) {\n &:hover {\n background-color: ${hoverPrimaryColor};\n color: ${hoverContrastColor};\n text-decoration: none;\n }\n }\n `;\n\n // Secondary\n const backgroundUsable = meetsContrastGuidelines(color, buttonSecondaryColor).AA;\n const secondaryColor = backgroundUsable ? buttonSecondaryColor : readableColor(color);\n const secondaryHoverBackgroundColor = tryCatch(() => mix(0.85, secondaryColor, color));\n const secondaryHoverForegroundColor = readableHue(\n color,\n secondaryHoverBackgroundColor ?? 'transparent'\n );\n const secondary = css`\n --button-background-color: ${secondaryColor};\n color: ${color};\n background-color: ${secondaryColor};\n border-color: ${color};\n\n @media (hover: hover) {\n &:hover {\n color: ${secondaryHoverForegroundColor};\n background-color: ${secondaryHoverBackgroundColor};\n text-decoration: none;\n border-color: ${secondaryHoverForegroundColor};\n }\n }\n `;\n\n // Simple\n const simple = css`\n --button-background-color: ${icon ? 'transparent' : backgroundColor};\n color: ${icon ? 'currentColor' : color};\n background-color: ${icon ? 'transparent' : backgroundColor};\n\n @media (hover: hover) {\n &:hover {\n ${icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.15;\n }\n `}\n\n ${!icon &&\n css`\n background-color: ${secondaryHoverBackgroundColor};\n color: ${secondaryHoverForegroundColor};\n border-color: ${secondaryHoverForegroundColor};\n text-decoration: none;\n `}\n }\n }\n `;\n\n return css`\n ${base}\n ${nonTextual}\n ${variant === 'primary' && primary}\n ${variant === 'secondary' && secondary}\n ${variant === 'simple' && simple}\n\n ${loading &&\n css`\n ${StyledBackdrop} {\n background-color: var(--button-background-color);\n border-radius: inherit;\n }\n\n ${StyledProgressRing} {\n width: 1em;\n height: 1em;\n\n ${!icon &&\n css`\n margin-inline-end: calc(${spacing} / 2);\n `}\n\n circle:nth-child(2) {\n animation-duration: calc(${speed} * 2);\n }\n }\n `}\n `;\n }\n);\n\nStyledButton.defaultProps = defaultThemeProp;\n\nexport const StyledButtonLink = styled.a.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({ theme, variant }) => {\n const {\n base: {\n palette: { 'foreground-color': textColor }\n },\n components: {\n link: { color: linkColor }\n }\n } = theme;\n\n const base = baseStyles(theme);\n\n const textual = css`\n background-color: transparent;\n display: inline;\n text-align: start;\n border: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n > ${StyledIcon} {\n vertical-align: bottom;\n }\n `;\n\n const link = css`\n color: ${linkColor};\n `;\n\n const text = css`\n color: ${textColor};\n `;\n\n return css`\n ${base}\n ${textual}\n ${variant === 'link' && link}\n ${variant === 'text' && text}\n `;\n }\n);\n\nStyledButtonLink.defaultProps = defaultThemeProp;\n\nconst Button: FunctionComponent<ButtonProps & ForwardProps> = forwardRef(function Button(\n {\n variant = 'secondary',\n type = 'button',\n disabled = false,\n icon = false,\n compact = false,\n href,\n as,\n forwardedAs,\n label,\n 'aria-label': ariaLabel,\n loading = false,\n children,\n ...restProps\n }: PropsWithoutRef<ButtonProps> & ForwardProps,\n ref: Ref<HTMLButtonElement>\n) {\n const [buttonEl, setButtonEl] = useElement();\n const mouseDownEvent = useRef<MouseEvent>();\n const buttonRef = useConsolidatedRef<HTMLButtonElement>(ref, setButtonEl);\n const isTextual = ['link', 'text'].includes(variant);\n const showProgress = loading && !isTextual;\n const StyledComp: React.ElementType = isTextual ? StyledButtonLink : StyledButton;\n\n useEffect(() => {\n return () => {\n mouseDownEvent.current = undefined;\n };\n }, []);\n\n return (\n <>\n <StyledComp\n {...restProps}\n ref={buttonRef}\n as={as || (href ? 'a' : 'button')}\n forwardedAs={forwardedAs || (href ? 'a' : 'button')}\n variant={variant}\n icon={icon}\n compact={compact}\n type={href ? undefined : type}\n href={href}\n disabled={disabled && !href}\n loading={showProgress}\n aria-label={ariaLabel || label}\n onMouseDown={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n (restProps.onMouseDown as MouseEventHandler | undefined)?.(e);\n e.persist();\n mouseDownEvent.current = e;\n }}\n onMouseUp={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n const shouldFocus = mouseDownEvent.current && !mouseDownEvent.current.defaultPrevented;\n mouseDownEvent.current = undefined;\n\n if (shouldFocus && buttonRef.current !== document.activeElement) {\n buttonRef.current?.focus();\n }\n\n return (restProps.onMouseUp as MouseEventHandler | undefined)?.(e);\n }}\n >\n {showProgress && <Progress variant='ring' placement='inline' />}\n {!icon || !showProgress ? children : null}\n </StyledComp>\n\n {buttonEl && label && (\n <Tooltip target={buttonEl} showDelay='none' hideDelay='none' describeTarget={false}>\n {label}\n </Tooltip>\n )}\n </>\n );\n});\n\nexport default Button;\n"]}
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAStD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,QAAQ,EAAE,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkD3C,MAAM,UAAU,GAAG,CAAC,KAAmB,EAAE,EAAE;IACzC,MAAM,EACJ,IAAI,EAAE,EACJ,OAAO,EACP,SAAS,EAAE,EACT,KAAK,EACL,MAAM,EAAE,EAAE,IAAI,EAAE,EACjB,EACD,kBAAkB,EAAE,eAAe,EACpC,EACD,UAAU,EAAE,EACV,MAAM,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,EACxC,EACF,GAAG,KAAK,CAAC;IAE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IAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,EAAC,cAAc,EAAE,KAAK,YAC/E,KAAK,GACE,CACX,IACA,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC","sourcesContent":["import { useRef, useEffect, forwardRef } from 'react';\nimport type {\n FunctionComponent,\n ReactNode,\n PropsWithoutRef,\n Ref,\n MouseEvent,\n MouseEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport type { DefaultTheme } from 'styled-components';\nimport { meetsContrastGuidelines, mix, readableColor } from 'polished';\n\nimport type { BaseProps, ForwardProps, PropsWithDefaults, AsProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { getHoverColors, omitProps, readableHue } from '../../styles';\nimport { useElement, useConsolidatedRef } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledIcon } from '../Icon';\nimport { StyledPopover } from '../Popover';\n\nexport interface ButtonProps extends BaseProps, AsProp {\n /** Text or content for the Button. */\n children: ReactNode;\n /**\n * Determines if the Button will be disabled.\n * @default false\n */\n disabled?: boolean;\n /** A location to navigate to. Passing an href will render an anchor styled as a Button. */\n href?: string;\n /**\n * Controls the styling of the Button.\n * @default 'secondary'\n */\n variant?: 'primary' | 'secondary' | 'simple' | 'link' | 'text';\n /**\n * Controls the behavior of a Button within a Form.\n * @default 'button'\n */\n type?: 'button' | 'reset' | 'submit';\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Button. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: boolean;\n /**\n * Used for a smaller sized button.\n * @default false\n */\n compact?: boolean;\n /** The label text will be used inside a Tooltip. */\n label?: string;\n /** The aria label text will be inserted as the aria-label on the Button. */\n 'aria-label'?: string;\n /**\n * Optionally renders an indeterminate progress indicator in a button.\n * @default false\n */\n loading?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\ntype ButtonPropsWithDefaults = PropsWithDefaults<\n ButtonProps,\n 'variant' | 'type' | 'disabled' | 'icon' | 'loading'\n>;\n\nconst baseStyles = (theme: DefaultTheme) => {\n const {\n base: {\n spacing,\n animation: {\n speed,\n timing: { ease }\n },\n 'disabled-opacity': disabledOpacity\n },\n components: {\n button: { 'focus-shadow': focusShadow }\n }\n } = theme;\n\n return css`\n outline: none;\n text-decoration: none;\n transition-property: background-color, color, box-shadow;\n transition-duration: calc(0.5 * ${speed});\n transition-timing-function: ${ease};\n cursor: pointer;\n\n & + & {\n margin-inline-start: ${spacing};\n }\n\n /* Not able to combine with selector above. Stylis bug? */\n & + ${StyledPopover} + & {\n margin-inline-start: ${spacing};\n }\n\n &:disabled,\n &[disabled] {\n opacity: ${disabledOpacity};\n cursor: not-allowed;\n pointer-events: none;\n }\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${focusShadow};\n }\n `;\n};\n\nexport const StyledButton = styled.button.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({ variant, icon, loading, compact, theme }) => {\n const {\n base: {\n spacing,\n 'border-radius': baseBorderRadius,\n palette: { 'primary-background': backgroundColor },\n 'hit-area': {\n 'mouse-min': hitAreaMouse,\n 'finger-min': hitAreaFinger,\n 'compact-min': hitAreaCompact\n },\n animation: { speed }\n },\n components: {\n button: {\n color,\n 'secondary-color': secondaryColor,\n padding,\n 'border-radius': borderRadius,\n 'border-width': borderWidth,\n touch: { padding: touchPadding }\n }\n }\n } = theme;\n const contrastColor = tryCatch(() => readableColor(color));\n\n // Base\n const base = baseStyles(theme);\n\n // Non-text base\n const nonTextual = css`\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n border: ${borderWidth} solid transparent;\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n -webkit-user-select: none;\n user-select: none;\n\n ${!icon &&\n css`\n padding: ${padding};\n `}\n\n ${icon &&\n css`\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n > svg {\n display: block;\n }\n `}\n\n ${compact &&\n css`\n min-height: ${hitAreaCompact};\n min-width: ${hitAreaCompact};\n `}\n\n @media (pointer: coarse) {\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n ${!compact &&\n css`\n min-height: ${hitAreaFinger};\n min-width: ${hitAreaFinger};\n `}\n\n ${!icon &&\n css`\n padding: ${touchPadding};\n `}\n }\n `;\n\n // Primary\n const hoverColors = getHoverColors(color);\n const hoverPrimaryColor = hoverColors.background;\n const hoverContrastColor = hoverColors.foreground;\n const primary = css`\n --button-background-color: ${color};\n color: ${contrastColor};\n background-color: ${color};\n\n @media (hover: hover) {\n &:hover {\n background-color: ${hoverPrimaryColor};\n color: ${hoverContrastColor};\n text-decoration: none;\n }\n }\n `;\n\n // Secondary\n const backgroundUsable = meetsContrastGuidelines(color, secondaryColor).AA;\n const usableColor = backgroundUsable ? color : readableHue(color, secondaryColor);\n const secondaryHoverBackgroundColor = tryCatch(() => mix(0.85, secondaryColor, usableColor));\n const secondaryHoverForegroundColor = readableHue(\n usableColor,\n secondaryHoverBackgroundColor ?? 'transparent'\n );\n const secondary = css`\n --button-background-color: ${secondaryColor};\n color: ${usableColor};\n background-color: ${secondaryColor};\n border-color: ${usableColor};\n\n @media (hover: hover) {\n &:hover {\n color: ${secondaryHoverForegroundColor};\n background-color: ${secondaryHoverBackgroundColor};\n text-decoration: none;\n border-color: ${secondaryHoverForegroundColor};\n }\n }\n `;\n\n // Simple\n const simple = css`\n --button-background-color: ${icon ? 'transparent' : backgroundColor};\n color: ${icon ? 'currentColor' : color};\n background-color: ${icon ? 'transparent' : backgroundColor};\n\n @media (hover: hover) {\n &:hover {\n ${icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.15;\n }\n `}\n\n ${!icon &&\n css`\n background-color: ${secondaryHoverBackgroundColor};\n color: ${secondaryHoverForegroundColor};\n border-color: ${secondaryHoverForegroundColor};\n text-decoration: none;\n `}\n }\n }\n `;\n\n return css`\n ${base}\n ${nonTextual}\n ${variant === 'primary' && primary}\n ${variant === 'secondary' && secondary}\n ${variant === 'simple' && simple}\n\n ${loading &&\n css`\n ${StyledBackdrop} {\n background-color: var(--button-background-color);\n border-radius: inherit;\n }\n\n ${StyledProgressRing} {\n width: 1em;\n height: 1em;\n\n ${!icon &&\n css`\n margin-inline-end: calc(${spacing} / 2);\n `}\n\n circle:nth-child(2) {\n animation-duration: calc(${speed} * 2);\n }\n }\n `}\n `;\n }\n);\n\nStyledButton.defaultProps = defaultThemeProp;\n\nexport const StyledButtonLink = styled.a.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({ theme, variant }) => {\n const {\n base: {\n palette: { 'foreground-color': textColor }\n },\n components: {\n link: { color: linkColor }\n }\n } = theme;\n\n const base = baseStyles(theme);\n\n const textual = css`\n background-color: transparent;\n display: inline;\n text-align: start;\n border: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n > ${StyledIcon} {\n vertical-align: bottom;\n }\n `;\n\n const link = css`\n color: ${linkColor};\n `;\n\n const text = css`\n color: ${textColor};\n `;\n\n return css`\n ${base}\n ${textual}\n ${variant === 'link' && link}\n ${variant === 'text' && text}\n `;\n }\n);\n\nStyledButtonLink.defaultProps = defaultThemeProp;\n\nconst Button: FunctionComponent<ButtonProps & ForwardProps> = forwardRef(function Button(\n {\n variant = 'secondary',\n type = 'button',\n disabled = false,\n icon = false,\n compact = false,\n href,\n as,\n forwardedAs,\n label,\n 'aria-label': ariaLabel,\n loading = false,\n children,\n ...restProps\n }: PropsWithoutRef<ButtonProps> & ForwardProps,\n ref: Ref<HTMLButtonElement>\n) {\n const [buttonEl, setButtonEl] = useElement();\n const mouseDownEvent = useRef<MouseEvent>();\n const buttonRef = useConsolidatedRef<HTMLButtonElement>(ref, setButtonEl);\n const isTextual = ['link', 'text'].includes(variant);\n const showProgress = loading && !isTextual;\n const StyledComp: React.ElementType = isTextual ? StyledButtonLink : StyledButton;\n\n useEffect(() => {\n return () => {\n mouseDownEvent.current = undefined;\n };\n }, []);\n\n return (\n <>\n <StyledComp\n {...restProps}\n ref={buttonRef}\n as={as || (href ? 'a' : 'button')}\n forwardedAs={forwardedAs || (href ? 'a' : 'button')}\n variant={variant}\n icon={icon}\n compact={compact}\n type={href ? undefined : type}\n href={href}\n disabled={disabled && !href}\n loading={showProgress}\n aria-label={ariaLabel || label}\n onMouseDown={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n (restProps.onMouseDown as MouseEventHandler | undefined)?.(e);\n e.persist();\n mouseDownEvent.current = e;\n }}\n onMouseUp={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n const shouldFocus = mouseDownEvent.current && !mouseDownEvent.current.defaultPrevented;\n mouseDownEvent.current = undefined;\n\n if (shouldFocus && buttonRef.current !== document.activeElement) {\n buttonRef.current?.focus();\n }\n\n return (restProps.onMouseUp as MouseEventHandler | undefined)?.(e);\n }}\n >\n {showProgress && <Progress variant='ring' placement='inline' />}\n {!icon || !showProgress ? children : null}\n </StyledComp>\n\n {buttonEl && label && (\n <Tooltip target={buttonEl} showDelay='none' hideDelay='none' describeTarget={false}>\n {label}\n </Tooltip>\n )}\n </>\n );\n});\n\nexport default Button;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAmB,GAAG,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAA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S,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,IAiPlB,CAAC;AAEH,eAAe,OAAO,CAAC"}
@@ -4,7 +4,6 @@ import { createPortal } from 'react-dom';
4
4
  import { usePopper } from 'react-popper';
5
5
  import { useAfterInitialEffect, useConfiguration, useConsolidatedRef, useElement, useUID } from '../../hooks';
6
6
  import { getRelativeOffset, popoverMap, windowIsAvailable } from '../../utils';
7
- import { BackdropContext } from '../Backdrop/Backdrop';
8
7
  import { PopoverManagerContext } from './PopoverContext';
9
8
  import { StyledPopover, StyledPopoverArrow } from './Popover.styles';
10
9
  import { placeAndContain } from './modifiers';
@@ -15,7 +14,6 @@ const delays = {
15
14
  };
16
15
  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) {
17
16
  const { portalTarget: configurationPortal } = useConfiguration();
18
- const { el: backdropPortal } = useContext(BackdropContext);
19
17
  const { checkActive, setActive, popovers } = useContext(PopoverManagerContext);
20
18
  const [popperEl, setPopperEl] = useElement();
21
19
  const popperRef = useConsolidatedRef(ref, setPopperEl);
@@ -27,7 +25,7 @@ const Popover = forwardRef(function Popover({ show = true, portal = true, target
27
25
  const uid = useUID();
28
26
  const pointerId = useUID();
29
27
  const resolvedTarget = target instanceof Element ? target : target?.contextElement;
30
- const portalTarget = typeof portal === 'boolean' ? backdropPortal ?? configurationPortal : portal;
28
+ const portalTarget = typeof portal === 'boolean' ? configurationPortal : portal;
31
29
  const memoedModifiers = useMemo(() => {
32
30
  const flipEnabled = !!modifiers
33
31
  .slice()
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,OAAO,EACP,QAAQ,EACR,eAAe,EAChB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA6D9C,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,IAAI;CACX,CAAC;AAEF,MAAM,OAAO,GAEc,UAAU,CAAC,SAAS,OAAO,CACpD,EACE,IAAI,GAAG,IAAI,EACX,MAAM,GAAG,IAAI,EACb,MAAM,EACN,SAAS,GAAG,QAAQ,EACpB,QAAQ,GAAG,OAAO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AM,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,YAAY,CAAC,EAClC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KACjC,UAAU,CAAC,MAAM,aAEpB,KAAK,IAAI,KAAC,kBAAkB,IAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,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 useRef,\n useEffect,\n useMemo,\n useState,\n useLayoutEffect\n} from 'react';\nimport type { PropsWithoutRef, Ref, CSSProperties, ReactElement, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper } from 'react-popper';\nimport type { PopperProps } from 'react-popper';\nimport type { VirtualElement } from '@popperjs/core';\nimport type { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\n\nimport type { 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 type { 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
+ {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,OAAO,EACP,QAAQ,EACR,eAAe,EAChB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC,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} from 'react';\nimport type { PropsWithoutRef, Ref, CSSProperties, ReactElement, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper } from 'react-popper';\nimport type { PopperProps } from 'react-popper';\nimport type { VirtualElement } from '@popperjs/core';\nimport type { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\n\nimport type { 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 type { 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 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 { 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' ? 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-core",
3
- "version": "5.0.0-dev.6.2",
3
+ "version": "5.0.0-dev.7.1",
4
4
  "description": "Cosmos is a visual design system and UI component collection. Its goal is to empower application developers in their pursuit to create engaging and rewarding user experiences.",
5
5
  "repository": {
6
6
  "type": "git",