@cloudscape-design/components 3.0.1193 → 3.0.1194

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.
@@ -7,7 +7,7 @@ import InternalAlert from '../alert/internal';
7
7
  import InternalButton from '../button/internal';
8
8
  import { useInternalI18n } from '../i18n/context';
9
9
  import { getBaseProps } from '../internal/base-component';
10
- import { refreshPage } from './utils';
10
+ import { canUseRefresh, refreshPage } from './utils';
11
11
  import styles from './styles.css.js';
12
12
  import testUtilStyles from './test-classes/styles.css.js';
13
13
  export function ErrorBoundaryFallback({ i18nStrings = {}, renderFallback, ...props }) {
@@ -18,8 +18,8 @@ export function ErrorBoundaryFallback({ i18nStrings = {}, renderFallback, ...pro
18
18
  React.createElement(DefaultHeaderContent, { i18nStrings: i18nStrings }))),
19
19
  description: (React.createElement("div", { className: clsx(styles.description, testUtilStyles.description) },
20
20
  React.createElement(DefaultDescriptionContent, { i18nStrings: i18nStrings }))),
21
- action: (React.createElement("div", { className: clsx(styles.action, testUtilStyles.action) },
22
- React.createElement(DefaultActionContent, { i18nStrings: i18nStrings }))),
21
+ action: canUseRefresh() ? (React.createElement("div", { className: clsx(styles.action, testUtilStyles.action) },
22
+ React.createElement(DefaultActionContent, { i18nStrings: i18nStrings }))) : null,
23
23
  };
