@cloudscape-design/components 3.0.799 → 3.0.801
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-layout/visual-refresh-toolbar/index.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/index.js +4 -2
- package/app-layout/visual-refresh-toolbar/index.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/multi-layout.d.ts +1 -1
- package/app-layout/visual-refresh-toolbar/multi-layout.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/multi-layout.js +5 -2
- package/app-layout/visual-refresh-toolbar/multi-layout.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/skeleton/index.d.ts +1 -1
- package/app-layout/visual-refresh-toolbar/skeleton/index.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/skeleton/index.js +3 -3
- package/app-layout/visual-refresh-toolbar/skeleton/index.js.map +1 -1
- package/attribute-editor/additional-info.js +2 -2
- package/attribute-editor/additional-info.js.map +1 -1
- package/attribute-editor/internal.d.ts.map +1 -1
- package/attribute-editor/internal.js +2 -2
- package/attribute-editor/internal.js.map +1 -1
- package/button/internal.d.ts.map +1 -1
- package/button/internal.js +3 -3
- package/button/internal.js.map +1 -1
- package/button-group/icon-button-item.d.ts.map +1 -1
- package/button-group/icon-button-item.js +3 -2
- package/button-group/icon-button-item.js.map +1 -1
- package/cards/index.js +3 -3
- package/cards/index.js.map +1 -1
- package/code-editor/index.d.ts.map +1 -1
- package/code-editor/index.js +2 -2
- package/code-editor/index.js.map +1 -1
- package/code-editor/status-bar.js +2 -2
- package/code-editor/status-bar.js.map +1 -1
- package/date-picker/index.js +2 -2
- package/date-picker/index.js.map +1 -1
- package/date-range-picker/calendar/header/index.js +2 -2
- package/date-range-picker/calendar/header/index.js.map +1 -1
- package/date-range-picker/calendar/index.d.ts.map +1 -1
- package/date-range-picker/calendar/index.js +2 -2
- package/date-range-picker/calendar/index.js.map +1 -1
- package/date-range-picker/dropdown.d.ts.map +1 -1
- package/date-range-picker/dropdown.js +2 -2
- package/date-range-picker/dropdown.js.map +1 -1
- package/drawer/implementation.d.ts.map +1 -1
- package/drawer/implementation.js +2 -2
- package/drawer/implementation.js.map +1 -1
- package/flashbar/flash.d.ts.map +1 -1
- package/flashbar/flash.js +2 -2
- package/flashbar/flash.js.map +1 -1
- package/form/internal.js +2 -2
- package/form/internal.js.map +1 -1
- package/form-field/internal.js +3 -3
- package/form-field/internal.js.map +1 -1
- package/help-panel/implementation.js +2 -2
- package/help-panel/implementation.js.map +1 -1
- package/internal/components/chart-plot/index.js +2 -2
- package/internal/components/chart-plot/index.js.map +1 -1
- package/internal/components/chart-status-container/index.d.ts.map +1 -1
- package/internal/components/chart-status-container/index.js +3 -1
- package/internal/components/chart-status-container/index.js.map +1 -1
- package/internal/components/dropdown-footer/index.d.ts.map +1 -1
- package/internal/components/dropdown-footer/index.js +2 -2
- package/internal/components/dropdown-footer/index.js.map +1 -1
- package/internal/components/live-region/controller.d.ts +35 -0
- package/internal/components/live-region/controller.d.ts.map +1 -0
- package/internal/components/live-region/controller.js +77 -0
- package/internal/components/live-region/controller.js.map +1 -0
- package/internal/components/live-region/index.d.ts +5 -64
- package/internal/components/live-region/index.d.ts.map +1 -1
- package/internal/components/live-region/index.js +11 -122
- package/internal/components/live-region/index.js.map +1 -1
- package/internal/components/live-region/interfaces.d.ts +34 -0
- package/internal/components/live-region/interfaces.d.ts.map +1 -0
- package/internal/components/live-region/interfaces.js +4 -0
- package/internal/components/live-region/interfaces.js.map +1 -0
- package/internal/components/live-region/internal.d.ts +31 -0
- package/internal/components/live-region/internal.d.ts.map +1 -0
- package/internal/components/live-region/internal.js +80 -0
- package/internal/components/live-region/internal.js.map +1 -0
- package/internal/components/live-region/styles.css.js +2 -2
- package/internal/components/live-region/styles.scoped.css +146 -4
- package/internal/components/live-region/styles.selectors.js +2 -2
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/hooks/use-intersection-observer/index.d.ts +5 -1
- package/internal/hooks/use-intersection-observer/index.d.ts.map +1 -1
- package/internal/hooks/use-intersection-observer/index.js +2 -2
- package/internal/hooks/use-intersection-observer/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/pie-chart/pie-chart.js +2 -2
- package/pie-chart/pie-chart.js.map +1 -1
- package/progress-bar/index.js +2 -2
- package/progress-bar/index.js.map +1 -1
- package/s3-resource-selector/s3-in-context/index.d.ts.map +1 -1
- package/s3-resource-selector/s3-in-context/index.js +2 -3
- package/s3-resource-selector/s3-in-context/index.js.map +1 -1
- package/s3-resource-selector/s3-modal/basic-table.js +2 -2
- package/s3-resource-selector/s3-modal/basic-table.js.map +1 -1
- package/select/parts/filter.d.ts +1 -1
- package/table/body-cell/disabled-inline-editor.d.ts.map +1 -1
- package/table/body-cell/disabled-inline-editor.js +2 -1
- package/table/body-cell/disabled-inline-editor.js.map +1 -1
- package/table/body-cell/index.d.ts.map +1 -1
- package/table/body-cell/index.js +2 -2
- package/table/body-cell/index.js.map +1 -1
- package/table/body-cell/inline-editor.d.ts.map +1 -1
- package/table/body-cell/inline-editor.js +4 -4
- package/table/body-cell/inline-editor.js.map +1 -1
- package/table/internal.js +2 -2
- package/table/internal.js.map +1 -1
- package/table/no-data-cell.js +2 -2
- package/table/no-data-cell.js.map +1 -1
- package/table/progressive-loading/items-loader.js +3 -3
- package/table/progressive-loading/items-loader.js.map +1 -1
- package/tag-editor/index.js +2 -2
- package/tag-editor/index.js.map +1 -1
- package/test-utils/dom/internal/live-region.d.ts +4 -0
- package/test-utils/dom/internal/live-region.js +11 -0
- package/test-utils/dom/internal/live-region.js.map +1 -0
- package/test-utils/selectors/internal/live-region.d.ts +4 -0
- package/test-utils/selectors/internal/live-region.js +11 -0
- package/test-utils/selectors/internal/live-region.js.map +1 -0
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/text-filter/search-results.js +2 -2
- package/text-filter/search-results.js.map +1 -1
- package/tutorial-panel/components/tutorial-list/index.js +2 -2
- package/tutorial-panel/components/tutorial-list/index.js.map +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InternalBaseComponentProps } from '../../hooks/use-base-component';
|
|
3
|
+
import { LiveRegionProps } from './interfaces';
|
|
4
|
+
export interface InternalLiveRegionProps extends InternalBaseComponentProps, LiveRegionProps {
|
|
5
|
+
/**
|
|
6
|
+
* The delay between each announcement from this live region. You should
|
|
7
|
+
* leave this set to the default unless this live region is commonly
|
|
8
|
+
* interrupted by other actions (like text entry in text filtering).
|
|
9
|
+
*/
|
|
10
|
+
delay?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Use a list of strings and/or refs to existing elements for building the
|
|
13
|
+
* announcement text. If this property is set, `children` and `message` will
|
|
14
|
+
* be ignored.
|
|
15
|
+
*/
|
|
16
|
+
sources?: ReadonlyArray<string | React.RefObject<HTMLElement> | undefined>;
|
|
17
|
+
}
|
|
18
|
+
export interface InternalLiveRegionRef {
|
|
19
|
+
/**
|
|
20
|
+
* Force the live region to announce the message, even if it's the same as
|
|
21
|
+
* the previously announced message.
|
|
22
|
+
*
|
|
23
|
+
* This is useful when making status updates after a change (e.g. filtering)
|
|
24
|
+
* where the new message might be the same as the old one, but the announcement
|
|
25
|
+
* also serves to tell screen reader users that the action was performed.
|
|
26
|
+
*/
|
|
27
|
+
reannounce(): void;
|
|
28
|
+
}
|
|
29
|
+
declare const _default: React.ForwardRefExoticComponent<InternalLiveRegionProps & React.RefAttributes<InternalLiveRegionRef>>;
|
|
30
|
+
export default _default;
|
|
31
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/live-region/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAItE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAG5E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,MAAM,WAAW,uBAAwB,SAAQ,0BAA0B,EAAE,eAAe;IAC1F;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC,CAAC;CAC5E;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,UAAU,IAAI,IAAI,CAAC;CACpB;;AAED,wBAsEG"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __rest } from "tslib";
|
|
4
|
+
import React, { useEffect, useImperativeHandle, useRef } from 'react';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { getBaseProps } from '../../base-component';
|
|
7
|
+
import { useMergeRefs } from '../../hooks/use-merge-refs';
|
|
8
|
+
import { LiveRegionController } from './controller';
|
|
9
|
+
import styles from './styles.css.js';
|
|
10
|
+
export default React.forwardRef(function InternalLiveRegion(_a, ref) {
|
|
11
|
+
var { assertive = false, hidden = false, tagName: TagName = 'div', delay, sources, message, children, __internalRootRef, className } = _a, restProps = __rest(_a, ["assertive", "hidden", "tagName", "delay", "sources", "message", "children", "__internalRootRef", "className"]);
|
|
12
|
+
const baseProps = getBaseProps(restProps);
|
|
13
|
+
const childrenRef = useRef(null);
|
|
14
|
+
const mergedRef = useMergeRefs(childrenRef, __internalRootRef);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
// We have to do this because `inert` isn't properly supported until
|
|
17
|
+
// React 19 and this seems much more maintainable than version detection.
|
|
18
|
+
// `inert` is better than `hidden` because it also blocks pointer and
|
|
19
|
+
// focus events as well as hiding the contents from screen readers.
|
|
20
|
+
// https://github.com/facebook/react/issues/17157
|
|
21
|
+
if (childrenRef.current) {
|
|
22
|
+
childrenRef.current.inert = hidden;
|
|
23
|
+
}
|
|
24
|
+
}, [hidden]);
|
|
25
|
+
// Initialize the live region controller inside an effect. We have to do this
|
|
26
|
+
// because the controller depends on DOM elements, which aren't available on the
|
|
27
|
+
// server.
|
|
28
|
+
const liveRegionControllerRef = useRef();
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const liveRegionController = new LiveRegionController(assertive ? 'assertive' : 'polite');
|
|
31
|
+
liveRegionControllerRef.current = liveRegionController;
|
|
32
|
+
return () => {
|
|
33
|
+
liveRegionController.destroy();
|
|
34
|
+
liveRegionControllerRef.current = undefined;
|
|
35
|
+
};
|
|
36
|
+
}, [assertive]);
|
|
37
|
+
const getContent = () => {
|
|
38
|
+
return sources
|
|
39
|
+
? getSourceContent(sources)
|
|
40
|
+
: message
|
|
41
|
+
? message
|
|
42
|
+
: childrenRef.current
|
|
43
|
+
? extractTextContent(childrenRef.current)
|
|
44
|
+
: undefined;
|
|
45
|
+
};
|
|
46
|
+
// Call the controller on every render. The controller will deduplicate the
|
|
47
|
+
// message against the previous announcement internally.
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
var _a;
|
|
50
|
+
(_a = liveRegionControllerRef.current) === null || _a === void 0 ? void 0 : _a.announce({ message: getContent(), delay });
|
|
51
|
+
});
|
|
52
|
+
useImperativeHandle(ref, () => ({
|
|
53
|
+
reannounce() {
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = liveRegionControllerRef.current) === null || _a === void 0 ? void 0 : _a.announce({ message: getContent(), delay, forceReannounce: true });
|
|
56
|
+
},
|
|
57
|
+
}));
|
|
58
|
+
return (React.createElement(TagName, Object.assign({ ref: mergedRef }, baseProps, { className: clsx(styles.root, className), hidden: hidden }), children));
|
|
59
|
+
});
|
|
60
|
+
function extractTextContent(node) {
|
|
61
|
+
// We use the text content of the node as the announcement text.
|
|
62
|
+
// This only extracts text content from the node including all its children which is enough for now.
|
|
63
|
+
// To make it more powerful, it is possible to create a more sophisticated extractor with respect to
|
|
64
|
+
// ARIA properties to ignore aria-hidden nodes and read ARIA labels from the live content.
|
|
65
|
+
return (node.textContent || '').replace(/\s+/g, ' ').trim();
|
|
66
|
+
}
|
|
67
|
+
function getSourceContent(source) {
|
|
68
|
+
return source
|
|
69
|
+
.map(item => {
|
|
70
|
+
if (!item || typeof item === 'string') {
|
|
71
|
+
return item;
|
|
72
|
+
}
|
|
73
|
+
if (item.current) {
|
|
74
|
+
return extractTextContent(item.current);
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join(' ');
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../../src/internal/components/live-region/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AA8BrC,eAAe,KAAK,CAAC,UAAU,CAAC,SAAS,kBAAkB,CACzD,EAW0B,EAC1B,GAAqC;QAZrC,EACE,SAAS,GAAG,KAAK,EACjB,MAAM,GAAG,KAAK,EACd,OAAO,EAAE,OAAO,GAAG,KAAK,EACxB,KAAK,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,iBAAiB,EACjB,SAAS,OAEe,EADrB,SAAS,cAVd,+GAWC,CADa;IAId,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM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AE,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,UAAU;;YACR,MAAA,uBAAuB,CAAC,OAAO,0CAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;QACrG,CAAC;KACF,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,oBAAC,OAAO,kBAAC,GAAG,EAAE,SAAS,IAAM,SAAS,IAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,KAC5F,QAAQ,CACD,CACX,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,kBAAkB,CAAC,IAAiB;IAC3C,gEAAgE;IAChE,oGAAoG;IACpG,oGAAoG;IACpG,0FAA0F;IAC1F,OAAO,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9D,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAwE;IAChG,OAAO,MAAM;SACV,GAAG,CAAC,IAAI,CAAC,EAAE;QACV,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YACrC,OAAO,IAAI,CAAC;SACb;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACzC;IACH,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../../base-component';\nimport { InternalBaseComponentProps } from '../../hooks/use-base-component';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\nimport { LiveRegionController } from './controller';\nimport { LiveRegionProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\nexport interface InternalLiveRegionProps extends InternalBaseComponentProps, LiveRegionProps {\n /**\n * The delay between each announcement from this live region. You should\n * leave this set to the default unless this live region is commonly\n * interrupted by other actions (like text entry in text filtering).\n */\n delay?: number;\n\n /**\n * Use a list of strings and/or refs to existing elements for building the\n * announcement text. If this property is set, `children` and `message` will\n * be ignored.\n */\n sources?: ReadonlyArray<string | React.RefObject<HTMLElement> | undefined>;\n}\n\nexport interface InternalLiveRegionRef {\n /**\n * Force the live region to announce the message, even if it's the same as\n * the previously announced message.\n *\n * This is useful when making status updates after a change (e.g. filtering)\n * where the new message might be the same as the old one, but the announcement\n * also serves to tell screen reader users that the action was performed.\n */\n reannounce(): void;\n}\n\nexport default React.forwardRef(function InternalLiveRegion(\n {\n assertive = false,\n hidden = false,\n tagName: TagName = 'div',\n delay,\n sources,\n message,\n children,\n __internalRootRef,\n className,\n ...restProps\n }: InternalLiveRegionProps,\n ref: React.Ref<InternalLiveRegionRef>\n) {\n const baseProps = getBaseProps(restProps);\n const childrenRef = useRef<HTMLSpanElement & HTMLDivElement>(null);\n const mergedRef = useMergeRefs(childrenRef, __internalRootRef);\n\n useEffect(() => {\n // We have to do this because `inert` isn't properly supported until\n // React 19 and this seems much more maintainable than version detection.\n // `inert` is better than `hidden` because it also blocks pointer and\n // focus events as well as hiding the contents from screen readers.\n // https://github.com/facebook/react/issues/17157\n if (childrenRef.current) {\n childrenRef.current.inert = hidden;\n }\n }, [hidden]);\n\n // Initialize the live region controller inside an effect. We have to do this\n // because the controller depends on DOM elements, which aren't available on the\n // server.\n const liveRegionControllerRef = useRef<LiveRegionController | undefined>();\n useEffect(() => {\n const liveRegionController = new LiveRegionController(assertive ? 'assertive' : 'polite');\n liveRegionControllerRef.current = liveRegionController;\n return () => {\n liveRegionController.destroy();\n liveRegionControllerRef.current = undefined;\n };\n }, [assertive]);\n\n const getContent = () => {\n return sources\n ? getSourceContent(sources)\n : message\n ? message\n : childrenRef.current\n ? extractTextContent(childrenRef.current)\n : undefined;\n };\n\n // Call the controller on every render. The controller will deduplicate the\n // message against the previous announcement internally.\n useEffect(() => {\n liveRegionControllerRef.current?.announce({ message: getContent(), delay });\n });\n\n useImperativeHandle(ref, () => ({\n reannounce() {\n liveRegionControllerRef.current?.announce({ message: getContent(), delay, forceReannounce: true });\n },\n }));\n\n return (\n <TagName ref={mergedRef} {...baseProps} className={clsx(styles.root, className)} hidden={hidden}>\n {children}\n </TagName>\n );\n});\n\nfunction extractTextContent(node: HTMLElement): string {\n // We use the text content of the node as the announcement text.\n // This only extracts text content from the node including all its children which is enough for now.\n // To make it more powerful, it is possible to create a more sophisticated extractor with respect to\n // ARIA properties to ignore aria-hidden nodes and read ARIA labels from the live content.\n return (node.textContent || '').replace(/\\s+/g, ' ').trim();\n}\n\nfunction getSourceContent(source: ReadonlyArray<string | React.RefObject<HTMLElement> | undefined>): string {\n return source\n .map(item => {\n if (!item || typeof item === 'string') {\n return item;\n }\n if (item.current) {\n return extractTextContent(item.current);\n }\n })\n .filter(Boolean)\n .join(' ');\n}\n"]}
|
|
@@ -2,10 +2,152 @@
|
|
|
2
2
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/*
|
|
6
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
/*
|
|
10
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
11
|
+
SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
*/
|
|
13
|
+
/*
|
|
14
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
15
|
+
SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
*/
|
|
17
|
+
/*
|
|
18
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
19
|
+
SPDX-License-Identifier: Apache-2.0
|
|
20
|
+
*/
|
|
21
|
+
/*
|
|
22
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
23
|
+
SPDX-License-Identifier: Apache-2.0
|
|
24
|
+
*/
|
|
25
|
+
/*
|
|
26
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
27
|
+
SPDX-License-Identifier: Apache-2.0
|
|
28
|
+
*/
|
|
29
|
+
/*
|
|
30
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
31
|
+
SPDX-License-Identifier: Apache-2.0
|
|
32
|
+
*/
|
|
33
|
+
/*
|
|
34
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
35
|
+
SPDX-License-Identifier: Apache-2.0
|
|
36
|
+
*/
|
|
37
|
+
/*
|
|
38
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
39
|
+
SPDX-License-Identifier: Apache-2.0
|
|
40
|
+
*/
|
|
41
|
+
/*
|
|
42
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
43
|
+
SPDX-License-Identifier: Apache-2.0
|
|
44
|
+
*/
|
|
45
|
+
/*
|
|
46
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
47
|
+
SPDX-License-Identifier: Apache-2.0
|
|
48
|
+
*/
|
|
49
|
+
/*
|
|
50
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
51
|
+
SPDX-License-Identifier: Apache-2.0
|
|
52
|
+
*/
|
|
53
|
+
/*
|
|
54
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
55
|
+
SPDX-License-Identifier: Apache-2.0
|
|
56
|
+
*/
|
|
57
|
+
/*
|
|
58
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
59
|
+
SPDX-License-Identifier: Apache-2.0
|
|
60
|
+
*/
|
|
61
|
+
/*
|
|
62
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
63
|
+
SPDX-License-Identifier: Apache-2.0
|
|
64
|
+
*/
|
|
65
|
+
/*
|
|
66
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
67
|
+
SPDX-License-Identifier: Apache-2.0
|
|
68
|
+
*/
|
|
69
|
+
/*
|
|
70
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
71
|
+
SPDX-License-Identifier: Apache-2.0
|
|
72
|
+
*/
|
|
73
|
+
/*
|
|
74
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
75
|
+
SPDX-License-Identifier: Apache-2.0
|
|
76
|
+
*/
|
|
77
|
+
/*
|
|
78
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
79
|
+
SPDX-License-Identifier: Apache-2.0
|
|
80
|
+
*/
|
|
81
|
+
/*
|
|
82
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
83
|
+
SPDX-License-Identifier: Apache-2.0
|
|
84
|
+
*/
|
|
85
|
+
/*
|
|
86
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
87
|
+
SPDX-License-Identifier: Apache-2.0
|
|
88
|
+
*/
|
|
89
|
+
/*
|
|
90
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
91
|
+
SPDX-License-Identifier: Apache-2.0
|
|
92
|
+
*/
|
|
93
|
+
/*
|
|
94
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
95
|
+
SPDX-License-Identifier: Apache-2.0
|
|
96
|
+
*/
|
|
97
|
+
/*
|
|
98
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
99
|
+
SPDX-License-Identifier: Apache-2.0
|
|
100
|
+
*/
|
|
101
|
+
/*
|
|
102
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
103
|
+
SPDX-License-Identifier: Apache-2.0
|
|
104
|
+
*/
|
|
105
|
+
/*
|
|
106
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
107
|
+
SPDX-License-Identifier: Apache-2.0
|
|
108
|
+
*/
|
|
109
|
+
/*
|
|
110
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
111
|
+
SPDX-License-Identifier: Apache-2.0
|
|
112
|
+
*/
|
|
113
|
+
/* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
114
|
+
/* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
115
|
+
/*
|
|
116
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
117
|
+
SPDX-License-Identifier: Apache-2.0
|
|
118
|
+
*/
|
|
119
|
+
/*
|
|
120
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
121
|
+
SPDX-License-Identifier: Apache-2.0
|
|
122
|
+
*/
|
|
123
|
+
/*
|
|
124
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
125
|
+
SPDX-License-Identifier: Apache-2.0
|
|
126
|
+
*/
|
|
127
|
+
/*
|
|
128
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
129
|
+
SPDX-License-Identifier: Apache-2.0
|
|
130
|
+
*/
|
|
131
|
+
/*
|
|
132
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
133
|
+
SPDX-License-Identifier: Apache-2.0
|
|
134
|
+
*/
|
|
135
|
+
/*
|
|
136
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
137
|
+
SPDX-License-Identifier: Apache-2.0
|
|
138
|
+
*/
|
|
139
|
+
/* Style used for links in slots/components that are text heavy, to help links stand out among
|
|
140
|
+
surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
|
|
141
|
+
.awsui_root_3bgfn_di2un_141:not(#\9) {
|
|
142
|
+
display: contents;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.awsui_root_3bgfn_di2un_141[hidden]:not(#\9) {
|
|
146
|
+
display: none;
|
|
7
147
|
}
|
|
8
148
|
|
|
9
|
-
.
|
|
10
|
-
|
|
149
|
+
.awsui_announcer_3bgfn_di2un_149:not(#\9) {
|
|
150
|
+
position: absolute !important;
|
|
151
|
+
inset-block-start: -9999px !important;
|
|
152
|
+
inset-inline-start: -9999px !important;
|
|
11
153
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"root": "
|
|
6
|
-
"
|
|
5
|
+
"root": "awsui_root_3bgfn_di2un_141",
|
|
6
|
+
"announcer": "awsui_announcer_3bgfn_di2un_149"
|
|
7
7
|
};
|
|
8
8
|
|
package/internal/environment.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
interface UseIntersectionObserverConfig {
|
|
2
|
+
initialState?: boolean;
|
|
3
|
+
}
|
|
1
4
|
/**
|
|
2
5
|
* A hook that uses an Intersection Observer on the target element ref
|
|
3
6
|
* and detects if the element is intersecting with its parent.
|
|
4
7
|
*/
|
|
5
|
-
export declare function useIntersectionObserver<T extends HTMLElement>(): {
|
|
8
|
+
export declare function useIntersectionObserver<T extends HTMLElement>({ initialState, }?: UseIntersectionObserverConfig): {
|
|
6
9
|
ref: (instance: T | null) => void;
|
|
7
10
|
isIntersecting: boolean;
|
|
8
11
|
};
|
|
12
|
+
export {};
|
|
9
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-intersection-observer/index.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-intersection-observer/index.ts"],"names":[],"mappings":"AAKA,UAAU,6BAA6B;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW,EAAE,EAC7D,YAAoB,GACrB,GAAE,6BAAkC;;;EAuBpC"}
|
|
@@ -5,9 +5,9 @@ import { useCallback, useRef, useState } from 'react';
|
|
|
5
5
|
* A hook that uses an Intersection Observer on the target element ref
|
|
6
6
|
* and detects if the element is intersecting with its parent.
|
|
7
7
|
*/
|
|
8
|
-
export function useIntersectionObserver() {
|
|
8
|
+
export function useIntersectionObserver({ initialState = false, } = {}) {
|
|
9
9
|
const observerRef = useRef(null);
|
|
10
|
-
const [isIntersecting, setIsIntersecting] = useState(
|
|
10
|
+
const [isIntersecting, setIsIntersecting] = useState(initialState);
|
|
11
11
|
const ref = useCallback(targetElement => {
|
|
12
12
|
if (typeof IntersectionObserver === 'undefined') {
|
|
13
13
|
// Do nothing in environments like JSDOM
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-intersection-observer/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-intersection-observer/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMnE;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAwB,EAC7D,YAAY,GAAG,KAAK,MACa,EAAE;IACnC,MAAM,WAAW,GAAG,MAAM,CAA8B,IAAI,CAAC,CAAC;IAC9D,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEnE,MAAM,GAAG,GAAG,WAAW,CAAiB,aAAa,CAAC,EAAE;QACtD,IAAI,OAAO,oBAAoB,KAAK,WAAW,EAAE;YAC/C,wCAAwC;YACxC,OAAO;SACR;QAED,IAAI,WAAW,CAAC,OAAO,EAAE;YACvB,uDAAuD;YACvD,WAAW,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;SAClC;QAED,gDAAgD;QAChD,IAAI,aAAa,EAAE;YACjB,WAAW,CAAC,OAAO,GAAG,IAAI,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;YACrG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;SAC5C;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;AACjC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { RefCallback, useCallback, useRef, useState } from 'react';\n\ninterface UseIntersectionObserverConfig {\n initialState?: boolean;\n}\n\n/**\n * A hook that uses an Intersection Observer on the target element ref\n * and detects if the element is intersecting with its parent.\n */\nexport function useIntersectionObserver<T extends HTMLElement>({\n initialState = false,\n}: UseIntersectionObserverConfig = {}) {\n const observerRef = useRef<IntersectionObserver | null>(null);\n const [isIntersecting, setIsIntersecting] = useState(initialState);\n\n const ref = useCallback<RefCallback<T>>(targetElement => {\n if (typeof IntersectionObserver === 'undefined') {\n // Do nothing in environments like JSDOM\n return;\n }\n\n if (observerRef.current) {\n // Dismiss previous observer because the target changed\n observerRef.current.disconnect();\n }\n\n // Create a new observer with the target element\n if (targetElement) {\n observerRef.current = new IntersectionObserver(([entry]) => setIsIntersecting(entry.isIntersecting));\n observerRef.current.observe(targetElement);\n }\n }, []);\n\n return { ref, isIntersecting };\n}\n"]}
|
package/internal/manifest.json
CHANGED
package/package.json
CHANGED
package/pie-chart/pie-chart.js
CHANGED
|
@@ -10,7 +10,7 @@ import ChartPopover from '../internal/components/chart-popover';
|
|
|
10
10
|
import ChartPopoverFooter from '../internal/components/chart-popover-footer';
|
|
11
11
|
import SeriesDetails from '../internal/components/chart-series-details';
|
|
12
12
|
import SeriesMarker from '../internal/components/chart-series-marker';
|
|
13
|
-
import
|
|
13
|
+
import InternalLiveRegion from '../internal/components/live-region/internal';
|
|
14
14
|
import { useHeightMeasure } from '../internal/hooks/container-queries/use-height-measure';
|
|
15
15
|
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
16
16
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
@@ -199,6 +199,6 @@ export default ({ fitHeight, height: explicitHeight, variant, size, width, i18nS
|
|
|
199
199
|
popoverData.series.label)), trackRef: popoverData.trackRef, trackKey: popoverData.series.index, dismissButton: pinnedSegment !== null, dismissAriaLabel: i18nStrings.detailPopoverDismissAriaLabel, onDismiss: onPopoverDismiss, container: ((_b = plotRef.current) === null || _b === void 0 ? void 0 : _b.svg) || null, size: detailPopoverSize, onMouseLeave: checkMouseLeave, onBlur: onApplicationBlur },
|
|
200
200
|
popoverContent,
|
|
201
201
|
detailPopoverFooterContent && React.createElement(ChartPopoverFooter, null, detailPopoverFooterContent))),
|
|
202
|
-
React.createElement(
|
|
202
|
+
React.createElement(InternalLiveRegion, { sources: [popoverContentRef] })));
|
|
203
203
|
};
|
|
204
204
|
//# sourceMappingURL=pie-chart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie-chart.js","sourceRoot":"","sources":["../../../src/pie-chart/pie-chart.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,SAA2B,MAAM,mCAAmC,CAAC;AAC5E,OAAO,YAAY,MAAM,sCAAsC,CAAC;AAChE,OAAO,kBAAkB,MAAM,6CAA6C,CAAC;AAC7E,OAAO,aAAa,MAAM,6CAA6C,CAAC;AACxE,OAAO,YAAY,MAAM,4CAA4C,CAAC;AACtE,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AA+BrC,eAAe,CAAgC,E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C,OAAO,EAAC,GAAG,IAChF,sBAAsB,CACX,CACf,CACG,CACP;QACA,aAAa,IAAI,WAAW,IAAI,CAC/B,oBAAC,YAAY,IACX,GAAG,EAAE,UAAU,EACf,KAAK,EACH,WAAW,CAAC,MAAM,IAAI,CACpB,oBAAC,WAAW,IAAC,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAC,QAAQ;gBAChE,oBAAC,YAAY,IAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,UAAU,GAAI;gBAAC,GAAG;gBACzF,WAAW,CAAC,MAAM,CAAC,KAAK,CACb,CACf,EAEH,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAC9B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,EAClC,aAAa,EAAE,aAAa,KAAK,IAAI,EACrC,gBAAgB,EAAE,WAAW,CAAC,6BAA6B,EAC3D,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,CAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,KAAI,IAAI,EACvC,IAAI,EAAE,iBAAiB,EACvB,YAAY,EAAE,eAAe,EAC7B,MAAM,EAAE,iBAAiB;YAExB,cAAc;YACd,0BAA0B,IAAI,oBAAC,kBAAkB,QAAE,0BAA0B,CAAsB,CACvF,CAChB;QACD,oBAAC,UAAU,IAAC,MAAM,EAAE,CAAC,iBAAiB,CAAC,GAAI,CACvC,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { PieArcDatum } from 'd3-shape';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport InternalBox from '../box/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport ChartPlot, { ChartPlotRef } from '../internal/components/chart-plot';\nimport ChartPopover from '../internal/components/chart-popover';\nimport ChartPopoverFooter from '../internal/components/chart-popover-footer';\nimport SeriesDetails from '../internal/components/chart-series-details';\nimport SeriesMarker from '../internal/components/chart-series-marker';\nimport LiveRegion from '../internal/components/live-region';\nimport { useHeightMeasure } from '../internal/hooks/container-queries/use-height-measure';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { KeyCode } from '../internal/keycode';\nimport { SomeRequired } from '../internal/types';\nimport { nodeBelongs } from '../internal/utils/node-belongs';\nimport { PieChartProps, SeriesInfo } from './interfaces';\nimport Labels from './labels';\nimport Segments from './segments';\nimport { defaultDetails, getDimensionsBySize } from './utils';\n\nimport styles from './styles.css.js';\n\nexport interface InternalChartDatum<T> {\n index: number;\n color: string;\n datum: Readonly<T>;\n}\n\ninterface InternalPieChartProps<T extends PieChartProps.Datum>\n extends SomeRequired<\n Omit<PieChartProps<T>, 'onHighlightChange' | 'statusType'>,\n 'variant' | 'size' | 'i18nStrings' | 'hideTitles' | 'hideDescriptions'\n > {\n width: number;\n height: number;\n\n highlightedSegment: T | null;\n onHighlightChange: (segment: null | T) => void;\n\n legendSegment: T | null;\n\n pieData: PieArcDatum<InternalChartDatum<T>>[];\n dataSum: number;\n}\n\nexport interface PopoverData<T> {\n datum: T;\n trackRef: React.RefObject<SVGElement>;\n series: SeriesInfo;\n}\n\nexport default <T extends PieChartProps.Datum>({\n fitHeight,\n height: explicitHeight,\n variant,\n size,\n width,\n i18nStrings,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n innerMetricValue,\n innerMetricDescription,\n hideTitles,\n hideDescriptions,\n detailPopoverContent,\n detailPopoverSize,\n detailPopoverFooter,\n segmentDescription,\n highlightedSegment,\n onHighlightChange,\n legendSegment,\n pieData,\n dataSum,\n}: InternalPieChartProps<T>) => {\n const [pinnedSegment, setPinnedSegment] = useState<T | null>(null);\n const plotRef = useRef<ChartPlotRef>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const focusedSegmentRef = useRef<SVGGElement>(null);\n const popoverTrackRef = useRef<SVGCircleElement>(null);\n const popoverRef = useRef<HTMLElement | null>(null);\n\n const hasLabels = !(hideTitles && hideDescriptions);\n const isRefresh = useVisualRefresh();\n\n const height = useHeightMeasure(() => plotRef.current?.svg ?? null, !fitHeight) ?? explicitHeight;\n\n const dimensions = useMemo(\n () =>\n getDimensionsBySize({ size: fitHeight ? Math.min(height, width) : size, hasLabels, visualRefresh: isRefresh }),\n [fitHeight, height, width, size, hasLabels, isRefresh]\n );\n\n // Inner content is only available for donut charts and the inner description is not displayed for small charts\n const hasInnerContent =\n variant === 'donut' && (innerMetricValue || (innerMetricDescription && dimensions.size !== 'small'));\n\n const innerMetricId = useUniqueId('awsui-pie-chart__inner');\n\n const [isPopoverOpen, setPopoverOpen] = useState<boolean>(false);\n const [popoverData, setPopoverData] = useState<PopoverData<T>>();\n\n const highlightedSegmentIndex = useMemo(() => {\n for (let index = 0; index < pieData.length; index++) {\n if (pieData[index].data.datum === highlightedSegment) {\n return index;\n }\n }\n return null;\n }, [pieData, highlightedSegment]);\n\n const detailPopoverFooterContent = useMemo(\n () => (detailPopoverFooter && highlightedSegment ? detailPopoverFooter(highlightedSegment) : null),\n [detailPopoverFooter, highlightedSegment]\n );\n\n const i18n = useInternalI18n('pie-chart');\n const detailFunction = detailPopoverContent || defaultDetails(i18n, i18nStrings);\n const details = popoverData ? detailFunction(popoverData.datum, dataSum) : [];\n const popoverContentRef = useRef<HTMLDivElement | null>(null);\n const popoverContent = popoverData && <SeriesDetails details={details} compactList={true} ref={popoverContentRef} />;\n\n const popoverDismissedRecently = useRef(false);\n const escapePressed = useRef(false);\n const duringTouch = useRef(false);\n\n const highlightSegment = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n const segment = internalDatum.datum;\n if (segment !== highlightedSegment) {\n onHighlightChange(segment);\n }\n\n if (popoverTrackRef.current) {\n setPopoverData({\n datum: internalDatum.datum,\n series: {\n color: internalDatum.color,\n index: internalDatum.index,\n label: internalDatum.datum.title,\n markerType: 'rectangle',\n },\n trackRef: popoverTrackRef,\n });\n setPopoverOpen(true);\n }\n },\n [highlightedSegment, setPopoverOpen, onHighlightChange]\n );\n\n const clearHighlightedSegment = useCallback(() => {\n setPopoverOpen(false);\n onHighlightChange(null);\n }, [onHighlightChange, setPopoverOpen]);\n\n const checkMouseLeave = (event: React.MouseEvent) => {\n if (pinnedSegment !== null) {\n return;\n }\n\n if (\n nodeContains(popoverRef.current, event.relatedTarget) ||\n nodeContains(focusedSegmentRef.current, event.relatedTarget)\n ) {\n return;\n }\n\n clearHighlightedSegment();\n };\n\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n clearHighlightedSegment();\n escapePressed.current = true;\n }\n };\n document.addEventListener('keydown', onKeyDown);\n return () => document.removeEventListener('keydown', onKeyDown);\n }, [clearHighlightedSegment]);\n\n const onMouseDown = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n if (pinnedSegment === internalDatum.datum) {\n setPinnedSegment(null);\n clearHighlightedSegment();\n } else {\n setPinnedSegment(internalDatum.datum);\n highlightSegment(internalDatum);\n }\n },\n [pinnedSegment, clearHighlightedSegment, setPinnedSegment, highlightSegment]\n );\n const onMouseOver = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n if (escapePressed.current) {\n escapePressed.current = false;\n return;\n }\n if (duringTouch.current) {\n duringTouch.current = false;\n return;\n }\n if (pinnedSegment !== null) {\n return;\n }\n highlightSegment(internalDatum);\n },\n [pinnedSegment, highlightSegment]\n );\n const onTouchStart = useCallback(() => {\n duringTouch.current = true;\n }, []);\n\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.enter &&\n keyCode !== KeyCode.space\n ) {\n return;\n }\n\n event.preventDefault();\n\n let nextIndex = highlightedSegmentIndex || 0;\n const MAX = pieData.length - 1;\n if (keyCode === KeyCode.right) {\n nextIndex++;\n if (nextIndex > MAX) {\n nextIndex = 0;\n }\n } else if (keyCode === KeyCode.left) {\n nextIndex--;\n if (nextIndex < 0) {\n nextIndex = MAX;\n }\n }\n if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n setPinnedSegment(pieData[nextIndex].data.datum);\n }\n highlightSegment(pieData[nextIndex].data);\n },\n [setPinnedSegment, highlightSegment, pieData, highlightedSegmentIndex]\n );\n const onApplicationFocus = useCallback(\n (_event: any, target: 'keyboard' | 'mouse') => {\n if (pinnedSegment !== null || popoverDismissedRecently.current || target === 'mouse') {\n return;\n }\n\n const segment = highlightedSegment || legendSegment || pieData[0].data.datum;\n const matched = pieData.filter(d => d.data.datum === segment);\n highlightSegment(matched[0].data);\n },\n [pinnedSegment, pieData, highlightSegment, highlightedSegment, legendSegment]\n );\n\n const onApplicationBlur = useCallback(\n (event: React.FocusEvent) => {\n const blurTarget = event.relatedTarget || event.target;\n if (blurTarget === null || !(blurTarget instanceof Element) || !nodeBelongs(containerRef.current, blurTarget)) {\n // We only need to close the popover and remove the pinned segment so that we keep track of the current\n // highlighted legendSeries. using clearHighlightedSegment() would set the legendSeries to null, in that case\n // using Keyboard Tab will always highlight the first legend item in the legend component.\n setPopoverOpen(false);\n setPinnedSegment(null);\n }\n },\n [setPinnedSegment]\n );\n const onPopoverDismiss = (outsideClick?: boolean) => {\n setPopoverOpen(false);\n setPinnedSegment(null);\n\n if (!outsideClick) {\n // The delay is needed to bypass focus events caused by click or keypress needed to unpin the popover.\n setTimeout(() => {\n popoverDismissedRecently.current = true;\n plotRef.current!.focusApplication();\n popoverDismissedRecently.current = false;\n }, 0);\n } else {\n onHighlightChange(null);\n }\n };\n\n return (\n <div\n className={clsx(styles['chart-container'], fitHeight && styles['chart-container--fit-height'])}\n ref={containerRef}\n >\n <div\n className={clsx(\n styles['chart-container-chart-plot'],\n fitHeight && styles['chart-container-chart-plot--fit-height']\n )}\n >\n <ChartPlot\n ref={plotRef}\n width=\"100%\"\n height={fitHeight ? '100%' : height}\n transform={`translate(${width / 2} ${height / 2})`}\n isPrecise={true}\n isClickable={!isPopoverOpen}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaDescribedby={hasInnerContent ? innerMetricId : undefined}\n ariaRoleDescription={i18nStrings?.chartAriaRoleDescription}\n activeElementRef={focusedSegmentRef}\n activeElementKey={highlightedSegmentIndex?.toString()}\n onApplicationFocus={onApplicationFocus}\n onApplicationBlur={onApplicationBlur}\n onKeyDown={onKeyDown}\n onMouseOut={checkMouseLeave}\n >\n <Segments\n pieData={pieData}\n dimensions={dimensions}\n variant={variant}\n focusedSegmentRef={focusedSegmentRef}\n popoverTrackRef={popoverTrackRef}\n highlightedSegment={highlightedSegment}\n segmentAriaRoleDescription={i18nStrings?.segmentAriaRoleDescription}\n onMouseDown={onMouseDown}\n onMouseOver={onMouseOver}\n onTouchStart={onTouchStart}\n />\n {hasLabels && (\n <Labels\n pieData={pieData}\n dimensions={dimensions}\n segmentDescription={segmentDescription}\n visibleDataSum={dataSum}\n hideTitles={hideTitles}\n hideDescriptions={hideDescriptions}\n highlightedSegment={highlightedSegment}\n containerRef={containerRef}\n />\n )}\n </ChartPlot>\n </div>\n\n {hasInnerContent && (\n <div className={styles['inner-content']} id={innerMetricId}>\n {innerMetricValue && (\n <InternalBox\n variant={dimensions.size === 'small' ? 'h3' : 'h1'}\n tagOverride=\"div\"\n color=\"inherit\"\n padding=\"n\"\n >\n {innerMetricValue}\n </InternalBox>\n )}\n {innerMetricDescription && dimensions.size !== 'small' && (\n <InternalBox variant=\"h3\" color=\"text-body-secondary\" tagOverride=\"div\" padding=\"n\">\n {innerMetricDescription}\n </InternalBox>\n )}\n </div>\n )}\n {isPopoverOpen && popoverData && (\n <ChartPopover\n ref={popoverRef}\n title={\n popoverData.series && (\n <InternalBox className={styles['popover-header']} variant=\"strong\">\n <SeriesMarker color={popoverData.series.color} type={popoverData.series.markerType} />{' '}\n {popoverData.series.label}\n </InternalBox>\n )\n }\n trackRef={popoverData.trackRef}\n trackKey={popoverData.series.index}\n dismissButton={pinnedSegment !== null}\n dismissAriaLabel={i18nStrings.detailPopoverDismissAriaLabel}\n onDismiss={onPopoverDismiss}\n container={plotRef.current?.svg || null}\n size={detailPopoverSize}\n onMouseLeave={checkMouseLeave}\n onBlur={onApplicationBlur}\n >\n {popoverContent}\n {detailPopoverFooterContent && <ChartPopoverFooter>{detailPopoverFooterContent}</ChartPopoverFooter>}\n </ChartPopover>\n )}\n <LiveRegion source={[popoverContentRef]} />\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"pie-chart.js","sourceRoot":"","sources":["../../../src/pie-chart/pie-chart.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,SAA2B,MAAM,mCAAmC,CAAC;AAC5E,OAAO,YAAY,MAAM,sCAAsC,CAAC;AAChE,OAAO,kBAAkB,MAAM,6CAA6C,CAAC;AAC7E,OAAO,aAAa,MAAM,6CAA6C,CAAC;AACxE,OAAO,YAAY,MAAM,4CAA4C,CAAC;AACtE,OAAO,kBAAkB,MAAM,6CAA6C,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAA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AAiB,CAAC,GAAI,CAChD,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { PieArcDatum } from 'd3-shape';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport InternalBox from '../box/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport ChartPlot, { ChartPlotRef } from '../internal/components/chart-plot';\nimport ChartPopover from '../internal/components/chart-popover';\nimport ChartPopoverFooter from '../internal/components/chart-popover-footer';\nimport SeriesDetails from '../internal/components/chart-series-details';\nimport SeriesMarker from '../internal/components/chart-series-marker';\nimport InternalLiveRegion from '../internal/components/live-region/internal';\nimport { useHeightMeasure } from '../internal/hooks/container-queries/use-height-measure';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { KeyCode } from '../internal/keycode';\nimport { SomeRequired } from '../internal/types';\nimport { nodeBelongs } from '../internal/utils/node-belongs';\nimport { PieChartProps, SeriesInfo } from './interfaces';\nimport Labels from './labels';\nimport Segments from './segments';\nimport { defaultDetails, getDimensionsBySize } from './utils';\n\nimport styles from './styles.css.js';\n\nexport interface InternalChartDatum<T> {\n index: number;\n color: string;\n datum: Readonly<T>;\n}\n\ninterface InternalPieChartProps<T extends PieChartProps.Datum>\n extends SomeRequired<\n Omit<PieChartProps<T>, 'onHighlightChange' | 'statusType'>,\n 'variant' | 'size' | 'i18nStrings' | 'hideTitles' | 'hideDescriptions'\n > {\n width: number;\n height: number;\n\n highlightedSegment: T | null;\n onHighlightChange: (segment: null | T) => void;\n\n legendSegment: T | null;\n\n pieData: PieArcDatum<InternalChartDatum<T>>[];\n dataSum: number;\n}\n\nexport interface PopoverData<T> {\n datum: T;\n trackRef: React.RefObject<SVGElement>;\n series: SeriesInfo;\n}\n\nexport default <T extends PieChartProps.Datum>({\n fitHeight,\n height: explicitHeight,\n variant,\n size,\n width,\n i18nStrings,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n innerMetricValue,\n innerMetricDescription,\n hideTitles,\n hideDescriptions,\n detailPopoverContent,\n detailPopoverSize,\n detailPopoverFooter,\n segmentDescription,\n highlightedSegment,\n onHighlightChange,\n legendSegment,\n pieData,\n dataSum,\n}: InternalPieChartProps<T>) => {\n const [pinnedSegment, setPinnedSegment] = useState<T | null>(null);\n const plotRef = useRef<ChartPlotRef>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const focusedSegmentRef = useRef<SVGGElement>(null);\n const popoverTrackRef = useRef<SVGCircleElement>(null);\n const popoverRef = useRef<HTMLElement | null>(null);\n\n const hasLabels = !(hideTitles && hideDescriptions);\n const isRefresh = useVisualRefresh();\n\n const height = useHeightMeasure(() => plotRef.current?.svg ?? null, !fitHeight) ?? explicitHeight;\n\n const dimensions = useMemo(\n () =>\n getDimensionsBySize({ size: fitHeight ? Math.min(height, width) : size, hasLabels, visualRefresh: isRefresh }),\n [fitHeight, height, width, size, hasLabels, isRefresh]\n );\n\n // Inner content is only available for donut charts and the inner description is not displayed for small charts\n const hasInnerContent =\n variant === 'donut' && (innerMetricValue || (innerMetricDescription && dimensions.size !== 'small'));\n\n const innerMetricId = useUniqueId('awsui-pie-chart__inner');\n\n const [isPopoverOpen, setPopoverOpen] = useState<boolean>(false);\n const [popoverData, setPopoverData] = useState<PopoverData<T>>();\n\n const highlightedSegmentIndex = useMemo(() => {\n for (let index = 0; index < pieData.length; index++) {\n if (pieData[index].data.datum === highlightedSegment) {\n return index;\n }\n }\n return null;\n }, [pieData, highlightedSegment]);\n\n const detailPopoverFooterContent = useMemo(\n () => (detailPopoverFooter && highlightedSegment ? detailPopoverFooter(highlightedSegment) : null),\n [detailPopoverFooter, highlightedSegment]\n );\n\n const i18n = useInternalI18n('pie-chart');\n const detailFunction = detailPopoverContent || defaultDetails(i18n, i18nStrings);\n const details = popoverData ? detailFunction(popoverData.datum, dataSum) : [];\n const popoverContentRef = useRef<HTMLDivElement | null>(null);\n const popoverContent = popoverData && <SeriesDetails details={details} compactList={true} ref={popoverContentRef} />;\n\n const popoverDismissedRecently = useRef(false);\n const escapePressed = useRef(false);\n const duringTouch = useRef(false);\n\n const highlightSegment = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n const segment = internalDatum.datum;\n if (segment !== highlightedSegment) {\n onHighlightChange(segment);\n }\n\n if (popoverTrackRef.current) {\n setPopoverData({\n datum: internalDatum.datum,\n series: {\n color: internalDatum.color,\n index: internalDatum.index,\n label: internalDatum.datum.title,\n markerType: 'rectangle',\n },\n trackRef: popoverTrackRef,\n });\n setPopoverOpen(true);\n }\n },\n [highlightedSegment, setPopoverOpen, onHighlightChange]\n );\n\n const clearHighlightedSegment = useCallback(() => {\n setPopoverOpen(false);\n onHighlightChange(null);\n }, [onHighlightChange, setPopoverOpen]);\n\n const checkMouseLeave = (event: React.MouseEvent) => {\n if (pinnedSegment !== null) {\n return;\n }\n\n if (\n nodeContains(popoverRef.current, event.relatedTarget) ||\n nodeContains(focusedSegmentRef.current, event.relatedTarget)\n ) {\n return;\n }\n\n clearHighlightedSegment();\n };\n\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n clearHighlightedSegment();\n escapePressed.current = true;\n }\n };\n document.addEventListener('keydown', onKeyDown);\n return () => document.removeEventListener('keydown', onKeyDown);\n }, [clearHighlightedSegment]);\n\n const onMouseDown = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n if (pinnedSegment === internalDatum.datum) {\n setPinnedSegment(null);\n clearHighlightedSegment();\n } else {\n setPinnedSegment(internalDatum.datum);\n highlightSegment(internalDatum);\n }\n },\n [pinnedSegment, clearHighlightedSegment, setPinnedSegment, highlightSegment]\n );\n const onMouseOver = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n if (escapePressed.current) {\n escapePressed.current = false;\n return;\n }\n if (duringTouch.current) {\n duringTouch.current = false;\n return;\n }\n if (pinnedSegment !== null) {\n return;\n }\n highlightSegment(internalDatum);\n },\n [pinnedSegment, highlightSegment]\n );\n const onTouchStart = useCallback(() => {\n duringTouch.current = true;\n }, []);\n\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.enter &&\n keyCode !== KeyCode.space\n ) {\n return;\n }\n\n event.preventDefault();\n\n let nextIndex = highlightedSegmentIndex || 0;\n const MAX = pieData.length - 1;\n if (keyCode === KeyCode.right) {\n nextIndex++;\n if (nextIndex > MAX) {\n nextIndex = 0;\n }\n } else if (keyCode === KeyCode.left) {\n nextIndex--;\n if (nextIndex < 0) {\n nextIndex = MAX;\n }\n }\n if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n setPinnedSegment(pieData[nextIndex].data.datum);\n }\n highlightSegment(pieData[nextIndex].data);\n },\n [setPinnedSegment, highlightSegment, pieData, highlightedSegmentIndex]\n );\n const onApplicationFocus = useCallback(\n (_event: any, target: 'keyboard' | 'mouse') => {\n if (pinnedSegment !== null || popoverDismissedRecently.current || target === 'mouse') {\n return;\n }\n\n const segment = highlightedSegment || legendSegment || pieData[0].data.datum;\n const matched = pieData.filter(d => d.data.datum === segment);\n highlightSegment(matched[0].data);\n },\n [pinnedSegment, pieData, highlightSegment, highlightedSegment, legendSegment]\n );\n\n const onApplicationBlur = useCallback(\n (event: React.FocusEvent) => {\n const blurTarget = event.relatedTarget || event.target;\n if (blurTarget === null || !(blurTarget instanceof Element) || !nodeBelongs(containerRef.current, blurTarget)) {\n // We only need to close the popover and remove the pinned segment so that we keep track of the current\n // highlighted legendSeries. using clearHighlightedSegment() would set the legendSeries to null, in that case\n // using Keyboard Tab will always highlight the first legend item in the legend component.\n setPopoverOpen(false);\n setPinnedSegment(null);\n }\n },\n [setPinnedSegment]\n );\n const onPopoverDismiss = (outsideClick?: boolean) => {\n setPopoverOpen(false);\n setPinnedSegment(null);\n\n if (!outsideClick) {\n // The delay is needed to bypass focus events caused by click or keypress needed to unpin the popover.\n setTimeout(() => {\n popoverDismissedRecently.current = true;\n plotRef.current!.focusApplication();\n popoverDismissedRecently.current = false;\n }, 0);\n } else {\n onHighlightChange(null);\n }\n };\n\n return (\n <div\n className={clsx(styles['chart-container'], fitHeight && styles['chart-container--fit-height'])}\n ref={containerRef}\n >\n <div\n className={clsx(\n styles['chart-container-chart-plot'],\n fitHeight && styles['chart-container-chart-plot--fit-height']\n )}\n >\n <ChartPlot\n ref={plotRef}\n width=\"100%\"\n height={fitHeight ? '100%' : height}\n transform={`translate(${width / 2} ${height / 2})`}\n isPrecise={true}\n isClickable={!isPopoverOpen}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaDescribedby={hasInnerContent ? innerMetricId : undefined}\n ariaRoleDescription={i18nStrings?.chartAriaRoleDescription}\n activeElementRef={focusedSegmentRef}\n activeElementKey={highlightedSegmentIndex?.toString()}\n onApplicationFocus={onApplicationFocus}\n onApplicationBlur={onApplicationBlur}\n onKeyDown={onKeyDown}\n onMouseOut={checkMouseLeave}\n >\n <Segments\n pieData={pieData}\n dimensions={dimensions}\n variant={variant}\n focusedSegmentRef={focusedSegmentRef}\n popoverTrackRef={popoverTrackRef}\n highlightedSegment={highlightedSegment}\n segmentAriaRoleDescription={i18nStrings?.segmentAriaRoleDescription}\n onMouseDown={onMouseDown}\n onMouseOver={onMouseOver}\n onTouchStart={onTouchStart}\n />\n {hasLabels && (\n <Labels\n pieData={pieData}\n dimensions={dimensions}\n segmentDescription={segmentDescription}\n visibleDataSum={dataSum}\n hideTitles={hideTitles}\n hideDescriptions={hideDescriptions}\n highlightedSegment={highlightedSegment}\n containerRef={containerRef}\n />\n )}\n </ChartPlot>\n </div>\n\n {hasInnerContent && (\n <div className={styles['inner-content']} id={innerMetricId}>\n {innerMetricValue && (\n <InternalBox\n variant={dimensions.size === 'small' ? 'h3' : 'h1'}\n tagOverride=\"div\"\n color=\"inherit\"\n padding=\"n\"\n >\n {innerMetricValue}\n </InternalBox>\n )}\n {innerMetricDescription && dimensions.size !== 'small' && (\n <InternalBox variant=\"h3\" color=\"text-body-secondary\" tagOverride=\"div\" padding=\"n\">\n {innerMetricDescription}\n </InternalBox>\n )}\n </div>\n )}\n {isPopoverOpen && popoverData && (\n <ChartPopover\n ref={popoverRef}\n title={\n popoverData.series && (\n <InternalBox className={styles['popover-header']} variant=\"strong\">\n <SeriesMarker color={popoverData.series.color} type={popoverData.series.markerType} />{' '}\n {popoverData.series.label}\n </InternalBox>\n )\n }\n trackRef={popoverData.trackRef}\n trackKey={popoverData.series.index}\n dismissButton={pinnedSegment !== null}\n dismissAriaLabel={i18nStrings.detailPopoverDismissAriaLabel}\n onDismiss={onPopoverDismiss}\n container={plotRef.current?.svg || null}\n size={detailPopoverSize}\n onMouseLeave={checkMouseLeave}\n onBlur={onApplicationBlur}\n >\n {popoverContent}\n {detailPopoverFooterContent && <ChartPopoverFooter>{detailPopoverFooterContent}</ChartPopoverFooter>}\n </ChartPopover>\n )}\n <InternalLiveRegion sources={[popoverContentRef]} />\n </div>\n );\n};\n"]}
|
package/progress-bar/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import React, { useEffect, useMemo, useState } from 'react';
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
7
7
|
import { getBaseProps } from '../internal/base-component';
|
|
8
|
-
import
|
|
8
|
+
import InternalLiveRegion from '../internal/components/live-region/internal';
|
|
9
9
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
10
10
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
11
11
|
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
@@ -45,7 +45,7 @@ export default function ProgressBar(_a) {
|
|
|
45
45
|
description && (React.createElement(SmallText, { color: isInFlash ? 'inherit' : undefined, id: descriptionId }, description)),
|
|
46
46
|
React.createElement("div", null, isInProgressState ? (React.createElement(React.Fragment, null,
|
|
47
47
|
React.createElement(Progress, { value: value, ariaLabel: ariaLabel, ariaLabelledby: joinStrings(labelId, ariaLabelledby), ariaDescribedby: joinStrings(description ? descriptionId : undefined, additionalInfo ? additionalInfoId : undefined, ariaDescribedby), isInFlash: isInFlash }),
|
|
48
|
-
React.createElement(
|
|
48
|
+
React.createElement(InternalLiveRegion, { hidden: true, tagName: "span", delay: 0 },
|
|
49
49
|
label,
|
|
50
50
|
label ? ': ' : null,
|
|
51
51
|
announcedValue))) : (React.createElement(ResultState, { resultText: resultText, isInFlash: isInFlash, resultButtonText: resultButtonText, status: status, onClick: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/progress-bar/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/progress-bar/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,kBAAkB,MAAM,6CAA6C,CAAC;AAC7E,OAAO,EAAE,sB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AW,CAAC,OAAO,EAAE,cAAc,CAAC,EACpD,eAAe,EAAE,WAAW,CAC1B,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EACvC,cAAc,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,EAC7C,eAAe,CAChB,EACD,SAAS,EAAE,SAAS,GACpB;gBACF,oBAAC,kBAAkB,IAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,EAAC,KAAK,EAAE,CAAC;oBACtD,KAAK;oBACL,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;oBACnB,cAAc,CACI,CACpB,CACJ,CAAC,CAAC,CAAC,CACF,oBAAC,WAAW,IACV,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;oBACZ,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;gBAC9C,CAAC,GACD,CACH,CACG,CACF;QACL,cAAc,IAAI,CACjB,oBAAC,SAAS,IACR,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,EACpC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EACxC,EAAE,EAAE,gBAAgB,IAEnB,cAAc,CACL,CACb,CACG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../internal/base-component';\nimport InternalLiveRegion from '../internal/components/live-region/internal';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { joinStrings } from '../internal/utils/strings';\nimport { throttle } from '../internal/utils/throttle';\nimport { ProgressBarProps } from './interfaces';\nimport { Progress, ResultState, SmallText } from './internal';\n\nimport styles from './styles.css.js';\n\nconst ASSERTION_FREQUENCY = 5000; // interval in ms between progress announcements\n\nexport { ProgressBarProps };\n\nexport default function ProgressBar({\n value = 0,\n status = 'in-progress',\n variant = 'standalone',\n resultButtonText,\n label,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n description,\n additionalInfo,\n resultText,\n onResultButtonClick,\n ...rest\n}: ProgressBarProps) {\n const { __internalRootRef } = useBaseComponent('ProgressBar', {\n props: { variant },\n });\n const baseProps = getBaseProps(rest);\n const generatedName = useUniqueId('awsui-progress-bar-');\n\n const labelId = `${generatedName}-label`;\n const isInFlash = variant === 'flash';\n const isInProgressState = status === 'in-progress';\n\n const descriptionId = useUniqueId('progressbar-description-');\n const additionalInfoId = useUniqueId('progressbar-additional-info-');\n\n const [announcedValue, setAnnouncedValue] = useState('');\n const throttledAssertion = useMemo(() => {\n return throttle((value: ProgressBarProps['value']) => {\n setAnnouncedValue(`${value}%`);\n }, ASSERTION_FREQUENCY);\n }, []);\n\n useEffect(() => {\n throttledAssertion(value);\n }, [throttledAssertion, value]);\n\n if (isInFlash && resultButtonText) {\n warnOnce(\n 'ProgressBar',\n 'The `resultButtonText` is ignored if you set `variant=\"flash\"`, and the result button is not displayed. Use the `buttonText` property and the `onButtonClick` event listener of the flashbar item in which the progress bar component is embedded.'\n );\n }\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root, variant && styles[variant])}\n ref={__internalRootRef}\n >\n <div className={isInFlash ? styles['flash-container'] : undefined}>\n <div className={clsx(styles['word-wrap'], styles[`label-${variant}`])} id={labelId}>\n {label}\n </div>\n {description && (\n <SmallText color={isInFlash ? 'inherit' : undefined} id={descriptionId}>\n {description}\n </SmallText>\n )}\n <div>\n {isInProgressState ? (\n <>\n <Progress\n value={value}\n ariaLabel={ariaLabel}\n ariaLabelledby={joinStrings(labelId, ariaLabelledby)}\n ariaDescribedby={joinStrings(\n description ? descriptionId : undefined,\n additionalInfo ? additionalInfoId : undefined,\n ariaDescribedby\n )}\n isInFlash={isInFlash}\n />\n <InternalLiveRegion hidden={true} tagName=\"span\" delay={0}>\n {label}\n {label ? ': ' : null}\n {announcedValue}\n </InternalLiveRegion>\n </>\n ) : (\n <ResultState\n resultText={resultText}\n isInFlash={isInFlash}\n resultButtonText={resultButtonText}\n status={status}\n onClick={() => {\n fireNonCancelableEvent(onResultButtonClick);\n }}\n />\n )}\n </div>\n </div>\n {additionalInfo && (\n <SmallText\n className={styles['additional-info']}\n color={isInFlash ? 'inherit' : undefined}\n id={additionalInfoId}\n >\n {additionalInfo}\n </SmallText>\n )}\n </div>\n );\n}\n\napplyDisplayName(ProgressBar, 'ProgressBar');\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/s3-resource-selector/s3-in-context/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAY3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAOxD,UAAU,gBAAgB;IACxB,WAAW,EAAE,uBAAuB,CAAC,WAAW,GAAG,SAAS,CAAC;IAC7D,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,CAAC;IAC3C,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,oBAAoB,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;IACtE,aAAa,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC;IACxD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,WAAW,EAAE,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAClG;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/s3-resource-selector/s3-in-context/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAY3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAOxD,UAAU,gBAAgB;IACxB,WAAW,EAAE,uBAAuB,CAAC,WAAW,GAAG,SAAS,CAAC;IAC7D,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,CAAC;IAC3C,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,oBAAoB,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;IACtE,aAAa,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC;IACxD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,WAAW,EAAE,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAClG;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,eAAO,MAAM,WAAW,yFA2HvB,CAAC"}
|
|
@@ -57,8 +57,7 @@ export const S3InContext = React.forwardRef(({ i18nStrings, inputPlaceholder, re
|
|
|
57
57
|
React.createElement("div", { className: styles['layout-divider'] }),
|
|
58
58
|
React.createElement("div", null,
|
|
59
59
|
React.createElement(InternalButton, { className: styles['browse-button'], disabled: loading, formAction: "none", onClick: onBrowse }, i18n('i18nStrings.inContextBrowseButton', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.inContextBrowseButton)))),
|
|
60
|
-
React.createElement(
|
|
61
|
-
React.createElement(InternalStatusIndicator, { type: "loading" },
|
|
62
|
-
React.createElement(LiveRegion, { visible: true }, i18n('i18nStrings.inContextLoadingText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.inContextLoadingText))))))));
|
|
60
|
+
React.createElement(LiveRegion, { assertive: true }, loading && (React.createElement(InternalBox, { margin: { top: 's' } },
|
|
61
|
+
React.createElement(InternalStatusIndicator, { type: "loading" }, i18n('i18nStrings.inContextLoadingText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.inContextLoadingText)))))));
|
|
63
62
|
});
|
|
64
63
|
//# sourceMappingURL=index.js.map
|