@cloudscape-design/components 3.0.103 → 3.0.105
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/annotation-context/annotation/annotation-popover.d.ts.map +1 -1
- package/annotation-context/annotation/annotation-popover.js +4 -8
- package/annotation-context/annotation/annotation-popover.js.map +1 -1
- package/area-chart/model/use-chart-model.d.ts.map +1 -1
- package/area-chart/model/use-chart-model.js +2 -1
- package/area-chart/model/use-chart-model.js.map +1 -1
- package/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +3 -3
- package/autosuggest/internal.js.map +1 -1
- package/internal/components/autosuggest-input/index.d.ts +1 -0
- package/internal/components/autosuggest-input/index.d.ts.map +1 -1
- package/internal/components/autosuggest-input/index.js +4 -18
- package/internal/components/autosuggest-input/index.js.map +1 -1
- package/internal/components/chart-popover/index.d.ts.map +1 -1
- package/internal/components/chart-popover/index.js +1 -1
- package/internal/components/chart-popover/index.js.map +1 -1
- package/internal/components/dropdown/index.d.ts +1 -1
- package/internal/components/dropdown/index.d.ts.map +1 -1
- package/internal/components/dropdown/index.js +22 -6
- package/internal/components/dropdown/index.js.map +1 -1
- package/internal/components/dropdown/interfaces.d.ts +10 -2
- package/internal/components/dropdown/interfaces.d.ts.map +1 -1
- package/internal/components/dropdown/interfaces.js.map +1 -1
- package/internal/components/dropdown-status/index.d.ts +2 -2
- package/internal/components/dropdown-status/index.d.ts.map +1 -1
- package/internal/components/dropdown-status/index.js +4 -5
- package/internal/components/dropdown-status/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/mixed-line-bar-chart/chart-container.d.ts.map +1 -1
- package/mixed-line-bar-chart/chart-container.js +2 -1
- package/mixed-line-bar-chart/chart-container.js.map +1 -1
- package/multiselect/internal.js +3 -4
- package/multiselect/internal.js.map +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/pie-chart/segments.d.ts +2 -2
- package/pie-chart/segments.d.ts.map +1 -1
- package/pie-chart/segments.js +5 -2
- package/pie-chart/segments.js.map +1 -1
- package/popover/body.d.ts +1 -4
- package/popover/body.d.ts.map +1 -1
- package/popover/body.js +16 -4
- package/popover/body.js.map +1 -1
- package/popover/internal.js +6 -1
- package/popover/internal.js.map +1 -1
- package/select/internal.js +3 -4
- package/select/internal.js.map +1 -1
- package/select/utils/use-select.d.ts +6 -16
- package/select/utils/use-select.d.ts.map +1 -1
- package/select/utils/use-select.js +11 -41
- package/select/utils/use-select.js.map +1 -1
|
@@ -51,9 +51,11 @@ var TransitionContent = function (_a) {
|
|
|
51
51
|
footer))))));
|
|
52
52
|
};
|
|
53
53
|
var Dropdown = function (_a) {
|
|
54
|
-
var children = _a.children, trigger = _a.trigger, open = _a.open, onDropdownClose = _a.onDropdownClose, onMouseDown = _a.onMouseDown, header = _a.header, footer = _a.footer, dropdownId = _a.dropdownId, _b = _a.stretchTriggerHeight, stretchTriggerHeight = _b === void 0 ? false : _b, _c = _a.stretchWidth, stretchWidth = _c === void 0 ? true : _c, _d = _a.stretchHeight, stretchHeight = _d === void 0 ? false : _d, _e = _a.stretchToTriggerWidth, stretchToTriggerWidth = _e === void 0 ? true : _e, _f = _a.expandToViewport, expandToViewport = _f === void 0 ? false : _f, _g = _a.preferCenter, preferCenter = _g === void 0 ? false : _g, _h = _a.interior, interior = _h === void 0 ? false : _h, minWidth = _a.minWidth, _j = _a.scrollable, scrollable = _j === void 0 ? true : _j, _k = _a.
|
|
54
|
+
var children = _a.children, trigger = _a.trigger, open = _a.open, onDropdownClose = _a.onDropdownClose, onMouseDown = _a.onMouseDown, header = _a.header, footer = _a.footer, dropdownId = _a.dropdownId, _b = _a.stretchTriggerHeight, stretchTriggerHeight = _b === void 0 ? false : _b, _c = _a.stretchWidth, stretchWidth = _c === void 0 ? true : _c, _d = _a.stretchHeight, stretchHeight = _d === void 0 ? false : _d, _e = _a.stretchToTriggerWidth, stretchToTriggerWidth = _e === void 0 ? true : _e, _f = _a.expandToViewport, expandToViewport = _f === void 0 ? false : _f, _g = _a.preferCenter, preferCenter = _g === void 0 ? false : _g, _h = _a.interior, interior = _h === void 0 ? false : _h, minWidth = _a.minWidth, _j = _a.scrollable, scrollable = _j === void 0 ? true : _j, _k = _a.loopFocus, loopFocus = _k === void 0 ? expandToViewport : _k, onFocus = _a.onFocus, onBlur = _a.onBlur, contentKey = _a.contentKey;
|
|
55
|
+
var wrapperRef = useRef(null);
|
|
55
56
|
var triggerRef = useRef(null);
|
|
56
57
|
var dropdownRef = useRef(null);
|
|
58
|
+
var dropdownContainerRef = useRef(null);
|
|
57
59
|
// This container is only needed to apply max-height to. We can't move max-height to it's parent
|
|
58
60
|
// because of an IE11 issue with flexbox. https://github.com/philipwalton/flexbugs/issues/216
|
|
59
61
|
var verticalContainerRef = useRef(null);
|
|
@@ -139,6 +141,20 @@ var Dropdown = function (_a) {
|
|
|
139
141
|
setPosition('bottom-right');
|
|
140
142
|
}
|
|
141
143
|
};
|
|
144
|
+
var isOutsideDropdown = function (element) {
|
|
145
|
+
return (!wrapperRef.current || !wrapperRef.current.contains(element)) &&
|
|
146
|
+
(!dropdownContainerRef.current || !dropdownContainerRef.current.contains(element));
|
|
147
|
+
};
|
|
148
|
+
var focusHandler = function (event) {
|
|
149
|
+
if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {
|
|
150
|
+
fireNonCancelableEvent(onFocus, event);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var blurHandler = function (event) {
|
|
154
|
+
if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {
|
|
155
|
+
fireNonCancelableEvent(onBlur, event);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
142
158
|
useLayoutEffect(function () {
|
|
143
159
|
var onDropdownOpen = function () {
|
|
144
160
|
if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {
|
|
@@ -226,14 +242,14 @@ var Dropdown = function (_a) {
|
|
|
226
242
|
window.removeEventListener('resize', updateDropdownPosition, true);
|
|
227
243
|
};
|
|
228
244
|
}, [open, expandToViewport]);
|
|
229
|
-
return (React.createElement("div", { className: clsx(styles.root, interior && styles.interior, stretchTriggerHeight && styles['stretch-trigger-height']) },
|
|
245
|
+
return (React.createElement("div", { className: clsx(styles.root, interior && styles.interior, stretchTriggerHeight && styles['stretch-trigger-height']), ref: wrapperRef, onFocus: focusHandler, onBlur: blurHandler },
|
|
230
246
|
React.createElement("div", { className: clsx(stretchTriggerHeight && styles['stretch-trigger-height']), ref: triggerRef }, trigger),
|
|
231
|
-
React.createElement(TabTrap, { focusNextCallback: function () { var _a; return dropdownRef.current && ((_a = getFirstFocusable(dropdownRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !
|
|
247
|
+
React.createElement(TabTrap, { focusNextCallback: function () { var _a; return dropdownRef.current && ((_a = getFirstFocusable(dropdownRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !loopFocus }),
|
|
232
248
|
React.createElement(DropdownContainer, { renderWithPortal: expandToViewport && !interior, id: dropdownId, open: open },
|
|
233
|
-
React.createElement(Transition, { "in": open !== null && open !== void 0 ? open : false, exit: false }, function (state, ref) { return (React.createElement("div", {
|
|
234
|
-
React.createElement(TabTrap, { focusNextCallback: function () { var _a; return triggerRef.current && ((_a = getLastFocusable(triggerRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !
|
|
249
|
+
React.createElement(Transition, { "in": open !== null && open !== void 0 ? open : false, exit: false }, function (state, ref) { return (React.createElement("div", { ref: dropdownContainerRef },
|
|
250
|
+
React.createElement(TabTrap, { focusNextCallback: function () { var _a; return triggerRef.current && ((_a = getLastFocusable(triggerRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !loopFocus }),
|
|
235
251
|
React.createElement(TransitionContent, { state: state, transitionRef: ref, dropdownClasses: dropdownClasses, open: open, stretchWidth: stretchWidth, interior: interior, header: header, expandToViewport: expandToViewport, footer: footer, onMouseDown: onMouseDown, isRefresh: isRefresh, dropdownRef: dropdownRef, verticalContainerRef: verticalContainerRef, position: position }, children),
|
|
236
|
-
React.createElement(TabTrap, { focusNextCallback: function () { var _a; return triggerRef.current && ((_a = getFirstFocusable(triggerRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !
|
|
252
|
+
React.createElement(TabTrap, { focusNextCallback: function () { var _a; return triggerRef.current && ((_a = getFirstFocusable(triggerRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !loopFocus }))); }))));
|
|
237
253
|
};
|
|
238
254
|
var isInteriorPosition = function (position) { return position.bottom !== undefined; };
|
|
239
255
|
export default Dropdown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAA8C,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAgC,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,OAAO,MAA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AE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC5F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B;gBAEF,oBAAC,iBAAiB,IAChB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,GAAG,EAClB,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,IAEjB,QAAQ,CACS;gBAEpB,oBAAC,OAAO,IACN,iBAAiB,EAAE,sBAAM,OAAA,UAAU,CAAC,OAAO,KAAI,MAAA,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC7F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B,CACE,CACP,EA/BgB,CA+BhB,CACU,CACK,CAChB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,IAAM,kBAAkB,GAAG,UACzB,QAAqD,IACZ,OAAC,QAAqC,CAAC,MAAM,KAAK,SAAS,EAA3D,CAA2D,CAAC;AAEvG,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport styles from './styles.css.js';\nimport clsx from 'clsx';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { fireNonCancelableEvent } from '../../events';\nimport { DropdownProps } from './interfaces';\nimport { DropdownPosition, InteriorDropdownPosition, calculatePosition } from './dropdown-fit-handler';\nimport { Transition, TransitionStatus } from '../transition';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport { useMobile } from '../../hooks/use-mobile';\nimport TabTrap from '../tab-trap/index.js';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\n\ninterface DropdownContainerProps {\n children?: React.ReactNode;\n renderWithPortal?: boolean;\n id?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({ children, renderWithPortal = false, id, open }: DropdownContainerProps) => {\n if (renderWithPortal) {\n if (open) {\n return createPortal(<div id={id}>{children}</div>, document.body);\n } else {\n return null;\n }\n } else {\n return <>{children}</>;\n }\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-upper-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles['is-empty']]: !header && !children,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n })}\n ref={contentRef}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n onMouseDown={onMouseDown}\n >\n <div className={clsx(styles['dropdown-content-wrapper'], isRefresh && styles.refresh)}>\n <div className={styles['ie11-wrapper']}>\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n trapFocus = false,\n contentKey,\n}: DropdownProps) => {\n const triggerRef = useRef<HTMLDivElement>(null);\n const dropdownRef = useRef<HTMLDivElement>(null);\n // This container is only needed to apply max-height to. We can't move max-height to it's parent\n // because of an IE11 issue with flexbox. https://github.com/philipwalton/flexbugs/issues/216\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: DOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxHeight = `${parseInt(position.height) + 1}px`;\n } else {\n verticalContainer.style.maxHeight = position.height;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.width = position.width;\n }\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropUp && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.bottom = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropLeft ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.left && position.left !== 'auto') {\n target.style.left = position.left;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n target.style.position = 'fixed';\n if (position.dropUp) {\n target.style.bottom = `calc(100% - ${triggerBox.top}px)`;\n } else {\n target.style.top = `${triggerBox.bottom}px`;\n }\n if (position.dropLeft) {\n target.style.left = `calc(${triggerBox.right}px - ${position.width})`;\n } else {\n target.style.left = `${triggerBox.left}px`;\n }\n // Keep track of the initial dropdown position and direction.\n // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.\n fixedPosition.current = position;\n return;\n }\n\n // For an interior dropdown (the fly out) we need exact values for positioning\n // and classes are not enough\n // usage of relative position is impossible due to overwrite of overflow-x\n if (interior && isInteriorPosition(position)) {\n if (position.dropUp) {\n target.style.bottom = position.bottom;\n } else {\n target.style.top = position.top;\n }\n target.style.left = position.left;\n }\n\n if (position.dropUp && position.dropLeft) {\n setPosition('top-left');\n } else if (position.dropUp) {\n setPosition('top-right');\n } else if (position.dropLeft) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (e: MouseEvent) => {\n if (!dropdownRef.current?.contains(e.target as Node)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n\n /*\n * This small delay allows the event that opened the dropdown to\n * finish bubbling, so that it is not immediately captured here.\n */\n const timeout = setTimeout(() => {\n window.addEventListener('click', clickListener);\n }, 0);\n\n return () => {\n clearTimeout(timeout);\n window.removeEventListener('click', clickListener);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const target = dropdownRef.current;\n if (fixedPosition.current) {\n if (fixedPosition.current.dropUp) {\n dropdownRef.current.style.bottom = `calc(100% - ${triggerRect.top}px)`;\n } else {\n target.style.top = `${triggerRect.bottom}px`;\n }\n if (fixedPosition.current.dropLeft) {\n target.style.left = `calc(${triggerRect.right}px - ${fixedPosition.current.width})`;\n } else {\n target.style.left = `${triggerRect.left}px`;\n }\n }\n }\n };\n\n updateDropdownPosition();\n\n window.addEventListener('scroll', updateDropdownPosition, true);\n window.addEventListener('resize', updateDropdownPosition, true);\n return () => {\n window.removeEventListener('scroll', updateDropdownPosition, true);\n window.removeEventListener('resize', updateDropdownPosition, true);\n };\n }, [open, expandToViewport]);\n\n return (\n <div\n className={clsx(\n styles.root,\n interior && styles.interior,\n stretchTriggerHeight && styles['stretch-trigger-height']\n )}\n >\n <div className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}>\n {trigger}\n </div>\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !trapFocus}\n />\n\n <DropdownContainer renderWithPortal={expandToViewport && !interior} id={dropdownId} open={open}>\n <Transition in={open ?? false} exit={false}>\n {(state, ref) => (\n <div onBlur={event => trapFocus && event.stopPropagation()}>\n <TabTrap\n focusNextCallback={() => triggerRef.current && getLastFocusable(triggerRef.current)?.focus()}\n disabled={!open || !trapFocus}\n />\n\n <TransitionContent\n state={state}\n transitionRef={ref}\n dropdownClasses={dropdownClasses}\n open={open}\n stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !trapFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).bottom !== undefined;\n\nexport default Dropdown;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,E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AAC,OAAO,IACN,iBAAiB,EAAE,sBAAM,OAAA,UAAU,CAAC,OAAO,KAAI,MAAA,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC5F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B;gBAEF,oBAAC,iBAAiB,IAChB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,GAAG,EAClB,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,IAEjB,QAAQ,CACS;gBAEpB,oBAAC,OAAO,IACN,iBAAiB,EAAE,sBAAM,OAAA,UAAU,CAAC,OAAO,KAAI,MAAA,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC7F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B,CACE,CACP,EA/BgB,CA+BhB,CACU,CACK,CAChB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,IAAM,kBAAkB,GAAG,UACzB,QAAqD,IACZ,OAAC,QAAqC,CAAC,MAAM,KAAK,SAAS,EAA3D,CAA2D,CAAC;AAEvG,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport styles from './styles.css.js';\nimport clsx from 'clsx';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { fireNonCancelableEvent } from '../../events';\nimport { DropdownProps } from './interfaces';\nimport { DropdownPosition, InteriorDropdownPosition, calculatePosition } from './dropdown-fit-handler';\nimport { Transition, TransitionStatus } from '../transition';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport { useMobile } from '../../hooks/use-mobile';\nimport TabTrap from '../tab-trap/index.js';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\n\ninterface DropdownContainerProps {\n children?: React.ReactNode;\n renderWithPortal?: boolean;\n id?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({ children, renderWithPortal = false, id, open }: DropdownContainerProps) => {\n if (renderWithPortal) {\n if (open) {\n return createPortal(<div id={id}>{children}</div>, document.body);\n } else {\n return null;\n }\n } else {\n return <>{children}</>;\n }\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-upper-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles['is-empty']]: !header && !children,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n })}\n ref={contentRef}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n onMouseDown={onMouseDown}\n >\n <div className={clsx(styles['dropdown-content-wrapper'], isRefresh && styles.refresh)}>\n <div className={styles['ie11-wrapper']}>\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\n // This container is only needed to apply max-height to. We can't move max-height to it's parent\n // because of an IE11 issue with flexbox. https://github.com/philipwalton/flexbugs/issues/216\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: DOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxHeight = `${parseInt(position.height) + 1}px`;\n } else {\n verticalContainer.style.maxHeight = position.height;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.width = position.width;\n }\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropUp && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.bottom = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropLeft ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.left && position.left !== 'auto') {\n target.style.left = position.left;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n target.style.position = 'fixed';\n if (position.dropUp) {\n target.style.bottom = `calc(100% - ${triggerBox.top}px)`;\n } else {\n target.style.top = `${triggerBox.bottom}px`;\n }\n if (position.dropLeft) {\n target.style.left = `calc(${triggerBox.right}px - ${position.width})`;\n } else {\n target.style.left = `${triggerBox.left}px`;\n }\n // Keep track of the initial dropdown position and direction.\n // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.\n fixedPosition.current = position;\n return;\n }\n\n // For an interior dropdown (the fly out) we need exact values for positioning\n // and classes are not enough\n // usage of relative position is impossible due to overwrite of overflow-x\n if (interior && isInteriorPosition(position)) {\n if (position.dropUp) {\n target.style.bottom = position.bottom;\n } else {\n target.style.top = position.top;\n }\n target.style.left = position.left;\n }\n\n if (position.dropUp && position.dropLeft) {\n setPosition('top-left');\n } else if (position.dropUp) {\n setPosition('top-right');\n } else if (position.dropLeft) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n const isOutsideDropdown = (element: Element) =>\n (!wrapperRef.current || !wrapperRef.current.contains(element)) &&\n (!dropdownContainerRef.current || !dropdownContainerRef.current.contains(element));\n\n const focusHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onFocus, event);\n }\n };\n\n const blurHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onBlur, event);\n }\n };\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (e: MouseEvent) => {\n if (!dropdownRef.current?.contains(e.target as Node)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n\n /*\n * This small delay allows the event that opened the dropdown to\n * finish bubbling, so that it is not immediately captured here.\n */\n const timeout = setTimeout(() => {\n window.addEventListener('click', clickListener);\n }, 0);\n\n return () => {\n clearTimeout(timeout);\n window.removeEventListener('click', clickListener);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const target = dropdownRef.current;\n if (fixedPosition.current) {\n if (fixedPosition.current.dropUp) {\n dropdownRef.current.style.bottom = `calc(100% - ${triggerRect.top}px)`;\n } else {\n target.style.top = `${triggerRect.bottom}px`;\n }\n if (fixedPosition.current.dropLeft) {\n target.style.left = `calc(${triggerRect.right}px - ${fixedPosition.current.width})`;\n } else {\n target.style.left = `${triggerRect.left}px`;\n }\n }\n }\n };\n\n updateDropdownPosition();\n\n window.addEventListener('scroll', updateDropdownPosition, true);\n window.addEventListener('resize', updateDropdownPosition, true);\n return () => {\n window.removeEventListener('scroll', updateDropdownPosition, true);\n window.removeEventListener('resize', updateDropdownPosition, true);\n };\n }, [open, expandToViewport]);\n\n return (\n <div\n className={clsx(\n styles.root,\n interior && styles.interior,\n stretchTriggerHeight && styles['stretch-trigger-height']\n )}\n ref={wrapperRef}\n onFocus={focusHandler}\n onBlur={blurHandler}\n >\n <div className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}>\n {trigger}\n </div>\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <DropdownContainer renderWithPortal={expandToViewport && !interior} id={dropdownId} open={open}>\n <Transition in={open ?? false} exit={false}>\n {(state, ref) => (\n <div ref={dropdownContainerRef}>\n <TabTrap\n focusNextCallback={() => triggerRef.current && getLastFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <TransitionContent\n state={state}\n transitionRef={ref}\n dropdownClasses={dropdownClasses}\n open={open}\n stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).bottom !== undefined;\n\nexport default Dropdown;\n"]}
|
|
@@ -108,9 +108,17 @@ export interface DropdownProps extends ExpandToViewport {
|
|
|
108
108
|
*/
|
|
109
109
|
scrollable?: boolean;
|
|
110
110
|
/**
|
|
111
|
-
* Whether the dropdown will have a focus
|
|
111
|
+
* Whether the dropdown will have a focus loop including trigger, header, content and footer.
|
|
112
112
|
*/
|
|
113
|
-
|
|
113
|
+
loopFocus?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Called when focus enters the trigger or dropdown content.
|
|
116
|
+
*/
|
|
117
|
+
onFocus?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;
|
|
118
|
+
/**
|
|
119
|
+
* Called when focus leaves the trigger or dropdown content.
|
|
120
|
+
*/
|
|
121
|
+
onBlur?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;
|
|
114
122
|
}
|
|
115
123
|
export interface ExpandToViewport {
|
|
116
124
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,oBAAY,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAC9D,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CA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H,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,GAAG,eAAe,CAAC,CAAC,CAAC;IAExF;;OAEG;IACH,MAAM,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,GAAG,eAAe,CAAC,CAAC,CAAC;CACxF;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { NonCancelableEventHandler } from '../../events';\nimport React from 'react';\n\nexport type OptionsFilteringType = 'none' | 'auto' | 'manual';\nexport interface OptionsLoadItemsDetail {\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n}\n\nexport interface BaseDropdownHostProps extends ExpandToViewport {\n /**\n * If you have more than 500 options, enable this flag to apply a performance optimization\n * that makes the filtering experience smoother. We don't recommend enabling the feature if you\n * have less than 500 options, because the improvements to performance are offset by a\n * visible scrolling lag.\n *\n * When you set this flag to `true`, it removes options that are not currently in view from the DOM.\n * If your test accesses such options, you need to first scroll the options container\n * to the correct offset, before performing any operations on them. Use the element returned\n * by the `findOptionsContainer` test utility for this.\n */\n virtualScroll?: boolean;\n\n /**\n * Use this event to implement the asynchronous behavior for the component.\n *\n * The event is called in the following situations:\n * * The user scrolls to the end of the list of options, if `statusType` is set to `pending`.\n * * The user clicks on the recovery button in the error state.\n * * The user types inside the input field.\n * * The user focuses the input field.\n *\n * The detail object contains the following properties:\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n **/\n onLoadItems?: NonCancelableEventHandler<OptionsLoadItemsDetail>;\n}\n\nexport interface DropdownProps extends ExpandToViewport {\n /**\n * Trigger element.\n */\n trigger: React.ReactNode;\n /**\n * \"Sticky\" header of the dropdown content\n */\n header?: React.ReactNode;\n /**\n * Footer slot fixed at the bottom of the dropdown\n */\n footer?: React.ReactNode;\n /**\n * Dropdown content elements.\n */\n children?: React.ReactNode;\n /**\n * Updating content key triggers dropdown position re-evaluation.\n */\n contentKey?: string;\n /**\n * Open state of the dropdown.\n */\n open?: boolean;\n /**\n * Called when a user clicks outside of the dropdown content, when it is open.\n */\n onDropdownClose?: NonCancelableEventHandler<null>;\n /**\n * Called when a mouse button is pressed inside the dropdown content.\n */\n onMouseDown?: React.MouseEventHandler;\n /**\n * Dropdown id\n */\n dropdownId?: string;\n /**\n * Stretches dropdown to occupy entire width.\n */\n stretchWidth?: boolean;\n /**\n * Stretches dropdown to occupy entire height.\n */\n stretchHeight?: boolean;\n\n /**\n * Stretches the trigger to the height of the dropdown container.\n */\n stretchTriggerHeight?: boolean;\n\n /**\n * Whether the dropdown content should be at least as wide as the trigger.\n *\n * @defaultValue true\n */\n stretchToTriggerWidth?: boolean;\n\n /**\n * Determines that the dropdown should preferably be aligned to the center of the trigger\n * instead of dropping left or right.\n */\n preferCenter?: boolean;\n\n /**\n * Indicates if this dropdown lies within a parent dropdown and positions itself relative to it (as a fly out).\n */\n interior?: boolean;\n /**\n * Sets the min width of the dropdown (in px)\n */\n minWidth?: number;\n /**\n * Whether the dropdown will have a scrollbar or not\n */\n scrollable?: boolean;\n /**\n * Whether the dropdown will have a focus
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { NonCancelableEventHandler } from '../../events';\nimport React from 'react';\n\nexport type OptionsFilteringType = 'none' | 'auto' | 'manual';\nexport interface OptionsLoadItemsDetail {\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n}\n\nexport interface BaseDropdownHostProps extends ExpandToViewport {\n /**\n * If you have more than 500 options, enable this flag to apply a performance optimization\n * that makes the filtering experience smoother. We don't recommend enabling the feature if you\n * have less than 500 options, because the improvements to performance are offset by a\n * visible scrolling lag.\n *\n * When you set this flag to `true`, it removes options that are not currently in view from the DOM.\n * If your test accesses such options, you need to first scroll the options container\n * to the correct offset, before performing any operations on them. Use the element returned\n * by the `findOptionsContainer` test utility for this.\n */\n virtualScroll?: boolean;\n\n /**\n * Use this event to implement the asynchronous behavior for the component.\n *\n * The event is called in the following situations:\n * * The user scrolls to the end of the list of options, if `statusType` is set to `pending`.\n * * The user clicks on the recovery button in the error state.\n * * The user types inside the input field.\n * * The user focuses the input field.\n *\n * The detail object contains the following properties:\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n **/\n onLoadItems?: NonCancelableEventHandler<OptionsLoadItemsDetail>;\n}\n\nexport interface DropdownProps extends ExpandToViewport {\n /**\n * Trigger element.\n */\n trigger: React.ReactNode;\n /**\n * \"Sticky\" header of the dropdown content\n */\n header?: React.ReactNode;\n /**\n * Footer slot fixed at the bottom of the dropdown\n */\n footer?: React.ReactNode;\n /**\n * Dropdown content elements.\n */\n children?: React.ReactNode;\n /**\n * Updating content key triggers dropdown position re-evaluation.\n */\n contentKey?: string;\n /**\n * Open state of the dropdown.\n */\n open?: boolean;\n /**\n * Called when a user clicks outside of the dropdown content, when it is open.\n */\n onDropdownClose?: NonCancelableEventHandler<null>;\n /**\n * Called when a mouse button is pressed inside the dropdown content.\n */\n onMouseDown?: React.MouseEventHandler;\n /**\n * Dropdown id\n */\n dropdownId?: string;\n /**\n * Stretches dropdown to occupy entire width.\n */\n stretchWidth?: boolean;\n /**\n * Stretches dropdown to occupy entire height.\n */\n stretchHeight?: boolean;\n\n /**\n * Stretches the trigger to the height of the dropdown container.\n */\n stretchTriggerHeight?: boolean;\n\n /**\n * Whether the dropdown content should be at least as wide as the trigger.\n *\n * @defaultValue true\n */\n stretchToTriggerWidth?: boolean;\n\n /**\n * Determines that the dropdown should preferably be aligned to the center of the trigger\n * instead of dropping left or right.\n */\n preferCenter?: boolean;\n\n /**\n * Indicates if this dropdown lies within a parent dropdown and positions itself relative to it (as a fly out).\n */\n interior?: boolean;\n /**\n * Sets the min width of the dropdown (in px)\n */\n minWidth?: number;\n /**\n * Whether the dropdown will have a scrollbar or not\n */\n scrollable?: boolean;\n\n /**\n * Whether the dropdown will have a focus loop including trigger, header, content and footer.\n */\n loopFocus?: boolean;\n\n /**\n * Called when focus enters the trigger or dropdown content.\n */\n onFocus?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when focus leaves the trigger or dropdown content.\n */\n onBlur?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n}\n\nexport interface ExpandToViewport {\n /**\n * Enabling this property will allow the dropdown to extend beyond its parent by using fixed positioning and\n * [React Portals](https://reactjs.org/docs/portals.html).\n * If you want the dropdown to ignore the `overflow` CSS property of its parents,\n * such as in a split view layout, enable this property.\n * However, use discretion. If you don't need to, we recommend you don't enable this property because fixed positioning results\n * in a slight, visible lag when scrolling complex pages.\n */\n expandToViewport?: boolean;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { RecoveryLinkProps } from '../../../select/utils/use-select';
|
|
3
3
|
import { NonCancelableEventHandler } from '../../events';
|
|
4
4
|
import { DropdownStatusProps } from './interfaces';
|
|
5
5
|
export { DropdownStatusProps };
|
|
@@ -14,7 +14,7 @@ export interface DropdownStatusPropsExtended extends DropdownStatusProps {
|
|
|
14
14
|
* to recover from the error.
|
|
15
15
|
*/
|
|
16
16
|
onRecoveryClick?: NonCancelableEventHandler;
|
|
17
|
-
recoveryProps?:
|
|
17
|
+
recoveryProps?: RecoveryLinkProps;
|
|
18
18
|
}
|
|
19
19
|
declare function DropdownStatus({ children }: {
|
|
20
20
|
children: React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown-status/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAGtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown-status/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAGtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,EAAE,yBAAyB,EAA0B,MAAM,cAAc,CAAC;AAGjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,iBAAS,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,eAMlE;AAED,aAAK,iBAAiB,GAAG,CAAC,EACxB,UAAU,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,OAAO,EACP,SAAS,EACT,OAAO,EACP,eAAe,EACf,aAAa,GACd,EAAE,2BAA2B,KAAK,oBAAoB,CAAC;AAExD,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAChC,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,eAAO,MAAM,iBAAiB,EAAE,iBA+C/B,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
3
|
import React, { useRef } from 'react';
|
|
5
4
|
import InternalLink from '../../../link/internal';
|
|
6
5
|
import InternalStatusIndicator from '../../../status-indicator/internal';
|
|
7
|
-
import { fireNonCancelableEvent
|
|
6
|
+
import { fireNonCancelableEvent } from '../../events';
|
|
8
7
|
import { usePrevious } from '../../hooks/use-previous';
|
|
9
8
|
import styles from './styles.css.js';
|
|
10
9
|
function DropdownStatus(_a) {
|
|
@@ -12,7 +11,7 @@ function DropdownStatus(_a) {
|
|
|
12
11
|
return (React.createElement("div", { className: styles.root, "aria-live": "polite" }, children));
|
|
13
12
|
}
|
|
14
13
|
export var useDropdownStatus = function (_a) {
|
|
15
|
-
var statusType = _a.statusType, empty = _a.empty, loadingText = _a.loadingText, finishedText = _a.finishedText, errorText = _a.errorText, recoveryText = _a.recoveryText, isEmpty = _a.isEmpty, isNoMatch = _a.isNoMatch, noMatch = _a.noMatch, onRecoveryClick = _a.onRecoveryClick
|
|
14
|
+
var statusType = _a.statusType, empty = _a.empty, loadingText = _a.loadingText, finishedText = _a.finishedText, errorText = _a.errorText, recoveryText = _a.recoveryText, isEmpty = _a.isEmpty, isNoMatch = _a.isNoMatch, noMatch = _a.noMatch, onRecoveryClick = _a.onRecoveryClick;
|
|
16
15
|
var linkRef = useRef(null);
|
|
17
16
|
var focusRecoveryLink = function () { var _a; return (_a = linkRef.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
18
17
|
var previousStatusType = usePrevious(statusType);
|
|
@@ -21,10 +20,10 @@ export var useDropdownStatus = function (_a) {
|
|
|
21
20
|
statusResult.content = React.createElement(InternalStatusIndicator, { type: 'loading' }, loadingText);
|
|
22
21
|
}
|
|
23
22
|
else if (statusType === 'error') {
|
|
24
|
-
statusResult.content = (React.createElement("span",
|
|
23
|
+
statusResult.content = (React.createElement("span", null,
|
|
25
24
|
React.createElement(InternalStatusIndicator, { type: "error", __animate: previousStatusType !== 'error' }, errorText),
|
|
26
25
|
' ',
|
|
27
|
-
recoveryText && (React.createElement(InternalLink,
|
|
26
|
+
recoveryText && (React.createElement(InternalLink, { ref: linkRef, onFollow: function () { return fireNonCancelableEvent(onRecoveryClick); }, variant: "recovery", className: styles.recovery }, recoveryText))));
|
|
28
27
|
}
|
|
29
28
|
else if (isEmpty && empty) {
|
|
30
29
|
statusResult.content = empty;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown-status/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown-status/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,YAAY,MAAM,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AC,GAAG;YAC7B,YAAY,IAAI,CACf,oBAAC,YAAY,IACX,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,cAAM,OAAA,sBAAsB,CAAC,eAAe,CAAC,EAAvC,CAAuC,EACvD,OAAO,EAAC,UAAU,EAClB,SAAS,EAAE,MAAM,CAAC,QAAQ,IAEzB,YAAY,CACA,CAChB,CACI,CACR,CAAC;KACH;SAAM,IAAI,OAAO,IAAI,KAAK,EAAE;QAC3B,YAAY,CAAC,OAAO,GAAG,KAAK,CAAC;KAC9B;SAAM,IAAI,SAAS,IAAI,OAAO,EAAE;QAC/B,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC;KAChC;SAAM,IAAI,UAAU,KAAK,UAAU,IAAI,YAAY,EAAE;QACpD,YAAY,CAAC,OAAO,GAAG,YAAY,CAAC;QACpC,YAAY,CAAC,QAAQ,GAAG,KAAK,CAAC;KAC/B;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport { LinkProps } from '../../../link/interfaces';\nimport InternalLink from '../../../link/internal';\nimport { RecoveryLinkProps } from '../../../select/utils/use-select';\n\nimport InternalStatusIndicator from '../../../status-indicator/internal';\nimport { NonCancelableEventHandler, fireNonCancelableEvent } from '../../events';\nimport { usePrevious } from '../../hooks/use-previous';\n\nimport { DropdownStatusProps } from './interfaces';\nimport styles from './styles.css.js';\n\nexport { DropdownStatusProps };\n\nexport interface DropdownStatusPropsExtended extends DropdownStatusProps {\n isEmpty?: boolean;\n isNoMatch?: boolean;\n noMatch?: React.ReactNode;\n /**\n * Called when the user clicks the recovery button placed at the\n * bottom of the dropdown list in the error state. Use this to\n * retry a failed request or provide another option for the user\n * to recover from the error.\n */\n onRecoveryClick?: NonCancelableEventHandler;\n recoveryProps?: RecoveryLinkProps;\n}\n\nfunction DropdownStatus({ children }: { children: React.ReactNode }) {\n return (\n <div className={styles.root} aria-live=\"polite\">\n {children}\n </div>\n );\n}\n\ntype UseDropdownStatus = ({\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n recoveryText,\n isEmpty,\n isNoMatch,\n noMatch,\n onRecoveryClick,\n recoveryProps,\n}: DropdownStatusPropsExtended) => DropdownStatusResult;\n\ninterface DropdownStatusResult {\n isSticky: boolean;\n content: React.ReactNode | null;\n focusRecoveryLink: () => void;\n}\n\nexport const useDropdownStatus: UseDropdownStatus = ({\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n recoveryText,\n isEmpty,\n isNoMatch,\n noMatch,\n onRecoveryClick,\n}) => {\n const linkRef = useRef<LinkProps.Ref | null>(null);\n const focusRecoveryLink = () => linkRef.current?.focus();\n const previousStatusType = usePrevious(statusType);\n const statusResult: DropdownStatusResult = { isSticky: true, content: null, focusRecoveryLink };\n\n if (statusType === 'loading') {\n statusResult.content = <InternalStatusIndicator type={'loading'}>{loadingText}</InternalStatusIndicator>;\n } else if (statusType === 'error') {\n statusResult.content = (\n <span>\n <InternalStatusIndicator type=\"error\" __animate={previousStatusType !== 'error'}>\n {errorText}\n </InternalStatusIndicator>{' '}\n {recoveryText && (\n <InternalLink\n ref={linkRef}\n onFollow={() => fireNonCancelableEvent(onRecoveryClick)}\n variant=\"recovery\"\n className={styles.recovery}\n >\n {recoveryText}\n </InternalLink>\n )}\n </span>\n );\n } else if (isEmpty && empty) {\n statusResult.content = empty;\n } else if (isNoMatch && noMatch) {\n statusResult.content = noMatch;\n } else if (statusType === 'finished' && finishedText) {\n statusResult.content = finishedText;\n statusResult.isSticky = false;\n }\n\n return statusResult;\n};\n\nexport default DropdownStatus;\n"]}
|
package/internal/environment.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-container.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/chart-container.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA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@@ export default function ChartContainer(_a) {
|
|
|
180
180
|
showPopover();
|
|
181
181
|
}
|
|
182
182
|
}, [highlightedX, showPopover]);
|
|
183
|
-
var onSVGMouseDown = function () {
|
|
183
|
+
var onSVGMouseDown = function (e) {
|
|
184
184
|
if (isPopoverOpen) {
|
|
185
185
|
if (isPopoverPinned) {
|
|
186
186
|
dismissPopover();
|
|
187
187
|
}
|
|
188
188
|
else {
|
|
189
189
|
pinPopover();
|
|
190
|
+
e.preventDefault();
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-container.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/chart-container.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElG,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AACxH,OAAO,SAA2B,MAAM,mCAAmC,CAAC;AAC5E,OAAO,SAAS,MAAM,mDAAmD,CAAC;AAC1E,OAAO,aAAa,MAAM,uDAAuD,CAAC;AAClF,OAAO,UAAU,MAAM,oDAAoD,CAAC;AAC5E,OAAO,YAAY,MAAM,sDAAsD,CAAC;AAChF,OAAO,iBAAiB,MAAM,4DAA4D,CAAC;AAC3F,OAAO,kBAAkB,MAAM,4DAA4D,CAAC;AAC5F,OAAO,gBAAgB,MAAM,0DAA0D,CAAC;AACxF,OAAO,cAAc,MAAM,wDAAwD,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAC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B,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,EACpB,qBAAqB,EAAE,qBAAqB,EAC5C,mBAAmB,EAAE,mBAAmB,GACxC,CACH;oBAED,oBAAC,YAAY,IACX,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAClB,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAClB,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAkB,EACnD,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAClB,mBAAmB,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAC9C,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,eAAe,GAAG,oBAAoB,EAClD,WAAW,EAAE,oBAAoB,EACjC,UAAU,EAAE,qBAAqB,GACjC,CACQ;gBAEZ,oBAAC,SAAS,IAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAI,CACxD;YAEN,oBAAC,YAAY,IACX,YAAY,EAAE,kBAAkB,EAChC,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,eAAe,EACzB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,gBAAgB,EAC3B,IAAI,EAAE,iBAAiB,EACvB,gBAAgB,EAAE,WAAW,CAAC,6BAA6B,GAC3D,CACE,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, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\n\nimport { nodeContains } from '../internal/utils/dom';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport { getXTickCount, getYTickCount, createXTicks, createYTicks } from '../internal/components/cartesian-chart/ticks';\nimport ChartPlot, { ChartPlotRef } from '../internal/components/chart-plot';\nimport AxisLabel from '../internal/components/cartesian-chart/axis-label';\nimport LabelsMeasure from '../internal/components/cartesian-chart/labels-measure';\nimport LeftLabels from '../internal/components/cartesian-chart/left-labels';\nimport BottomLabels from '../internal/components/cartesian-chart/bottom-labels';\nimport VerticalGridLines from '../internal/components/cartesian-chart/vertical-grid-lines';\nimport EmphasizedBaseline from '../internal/components/cartesian-chart/emphasized-baseline';\nimport HighlightedPoint from '../internal/components/cartesian-chart/highlighted-point';\nimport VerticalMarker from '../internal/components/cartesian-chart/vertical-marker';\nimport { ChartScale, NumericChartScale } from '../internal/components/cartesian-chart/scales';\nimport ChartPopover from './chart-popover';\nimport { ChartDataTypes, InternalChartSeries, MixedLineBarChartProps, ScaleType } from './interfaces';\nimport { computeDomainX, computeDomainY } from './domain';\nimport { isXThreshold } from './utils';\nimport makeScaledSeries, { ScaledPoint } from './make-scaled-series';\nimport makeScaledBarGroups, { ScaledBarGroup } from './make-scaled-bar-groups';\nimport formatHighlighted from './format-highlighted';\nimport DataSeries from './data-series';\nimport BarGroups from './bar-groups';\nimport { useMouseHover } from './hooks/use-mouse-hover';\nimport { useNavigation } from './hooks/use-navigation';\nimport { usePopover } from './hooks/use-popover';\n\nimport styles from './styles.css.js';\nimport { CartesianChartProps } from '../internal/components/cartesian-chart/interfaces';\nimport useContainerWidth from '../internal/utils/use-container-width';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nconst LEFT_LABELS_MARGIN = 16;\nconst BOTTOM_LABELS_OFFSET = 12;\n\ntype TickFormatter = undefined | ((value: ChartDataTypes) => string);\n\nexport interface ChartContainerProps<T extends ChartDataTypes> {\n series: ReadonlyArray<InternalChartSeries<T>>;\n visibleSeries: ReadonlyArray<InternalChartSeries<T>>;\n\n height: number;\n detailPopoverSize: MixedLineBarChartProps<T>['detailPopoverSize'];\n\n xScaleType: ScaleType;\n yScaleType: 'linear' | 'log';\n\n xDomain: MixedLineBarChartProps<T>['xDomain'];\n yDomain: MixedLineBarChartProps<T>['yDomain'];\n\n xTickFormatter?: CartesianChartProps.TickFormatter<T>;\n yTickFormatter?: CartesianChartProps.TickFormatter<number>;\n\n xTitle?: string;\n yTitle?: string;\n\n stackedBars?: boolean;\n emphasizeBaselineAxis: boolean;\n horizontalBars?: boolean;\n\n highlightedSeries?: MixedLineBarChartProps<T>['highlightedSeries'];\n onHighlightChange: (series: InternalChartSeries<T>['series'] | null) => void;\n highlightedPoint: ScaledPoint<T> | null;\n setHighlightedPoint: (point: ScaledPoint<T> | null) => void;\n highlightedGroupIndex: number | null;\n setHighlightedGroupIndex: (groupIndex: number | null) => void;\n legendSeries: null | MixedLineBarChartProps.ChartSeries<T>;\n\n ariaLabel: MixedLineBarChartProps<T>['ariaLabel'];\n ariaLabelledby: MixedLineBarChartProps<T>['ariaLabelledby'];\n ariaDescription: MixedLineBarChartProps<T>['ariaDescription'];\n i18nStrings: MixedLineBarChartProps<T>['i18nStrings'];\n\n plotContainerRef: React.RefObject<HTMLDivElement>;\n}\n\nexport default function ChartContainer<T extends ChartDataTypes>({\n height: plotHeight,\n series,\n visibleSeries,\n highlightedSeries,\n onHighlightChange,\n highlightedPoint,\n setHighlightedPoint,\n highlightedGroupIndex,\n setHighlightedGroupIndex,\n legendSeries,\n detailPopoverSize = 'medium',\n stackedBars = false,\n horizontalBars = false,\n xScaleType,\n yScaleType,\n xTickFormatter,\n yTickFormatter,\n emphasizeBaselineAxis,\n xTitle,\n yTitle,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n i18nStrings = {},\n plotContainerRef,\n ...props\n}: ChartContainerProps<T>) {\n const plotRef = useRef<ChartPlotRef>(null);\n const verticalMarkerRef = useRef<SVGLineElement>(null);\n\n const [leftLabelsWidth, setLeftLabelsWidth] = useState(0);\n const [bottomLabelsHeight, setBottomLabelsHeight] = useState(0);\n const [containerWidth, containerMeasureRef] = useContainerWidth(500);\n const plotWidth = containerWidth ? containerWidth - leftLabelsWidth - LEFT_LABELS_MARGIN : 500;\n const containerRefObject = useRef(null);\n const containerRef = useMergeRefs(containerMeasureRef, containerRefObject);\n\n const isRefresh = useVisualRefresh();\n\n const linesOnly = series.every(({ series }) => series.type === 'line' || series.type === 'threshold');\n\n const xDomain = (props.xDomain || computeDomainX(series, xScaleType)) as\n | readonly number[]\n | readonly string[]\n | readonly Date[];\n const yDomain = (props.yDomain || computeDomainY(series, yScaleType, stackedBars)) as readonly number[];\n\n const xTickCount = getXTickCount(plotWidth);\n const yTickCount = getYTickCount(plotHeight);\n\n const rangeBottomTop: [number, number] = [0, plotHeight];\n const rangeTopBottom: [number, number] = [plotHeight, 0];\n const rangeLeftRight: [number, number] = [0, plotWidth];\n const xScale = new ChartScale(xScaleType, xDomain, horizontalBars ? rangeBottomTop : rangeLeftRight, linesOnly);\n const yScale = new NumericChartScale(\n yScaleType,\n yDomain,\n horizontalBars ? rangeLeftRight : rangeTopBottom,\n props.yDomain ? null : yTickCount\n );\n\n const xTicks = createXTicks(xScale, xTickCount);\n const yTicks = createYTicks(yScale, yTickCount);\n\n /**\n * Interactions\n */\n const highlightedPointRef = useRef<SVGGElement>(null);\n const highlightedGroupRef = useRef<SVGRectElement>(null);\n const [isPlotFocused, setPlotFocused] = useState(false);\n\n // Some chart components are rendered against \"x\" or \"y\" axes,\n // When \"horizontalBars\" is enabled, the axes are inverted.\n const x = !horizontalBars ? 'x' : 'y';\n const y = !horizontalBars ? 'y' : 'x';\n const xy = {\n ticks: { x: xTicks, y: yTicks },\n scale: { x: xScale, y: yScale },\n tickFormatter: { x: xTickFormatter, y: yTickFormatter },\n title: { x: xTitle, y: yTitle },\n ariaRoleDescription: { x: i18nStrings.xAxisAriaRoleDescription, y: i18nStrings.yAxisAriaRoleDescription },\n };\n\n const scaledSeries = makeScaledSeries(visibleSeries, xScale, yScale);\n const barGroups: ScaledBarGroup<T>[] = makeScaledBarGroups(visibleSeries, xScale, plotWidth, plotHeight, y);\n\n const { isPopoverOpen, isPopoverPinned, showPopover, pinPopover, dismissPopover } = usePopover();\n\n // Allows to add a delay between popover is dismissed and handlers are enabled to prevent immediate popover reopening.\n const [isHandlersDisabled, setHandlersDisabled] = useState(!isPopoverPinned);\n useEffect(() => {\n if (isPopoverPinned) {\n setHandlersDisabled(true);\n } else {\n const timeoutId = setTimeout(() => setHandlersDisabled(false), 25);\n return () => clearTimeout(timeoutId);\n }\n }, [isPopoverPinned]);\n\n // Highlighted point and highlighted series must be in sync.\n // TODO: refactor the code so that it is not possible to make series and point highlight out of sync.\n const highlightPoint = useCallback(\n (point: ScaledPoint<T> | null) => {\n setHighlightedGroupIndex(null);\n setHighlightedPoint(point);\n },\n [setHighlightedPoint, setHighlightedGroupIndex]\n );\n\n const highlightSeries = useCallback(\n (series: MixedLineBarChartProps.ChartSeries<T> | null) => {\n if (series !== highlightedSeries) {\n onHighlightChange(series);\n }\n },\n [highlightedSeries, onHighlightChange]\n );\n\n const highlightGroup = useCallback(\n (groupIndex: number) => {\n highlightSeries(null);\n setHighlightedPoint(null);\n setHighlightedGroupIndex(groupIndex);\n },\n [highlightSeries, setHighlightedPoint, setHighlightedGroupIndex]\n );\n\n const clearHighlightedSeries = useCallback(() => {\n highlightSeries(null);\n setHighlightedGroupIndex(null);\n setHighlightedPoint(null);\n dismissPopover();\n }, [dismissPopover, highlightSeries, setHighlightedGroupIndex, setHighlightedPoint]);\n\n const { isGroupNavigation, ...handlers } = useNavigation({\n series,\n visibleSeries,\n scaledSeries,\n barGroups,\n xScale,\n yScale,\n highlightedPoint,\n highlightedGroupIndex,\n highlightedSeries,\n legendSeries,\n isHandlersDisabled,\n pinPopover,\n highlightSeries,\n highlightGroup,\n highlightPoint,\n clearHighlightedSeries,\n });\n\n const { onSVGMouseMove, onSVGMouseOut, verticalMarkerLeft } = useMouseHover<T>({\n scaledSeries,\n barGroups,\n plotRef,\n highlightSeries,\n highlightPoint,\n highlightGroup,\n clearHighlightedSeries,\n isGroupNavigation,\n isHandlersDisabled,\n });\n\n // There are multiple ways to indicate what X is selected.\n // TODO: make a uniform verticalMarkerX state to fit all use-cases.\n const highlightedX = useMemo(() => {\n if (highlightedGroupIndex !== null) {\n return barGroups[highlightedGroupIndex].x;\n }\n if (verticalMarkerLeft !== null) {\n for (const series of scaledSeries) {\n if (series.x === verticalMarkerLeft) {\n return series.datum?.x ?? null;\n }\n }\n }\n if (highlightedPoint !== null) {\n return highlightedPoint?.datum?.x ?? null;\n }\n return null;\n }, [highlightedPoint, verticalMarkerLeft, highlightedGroupIndex, scaledSeries, barGroups]);\n\n const onPopoverDismiss = (outsideClick?: boolean) => {\n dismissPopover();\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 if (highlightedPoint || highlightedGroupIndex !== null) {\n plotRef.current?.focusApplication();\n } else {\n plotRef.current?.focusPlot();\n }\n }, 0);\n }\n };\n\n useLayoutEffect(() => {\n if (highlightedX !== null) {\n showPopover();\n }\n }, [highlightedX, showPopover]);\n\n const onSVGMouseDown = () => {\n if (isPopoverOpen) {\n if (isPopoverPinned) {\n dismissPopover();\n } else {\n pinPopover();\n }\n } else {\n showPopover();\n }\n };\n\n const onSVGFocus = (event: React.FocusEvent, trigger: 'mouse' | 'keyboard') => {\n setPlotFocused(true);\n if (trigger === 'keyboard') {\n handlers.onFocus();\n } else {\n // noop: clicks are handled separately\n }\n };\n\n const onSVGBlur = (event: React.FocusEvent<Element>) => {\n setPlotFocused(false);\n const blurTarget = event.relatedTarget || event.target;\n if (\n blurTarget === null ||\n !(blurTarget instanceof Element) ||\n !nodeContains(containerRefObject.current, blurTarget)\n ) {\n setHighlightedPoint(null);\n if (!plotContainerRef?.current?.contains(blurTarget)) {\n clearHighlightedSeries();\n }\n\n if (isPopoverOpen && !isPopoverPinned) {\n dismissPopover();\n }\n }\n };\n\n const onSVGKeyDown = handlers.onKeyDown;\n\n const xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;\n\n let verticalLineX: number | null = null;\n if (verticalMarkerLeft !== null) {\n verticalLineX = verticalMarkerLeft;\n } else if (isGroupNavigation && highlightedGroupIndex !== null) {\n const x = xScale.d3Scale(barGroups[highlightedGroupIndex].x as any) ?? null;\n if (x !== null) {\n verticalLineX = xOffset + x;\n }\n }\n\n const point = useMemo(\n () =>\n highlightedPoint\n ? {\n key: `${highlightedPoint.x}-${highlightedPoint.y}`,\n x: highlightedPoint.x,\n y: highlightedPoint.y,\n color: highlightedPoint.color,\n }\n : null,\n [highlightedPoint]\n );\n\n const verticalMarkers = useMemo(\n () =>\n verticalLineX !== null\n ? scaledSeries\n .filter(({ x, y }) => (x === verticalLineX || isNaN(x)) && !isNaN(y))\n .map(({ x, y, color }, index) => ({\n key: `${index}-${x}-${y}`,\n x: !horizontalBars ? verticalLineX || 0 : y,\n y: !horizontalBars ? y : verticalLineX || 0,\n color: color,\n }))\n : [],\n [scaledSeries, verticalLineX, horizontalBars]\n );\n\n const popoverTrackRef = isGroupNavigation\n ? highlightedGroupRef\n : highlightedPoint\n ? highlightedPointRef\n : verticalMarkerRef;\n\n const highlightDetails = useMemo(() => {\n if (highlightedX === null) {\n return null;\n }\n\n // When series point is highlighted show the corresponding series and matching x-thresholds.\n if (highlightedPoint) {\n const seriesToShow = visibleSeries.filter(\n series => series.series === highlightedPoint?.series || isXThreshold(series.series)\n );\n return formatHighlighted(highlightedX, seriesToShow, xTickFormatter);\n }\n\n // Otherwise - show all visible series details.\n return formatHighlighted(highlightedX, visibleSeries, xTickFormatter);\n }, [highlightedX, highlightedPoint, visibleSeries, xTickFormatter]);\n\n const activeAriaLabel = useMemo(\n () =>\n highlightDetails\n ? `${highlightDetails.position}, ${highlightDetails.details.map(d => d.key + ' ' + d.value).join(',')}`\n : '',\n [highlightDetails]\n );\n\n // Live region is used when nothing is focused e.g. when hovering.\n const activeLiveRegion =\n activeAriaLabel && !highlightedPoint && highlightedGroupIndex === null ? activeAriaLabel : '';\n\n return (\n <div className={styles['chart-container']} ref={containerRef}>\n <AxisLabel axis={y} position=\"left\" title={xy.title[y]} />\n <div className={styles['chart-container__horizontal']}>\n <LabelsMeasure\n ticks={xy.ticks[y]}\n scale={xy.scale[y]}\n tickFormatter={xy.tickFormatter[y] as TickFormatter}\n autoWidth={setLeftLabelsWidth}\n />\n\n <div className={styles['chart-container__vertical']}>\n <ChartPlot\n ref={plotRef}\n width={plotWidth}\n height={plotHeight}\n offsetBottom={bottomLabelsHeight}\n isClickable={isPopoverOpen && !isPopoverPinned}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaRoleDescription={i18nStrings?.chartAriaRoleDescription}\n ariaLiveRegion={activeLiveRegion}\n activeElementRef={isGroupNavigation ? highlightedGroupRef : highlightedPointRef}\n activeElementKey={isPlotFocused && (highlightedGroupIndex?.toString() || point?.key)}\n activeElementFocusOffset={isGroupNavigation ? 0 : 3}\n onMouseMove={onSVGMouseMove}\n onMouseOut={onSVGMouseOut}\n onMouseDown={onSVGMouseDown}\n onFocus={onSVGFocus}\n onBlur={onSVGBlur}\n onKeyDown={onSVGKeyDown}\n >\n <LeftLabels\n axis={y}\n ticks={xy.ticks[y]}\n scale={xy.scale[y]}\n tickFormatter={xy.tickFormatter[y] as TickFormatter}\n title={xy.title[y]}\n ariaRoleDescription={xy.ariaRoleDescription[y]}\n width={plotWidth}\n height={plotHeight}\n />\n\n {horizontalBars && <VerticalGridLines scale={yScale} ticks={yTicks} height={plotHeight} />}\n\n {emphasizeBaselineAxis && linesOnly && (\n <EmphasizedBaseline axis={x} scale={yScale} width={plotWidth} height={plotHeight} />\n )}\n\n <DataSeries\n axis={x}\n plotWidth={plotWidth}\n plotHeight={plotHeight}\n highlightedSeries={highlightedSeries ?? null}\n highlightedGroupIndex={highlightedGroupIndex}\n stackedBars={stackedBars}\n isGroupNavigation={isGroupNavigation}\n visibleSeries={visibleSeries}\n xScale={xScale}\n yScale={yScale}\n />\n\n {emphasizeBaselineAxis && !linesOnly && (\n <EmphasizedBaseline axis={x} scale={yScale} width={plotWidth} height={plotHeight} />\n )}\n\n <VerticalMarker\n key={verticalLineX || ''}\n height={plotHeight}\n showPoints={highlightedPoint === null}\n showLine={!isGroupNavigation}\n points={verticalMarkers}\n ref={verticalMarkerRef}\n />\n\n {highlightedPoint && (\n <HighlightedPoint\n ref={highlightedPointRef}\n point={point}\n role=\"button\"\n ariaLabel={activeAriaLabel}\n ariaHasPopup={true}\n ariaExpanded={isPopoverPinned}\n />\n )}\n\n {isGroupNavigation && xScale.isCategorical() && (\n <BarGroups\n ariaLabel={activeAriaLabel}\n isRefresh={isRefresh}\n isPopoverPinned={isPopoverPinned}\n barGroups={barGroups}\n highlightedGroupIndex={highlightedGroupIndex}\n highlightedGroupRef={highlightedGroupRef}\n />\n )}\n\n <BottomLabels\n axis={x}\n ticks={xy.ticks[x]}\n scale={xy.scale[x]}\n tickFormatter={xy.tickFormatter[x] as TickFormatter}\n title={xy.title[x]}\n ariaRoleDescription={xy.ariaRoleDescription[x]}\n height={plotHeight}\n width={plotWidth}\n offsetLeft={leftLabelsWidth + BOTTOM_LABELS_OFFSET}\n offsetRight={BOTTOM_LABELS_OFFSET}\n autoHeight={setBottomLabelsHeight}\n />\n </ChartPlot>\n\n <AxisLabel axis={x} position=\"bottom\" title={xy.title[x]} />\n </div>\n\n <ChartPopover\n containerRef={containerRefObject}\n trackRef={popoverTrackRef}\n isOpen={isPopoverOpen}\n isPinned={isPopoverPinned}\n highlightDetails={highlightDetails}\n onDismiss={onPopoverDismiss}\n size={detailPopoverSize}\n dismissAriaLabel={i18nStrings.detailPopoverDismissAriaLabel}\n />\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chart-container.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/chart-container.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE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EAAE,SAAS,EAChB,UAAU,EAAE,eAAe,GAAG,oBAAoB,EAClD,WAAW,EAAE,oBAAoB,EACjC,UAAU,EAAE,qBAAqB,GACjC,CACQ;gBAEZ,oBAAC,SAAS,IAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAI,CACxD;YAEN,oBAAC,YAAY,IACX,YAAY,EAAE,kBAAkB,EAChC,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,eAAe,EACzB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,gBAAgB,EAC3B,IAAI,EAAE,iBAAiB,EACvB,gBAAgB,EAAE,WAAW,CAAC,6BAA6B,GAC3D,CACE,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, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\n\nimport { nodeContains } from '../internal/utils/dom';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport { getXTickCount, getYTickCount, createXTicks, createYTicks } from '../internal/components/cartesian-chart/ticks';\nimport ChartPlot, { ChartPlotRef } from '../internal/components/chart-plot';\nimport AxisLabel from '../internal/components/cartesian-chart/axis-label';\nimport LabelsMeasure from '../internal/components/cartesian-chart/labels-measure';\nimport LeftLabels from '../internal/components/cartesian-chart/left-labels';\nimport BottomLabels from '../internal/components/cartesian-chart/bottom-labels';\nimport VerticalGridLines from '../internal/components/cartesian-chart/vertical-grid-lines';\nimport EmphasizedBaseline from '../internal/components/cartesian-chart/emphasized-baseline';\nimport HighlightedPoint from '../internal/components/cartesian-chart/highlighted-point';\nimport VerticalMarker from '../internal/components/cartesian-chart/vertical-marker';\nimport { ChartScale, NumericChartScale } from '../internal/components/cartesian-chart/scales';\nimport ChartPopover from './chart-popover';\nimport { ChartDataTypes, InternalChartSeries, MixedLineBarChartProps, ScaleType } from './interfaces';\nimport { computeDomainX, computeDomainY } from './domain';\nimport { isXThreshold } from './utils';\nimport makeScaledSeries, { ScaledPoint } from './make-scaled-series';\nimport makeScaledBarGroups, { ScaledBarGroup } from './make-scaled-bar-groups';\nimport formatHighlighted from './format-highlighted';\nimport DataSeries from './data-series';\nimport BarGroups from './bar-groups';\nimport { useMouseHover } from './hooks/use-mouse-hover';\nimport { useNavigation } from './hooks/use-navigation';\nimport { usePopover } from './hooks/use-popover';\n\nimport styles from './styles.css.js';\nimport { CartesianChartProps } from '../internal/components/cartesian-chart/interfaces';\nimport useContainerWidth from '../internal/utils/use-container-width';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nconst LEFT_LABELS_MARGIN = 16;\nconst BOTTOM_LABELS_OFFSET = 12;\n\ntype TickFormatter = undefined | ((value: ChartDataTypes) => string);\n\nexport interface ChartContainerProps<T extends ChartDataTypes> {\n series: ReadonlyArray<InternalChartSeries<T>>;\n visibleSeries: ReadonlyArray<InternalChartSeries<T>>;\n\n height: number;\n detailPopoverSize: MixedLineBarChartProps<T>['detailPopoverSize'];\n\n xScaleType: ScaleType;\n yScaleType: 'linear' | 'log';\n\n xDomain: MixedLineBarChartProps<T>['xDomain'];\n yDomain: MixedLineBarChartProps<T>['yDomain'];\n\n xTickFormatter?: CartesianChartProps.TickFormatter<T>;\n yTickFormatter?: CartesianChartProps.TickFormatter<number>;\n\n xTitle?: string;\n yTitle?: string;\n\n stackedBars?: boolean;\n emphasizeBaselineAxis: boolean;\n horizontalBars?: boolean;\n\n highlightedSeries?: MixedLineBarChartProps<T>['highlightedSeries'];\n onHighlightChange: (series: InternalChartSeries<T>['series'] | null) => void;\n highlightedPoint: ScaledPoint<T> | null;\n setHighlightedPoint: (point: ScaledPoint<T> | null) => void;\n highlightedGroupIndex: number | null;\n setHighlightedGroupIndex: (groupIndex: number | null) => void;\n legendSeries: null | MixedLineBarChartProps.ChartSeries<T>;\n\n ariaLabel: MixedLineBarChartProps<T>['ariaLabel'];\n ariaLabelledby: MixedLineBarChartProps<T>['ariaLabelledby'];\n ariaDescription: MixedLineBarChartProps<T>['ariaDescription'];\n i18nStrings: MixedLineBarChartProps<T>['i18nStrings'];\n\n plotContainerRef: React.RefObject<HTMLDivElement>;\n}\n\nexport default function ChartContainer<T extends ChartDataTypes>({\n height: plotHeight,\n series,\n visibleSeries,\n highlightedSeries,\n onHighlightChange,\n highlightedPoint,\n setHighlightedPoint,\n highlightedGroupIndex,\n setHighlightedGroupIndex,\n legendSeries,\n detailPopoverSize = 'medium',\n stackedBars = false,\n horizontalBars = false,\n xScaleType,\n yScaleType,\n xTickFormatter,\n yTickFormatter,\n emphasizeBaselineAxis,\n xTitle,\n yTitle,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n i18nStrings = {},\n plotContainerRef,\n ...props\n}: ChartContainerProps<T>) {\n const plotRef = useRef<ChartPlotRef>(null);\n const verticalMarkerRef = useRef<SVGLineElement>(null);\n\n const [leftLabelsWidth, setLeftLabelsWidth] = useState(0);\n const [bottomLabelsHeight, setBottomLabelsHeight] = useState(0);\n const [containerWidth, containerMeasureRef] = useContainerWidth(500);\n const plotWidth = containerWidth ? containerWidth - leftLabelsWidth - LEFT_LABELS_MARGIN : 500;\n const containerRefObject = useRef(null);\n const containerRef = useMergeRefs(containerMeasureRef, containerRefObject);\n\n const isRefresh = useVisualRefresh();\n\n const linesOnly = series.every(({ series }) => series.type === 'line' || series.type === 'threshold');\n\n const xDomain = (props.xDomain || computeDomainX(series, xScaleType)) as\n | readonly number[]\n | readonly string[]\n | readonly Date[];\n const yDomain = (props.yDomain || computeDomainY(series, yScaleType, stackedBars)) as readonly number[];\n\n const xTickCount = getXTickCount(plotWidth);\n const yTickCount = getYTickCount(plotHeight);\n\n const rangeBottomTop: [number, number] = [0, plotHeight];\n const rangeTopBottom: [number, number] = [plotHeight, 0];\n const rangeLeftRight: [number, number] = [0, plotWidth];\n const xScale = new ChartScale(xScaleType, xDomain, horizontalBars ? rangeBottomTop : rangeLeftRight, linesOnly);\n const yScale = new NumericChartScale(\n yScaleType,\n yDomain,\n horizontalBars ? rangeLeftRight : rangeTopBottom,\n props.yDomain ? null : yTickCount\n );\n\n const xTicks = createXTicks(xScale, xTickCount);\n const yTicks = createYTicks(yScale, yTickCount);\n\n /**\n * Interactions\n */\n const highlightedPointRef = useRef<SVGGElement>(null);\n const highlightedGroupRef = useRef<SVGRectElement>(null);\n const [isPlotFocused, setPlotFocused] = useState(false);\n\n // Some chart components are rendered against \"x\" or \"y\" axes,\n // When \"horizontalBars\" is enabled, the axes are inverted.\n const x = !horizontalBars ? 'x' : 'y';\n const y = !horizontalBars ? 'y' : 'x';\n const xy = {\n ticks: { x: xTicks, y: yTicks },\n scale: { x: xScale, y: yScale },\n tickFormatter: { x: xTickFormatter, y: yTickFormatter },\n title: { x: xTitle, y: yTitle },\n ariaRoleDescription: { x: i18nStrings.xAxisAriaRoleDescription, y: i18nStrings.yAxisAriaRoleDescription },\n };\n\n const scaledSeries = makeScaledSeries(visibleSeries, xScale, yScale);\n const barGroups: ScaledBarGroup<T>[] = makeScaledBarGroups(visibleSeries, xScale, plotWidth, plotHeight, y);\n\n const { isPopoverOpen, isPopoverPinned, showPopover, pinPopover, dismissPopover } = usePopover();\n\n // Allows to add a delay between popover is dismissed and handlers are enabled to prevent immediate popover reopening.\n const [isHandlersDisabled, setHandlersDisabled] = useState(!isPopoverPinned);\n useEffect(() => {\n if (isPopoverPinned) {\n setHandlersDisabled(true);\n } else {\n const timeoutId = setTimeout(() => setHandlersDisabled(false), 25);\n return () => clearTimeout(timeoutId);\n }\n }, [isPopoverPinned]);\n\n // Highlighted point and highlighted series must be in sync.\n // TODO: refactor the code so that it is not possible to make series and point highlight out of sync.\n const highlightPoint = useCallback(\n (point: ScaledPoint<T> | null) => {\n setHighlightedGroupIndex(null);\n setHighlightedPoint(point);\n },\n [setHighlightedPoint, setHighlightedGroupIndex]\n );\n\n const highlightSeries = useCallback(\n (series: MixedLineBarChartProps.ChartSeries<T> | null) => {\n if (series !== highlightedSeries) {\n onHighlightChange(series);\n }\n },\n [highlightedSeries, onHighlightChange]\n );\n\n const highlightGroup = useCallback(\n (groupIndex: number) => {\n highlightSeries(null);\n setHighlightedPoint(null);\n setHighlightedGroupIndex(groupIndex);\n },\n [highlightSeries, setHighlightedPoint, setHighlightedGroupIndex]\n );\n\n const clearHighlightedSeries = useCallback(() => {\n highlightSeries(null);\n setHighlightedGroupIndex(null);\n setHighlightedPoint(null);\n dismissPopover();\n }, [dismissPopover, highlightSeries, setHighlightedGroupIndex, setHighlightedPoint]);\n\n const { isGroupNavigation, ...handlers } = useNavigation({\n series,\n visibleSeries,\n scaledSeries,\n barGroups,\n xScale,\n yScale,\n highlightedPoint,\n highlightedGroupIndex,\n highlightedSeries,\n legendSeries,\n isHandlersDisabled,\n pinPopover,\n highlightSeries,\n highlightGroup,\n highlightPoint,\n clearHighlightedSeries,\n });\n\n const { onSVGMouseMove, onSVGMouseOut, verticalMarkerLeft } = useMouseHover<T>({\n scaledSeries,\n barGroups,\n plotRef,\n highlightSeries,\n highlightPoint,\n highlightGroup,\n clearHighlightedSeries,\n isGroupNavigation,\n isHandlersDisabled,\n });\n\n // There are multiple ways to indicate what X is selected.\n // TODO: make a uniform verticalMarkerX state to fit all use-cases.\n const highlightedX = useMemo(() => {\n if (highlightedGroupIndex !== null) {\n return barGroups[highlightedGroupIndex].x;\n }\n if (verticalMarkerLeft !== null) {\n for (const series of scaledSeries) {\n if (series.x === verticalMarkerLeft) {\n return series.datum?.x ?? null;\n }\n }\n }\n if (highlightedPoint !== null) {\n return highlightedPoint?.datum?.x ?? null;\n }\n return null;\n }, [highlightedPoint, verticalMarkerLeft, highlightedGroupIndex, scaledSeries, barGroups]);\n\n const onPopoverDismiss = (outsideClick?: boolean) => {\n dismissPopover();\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 if (highlightedPoint || highlightedGroupIndex !== null) {\n plotRef.current?.focusApplication();\n } else {\n plotRef.current?.focusPlot();\n }\n }, 0);\n }\n };\n\n useLayoutEffect(() => {\n if (highlightedX !== null) {\n showPopover();\n }\n }, [highlightedX, showPopover]);\n\n const onSVGMouseDown = (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => {\n if (isPopoverOpen) {\n if (isPopoverPinned) {\n dismissPopover();\n } else {\n pinPopover();\n e.preventDefault();\n }\n } else {\n showPopover();\n }\n };\n\n const onSVGFocus = (event: React.FocusEvent, trigger: 'mouse' | 'keyboard') => {\n setPlotFocused(true);\n if (trigger === 'keyboard') {\n handlers.onFocus();\n } else {\n // noop: clicks are handled separately\n }\n };\n\n const onSVGBlur = (event: React.FocusEvent<Element>) => {\n setPlotFocused(false);\n const blurTarget = event.relatedTarget || event.target;\n if (\n blurTarget === null ||\n !(blurTarget instanceof Element) ||\n !nodeContains(containerRefObject.current, blurTarget)\n ) {\n setHighlightedPoint(null);\n if (!plotContainerRef?.current?.contains(blurTarget)) {\n clearHighlightedSeries();\n }\n\n if (isPopoverOpen && !isPopoverPinned) {\n dismissPopover();\n }\n }\n };\n\n const onSVGKeyDown = handlers.onKeyDown;\n\n const xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;\n\n let verticalLineX: number | null = null;\n if (verticalMarkerLeft !== null) {\n verticalLineX = verticalMarkerLeft;\n } else if (isGroupNavigation && highlightedGroupIndex !== null) {\n const x = xScale.d3Scale(barGroups[highlightedGroupIndex].x as any) ?? null;\n if (x !== null) {\n verticalLineX = xOffset + x;\n }\n }\n\n const point = useMemo(\n () =>\n highlightedPoint\n ? {\n key: `${highlightedPoint.x}-${highlightedPoint.y}`,\n x: highlightedPoint.x,\n y: highlightedPoint.y,\n color: highlightedPoint.color,\n }\n : null,\n [highlightedPoint]\n );\n\n const verticalMarkers = useMemo(\n () =>\n verticalLineX !== null\n ? scaledSeries\n .filter(({ x, y }) => (x === verticalLineX || isNaN(x)) && !isNaN(y))\n .map(({ x, y, color }, index) => ({\n key: `${index}-${x}-${y}`,\n x: !horizontalBars ? verticalLineX || 0 : y,\n y: !horizontalBars ? y : verticalLineX || 0,\n color: color,\n }))\n : [],\n [scaledSeries, verticalLineX, horizontalBars]\n );\n\n const popoverTrackRef = isGroupNavigation\n ? highlightedGroupRef\n : highlightedPoint\n ? highlightedPointRef\n : verticalMarkerRef;\n\n const highlightDetails = useMemo(() => {\n if (highlightedX === null) {\n return null;\n }\n\n // When series point is highlighted show the corresponding series and matching x-thresholds.\n if (highlightedPoint) {\n const seriesToShow = visibleSeries.filter(\n series => series.series === highlightedPoint?.series || isXThreshold(series.series)\n );\n return formatHighlighted(highlightedX, seriesToShow, xTickFormatter);\n }\n\n // Otherwise - show all visible series details.\n return formatHighlighted(highlightedX, visibleSeries, xTickFormatter);\n }, [highlightedX, highlightedPoint, visibleSeries, xTickFormatter]);\n\n const activeAriaLabel = useMemo(\n () =>\n highlightDetails\n ? `${highlightDetails.position}, ${highlightDetails.details.map(d => d.key + ' ' + d.value).join(',')}`\n : '',\n [highlightDetails]\n );\n\n // Live region is used when nothing is focused e.g. when hovering.\n const activeLiveRegion =\n activeAriaLabel && !highlightedPoint && highlightedGroupIndex === null ? activeAriaLabel : '';\n\n return (\n <div className={styles['chart-container']} ref={containerRef}>\n <AxisLabel axis={y} position=\"left\" title={xy.title[y]} />\n <div className={styles['chart-container__horizontal']}>\n <LabelsMeasure\n ticks={xy.ticks[y]}\n scale={xy.scale[y]}\n tickFormatter={xy.tickFormatter[y] as TickFormatter}\n autoWidth={setLeftLabelsWidth}\n />\n\n <div className={styles['chart-container__vertical']}>\n <ChartPlot\n ref={plotRef}\n width={plotWidth}\n height={plotHeight}\n offsetBottom={bottomLabelsHeight}\n isClickable={isPopoverOpen && !isPopoverPinned}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaRoleDescription={i18nStrings?.chartAriaRoleDescription}\n ariaLiveRegion={activeLiveRegion}\n activeElementRef={isGroupNavigation ? highlightedGroupRef : highlightedPointRef}\n activeElementKey={isPlotFocused && (highlightedGroupIndex?.toString() || point?.key)}\n activeElementFocusOffset={isGroupNavigation ? 0 : 3}\n onMouseMove={onSVGMouseMove}\n onMouseOut={onSVGMouseOut}\n onMouseDown={onSVGMouseDown}\n onFocus={onSVGFocus}\n onBlur={onSVGBlur}\n onKeyDown={onSVGKeyDown}\n >\n <LeftLabels\n axis={y}\n ticks={xy.ticks[y]}\n scale={xy.scale[y]}\n tickFormatter={xy.tickFormatter[y] as TickFormatter}\n title={xy.title[y]}\n ariaRoleDescription={xy.ariaRoleDescription[y]}\n width={plotWidth}\n height={plotHeight}\n />\n\n {horizontalBars && <VerticalGridLines scale={yScale} ticks={yTicks} height={plotHeight} />}\n\n {emphasizeBaselineAxis && linesOnly && (\n <EmphasizedBaseline axis={x} scale={yScale} width={plotWidth} height={plotHeight} />\n )}\n\n <DataSeries\n axis={x}\n plotWidth={plotWidth}\n plotHeight={plotHeight}\n highlightedSeries={highlightedSeries ?? null}\n highlightedGroupIndex={highlightedGroupIndex}\n stackedBars={stackedBars}\n isGroupNavigation={isGroupNavigation}\n visibleSeries={visibleSeries}\n xScale={xScale}\n yScale={yScale}\n />\n\n {emphasizeBaselineAxis && !linesOnly && (\n <EmphasizedBaseline axis={x} scale={yScale} width={plotWidth} height={plotHeight} />\n )}\n\n <VerticalMarker\n key={verticalLineX || ''}\n height={plotHeight}\n showPoints={highlightedPoint === null}\n showLine={!isGroupNavigation}\n points={verticalMarkers}\n ref={verticalMarkerRef}\n />\n\n {highlightedPoint && (\n <HighlightedPoint\n ref={highlightedPointRef}\n point={point}\n role=\"button\"\n ariaLabel={activeAriaLabel}\n ariaHasPopup={true}\n ariaExpanded={isPopoverPinned}\n />\n )}\n\n {isGroupNavigation && xScale.isCategorical() && (\n <BarGroups\n ariaLabel={activeAriaLabel}\n isRefresh={isRefresh}\n isPopoverPinned={isPopoverPinned}\n barGroups={barGroups}\n highlightedGroupIndex={highlightedGroupIndex}\n highlightedGroupRef={highlightedGroupRef}\n />\n )}\n\n <BottomLabels\n axis={x}\n ticks={xy.ticks[x]}\n scale={xy.scale[x]}\n tickFormatter={xy.tickFormatter[x] as TickFormatter}\n title={xy.title[x]}\n ariaRoleDescription={xy.ariaRoleDescription[x]}\n height={plotHeight}\n width={plotWidth}\n offsetLeft={leftLabelsWidth + BOTTOM_LABELS_OFFSET}\n offsetRight={BOTTOM_LABELS_OFFSET}\n autoHeight={setBottomLabelsHeight}\n />\n </ChartPlot>\n\n <AxisLabel axis={x} position=\"bottom\" title={xy.title[x]} />\n </div>\n\n <ChartPopover\n containerRef={containerRefObject}\n trackRef={popoverTrackRef}\n isOpen={isPopoverOpen}\n isPinned={isPopoverPinned}\n highlightDetails={highlightDetails}\n onDismiss={onPopoverDismiss}\n size={detailPopoverSize}\n dismissAriaLabel={i18nStrings.detailPopoverDismissAriaLabel}\n />\n </div>\n </div>\n );\n}\n"]}
|
package/multiselect/internal.js
CHANGED
|
@@ -90,7 +90,7 @@ var InternalMultiselect = React.forwardRef(function (_a, externalRef) {
|
|
|
90
90
|
fireLoadItems: fireLoadItems,
|
|
91
91
|
setFilteringValue: setFilteringValue,
|
|
92
92
|
useInteractiveGroups: useInteractiveGroups
|
|
93
|
-
}), isOpen = _o.isOpen, highlightType = _o.highlightType, highlightedOption = _o.highlightedOption, highlightedIndex = _o.highlightedIndex, getTriggerProps = _o.getTriggerProps,
|
|
93
|
+
}), isOpen = _o.isOpen, highlightType = _o.highlightType, highlightedOption = _o.highlightedOption, highlightedIndex = _o.highlightedIndex, getTriggerProps = _o.getTriggerProps, getDropdownProps = _o.getDropdownProps, getFilterProps = _o.getFilterProps, getMenuProps = _o.getMenuProps, getOptionProps = _o.getOptionProps, highlightOption = _o.highlightOption, announceSelected = _o.announceSelected;
|
|
94
94
|
var handleNativeSearch = useNativeSearch({
|
|
95
95
|
isEnabled: filteringType === 'none' && isOpen,
|
|
96
96
|
options: filteredOptions,
|
|
@@ -110,8 +110,7 @@ var InternalMultiselect = React.forwardRef(function (_a, externalRef) {
|
|
|
110
110
|
isEmpty: isEmpty,
|
|
111
111
|
isNoMatch: isNoMatch,
|
|
112
112
|
noMatch: noMatch,
|
|
113
|
-
onRecoveryClick: handleRecoveryClick
|
|
114
|
-
recoveryProps: getRecoveryProps()
|
|
113
|
+
onRecoveryClick: handleRecoveryClick
|
|
115
114
|
});
|
|
116
115
|
var filter = (React.createElement(Filter, __assign({ filteringType: filteringType, placeholder: filteringPlaceholder, ariaLabel: filteringAriaLabel, ariaRequired: ariaRequired, value: filteringValue }, getFilterProps())));
|
|
117
116
|
var trigger = (React.createElement(Trigger, __assign({ placeholder: placeholder, disabled: disabled, ariaLabel: ariaLabel, triggerProps: getTriggerProps(disabled), selectedOption: null, isOpen: isOpen }, formFieldContext, { controlId: controlId })));
|
|
@@ -163,7 +162,7 @@ var InternalMultiselect = React.forwardRef(function (_a, externalRef) {
|
|
|
163
162
|
};
|
|
164
163
|
var mergedRef = useMergeRefs(rootRef, __internalRootRef);
|
|
165
164
|
return (React.createElement("div", __assign({}, baseProps, { ref: mergedRef, className: clsx(styles.root, baseProps.className), onKeyPress: handleNativeSearch }),
|
|
166
|
-
React.createElement(Dropdown, { open: isOpen, trigger: trigger, header: filter, onMouseDown: handleMouseDown, footer: dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content }) : null, expandToViewport: expandToViewport },
|
|
165
|
+
React.createElement(Dropdown, __assign({}, getDropdownProps(), { open: isOpen, trigger: trigger, header: filter, onMouseDown: handleMouseDown, footer: dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content }) : null, expandToViewport: expandToViewport }),
|
|
167
166
|
React.createElement(ListComponent, { listBottom: !dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content }) : null, menuProps: menuProps, getOptionProps: getOptionProps, filteredOptions: filteredOptions, filteringValue: filteringValue, ref: scrollToIndex, hasDropdownStatus: dropdownStatus.content !== null, checkboxes: true, useInteractiveGroups: useInteractiveGroups, screenReaderContent: announcement, highlightType: highlightType })),
|
|
168
167
|
showTokens && (React.createElement(TokenGroup, { limit: tokenLimit, items: tokens, onDismiss: handleTokenDismiss, i18nStrings: tokenGroupI18nStrings }))));
|
|
169
168
|
});
|