24
24
  return (React.createElement("div", { ...baseProps, className: clsx(baseProps.className, testUtilStyles.fallback) }, (_a = renderFallback === null || renderFallback === void 0 ? void 0 : renderFallback(defaultSlots)) !== null && _a !== void 0 ? _a : (React.createElement(InternalAlert, { type: "error", header: defaultSlots.header, action: defaultSlots.action }, defaultSlots.description))));
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fallback.js","sourceRoot":"","sources":["../../../src/error-boundary/fallback.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,iBAAiB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,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,6BAA6B,EAAE,UAAU,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAE/G,kHAAkH;IAClH,2EAA2E;IAC3E,OAAO,CACL,0CACG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,CAAC,IAAG,KAAK,CAAkB,CAAC,CAAC,CAAC,CAAC,OAAO,CAC9G,CACJ,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,EAAE,WAAW,EAAoD;IAC7F,MAAM,IAAI,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC;IAC/C,OAAO,CACL,oBAAC,cAAc,IAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,CAAC,gBAAgB,CAAC,IACjG,IAAI,CAAC,+BAA+B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC,CACvD,CAClB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport clsx from 'clsx';\nimport IntlMessageFormat from 'intl-messageformat';\n\nimport InternalAlert from '../alert/internal';\nimport InternalButton from '../button/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport { ErrorBoundaryProps } from './interfaces';\nimport { refreshPage } from './utils';\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport function ErrorBoundaryFallback({\n i18nStrings = {},\n renderFallback,\n ...props\n}: Pick<ErrorBoundaryProps, 'renderFallback' | 'i18nStrings'>) {\n const baseProps = getBaseProps(props);\n const defaultSlots = {\n header: (\n <div className={clsx(styles.header, testUtilStyles.header)}>\n <DefaultHeaderContent i18nStrings={i18nStrings} />\n </div>\n ),\n description: (\n <div className={clsx(styles.description, testUtilStyles.description)}>\n <DefaultDescriptionContent i18nStrings={i18nStrings} />\n </div>\n ),\n action: (\n <div className={clsx(styles.action, testUtilStyles.action)}>\n <DefaultActionContent i18nStrings={i18nStrings} />\n </div>\n ),\n };\n return (\n <div {...baseProps} className={clsx(baseProps.className, testUtilStyles.fallback)}>\n {renderFallback?.(defaultSlots) ?? (\n <InternalAlert type=\"error\" header={defaultSlots.header} action={defaultSlots.action}>\n {defaultSlots.description}\n </InternalAlert>\n )}\n </div>\n );\n}\n\nfunction DefaultHeaderContent({ i18nStrings }: { i18nStrings: ErrorBoundaryProps.I18nStrings }) {\n const i18n = useInternalI18n('error-boundary');\n return <>{i18n('i18nStrings.headerText', i18nStrings?.headerText)}</>;\n}\n\nfunction DefaultDescriptionContent({\n i18nStrings: { descriptionText, components: { Feedback } = {} } = {},\n}: {\n i18nStrings: ErrorBoundaryProps.I18nStrings;\n}) {\n const i18n = useInternalI18n('error-boundary');\n\n // Dependencies for the intl-format function, where the pseudo-tags are declared as functions from parsed chunks.\n const formatArgs = Feedback\n ? {\n hasFeedback: true,\n Feedback: (chunks: React.ReactNode[]) => (\n <span className={testUtilStyles['feedback-action']}>\n <Feedback>{chunks[0] ?? ''}</Feedback>\n </span>\n ),\n }\n : { hasFeedback: false, Feedback: () => <></> };\n\n // This ensures that the description string provided via i18nStrings also supports the <Feedback> injection,\n // because the i18n() helper propagates the second argument as is, without applying intl-format to it.\n // We wrap the format with try-catch to avoid intl errors caused by incorrectly referenced components.\n function safeFormat(descriptionText?: string) {\n try {\n return descriptionText ? new IntlMessageFormat(descriptionText).format(formatArgs) : undefined;\n } catch {\n return descriptionText;\n }\n }\n const message = i18n('i18nStrings.descriptionText', safeFormat(descriptionText), format => format(formatArgs));\n\n // When the description includes <Feedback>, then the translated message is represented as an array of strings and\n // React elements that require keys when rendering to avoid React warnings.\n return (\n <>\n {Array.isArray(message) ? message.map((chunk, i) => <React.Fragment key={i}>{chunk}</React.Fragment>) : message}\n </>\n );\n}\n\nfunction DefaultActionContent({ i18nStrings }: { i18nStrings?: ErrorBoundaryProps.I18nStrings }) {\n const i18n = useInternalI18n('error-boundary');\n return (\n <InternalButton iconName=\"refresh\" onClick={refreshPage} className={testUtilStyles['refresh-action']}>\n {i18n('i18nStrings.refreshActionText', i18nStrings?.refreshActionText)}\n </InternalButton>\n );\n}\n"]}
1
+ {"version":3,"file":"fallback.js","sourceRoot":"","sources":["../../../src/error-boundary/fallback.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAEnD,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAE1D,MAAM,UAAU,qBAAqB,CAAC,EACpC,WAAW,GAAG,EAAE,EAChB,cAAc,EACd,GAAG,KAAK,EACmD;;IAC3D,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG;QACnB,MAAM,EAAE,CACN,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC;YACxD,oBAAC,oBAAoB,IAAC,WAAW,EAAE,WAAW,GAAI,CAC9C,C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,EAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,CAAC,gBAAgB,CAAC,IACjG,IAAI,CAAC,+BAA+B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC,CACvD,CAClB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport clsx from 'clsx';\nimport IntlMessageFormat from 'intl-messageformat';\n\nimport InternalAlert from '../alert/internal';\nimport InternalButton from '../button/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport { ErrorBoundaryProps } from './interfaces';\nimport { canUseRefresh, refreshPage } from './utils';\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport function ErrorBoundaryFallback({\n i18nStrings = {},\n renderFallback,\n ...props\n}: Pick<ErrorBoundaryProps, 'renderFallback' | 'i18nStrings'>) {\n const baseProps = getBaseProps(props);\n const defaultSlots = {\n header: (\n <div className={clsx(styles.header, testUtilStyles.header)}>\n <DefaultHeaderContent i18nStrings={i18nStrings} />\n </div>\n ),\n description: (\n <div className={clsx(styles.description, testUtilStyles.description)}>\n <DefaultDescriptionContent i18nStrings={i18nStrings} />\n </div>\n ),\n action: canUseRefresh() ? (\n <div className={clsx(styles.action, testUtilStyles.action)}>\n <DefaultActionContent i18nStrings={i18nStrings} />\n </div>\n ) : null,\n };\n return (\n <div {...baseProps} className={clsx(baseProps.className, testUtilStyles.fallback)}>\n {renderFallback?.(defaultSlots) ?? (\n <InternalAlert type=\"error\" header={defaultSlots.header} action={defaultSlots.action}>\n {defaultSlots.description}\n </InternalAlert>\n )}\n </div>\n );\n}\n\nfunction DefaultHeaderContent({ i18nStrings }: { i18nStrings: ErrorBoundaryProps.I18nStrings }) {\n const i18n = useInternalI18n('error-boundary');\n return <>{i18n('i18nStrings.headerText', i18nStrings?.headerText)}</>;\n}\n\nfunction DefaultDescriptionContent({\n i18nStrings: { descriptionText, components: { Feedback } = {} } = {},\n}: {\n i18nStrings: ErrorBoundaryProps.I18nStrings;\n}) {\n const i18n = useInternalI18n('error-boundary');\n\n // Dependencies for the intl-format function, where the pseudo-tags are declared as functions from parsed chunks.\n const formatArgs = Feedback\n ? {\n hasFeedback: true,\n Feedback: (chunks: React.ReactNode[]) => (\n <span className={testUtilStyles['feedback-action']}>\n <Feedback>{chunks[0] ?? ''}</Feedback>\n </span>\n ),\n }\n : { hasFeedback: false, Feedback: () => <></> };\n\n // This ensures that the description string provided via i18nStrings also supports the <Feedback> injection,\n // because the i18n() helper propagates the second argument as is, without applying intl-format to it.\n // We wrap the format with try-catch to avoid intl errors caused by incorrectly referenced components.\n function safeFormat(descriptionText?: string) {\n try {\n return descriptionText ? new IntlMessageFormat(descriptionText).format(formatArgs) : undefined;\n } catch {\n return descriptionText;\n }\n }\n const message = i18n('i18nStrings.descriptionText', safeFormat(descriptionText), format => format(formatArgs));\n\n // When the description includes <Feedback>, then the translated message is represented as an array of strings and\n // React elements that require keys when rendering to avoid React warnings.\n return (\n <>\n {Array.isArray(message) ? message.map((chunk, i) => <React.Fragment key={i}>{chunk}</React.Fragment>) : message}\n </>\n );\n}\n\nfunction DefaultActionContent({ i18nStrings }: { i18nStrings?: ErrorBoundaryProps.I18nStrings }) {\n const i18n = useInternalI18n('error-boundary');\n return (\n <InternalButton iconName=\"refresh\" onClick={refreshPage} className={testUtilStyles['refresh-action']}>\n {i18n('i18nStrings.refreshActionText', i18nStrings?.refreshActionText)}\n </InternalButton>\n );\n}\n"]}
@@ -1 +1,2 @@
1
+ export declare function canUseRefresh(): boolean;
1
2
  export declare function refreshPage(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/error-boundary/utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,SAE1B"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/error-boundary/utils.ts"],"names":[],"mappings":"AAKA,wBAAgB,aAAa,IAAI,OAAO,CAQvC;AAED,wBAAgB,WAAW,IAAI,IAAI,CAMlC"}
