@cloudscape-design/components 3.0.218 → 3.0.220
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/flashbar/common.d.ts.map +1 -1
- package/flashbar/common.js +10 -9
- package/flashbar/common.js.map +1 -1
- package/internal/components/dropdown/index.d.ts.map +1 -1
- package/internal/components/dropdown/index.js +1 -2
- package/internal/components/dropdown/index.js.map +1 -1
- package/internal/components/options-list/utils/use-keyboard.d.ts.map +1 -1
- package/internal/components/options-list/utils/use-keyboard.js +1 -0
- package/internal/components/options-list/utils/use-keyboard.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/popover/body.d.ts.map +1 -1
- package/popover/body.js +13 -3
- package/popover/body.js.map +1 -1
- package/popover/index.d.ts +1 -1
- package/popover/index.d.ts.map +1 -1
- package/popover/index.js +9 -2
- package/popover/index.js.map +1 -1
package/flashbar/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/flashbar/common.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/flashbar/common.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,eAAO,MAAM,aAAa,aAAa,CAAC;AAGxC,wBAAgB,WAAW,CAAC,EAC1B,WAAW,EACX,KAAK,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,GAAG,SAAS,EACb,EAAE,aAAa,GAAG;IACjB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,EAAE,KAAK,IAAI,CAAC;IAClE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,EAAE,KAAK,IAAI,CAAC;IACpE,cAAc,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAC9F;;;;;;;;;EAuDA"}
|
package/flashbar/common.js
CHANGED
|
@@ -8,6 +8,8 @@ import { useContainerBreakpoints } from '../internal/hooks/container-queries';
|
|
|
8
8
|
import { useReducedMotion, useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
9
9
|
import { getBaseProps } from '../internal/base-component';
|
|
10
10
|
import { focusFlashById } from './flash';
|
|
11
|
+
import { isDevelopment } from '../internal/is-development';
|
|
12
|
+
import { warnOnce } from '../internal/logging';
|
|
11
13
|
export var componentName = 'Flashbar';
|
|
12
14
|
// Common logic for collapsible and non-collapsible Flashbar
|
|
13
15
|
export function useFlashbar(_a) {
|
|
@@ -22,6 +24,11 @@ export function useFlashbar(_a) {
|
|
|
22
24
|
var isVisualRefresh = useVisualRefresh();
|
|
23
25
|
var _c = useState(items), previousItems = _c[0], setPreviousItems = _c[1];
|
|
24
26
|
var _d = useState(null), nextFocusId = _d[0], setNextFocusId = _d[1];
|
|
27
|
+
if (isDevelopment) {
|
|
28
|
+
if (items === null || items === void 0 ? void 0 : items.some(function (item) { return item.ariaRole === 'alert' && !item.id; })) {
|
|
29
|
+
warnOnce('Flashbar', "You provided `ariaRole=\"alert\"` for a flashbar item without providing an `id`. Focus will not be moved to the newly added flash message.");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
25
32
|
// Track new or removed item IDs in state to only trigger focus changes for newly added items.
|
|
26
33
|
// https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
|
|
27
34
|
if (items) {
|
|
@@ -35,12 +42,9 @@ export function useFlashbar(_a) {
|
|
|
35
42
|
});
|
|
36
43
|
if (newItems.length > 0 || removedItems.length > 0) {
|
|
37
44
|
setPreviousItems(items);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
if (onItemsRemoved) {
|
|
42
|
-
onItemsRemoved(removedItems);
|
|
43
|
-
}
|
|
45
|
+
onItemsAdded === null || onItemsAdded === void 0 ? void 0 : onItemsAdded(newItems);
|
|
46
|
+
onItemsRemoved === null || onItemsRemoved === void 0 ? void 0 : onItemsRemoved(removedItems);
|
|
47
|
+
onItemsChanged === null || onItemsChanged === void 0 ? void 0 : onItemsChanged({ allItemsHaveId: allItemsHaveId, isReducedMotion: isReducedMotion });
|
|
44
48
|
var newFocusItems = newItems.filter(function (_a) {
|
|
45
49
|
var ariaRole = _a.ariaRole;
|
|
46
50
|
return ariaRole === 'alert';
|
|
@@ -48,9 +52,6 @@ export function useFlashbar(_a) {
|
|
|
48
52
|
if (newFocusItems.length > 0) {
|
|
49
53
|
setNextFocusId(newFocusItems[0].id);
|
|
50
54
|
}
|
|
51
|
-
if (onItemsChanged) {
|
|
52
|
-
onItemsChanged({ allItemsHaveId: allItemsHaveId, isReducedMotion: isReducedMotion });
|
|
53
|
-
}
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
useEffect(function () {
|
package/flashbar/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/flashbar/common.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,C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,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YAClD,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACxB,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,QAAQ,CAAC,CAAC;YACzB,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAG,YAAY,CAAC,CAAC;YAC/B,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAG,EAAE,cAAc,gBAAA,EAAE,eAAe,iBAAA,EAAE,CAAC,CAAC;YAEtD,IAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAC,EAAY;oBAAV,QAAQ,cAAA;gBAAO,OAAA,QAAQ,KAAK,OAAO;YAApB,CAAoB,CAAC,CAAC;YAC9E,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5B,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAG,CAAC,CAAC;aACtC;SACF;KACF;IAED,SAAS,CAAC;QACR,IAAI,WAAW,EAAE;YACf,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SAC1C;IACH,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IAEvB,OAAO;QACL,cAAc,gBAAA;QACd,SAAS,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,SAAS;QACjC,SAAS,WAAA;QACT,UAAU,YAAA;QACV,eAAe,iBAAA;QACf,eAAe,iBAAA;QACf,SAAS,WAAA;QACT,GAAG,KAAA;KACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useContainerBreakpoints } from '../internal/hooks/container-queries';\nimport { useReducedMotion, useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { getBaseProps } from '../internal/base-component';\nimport { FlashbarProps } from './interfaces';\nimport { focusFlashById } from './flash';\nimport { isDevelopment } from '../internal/is-development';\nimport { warnOnce } from '../internal/logging';\n\nexport const componentName = 'Flashbar';\n\n// Common logic for collapsible and non-collapsible Flashbar\nexport function useFlashbar({\n i18nStrings,\n items,\n onItemsAdded,\n onItemsChanged,\n onItemsRemoved,\n ...restProps\n}: FlashbarProps & {\n onItemsAdded?: (items: FlashbarProps.MessageDefinition[]) => void;\n onItemsRemoved?: (items: FlashbarProps.MessageDefinition[]) => void;\n onItemsChanged?: (options?: { allItemsHaveId?: boolean; isReducedMotion?: boolean }) => void;\n}) {\n const { __internalRootRef } = useBaseComponent(componentName);\n const allItemsHaveId = useMemo(() => items.every(item => 'id' in item), [items]);\n const baseProps = getBaseProps(restProps);\n const ref = useRef<HTMLDivElement | null>(null);\n const [breakpoint, breakpointRef] = useContainerBreakpoints(['xs']);\n const mergedRef = useMergeRefs(ref, breakpointRef, __internalRootRef);\n const isReducedMotion = useReducedMotion(breakpointRef as any);\n const isVisualRefresh = useVisualRefresh();\n const [previousItems, setPreviousItems] = useState<ReadonlyArray<FlashbarProps.MessageDefinition>>(items);\n const [nextFocusId, setNextFocusId] = useState<string | null>(null);\n\n if (isDevelopment) {\n if (items?.some(item => item.ariaRole === 'alert' && !item.id)) {\n warnOnce(\n 'Flashbar',\n `You provided \\`ariaRole=\"alert\"\\` for a flashbar item without providing an \\`id\\`. Focus will not be moved to the newly added flash message.`\n );\n }\n }\n\n // Track new or removed item IDs in state to only trigger focus changes for newly added items.\n // https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops\n if (items) {\n const newItems = items.filter(({ id }) => id && !previousItems.some(item => item.id === id));\n const removedItems = previousItems.filter(({ id }) => id && !items.some(item => item.id === id));\n if (newItems.length > 0 || removedItems.length > 0) {\n setPreviousItems(items);\n onItemsAdded?.(newItems);\n onItemsRemoved?.(removedItems);\n onItemsChanged?.({ allItemsHaveId, isReducedMotion });\n\n const newFocusItems = newItems.filter(({ ariaRole }) => ariaRole === 'alert');\n if (newFocusItems.length > 0) {\n setNextFocusId(newFocusItems[0].id!);\n }\n }\n }\n\n useEffect(() => {\n if (nextFocusId) {\n focusFlashById(ref.current, nextFocusId);\n }\n }, [nextFocusId, ref]);\n\n return {\n allItemsHaveId,\n ariaLabel: i18nStrings?.ariaLabel,\n baseProps,\n breakpoint,\n isReducedMotion,\n isVisualRefresh,\n mergedRef,\n ref,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAiG7C,QAAA,MAAM,QAAQ,6QAsBX,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAiG7C,QAAA,MAAM,QAAQ,6QAsBX,aAAa,gBA6Qf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
|
|
@@ -193,8 +193,7 @@ var Dropdown = function (_a) {
|
|
|
193
193
|
}
|
|
194
194
|
var clickListener = function (e) {
|
|
195
195
|
var _a, _b;
|
|
196
|
-
|
|
197
|
-
if (!((_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.contains(target)) && !((_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.contains(target))) {
|
|
196
|
+
if (!((_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) && !((_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.contains(e.target))) {
|
|
198
197
|
fireNonCancelableEvent(onDropdownClose);
|
|
199
198
|
}
|
|
200
199
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-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AC,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 const target = e.composedPath()[0];\n\n if (!dropdownRef.current?.contains(target as Node) && !triggerRef.current?.contains(target as Node)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\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"]}
|
|
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,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AAM,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) && !triggerRef.current?.contains(e.target as Node)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-keyboard.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/components/options-list/utils/use-keyboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAKxE,UAAU,eAAe;IACvB,CAAC,UAAU,EAAE;QACX,aAAa,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;QAChE,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,MAAM,EAAE,MAAM,IAAI,CAAC;QACnB,KAAK,EAAE,MAAM,IAAI,CAAC;QAClB,aAAa,EAAE,MAAM,IAAI,CAAC;QAC1B,qBAAqB,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACjD,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,eAAe,EAAE,eA2C7B,CAAC;AAEF,UAAU,kBAAkB;IAC1B,CAAC,UAAU,EAAE;QAAE,YAAY,EAAE,MAAM,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,IAAI,CAAA;KAAE,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;CACvG;AAED,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"use-keyboard.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/components/options-list/utils/use-keyboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAKxE,UAAU,eAAe;IACvB,CAAC,UAAU,EAAE;QACX,aAAa,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;QAChE,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,MAAM,EAAE,MAAM,IAAI,CAAC;QACnB,KAAK,EAAE,MAAM,IAAI,CAAC;QAClB,aAAa,EAAE,MAAM,IAAI,CAAC;QAC1B,qBAAqB,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACjD,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,eAAe,EAAE,eA2C7B,CAAC;AAEF,UAAU,kBAAkB;IAC1B,CAAC,UAAU,EAAE;QAAE,YAAY,EAAE,MAAM,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,IAAI,CAAA;KAAE,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;CACvG;AAED,eAAO,MAAM,kBAAkB,EAAE,kBAmBhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-keyboard.js","sourceRoot":"","sources":["../../../../../../src/internal/components/options-list/utils/use-keyboard.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAoB,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,IAAM,IAAI,GAAG,EAAE,CAAC;AAChB,IAAM,GAAG,GAAG,EAAE,CAAC;AAcf,MAAM,CAAC,IAAM,eAAe,GAAoB,UAAC,EAQhD;QAPC,aAAa,mBAAA,EACb,YAAY,kBAAA,EACZ,MAAM,YAAA,EACN,KAAK,WAAA,EACL,aAAa,mBAAA,EACb,qBAAqB,2BAAA,EACrB,0BAA0B,EAA1B,kBAAkB,mBAAG,KAAK,KAAA;IAE1B,OAAO,WAAW,CAChB,UAAC,CAA6B;QAC5B,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;YACxB,KAAK,OAAO,CAAC,EAAE;gBACb,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClB,MAAM;YACR,KAAK,OAAO,CAAC,IAAI;gBACf,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,aA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ache-2.0\nimport { useCallback, MutableRefObject } from 'react';\nimport { KeyCode } from '../../../keycode';\nimport { BaseKeyDetail, CancelableEventHandler } from '../../../events';\n\nconst HOME = 36;\nconst END = 35;\n\ninterface UseMenuKeyboard {\n (inputProps: {\n moveHighlight: (direction: -1 | 1, startIndex?: number) => void;\n selectOption: () => void;\n goHome: () => void;\n goEnd: () => void;\n closeDropdown: () => void;\n isSelectingUsingSpace: MutableRefObject<boolean>;\n preventNativeSpace?: boolean;\n }): CancelableEventHandler<BaseKeyDetail>;\n}\n\nexport const useMenuKeyboard: UseMenuKeyboard = ({\n moveHighlight,\n selectOption,\n goHome,\n goEnd,\n closeDropdown,\n isSelectingUsingSpace,\n preventNativeSpace = false,\n}) => {\n return useCallback(\n (e: CustomEvent<BaseKeyDetail>) => {\n switch (e.detail.keyCode) {\n case KeyCode.up:\n e.preventDefault();\n moveHighlight(-1);\n break;\n case KeyCode.down:\n e.preventDefault();\n moveHighlight(1);\n break;\n case HOME:\n goHome();\n break;\n case END:\n goEnd();\n break;\n case KeyCode.escape:\n closeDropdown();\n break;\n case KeyCode.enter:\n e.preventDefault();\n selectOption();\n break;\n case KeyCode.space:\n if (preventNativeSpace) {\n e.preventDefault();\n selectOption();\n isSelectingUsingSpace.current = true;\n }\n }\n },\n [moveHighlight, selectOption, goHome, goEnd, closeDropdown, isSelectingUsingSpace, preventNativeSpace]\n );\n};\n\ninterface UseTriggerKeyboard {\n (inputProps: { openDropdown: () => void; goHome: () => void }): CancelableEventHandler<BaseKeyDetail>;\n}\n\nexport const useTriggerKeyboard: UseTriggerKeyboard = ({ openDropdown, goHome }) => {\n return useCallback(\n (e: CustomEvent<BaseKeyDetail>) => {\n switch (e.detail.keyCode) {\n case KeyCode.up:\n case KeyCode.down:\n e.preventDefault();\n goHome();\n openDropdown();\n break;\n case KeyCode.space:\n e.preventDefault();\n openDropdown();\n break;\n }\n },\n [openDropdown, goHome]\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"use-keyboard.js","sourceRoot":"","sources":["../../../../../../src/internal/components/options-list/utils/use-keyboard.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAoB,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,IAAM,IAAI,GAAG,EAAE,CAAC;AAChB,IAAM,GAAG,GAAG,EAAE,CAAC;AAcf,MAAM,CAAC,IAAM,eAAe,GAAoB,UAAC,EAQhD;QAPC,aAAa,mBAAA,EACb,YAAY,kBAAA,EACZ,MAAM,YAAA,EACN,KAAK,WAAA,EACL,aAAa,mBAAA,EACb,qBAAqB,2BAAA,EACrB,0BAA0B,EAA1B,kBAAkB,mBAAG,KAAK,KAAA;IAE1B,OAAO,WAAW,CAChB,UAAC,CAA6B;QAC5B,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;YACxB,KAAK,OAAO,CAAC,EAAE;gBACb,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClB,MAAM;YACR,KAAK,OAAO,CAAC,IAAI;gBACf,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,aAAa,CAAC,CAAC,CAAC,CAAC;gBACjB,MAAM;YACR,KAAK,IAAI;gBACP,MAAM,EAAE,CAAC;gBACT,MAAM;YACR,KAAK,GAAG;gBACN,KAAK,EAAE,CAAC;gBACR,MAAM;YACR,KAAK,OAAO,CAAC,MAAM;gBACjB,aAAa,EAAE,CAAC;gBAChB,MAAM;YACR,KAAK,OAAO,CAAC,KAAK;gBAChB,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,YAAY,EAAE,CAAC;gBACf,MAAM;YACR,KAAK,OAAO,CAAC,KAAK;gBAChB,IAAI,kBAAkB,EAAE;oBACtB,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnB,YAAY,EAAE,CAAC;oBACf,qBAAqB,CAAC,OAAO,GAAG,IAAI,CAAC;iBACtC;SACJ;IACH,CAAC,EACD,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,kBAAkB,CAAC,CACvG,CAAC;AACJ,CAAC,CAAC;AAMF,MAAM,CAAC,IAAM,kBAAkB,GAAuB,UAAC,EAAwB;QAAtB,YAAY,kBAAA,EAAE,MAAM,YAAA;IAC3E,OAAO,WAAW,CAChB,UAAC,CAA6B;QAC5B,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;YACxB,KAAK,OAAO,CAAC,EAAE,CAAC;YAChB,KAAK,OAAO,CAAC,IAAI;gBACf,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,MAAM,EAAE,CAAC;gBACT,YAAY,EAAE,CAAC;gBACf,MAAM;YACR,KAAK,OAAO,CAAC,KAAK,CAAC;YACnB,KAAK,OAAO,CAAC,KAAK;gBAChB,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,YAAY,EAAE,CAAC;gBACf,MAAM;SACT;IACH,CAAC,EACD,CAAC,YAAY,EAAE,MAAM,CAAC,CACvB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, MutableRefObject } from 'react';\nimport { KeyCode } from '../../../keycode';\nimport { BaseKeyDetail, CancelableEventHandler } from '../../../events';\n\nconst HOME = 36;\nconst END = 35;\n\ninterface UseMenuKeyboard {\n (inputProps: {\n moveHighlight: (direction: -1 | 1, startIndex?: number) => void;\n selectOption: () => void;\n goHome: () => void;\n goEnd: () => void;\n closeDropdown: () => void;\n isSelectingUsingSpace: MutableRefObject<boolean>;\n preventNativeSpace?: boolean;\n }): CancelableEventHandler<BaseKeyDetail>;\n}\n\nexport const useMenuKeyboard: UseMenuKeyboard = ({\n moveHighlight,\n selectOption,\n goHome,\n goEnd,\n closeDropdown,\n isSelectingUsingSpace,\n preventNativeSpace = false,\n}) => {\n return useCallback(\n (e: CustomEvent<BaseKeyDetail>) => {\n switch (e.detail.keyCode) {\n case KeyCode.up:\n e.preventDefault();\n moveHighlight(-1);\n break;\n case KeyCode.down:\n e.preventDefault();\n moveHighlight(1);\n break;\n case HOME:\n goHome();\n break;\n case END:\n goEnd();\n break;\n case KeyCode.escape:\n closeDropdown();\n break;\n case KeyCode.enter:\n e.preventDefault();\n selectOption();\n break;\n case KeyCode.space:\n if (preventNativeSpace) {\n e.preventDefault();\n selectOption();\n isSelectingUsingSpace.current = true;\n }\n }\n },\n [moveHighlight, selectOption, goHome, goEnd, closeDropdown, isSelectingUsingSpace, preventNativeSpace]\n );\n};\n\ninterface UseTriggerKeyboard {\n (inputProps: { openDropdown: () => void; goHome: () => void }): CancelableEventHandler<BaseKeyDetail>;\n}\n\nexport const useTriggerKeyboard: UseTriggerKeyboard = ({ openDropdown, goHome }) => {\n return useCallback(\n (e: CustomEvent<BaseKeyDetail>) => {\n switch (e.detail.keyCode) {\n case KeyCode.up:\n case KeyCode.down:\n e.preventDefault();\n goHome();\n openDropdown();\n break;\n case KeyCode.space:\n case KeyCode.enter:\n e.preventDefault();\n openDropdown();\n break;\n }\n },\n [openDropdown, goHome]\n );\n};\n"]}
|
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
package/package.json
CHANGED
package/popover/body.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/popover/body.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAW9D,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB,MAAM,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAErC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,aAAa,EAAE,iBAAiB,EAChC,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,eAAe,EACf,SAAS,EACT,cAAc,GACf,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/popover/body.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAW9D,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB,MAAM,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAErC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,aAAa,EAAE,iBAAiB,EAChC,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,eAAe,EACf,SAAS,EACT,cAAc,GACf,EAAE,gBAAgB,eA2ElB"}
|
package/popover/body.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
@@ -30,10 +31,19 @@ export default function PopoverBody(_a) {
|
|
|
30
31
|
}, [showDismissButton]);
|
|
31
32
|
var dismissButton = (showDismissButton !== null && showDismissButton !== void 0 ? showDismissButton : null) && (React.createElement("div", { className: styles.dismiss },
|
|
32
33
|
React.createElement(InternalButton, { variant: "icon", formAction: "none", iconName: "close", className: styles['dismiss-control'], ariaLabel: dismissAriaLabel, onClick: function () { return onDismiss(); }, ref: dismissButtonRef })));
|
|
33
|
-
|
|
34
|
+
var isDialog = showDismissButton;
|
|
35
|
+
var shouldTrapFocus = showDismissButton && variant !== 'annotation';
|
|
36
|
+
var dialogProps = isDialog
|
|
37
|
+
? {
|
|
38
|
+
role: 'dialog',
|
|
39
|
+
'aria-modal': shouldTrapFocus ? true : undefined,
|
|
40
|
+
'aria-labelledby': ariaLabelledby !== null && ariaLabelledby !== void 0 ? ariaLabelledby : (header ? labelledById : undefined)
|
|
41
|
+
}
|
|
42
|
+
: {};
|
|
43
|
+
return (React.createElement("div", __assign({ className: clsx(styles.body, className, (_b = {},
|
|
34
44
|
_b[styles['body-overflow-visible']] = overflowVisible === 'both',
|
|
35
|
-
_b)),
|
|
36
|
-
React.createElement(FocusLock, { disabled:
|
|
45
|
+
_b)), onKeyDown: onKeyDown }, dialogProps),
|
|
46
|
+
React.createElement(FocusLock, { disabled: !shouldTrapFocus, autoFocus: false },
|
|
37
47
|
header && (React.createElement("div", { className: clsx(styles['header-row'], showDismissButton && styles['has-dismiss']) },
|
|
38
48
|
dismissButton,
|
|
39
49
|
React.createElement("div", { className: styles.header, id: labelledById },
|
package/popover/body.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../../src/popover/body.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO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AC,CAAC,SAAS,CAAC;SACzE;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,CACL,sCACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS;YACpC,GAAC,MAAM,CAAC,uBAAuB,CAAC,IAAG,eAAe,KAAK,MAAM;gBAC7D,EACF,SAAS,EAAE,SAAS,IAChB,WAAW;QAEf,oBAAC,SAAS,IAAC,QAAQ,EAAE,CAAC,eAAe,EAAE,SAAS,EAAE,KAAK;YACpD,MAAM,IAAI,CACT,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,iBAAiB,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;gBACnF,aAAa;gBACd,6BAAK,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,YAAY;oBAC7C,gCAAK,MAAM,CAAM,CACb,CACF,CACP;YACD,6BAAK,SAAS,EAAE,CAAC,MAAM,IAAI,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS;gBAC7E,CAAC,MAAM,IAAI,aAAa;gBACzB,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,YAAI,GAAC,MAAM,CAAC,0BAA0B,CAAC,IAAG,CAAC,CAAC,eAAe,MAAG,IAC9F,QAAQ,CACL,CACF,CACI,CACR,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, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { KeyCode } from '../internal/keycode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport FocusLock from '../internal/components/focus-lock';\n\nimport styles from './styles.css.js';\n\nexport interface PopoverBodyProps {\n dismissButton: boolean;\n dismissAriaLabel: string | undefined;\n onDismiss: () => void;\n\n header: React.ReactNode | undefined;\n children: React.ReactNode;\n variant?: 'annotation';\n overflowVisible?: 'content' | 'both';\n\n className?: string;\n ariaLabelledby?: string;\n}\n\nexport default function PopoverBody({\n dismissButton: showDismissButton,\n dismissAriaLabel,\n header,\n children,\n onDismiss,\n variant,\n overflowVisible,\n className,\n ariaLabelledby,\n}: PopoverBodyProps) {\n const labelledById = useUniqueId('awsui-popover-');\n const dismissButtonFocused = useRef(false);\n const dismissButtonRef = useRef<ButtonProps.Ref>(null);\n\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.keyCode === KeyCode.escape) {\n onDismiss();\n }\n },\n [onDismiss]\n );\n\n // Implement our own auto-focus rather than using FocusLock's,\n // because we also want to focus the dismiss button when it\n // is added dyamically (e.g. in chart popovers)\n useEffect(() => {\n if (showDismissButton && !dismissButtonFocused.current) {\n dismissButtonRef.current?.focus({ preventScroll: true });\n }\n dismissButtonFocused.current = showDismissButton;\n }, [showDismissButton]);\n\n const dismissButton = (showDismissButton ?? null) && (\n <div className={styles.dismiss}>\n <InternalButton\n variant=\"icon\"\n formAction=\"none\"\n iconName=\"close\"\n className={styles['dismiss-control']}\n ariaLabel={dismissAriaLabel}\n onClick={() => onDismiss()}\n ref={dismissButtonRef}\n />\n </div>\n );\n\n const isDialog = showDismissButton;\n const shouldTrapFocus = showDismissButton && variant !== 'annotation';\n\n const dialogProps = isDialog\n ? {\n role: 'dialog',\n 'aria-modal': shouldTrapFocus ? true : undefined,\n 'aria-labelledby': ariaLabelledby ?? (header ? labelledById : undefined),\n }\n : {};\n\n return (\n <div\n className={clsx(styles.body, className, {\n [styles['body-overflow-visible']]: overflowVisible === 'both',\n })}\n onKeyDown={onKeyDown}\n {...dialogProps}\n >\n <FocusLock disabled={!shouldTrapFocus} autoFocus={false}>\n {header && (\n <div className={clsx(styles['header-row'], showDismissButton && styles['has-dismiss'])}>\n {dismissButton}\n <div className={styles.header} id={labelledById}>\n <h2>{header}</h2>\n </div>\n </div>\n )}\n <div className={!header && showDismissButton ? styles['has-dismiss'] : undefined}>\n {!header && dismissButton}\n <div className={clsx(styles.content, { [styles['content-overflow-visible']]: !!overflowVisible })}>\n {children}\n </div>\n </div>\n </FocusLock>\n </div>\n );\n}\n"]}
|
package/popover/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PopoverProps } from './interfaces';
|
|
2
2
|
export { PopoverProps };
|
|
3
|
-
export default function Popover({ position, size, fixedWidth, triggerType, dismissButton, renderWithPortal, ...rest }: PopoverProps): JSX.Element;
|
|
3
|
+
export default function Popover({ position, size, fixedWidth, triggerType, dismissButton, renderWithPortal, header, ...rest }: PopoverProps): JSX.Element;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/popover/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/popover/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/popover/index.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,QAAkB,EAClB,IAAe,EACf,UAAkB,EAClB,WAAoB,EACpB,aAAoB,EACpB,gBAAwB,EACxB,MAAM,EACN,GAAG,IAAI,EACR,EAAE,YAAY,eAsBd"}
|
package/popover/index.js
CHANGED
|
@@ -6,11 +6,18 @@ import InternalPopover from './internal';
|
|
|
6
6
|
import { getExternalProps } from '../internal/utils/external-props';
|
|
7
7
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
8
8
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
9
|
+
import { isDevelopment } from '../internal/is-development';
|
|
10
|
+
import { warnOnce } from '../internal/logging';
|
|
9
11
|
export default function Popover(_a) {
|
|
10
|
-
var _b = _a.position, position = _b === void 0 ? 'right' : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, _d = _a.fixedWidth, fixedWidth = _d === void 0 ? false : _d, _e = _a.triggerType, triggerType = _e === void 0 ? 'text' : _e, _f = _a.dismissButton, dismissButton = _f === void 0 ? true : _f, _g = _a.renderWithPortal, renderWithPortal = _g === void 0 ? false : _g, rest = __rest(_a, ["position", "size", "fixedWidth", "triggerType", "dismissButton", "renderWithPortal"]);
|
|
12
|
+
var _b = _a.position, position = _b === void 0 ? 'right' : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, _d = _a.fixedWidth, fixedWidth = _d === void 0 ? false : _d, _e = _a.triggerType, triggerType = _e === void 0 ? 'text' : _e, _f = _a.dismissButton, dismissButton = _f === void 0 ? true : _f, _g = _a.renderWithPortal, renderWithPortal = _g === void 0 ? false : _g, header = _a.header, rest = __rest(_a, ["position", "size", "fixedWidth", "triggerType", "dismissButton", "renderWithPortal", "header"]);
|
|
13
|
+
if (isDevelopment) {
|
|
14
|
+
if (dismissButton && !header) {
|
|
15
|
+
warnOnce('Popover', "You should provide a `header` when `dismissButton` is true.");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
11
18
|
var baseComponentProps = useBaseComponent('Popover');
|
|
12
19
|
var externalProps = getExternalProps(rest);
|
|
13
|
-
return (React.createElement(InternalPopover, __assign({ position: position, size: size, fixedWidth: fixedWidth, triggerType: triggerType, dismissButton: dismissButton, renderWithPortal: renderWithPortal }, externalProps, baseComponentProps)));
|
|
20
|
+
return (React.createElement(InternalPopover, __assign({ header: header, position: position, size: size, fixedWidth: fixedWidth, triggerType: triggerType, dismissButton: dismissButton, renderWithPortal: renderWithPortal }, externalProps, baseComponentProps)));
|
|
14
21
|
}
|
|
15
22
|
applyDisplayName(Popover, 'Popover');
|
|
16
23
|
//# sourceMappingURL=index.js.map
|
package/popover/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/popover/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/popover/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAK/C,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EASjB;IARb,IAAA,gBAAkB,EAAlB,QAAQ,mBAAG,OAAO,KAAA,EAClB,YAAe,EAAf,IAAI,mBAAG,QAAQ,KAAA,EACf,kBAAkB,EAAlB,UAAU,mBAAG,KAAK,KAAA,EAClB,mBAAoB,EAApB,WAAW,mBAAG,MAAM,KAAA,EACpB,qBAAoB,EAApB,aAAa,mBAAG,IAAI,KAAA,EACpB,wBAAwB,EAAxB,gBAAgB,mBAAG,KAAK,KAAA,EACxB,MAAM,YAAA,EACH,IAAI,cARuB,gGAS/B,CADQ;IAEP,IAAI,aAAa,EAAE;QACjB,IAAI,aAAa,IAAI,CAAC,MAAM,EAAE;YAC5B,QAAQ,CAAC,SAAS,EAAE,6DAAiE,CAAC,CAAC;SACxF;KACF;IAED,IAAM,kBAAkB,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACvD,IAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,CACL,oBAAC,eAAe,aACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,IAC9B,aAAa,EACb,kBAAkB,EACtB,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport InternalPopover from './internal';\nimport { getExternalProps } from '../internal/utils/external-props';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { isDevelopment } from '../internal/is-development';\nimport { warnOnce } from '../internal/logging';\nimport { PopoverProps } from './interfaces';\n\nexport { PopoverProps };\n\nexport default function Popover({\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n triggerType = 'text',\n dismissButton = true,\n renderWithPortal = false,\n header,\n ...rest\n}: PopoverProps) {\n if (isDevelopment) {\n if (dismissButton && !header) {\n warnOnce('Popover', `You should provide a \\`header\\` when \\`dismissButton\\` is true.`);\n }\n }\n\n const baseComponentProps = useBaseComponent('Popover');\n const externalProps = getExternalProps(rest);\n return (\n <InternalPopover\n header={header}\n position={position}\n size={size}\n fixedWidth={fixedWidth}\n triggerType={triggerType}\n dismissButton={dismissButton}\n renderWithPortal={renderWithPortal}\n {...externalProps}\n {...baseComponentProps}\n />\n );\n}\n\napplyDisplayName(Popover, 'Popover');\n"]}
|