@@ -1,7 +1,28 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- /* istanbul ignore next */
3
+ // The default refresh action reloads the top window to avoid iframe lifecycle getting out of sync with the parent page.
4
+ // This is not possible from cross-origin iframes, in which case the default refresh action must be hidden.
5
+ export function canUseRefresh() {
6
+ try {
7
+ // In cross-origin iframes, accessing top.location can throw a SecurityError.
8
+ void getTopWindow().location.href;
9
+ return true;
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }
4
15
  export function refreshPage() {
5
- window.location.reload();
16
+ try {
17
+ getTopWindow().location.reload();
18
+ }
19
+ catch {
20
+ // noop
21
+ }
22
+ }
23
+ // In browsers, window.top is always defined, but it is treated as optional by our current DOM types.
24
+ function getTopWindow() {
25
+ var _a;
26
+ return (_a = window.top) !== null && _a !== void 0 ? _a : window;
6
27
  }
7
28
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/error-boundary/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,0BAA0B;AAC1B,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n/* istanbul ignore next */\nexport function refreshPage() {\n window.location.reload();\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/error-boundary/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,wHAAwH;AACxH,2GAA2G;AAC3G,MAAM,UAAU,aAAa;IAC3B,IAAI,CAAC;QACH,6EAA6E;QAC7E,KAAK,YAAY,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC;QACH,YAAY,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;IACT,CAAC;AACH,CAAC;AAED,qGAAqG;AACrG,SAAS,YAAY;;IACnB,OAAO,MAAA,MAAM,CAAC,GAAG,mCAAI,MAAM,CAAC;AAC9B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n// The default refresh action reloads the top window to avoid iframe lifecycle getting out of sync with the parent page.\n// This is not possible from cross-origin iframes, in which case the default refresh action must be hidden.\nexport function canUseRefresh(): boolean {\n try {\n // In cross-origin iframes, accessing top.location can throw a SecurityError.\n void getTopWindow().location.href;\n return true;\n } catch {\n return false;\n }\n}\n\nexport function refreshPage(): void {\n try {\n getTopWindow().location.reload();\n } catch {\n // noop\n }\n}\n\n// In browsers, window.top is always defined, but it is treated as optional by our current DOM types.\nfunction getTopWindow(): Window {\n return window.top ?? window;\n}\n"]}
@@ -2034,5 +2034,5 @@ body {
2034
2034
  }
2035
2035
  }
2036
2036
  :root {
2037
- --awsui-version-info-ed206118: true;
2037
+ --awsui-version-info-83dc7058: true;
2038
2038
  }
@@ -38,7 +38,7 @@ function ChartPopover({ position = 'right', size = 'medium', fixedWidth = false,
38
38
  }, [container, onDismiss]);
39
39
  // In chart popovers, dismiss button is present when they are pinned, so both values are equivalent.
40
40
  const isPinned = dismissButton;
41
- return (React.createElement("div", { ...baseProps, className: clsx(popoverStyles.root, styles.root, baseProps.className), ref: popoverRef, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseDown: onMouseDown, onBlur: onBlur,
41
+ return (React.createElement("div", { ...baseProps, role: !dismissButton ? 'tooltip' : undefined, className: clsx(popoverStyles.root, styles.root, baseProps.className), ref: popoverRef, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseDown: onMouseDown, onBlur: onBlur,
42
42
  // The tabIndex makes it so that clicking inside popover assigns this element as blur target.
43
43
  // That is necessary in charts to ensure the blur target is within the chart and no cleanup is needed.
44
44
  tabIndex: -1 },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/chart-popover/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,WAAW,MAAM,8BAA8B,CAAC;AA0CvD,eAAe,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AAE9C,SAAS,YAAY,CACnB,EACE,QAAQ,GAAG,OAAO,EAClB,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,KAAK,EAClB,aAAa,GAAG,KAAK,EACrB,gBAAgB,EAEhB,QAAQ,EACR,MAAM,EAEN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,mBAAmB,EAEnB,YAAY,EACZ,YAAY,EACZ,MAAM,EAEN,GAAG,SAAS,EACM,EAC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AM,CAAO,CACtE,CACG,CACf,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport PopoverBody from '../../../popover/body';\nimport PopoverContainer from '../../../popover/container';\nimport { PopoverProps } from '../../../popover/interfaces';\nimport { getBaseProps } from '../../base-component';\n\nimport popoverStyles from '../../../popover/styles.css.js';\nimport styles from './styles.css.js';\nimport testClasses from './test-classes/styles.css.js';\n\nexport interface ChartPopoverProps extends PopoverProps {\n /** Title of the popover */\n title?: React.ReactNode;\n\n /** References the element the container is positioned against. */\n trackRef?: React.RefObject<HTMLElement | SVGElement>;\n getTrack?: () => null | HTMLElement | SVGElement;\n /**\n Used to update the container position in case track or track position changes:\n \n const trackRef = useRef<Element>(null)\n return (<>\n <Track style={getPosition(selectedItemId)} ref={trackRef} />\n <PopoverContainer trackRef={trackRef} trackKey={selectedItemId} .../>\n </>)\n */\n trackKey?: string | number;\n minVisibleBlockSize?: number;\n\n /** Optional container element that prevents any clicks in there from dismissing the popover */\n container: Element | null;\n\n /** Event that is fired when the popover is dismissed */\n onDismiss: (outsideClick?: boolean) => void;\n\n /** Fired when the pointer enters the hoverable area around the popover */\n onMouseEnter?: (event: React.MouseEvent) => void;\n\n /** Fired when the pointer leaves the hoverable area around the popover */\n onMouseLeave?: (event: React.MouseEvent) => void;\n\n onBlur?: (event: React.FocusEvent) => void;\n\n /** Popover content */\n children?: React.ReactNode;\n\n /** Popover footer */\n footer?: React.ReactNode;\n}\n\nexport default React.forwardRef(ChartPopover);\n\nfunction ChartPopover(\n {\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n dismissButton = false,\n dismissAriaLabel,\n\n children,\n footer,\n\n title,\n trackRef,\n getTrack,\n trackKey,\n onDismiss,\n container,\n minVisibleBlockSize,\n\n onMouseEnter,\n onMouseLeave,\n onBlur,\n\n ...restProps\n }: ChartPopoverProps,\n ref: React.Ref<HTMLElement>\n) {\n const baseProps = getBaseProps(restProps);\n const popoverObjectRef = useRef<HTMLDivElement | null>(null);\n const popoverRef = useMergeRefs(popoverObjectRef, ref);\n\n const clickFrameId = useRef<number | null>(null);\n const onMouseDown = () => {\n // Indicate there was a click inside popover recently.\n clickFrameId.current = requestAnimationFrame(() => (clickFrameId.current = null));\n };\n\n useEffect(() => {\n if (popoverObjectRef.current) {\n const document = popoverObjectRef.current.ownerDocument;\n const onDocumentClick = (event: MouseEvent) => {\n // Dismiss popover unless there was a click inside within the last animation frame.\n // Ignore clicks inside the chart as those are handled separately.\n if (clickFrameId.current === null && !nodeContains(container, event.target as Element)) {\n onDismiss(true);\n }\n };\n\n document.addEventListener('mousedown', onDocumentClick);\n\n return () => {\n document.removeEventListener('mousedown', onDocumentClick);\n };\n }\n }, [container, onDismiss]);\n\n // In chart popovers, dismiss button is present when they are pinned, so both values are equivalent.\n const isPinned = dismissButton;\n\n return (\n <div\n {...baseProps}\n className={clsx(popoverStyles.root, styles.root, baseProps.className)}\n ref={popoverRef}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onMouseDown={onMouseDown}\n onBlur={onBlur}\n // The tabIndex makes it so that clicking inside popover assigns this element as blur target.\n // That is necessary in charts to ensure the blur target is within the chart and no cleanup is needed.\n tabIndex={-1}\n >\n <PopoverContainer\n size={size}\n fixedWidth={fixedWidth}\n position={position}\n trackRef={trackRef}\n getTrack={getTrack}\n trackKey={trackKey}\n minVisibleBlockSize={minVisibleBlockSize}\n arrow={position => (\n <div className={clsx(popoverStyles.arrow, popoverStyles[`arrow-position-${position}`])}>\n <div className={popoverStyles['arrow-outer']} />\n <div className={popoverStyles['arrow-inner']} />\n </div>\n )}\n keepPosition={true}\n allowVerticalOverflow={true}\n allowScrollToFit={isPinned}\n hoverArea={true}\n >\n <PopoverBody\n dismissButton={dismissButton}\n dismissAriaLabel={dismissAriaLabel}\n header={<span className={testClasses.header}>{title}</span>}\n onDismiss={onDismiss}\n overflowVisible=\"content\"\n className={styles['popover-body']}\n variant=\"chart\"\n >\n <div className={testClasses.body}>{children}</div>\n {footer && <div className={clsx(testClasses.footer, styles.footer)}>{footer}</div>}\n </PopoverBody>\n </PopoverContainer>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/chart-popover/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,WAAW,MAAM,8BAA8B,CAAC;AA0CvD,eAAe,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AAE9C,SAAS,YAAY,CACnB,EACE,QAAQ,GAAG,OAAO,EAClB,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,KAAK,EAClB,aAAa,GAAG,KAAK,EACrB,gBAAgB,EAEhB,QAAQ,EACR,MAAM,EAEN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,mBAAmB,EAEnB,YAAY,EACZ,YAAY,EACZ,MAAM,EAEN,GAAG,SAAS,EACM,EACpB,GAA2B;IAE3B,MAAM,SAAS,GAAG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MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAG,MAAM,CAAO,CACtE,CACG,CACf,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport PopoverBody from '../../../popover/body';\nimport PopoverContainer from '../../../popover/container';\nimport { PopoverProps } from '../../../popover/interfaces';\nimport { getBaseProps } from '../../base-component';\n\nimport popoverStyles from '../../../popover/styles.css.js';\nimport styles from './styles.css.js';\nimport testClasses from './test-classes/styles.css.js';\n\nexport interface ChartPopoverProps extends PopoverProps {\n /** Title of the popover */\n title?: React.ReactNode;\n\n /** References the element the container is positioned against. */\n trackRef?: React.RefObject<HTMLElement | SVGElement>;\n getTrack?: () => null | HTMLElement | SVGElement;\n /**\n Used to update the container position in case track or track position changes:\n \n const trackRef = useRef<Element>(null)\n return (<>\n <Track style={getPosition(selectedItemId)} ref={trackRef} />\n <PopoverContainer trackRef={trackRef} trackKey={selectedItemId} .../>\n </>)\n */\n trackKey?: string | number;\n minVisibleBlockSize?: number;\n\n /** Optional container element that prevents any clicks in there from dismissing the popover */\n container: Element | null;\n\n /** Event that is fired when the popover is dismissed */\n onDismiss: (outsideClick?: boolean) => void;\n\n /** Fired when the pointer enters the hoverable area around the popover */\n onMouseEnter?: (event: React.MouseEvent) => void;\n\n /** Fired when the pointer leaves the hoverable area around the popover */\n onMouseLeave?: (event: React.MouseEvent) => void;\n\n onBlur?: (event: React.FocusEvent) => void;\n\n /** Popover content */\n children?: React.ReactNode;\n\n /** Popover footer */\n footer?: React.ReactNode;\n}\n\nexport default React.forwardRef(ChartPopover);\n\nfunction ChartPopover(\n {\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n dismissButton = false,\n dismissAriaLabel,\n\n children,\n footer,\n\n title,\n trackRef,\n getTrack,\n trackKey,\n onDismiss,\n container,\n minVisibleBlockSize,\n\n onMouseEnter,\n onMouseLeave,\n onBlur,\n\n ...restProps\n }: ChartPopoverProps,\n ref: React.Ref<HTMLElement>\n) {\n const baseProps = getBaseProps(restProps);\n const popoverObjectRef = useRef<HTMLDivElement | null>(null);\n const popoverRef = useMergeRefs(popoverObjectRef, ref);\n\n const clickFrameId = useRef<number | null>(null);\n const onMouseDown = () => {\n // Indicate there was a click inside popover recently.\n clickFrameId.current = requestAnimationFrame(() => (clickFrameId.current = null));\n };\n\n useEffect(() => {\n if (popoverObjectRef.current) {\n const document = popoverObjectRef.current.ownerDocument;\n const onDocumentClick = (event: MouseEvent) => {\n // Dismiss popover unless there was a click inside within the last animation frame.\n // Ignore clicks inside the chart as those are handled separately.\n if (clickFrameId.current === null && !nodeContains(container, event.target as Element)) {\n onDismiss(true);\n }\n };\n\n document.addEventListener('mousedown', onDocumentClick);\n\n return () => {\n document.removeEventListener('mousedown', onDocumentClick);\n };\n }\n }, [container, onDismiss]);\n\n // In chart popovers, dismiss button is present when they are pinned, so both values are equivalent.\n const isPinned = dismissButton;\n\n return (\n <div\n {...baseProps}\n role={!dismissButton ? 'tooltip' : undefined}\n className={clsx(popoverStyles.root, styles.root, baseProps.className)}\n ref={popoverRef}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onMouseDown={onMouseDown}\n onBlur={onBlur}\n // The tabIndex makes it so that clicking inside popover assigns this element as blur target.\n // That is necessary in charts to ensure the blur target is within the chart and no cleanup is needed.\n tabIndex={-1}\n >\n <PopoverContainer\n size={size}\n fixedWidth={fixedWidth}\n position={position}\n trackRef={trackRef}\n getTrack={getTrack}\n trackKey={trackKey}\n minVisibleBlockSize={minVisibleBlockSize}\n arrow={position => (\n <div className={clsx(popoverStyles.arrow, popoverStyles[`arrow-position-${position}`])}>\n <div className={popoverStyles['arrow-outer']} />\n <div className={popoverStyles['arrow-inner']} />\n </div>\n )}\n keepPosition={true}\n allowVerticalOverflow={true}\n allowScrollToFit={isPinned}\n hoverArea={true}\n >\n <PopoverBody\n dismissButton={dismissButton}\n dismissAriaLabel={dismissAriaLabel}\n header={<span className={testClasses.header}>{title}</span>}\n onDismiss={onDismiss}\n overflowVisible=\"content\"\n className={styles['popover-body']}\n variant=\"chart\"\n >\n <div className={testClasses.body}>{children}</div>\n {footer && <div className={clsx(testClasses.footer, styles.footer)}>{footer}</div>}\n </PopoverBody>\n </PopoverContainer>\n </div>\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (ed206118)";
3
- export var GIT_SHA = "ed206118";
2
+ export var PACKAGE_VERSION = "3.0.0 (83dc7058)";
3
+ export var GIT_SHA = "83dc7058";
4
4
  export var THEME = "open-source-visual-refresh";
5
5
  export var SYSTEM = "core";
6
6
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (ed206118)",
4
- "GIT_SHA": "ed206118",
3
+ "PACKAGE_VERSION": "3.0.0 (83dc7058)",
4
+ "GIT_SHA": "83dc7058",
5
5
  "THEME": "open-source-visual-refresh",
6
6
  "SYSTEM": "core",
7
7
  "ALWAYS_VISUAL_REFRESH": true
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "ed206118e11bd3d641deb2325b1b4cd5be2874df"
2
+ "commit": "83dc70581d08ddb866a76914f7be63d0e01d0720"
3
3
  }
package/package.json CHANGED
@@ -159,7 +159,7 @@
159
159
  "./internal/base-component/index.js",
160
160
  "./internal/base-component/styles.css.js"
161
161
  ],
162
- "version": "3.0.1193",
162
+ "version": "3.0.1194",
163
163
  "repository": {
164
164
  "type": "git",
165
165
  "url": "https://github.com/cloudscape-design/components.git"