@cloudscape-design/components 3.0.608 → 3.0.610

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.
Files changed (93) hide show
  1. package/annotation-context/annotation/styles.css.js +24 -24
  2. package/annotation-context/annotation/styles.scoped.css +33 -29
  3. package/annotation-context/annotation/styles.selectors.js +24 -24
  4. package/app-layout/classic.d.ts +9 -3
  5. package/app-layout/classic.d.ts.map +1 -1
  6. package/app-layout/classic.js +26 -25
  7. package/app-layout/classic.js.map +1 -1
  8. package/app-layout/implementation.d.ts +9 -3
  9. package/app-layout/implementation.d.ts.map +1 -1
  10. package/app-layout/index.d.ts.map +1 -1
  11. package/app-layout/index.js +6 -4
  12. package/app-layout/index.js.map +1 -1
  13. package/app-layout/interfaces.d.ts +9 -1
  14. package/app-layout/interfaces.d.ts.map +1 -1
  15. package/app-layout/interfaces.js.map +1 -1
  16. package/app-layout/internal.d.ts +9 -3
  17. package/app-layout/internal.d.ts.map +1 -1
  18. package/app-layout/utils/use-app-layout-placement.d.ts +9 -0
  19. package/app-layout/utils/use-app-layout-placement.d.ts.map +1 -0
  20. package/app-layout/utils/use-app-layout-placement.js +29 -0
  21. package/app-layout/utils/use-app-layout-placement.js.map +1 -0
  22. package/app-layout/visual-refresh/context.d.ts.map +1 -1
  23. package/app-layout/visual-refresh/context.js +10 -41
  24. package/app-layout/visual-refresh/context.js.map +1 -1
  25. package/app-layout/visual-refresh/index.d.ts +9 -3
  26. package/app-layout/visual-refresh/index.d.ts.map +1 -1
  27. package/app-layout/visual-refresh/tools.d.ts.map +1 -1
  28. package/app-layout/visual-refresh/tools.js +2 -9
  29. package/app-layout/visual-refresh/tools.js.map +1 -1
  30. package/button-dropdown/category-elements/styles.css.js +14 -14
  31. package/button-dropdown/category-elements/styles.scoped.css +25 -22
  32. package/button-dropdown/category-elements/styles.selectors.js +14 -14
  33. package/internal/components/chart-popover/index.d.ts +1 -1
  34. package/internal/components/chart-popover/index.d.ts.map +1 -1
  35. package/internal/components/chart-popover/index.js.map +1 -1
  36. package/internal/components/dropdown/dropdown-fit-handler.d.ts +12 -12
  37. package/internal/components/dropdown/dropdown-fit-handler.d.ts.map +1 -1
  38. package/internal/components/dropdown/dropdown-fit-handler.js +103 -83
  39. package/internal/components/dropdown/dropdown-fit-handler.js.map +1 -1
  40. package/internal/components/dropdown/index.d.ts.map +1 -1
  41. package/internal/components/dropdown/index.js +30 -29
  42. package/internal/components/dropdown/index.js.map +1 -1
  43. package/internal/components/tooltip/index.d.ts +1 -1
  44. package/internal/components/tooltip/index.d.ts.map +1 -1
  45. package/internal/components/tooltip/index.js.map +1 -1
  46. package/internal/direction.d.ts +14 -0
  47. package/internal/direction.d.ts.map +1 -1
  48. package/internal/direction.js +25 -0
  49. package/internal/direction.js.map +1 -1
  50. package/internal/environment.js +1 -1
  51. package/internal/environment.json +1 -1
  52. package/internal/manifest.json +1 -1
  53. package/internal/utils/handle-key.d.ts +15 -11
  54. package/internal/utils/handle-key.d.ts.map +1 -1
  55. package/internal/utils/handle-key.js +9 -9
  56. package/internal/utils/handle-key.js.map +1 -1
  57. package/internal/utils/scrollable-containers.d.ts +5 -5
  58. package/internal/utils/scrollable-containers.d.ts.map +1 -1
  59. package/internal/utils/scrollable-containers.js +19 -19
  60. package/internal/utils/scrollable-containers.js.map +1 -1
  61. package/package.json +1 -1
  62. package/popover/container.d.ts +1 -1
  63. package/popover/container.d.ts.map +1 -1
  64. package/popover/container.js.map +1 -1
  65. package/popover/interfaces.d.ts +4 -4
  66. package/popover/interfaces.d.ts.map +1 -1
  67. package/popover/interfaces.js.map +1 -1
  68. package/popover/styles.css.js +50 -50
  69. package/popover/styles.scoped.css +76 -64
  70. package/popover/styles.selectors.js +50 -50
  71. package/popover/use-popover-position.d.ts +1 -1
  72. package/popover/use-popover-position.d.ts.map +1 -1
  73. package/popover/use-popover-position.js +32 -29
  74. package/popover/use-popover-position.js.map +1 -1
  75. package/popover/utils/positions.d.ts +2 -2
  76. package/popover/utils/positions.d.ts.map +1 -1
  77. package/popover/utils/positions.js +74 -74
  78. package/popover/utils/positions.js.map +1 -1
  79. package/test-utils/dom/app-layout/index.d.ts +1 -0
  80. package/test-utils/dom/app-layout/index.js +4 -0
  81. package/test-utils/dom/app-layout/index.js.map +1 -1
  82. package/test-utils/selectors/app-layout/index.d.ts +1 -0
  83. package/test-utils/selectors/app-layout/index.js +4 -0
  84. package/test-utils/selectors/app-layout/index.js.map +1 -1
  85. package/test-utils/tsconfig.tsbuildinfo +1 -1
  86. package/app-layout/utils/use-app-layout-rect.d.ts +0 -8
  87. package/app-layout/utils/use-app-layout-rect.d.ts.map +0 -1
  88. package/app-layout/utils/use-app-layout-rect.js +0 -24
  89. package/app-layout/utils/use-app-layout-rect.js.map +0 -1
  90. package/app-layout/utils/use-content-height.d.ts +0 -8
  91. package/app-layout/utils/use-content-height.d.ts.map +0 -1
  92. package/app-layout/utils/use-content-height.js +0 -25
  93. package/app-layout/utils/use-content-height.js.map +0 -1
@@ -18,6 +18,7 @@ import { useUniqueId } from '../../hooks/use-unique-id/index.js';
18
18
  import customCssProps from '../../generated/custom-css-properties';
19
19
  import { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';
20
20
  import { nodeBelongs } from '../../utils/node-belongs';
21
+ import { getLogicalBoundingClientRect } from '../../direction.js';
21
22
  const DropdownContainer = ({ children, renderWithPortal = false, id, referrerId, open }) => {
22
23
  if (renderWithPortal) {
23
24
  if (open) {
@@ -67,10 +68,10 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
67
68
  const entireWidth = !interior && stretchWidth;
68
69
  if (!stretchWidth) {
69
70
  // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items
70
- verticalContainer.style.maxHeight = `${parseInt(position.height) + 1}px`;
71
+ verticalContainer.style.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;
71
72
  }
72
73
  else {
73
- verticalContainer.style.maxHeight = position.height;
74
+ verticalContainer.style.maxBlockSize = position.blockSize;
74
75
  }
75
76
  if (entireWidth && !expandToViewport) {
76
77
  if (stretchToTriggerWidth) {
@@ -78,36 +79,36 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
78
79
  }
79
80
  }
80
81
  else {
81
- target.style.width = position.width;
82
+ target.style.inlineSize = position.inlineSize;
82
83
  }
83
84
  // Using styles for main dropdown to adjust its position as preferred alternative
84
- if (position.dropUp && !interior) {
85
+ if (position.dropBlockStart && !interior) {
85
86
  target.classList.add(styles['dropdown-drop-up']);
86
87
  if (!expandToViewport) {
87
- target.style.bottom = '100%';
88
+ target.style.insetBlockEnd = '100%';
88
89
  }
89
90
  }
90
91
  else {
91
92
  target.classList.remove(styles['dropdown-drop-up']);
92
93
  }
93
- target.classList.add(position.dropLeft ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);
94
- if (position.left && position.left !== 'auto') {
95
- target.style.left = position.left;
94
+ target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);
95
+ if (position.insetInlineStart && position.insetInlineStart !== 'auto') {
96
+ target.style.insetInlineStart = position.insetInlineStart;
96
97
  }
97
98
  // Position normal overflow dropdowns with fixed positioning relative to viewport
98
99
  if (expandToViewport && !interior) {
99
100
  target.style.position = 'fixed';
100
- if (position.dropUp) {
101
- target.style.bottom = `calc(100% - ${triggerBox.top}px)`;
101
+ if (position.dropBlockStart) {
102
+ target.style.insetBlockEnd = `calc(100% - ${triggerBox.top}px)`;
102
103
  }
103
104
  else {
104
- target.style.top = `${triggerBox.bottom}px`;
105
+ target.style.insetBlockStart = `${triggerBox.bottom}px`;
105
106
  }
106
- if (position.dropLeft) {
107
- target.style.left = `calc(${triggerBox.right}px - ${position.width})`;
107
+ if (position.dropInlineStart) {
108
+ target.style.insetInlineStart = `calc(${triggerBox.right}px - ${position.inlineSize})`;
108
109
  }
109
110
  else {
110
- target.style.left = `${triggerBox.left}px`;
111
+ target.style.insetInlineStart = `${triggerBox.left}px`;
111
112
  }
112
113
  // Keep track of the initial dropdown position and direction.
113
114
  // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.
@@ -118,21 +119,21 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
118
119
  // and classes are not enough
119
120
  // usage of relative position is impossible due to overwrite of overflow-x
120
121
  if (interior && isInteriorPosition(position)) {
121
- if (position.dropUp) {
122
- target.style.bottom = position.bottom;
122
+ if (position.dropBlockStart) {
123
+ target.style.insetBlockEnd = position.insetBlockEnd;
123
124
  }
124
125
  else {
125
- target.style.top = position.top;
126
+ target.style.insetBlockStart = position.insetBlockStart;
126
127
  }
127
- target.style.left = position.left;
128
+ target.style.insetInlineStart = position.insetInlineStart;
128
129
  }
129
- if (position.dropUp && position.dropLeft) {
130
+ if (position.dropBlockStart && position.dropInlineStart) {
130
131
  setPosition('top-left');
131
132
  }
132
- else if (position.dropUp) {
133
+ else if (position.dropBlockStart) {
133
134
  setPosition('top-right');
134
135
  }
135
- else if (position.dropLeft) {
136
+ else if (position.dropInlineStart) {
136
137
  setPosition('bottom-left');
137
138
  }
138
139
  else {
@@ -225,20 +226,20 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
225
226
  }
226
227
  const updateDropdownPosition = () => {
227
228
  if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {
228
- const triggerRect = triggerRef.current.getBoundingClientRect();
229
+ const triggerRect = getLogicalBoundingClientRect(triggerRef.current);
229
230
  const target = dropdownRef.current;
230
231
  if (fixedPosition.current) {
231
- if (fixedPosition.current.dropUp) {
232
- dropdownRef.current.style.bottom = `calc(100% - ${triggerRect.top}px)`;
232
+ if (fixedPosition.current.dropBlockStart) {
233
+ dropdownRef.current.style.insetBlockEnd = `calc(100% - ${triggerRect.insetBlockStart}px)`;
233
234
  }
234
235
  else {
235
- target.style.top = `${triggerRect.bottom}px`;
236
+ target.style.insetBlockStart = `${triggerRect.insetBlockEnd}px`;
236
237
  }
237
- if (fixedPosition.current.dropLeft) {
238
- target.style.left = `calc(${triggerRect.right}px - ${fixedPosition.current.width})`;
238
+ if (fixedPosition.current.dropInlineStart) {
239
+ target.style.insetInlineStart = `calc(${triggerRect.insetInlineEnd}px - ${fixedPosition.current.inlineSize})`;
239
240
  }
240
241
  else {
241
- target.style.left = `${triggerRect.left}px`;
242
+ target.style.insetInlineStart = `${triggerRect.insetInlineStart}px`;
242
243
  }
243
244
  }
244
245
  }
@@ -261,6 +262,6 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
261
262
  React.createElement(TransitionContent, { state: state, transitionRef: ref, dropdownClasses: dropdownClasses, open: open, stretchWidth: stretchWidth, interior: interior, header: header, expandToViewport: expandToViewport, stretchBeyondTriggerWidth: stretchBeyondTriggerWidth, footer: footer, onMouseDown: onMouseDown, isRefresh: isRefresh, dropdownRef: dropdownRef, verticalContainerRef: verticalContainerRef, position: position, id: dropdownContentId, role: dropdownContentRole, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby }, children),
262
263
  React.createElement(TabTrap, { focusNextCallback: () => { var _a; return triggerRef.current && ((_a = getFirstFocusable(triggerRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !loopFocus })))))));
263
264
  };
264
- const isInteriorPosition = (position) => position.bottom !== undefined;
265
+ const isInteriorPosition = (position) => position.insetBlockEnd !== undefined;
265
266
  export default Dropdown;
266
267
  //# sourceMappingURL=index.js.map
@@ -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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AAI,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,yBAAyB,EAAE,yBAAyB,EACpD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,mBAAmB,EACzB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,IAE/B,QAAQ,CACS;gBAEpB,oBAAC,OAAO,IACN,iBAAiB,EAAE,GAAG,EAAE,WAAC,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,CACU,CACK,CAChB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,QAAqD,EACf,EAAE,CAAE,QAAqC,CAAC,MAAM,KAAK,SAAS,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 {\n DropdownPosition,\n InteriorDropdownPosition,\n calculatePosition,\n defaultMaxDropdownWidth,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\n} 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';\nimport { useUniqueId } from '../../hooks/use-unique-id/index.js';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\ninterface DropdownContainerProps {\n children?: React.ReactNode;\n renderWithPortal?: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({ children, renderWithPortal = false, id, referrerId, open }: DropdownContainerProps) => {\n if (renderWithPortal) {\n if (open) {\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n document.body\n );\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 stretchBeyondTriggerWidth?: 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 id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\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-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\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 );\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 stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\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\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 || !nodeBelongs(wrapperRef.current, element)) &&\n (!dropdownContainerRef.current || !nodeBelongs(dropdownContainerRef.current, 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 // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\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 stretchBeyondTriggerWidth\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 (!nodeBelongs(dropdownRef.current, e.target) && !nodeBelongs(triggerRef.current, e.target)) {\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 const referrerId = useUniqueId();\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 id={referrerId} 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\n renderWithPortal={expandToViewport && !interior}\n id={dropdownId}\n referrerId={referrerId}\n open={open}\n >\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 stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\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,EAGL,iBAAiB,EACjB,uBAAuB,EACvB,yCAAyC,GAC1C,MAAM,wBAAwB,CAAC;AAChC,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,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,cAAc,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,E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AA,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC7F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B,CACE,CACP,CACU,CACK,CAChB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,QAAqD,EACf,EAAE,CAAE,QAAqC,CAAC,aAAa,KAAK,SAAS,CAAC;AAE9G,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 {\n DropdownPosition,\n InteriorDropdownPosition,\n calculatePosition,\n defaultMaxDropdownWidth,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\n} 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';\nimport { useUniqueId } from '../../hooks/use-unique-id/index.js';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { getLogicalBoundingClientRect } from '../../direction.js';\n\ninterface DropdownContainerProps {\n children?: React.ReactNode;\n renderWithPortal?: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({ children, renderWithPortal = false, id, referrerId, open }: DropdownContainerProps) => {\n if (renderWithPortal) {\n if (open) {\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n document.body\n );\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 stretchBeyondTriggerWidth?: 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 id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\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-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\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 );\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 stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\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.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;\n } else {\n verticalContainer.style.maxBlockSize = position.blockSize;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.inlineSize = position.inlineSize;\n }\n\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropBlockStart && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.insetBlockEnd = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.insetInlineStart && position.insetInlineStart !== 'auto') {\n target.style.insetInlineStart = position.insetInlineStart;\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.dropBlockStart) {\n target.style.insetBlockEnd = `calc(100% - ${triggerBox.top}px)`;\n } else {\n target.style.insetBlockStart = `${triggerBox.bottom}px`;\n }\n if (position.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerBox.right}px - ${position.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${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.dropBlockStart) {\n target.style.insetBlockEnd = position.insetBlockEnd;\n } else {\n target.style.insetBlockStart = position.insetBlockStart;\n }\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n if (position.dropBlockStart && position.dropInlineStart) {\n setPosition('top-left');\n } else if (position.dropBlockStart) {\n setPosition('top-right');\n } else if (position.dropInlineStart) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n const isOutsideDropdown = (element: Element) =>\n (!wrapperRef.current || !nodeBelongs(wrapperRef.current, element)) &&\n (!dropdownContainerRef.current || !nodeBelongs(dropdownContainerRef.current, 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 // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\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 stretchBeyondTriggerWidth\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 (!nodeBelongs(dropdownRef.current, e.target) && !nodeBelongs(triggerRef.current, e.target)) {\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 = getLogicalBoundingClientRect(triggerRef.current);\n const target = dropdownRef.current;\n if (fixedPosition.current) {\n if (fixedPosition.current.dropBlockStart) {\n dropdownRef.current.style.insetBlockEnd = `calc(100% - ${triggerRect.insetBlockStart}px)`;\n } else {\n target.style.insetBlockStart = `${triggerRect.insetBlockEnd}px`;\n }\n if (fixedPosition.current.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerRect.insetInlineEnd}px - ${fixedPosition.current.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerRect.insetInlineStart}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 const referrerId = useUniqueId();\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 id={referrerId} 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\n renderWithPortal={expandToViewport && !interior}\n id={dropdownId}\n referrerId={referrerId}\n open={open}\n >\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 stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\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).insetBlockEnd !== undefined;\n\nexport default Dropdown;\n"]}
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  export interface TooltipProps {
3
3
  value: number | string;
4
- trackRef: React.RefObject<Element>;
4
+ trackRef: React.RefObject<HTMLElement | SVGElement>;
5
5
  }
6
6
  export default function Tooltip({ value, trackRef }: TooltipProps): JSX.Element;
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,YAAY,eA4BhE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;CACrD;AAED,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,YAAY,eA4BhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAOrC,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAgB;IAC/D,OAAO,CACL,oBAAC,MAAM;QACL,6BAAK,SAAS,EAAE,MAAM,CAAC,IAAI;YACzB,oBAAC,UAAU,IAAC,EAAE,EAAE,IAAI,IACjB,GAAG,EAAE,CAAC,CACL,oBAAC,gBAAgB,IACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,KAAK,EACf,IAAI,EAAC,OAAO,EACZ,UAAU,EAAE,KAAK,EACjB,QAAQ,EAAC,KAAK,EACd,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CACjB,6BAAK,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC;oBACpF,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI;oBAChD,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI,CAC5C,CACP;gBAED,oBAAC,WAAW,IAAC,aAAa,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,IACpG,KAAK,CACM,CACG,CACpB,CACU,CACT,CACC,CACV,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { Transition } from '../transition';\nimport PopoverContainer from '../../../popover/container';\nimport PopoverBody from '../../../popover/body';\nimport Portal from '../portal';\nimport popoverStyles from '../../../popover/styles.css.js';\nimport styles from './styles.css.js';\n\nexport interface TooltipProps {\n value: number | string;\n trackRef: React.RefObject<Element>;\n}\n\nexport default function Tooltip({ value, trackRef }: TooltipProps) {\n return (\n <Portal>\n <div className={styles.root}>\n <Transition in={true}>\n {() => (\n <PopoverContainer\n trackRef={trackRef}\n trackKey={value}\n size=\"small\"\n fixedWidth={false}\n position=\"top\"\n arrow={position => (\n <div className={clsx(popoverStyles.arrow, popoverStyles[`arrow-position-${position}`])}>\n <div className={popoverStyles['arrow-outer']} />\n <div className={popoverStyles['arrow-inner']} />\n </div>\n )}\n >\n <PopoverBody dismissButton={false} dismissAriaLabel={undefined} onDismiss={undefined} header={undefined}>\n {value}\n </PopoverBody>\n </PopoverContainer>\n )}\n </Transition>\n </div>\n </Portal>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAOrC,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAgB;IAC/D,OAAO,CACL,oBAAC,MAAM;QACL,6BAAK,SAAS,EAAE,MAAM,CAAC,IAAI;YACzB,oBAAC,UAAU,IAAC,EAAE,EAAE,IAAI,IACjB,GAAG,EAAE,CAAC,CACL,oBAAC,gBAAgB,IACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,KAAK,EACf,IAAI,EAAC,OAAO,EACZ,UAAU,EAAE,KAAK,EACjB,QAAQ,EAAC,KAAK,EACd,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CACjB,6BAAK,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC;oBACpF,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI;oBAChD,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI,CAC5C,CACP;gBAED,oBAAC,WAAW,IAAC,aAAa,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,IACpG,KAAK,CACM,CACG,CACpB,CACU,CACT,CACC,CACV,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { Transition } from '../transition';\nimport PopoverContainer from '../../../popover/container';\nimport PopoverBody from '../../../popover/body';\nimport Portal from '../portal';\nimport popoverStyles from '../../../popover/styles.css.js';\nimport styles from './styles.css.js';\n\nexport interface TooltipProps {\n value: number | string;\n trackRef: React.RefObject<HTMLElement | SVGElement>;\n}\n\nexport default function Tooltip({ value, trackRef }: TooltipProps) {\n return (\n <Portal>\n <div className={styles.root}>\n <Transition in={true}>\n {() => (\n <PopoverContainer\n trackRef={trackRef}\n trackKey={value}\n size=\"small\"\n fixedWidth={false}\n position=\"top\"\n arrow={position => (\n <div className={clsx(popoverStyles.arrow, popoverStyles[`arrow-position-${position}`])}>\n <div className={popoverStyles['arrow-outer']} />\n <div className={popoverStyles['arrow-inner']} />\n </div>\n )}\n >\n <PopoverBody dismissButton={false} dismissAriaLabel={undefined} onDismiss={undefined} header={undefined}>\n {value}\n </PopoverBody>\n </PopoverContainer>\n )}\n </Transition>\n </div>\n </Portal>\n );\n}\n"]}
@@ -6,4 +6,18 @@ export declare function isRtl(element: HTMLElement | SVGElement): boolean;
6
6
  * systems using display scaling requiring the floor and ceiling calls.
7
7
  */
8
8
  export declare function getScrollInlineStart(element: HTMLElement): number;
9
+ /**
10
+ * The getBoundingClientRect() function returns values relative to the top left
11
+ * corner of the document regardless of document direction. The left/right position
12
+ * will be transformed to insetInlineStart based on element direction in order to
13
+ * support direction agnostic position computation.
14
+ */
15
+ export declare function getLogicalBoundingClientRect(element: HTMLElement | SVGElement): {
16
+ blockSize: number;
17
+ inlineSize: number;
18
+ insetBlockStart: number;
19
+ insetBlockEnd: number;
20
+ insetInlineStart: number;
21
+ insetInlineEnd: number;
22
+ };
9
23
  //# sourceMappingURL=direction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../../src/internal/direction.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,WAEtD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,UAExD"}
1
+ {"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../../src/internal/direction.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,WAEtD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,UAExD;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU;;;;;;;EAoB7E"}
@@ -12,4 +12,29 @@ export function isRtl(element) {
12
12
  export function getScrollInlineStart(element) {
13
13
  return isRtl(element) ? Math.floor(element.scrollLeft) * -1 : Math.ceil(element.scrollLeft);
14
14
  }
15
+ /**
16
+ * The getBoundingClientRect() function returns values relative to the top left
17
+ * corner of the document regardless of document direction. The left/right position
18
+ * will be transformed to insetInlineStart based on element direction in order to
19
+ * support direction agnostic position computation.
20
+ */
21
+ export function getLogicalBoundingClientRect(element) {
22
+ const boundingClientRect = element.getBoundingClientRect();
23
+ const blockSize = boundingClientRect.height;
24
+ const inlineSize = boundingClientRect.width;
25
+ const insetBlockStart = boundingClientRect.top;
26
+ const insetBlockEnd = boundingClientRect.bottom;
27
+ const insetInlineStart = isRtl(element)
28
+ ? document.documentElement.clientWidth - boundingClientRect.right
29
+ : boundingClientRect.left;
30
+ const insetInlineEnd = insetInlineStart + inlineSize;
31
+ return {
32
+ blockSize,
33
+ inlineSize,
34
+ insetBlockStart,
35
+ insetBlockEnd,
36
+ insetInlineStart,
37
+ insetInlineEnd,
38
+ };
39
+ }
15
40
  //# sourceMappingURL=direction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"direction.js","sourceRoot":"","sources":["../../../src/internal/direction.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,UAAU,KAAK,CAAC,OAAiC;IACrD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACvD,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC9F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function isRtl(element: HTMLElement | SVGElement) {\n return getComputedStyle(element).direction === 'rtl';\n}\n\n/**\n * The scrollLeft value will be a negative number if the direction is RTL and\n * needs to be converted to a positive value for direction independent scroll\n * computations. Additionally, the scrollLeft value can be a decimal value on\n * systems using display scaling requiring the floor and ceiling calls.\n */\nexport function getScrollInlineStart(element: HTMLElement) {\n return isRtl(element) ? Math.floor(element.scrollLeft) * -1 : Math.ceil(element.scrollLeft);\n}\n"]}
1
+ {"version":3,"file":"direction.js","sourceRoot":"","sources":["../../../src/internal/direction.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,UAAU,KAAK,CAAC,OAAiC;IACrD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACvD,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC9F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAAiC;IAC5E,MAAM,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAE3D,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAC5C,MAAM,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC;IAC5C,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC;IAC/C,MAAM,aAAa,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAChD,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC;QACrC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,WAAW,GAAG,kBAAkB,CAAC,KAAK;QACjE,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC;IAC5B,MAAM,cAAc,GAAG,gBAAgB,GAAG,UAAU,CAAC;IAErD,OAAO;QACL,SAAS;QACT,UAAU;QACV,eAAe;QACf,aAAa;QACb,gBAAgB;QAChB,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function isRtl(element: HTMLElement | SVGElement) {\n return getComputedStyle(element).direction === 'rtl';\n}\n\n/**\n * The scrollLeft value will be a negative number if the direction is RTL and\n * needs to be converted to a positive value for direction independent scroll\n * computations. Additionally, the scrollLeft value can be a decimal value on\n * systems using display scaling requiring the floor and ceiling calls.\n */\nexport function getScrollInlineStart(element: HTMLElement) {\n return isRtl(element) ? Math.floor(element.scrollLeft) * -1 : Math.ceil(element.scrollLeft);\n}\n\n/**\n * The getBoundingClientRect() function returns values relative to the top left\n * corner of the document regardless of document direction. The left/right position\n * will be transformed to insetInlineStart based on element direction in order to\n * support direction agnostic position computation.\n */\nexport function getLogicalBoundingClientRect(element: HTMLElement | SVGElement) {\n const boundingClientRect = element.getBoundingClientRect();\n\n const blockSize = boundingClientRect.height;\n const inlineSize = boundingClientRect.width;\n const insetBlockStart = boundingClientRect.top;\n const insetBlockEnd = boundingClientRect.bottom;\n const insetInlineStart = isRtl(element)\n ? document.documentElement.clientWidth - boundingClientRect.right\n : boundingClientRect.left;\n const insetInlineEnd = insetInlineStart + inlineSize;\n\n return {\n blockSize,\n inlineSize,\n insetBlockStart,\n insetBlockEnd,\n insetInlineStart,\n insetInlineEnd,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (395d6a9a)";
2
+ export var PACKAGE_VERSION = "3.0.0 (d3e2c615)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (395d6a9a)",
3
+ "PACKAGE_VERSION": "3.0.0 (d3e2c615)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "395d6a9a132d11ccfa111ec91b456e870872a1e8"
2
+ "commit": "d3e2c6152494624e3f8446308c16b48cc701fb2f"
3
3
  }
@@ -1,13 +1,17 @@
1
- import React from 'react';
2
- export default function handleKey(event: React.KeyboardEvent<HTMLElement>, { onActivate, onBlockEnd, onBlockStart, onEnd, onHome, onInlineEnd, onInlineStart, onPageDown, onPageUp, }: {
3
- onActivate?: (event: React.KeyboardEvent) => void;
4
- onBlockEnd?: (event: React.KeyboardEvent) => void;
5
- onBlockStart?: (event: React.KeyboardEvent) => void;
6
- onEnd?: (event: React.KeyboardEvent) => void;
7
- onHome?: (event: React.KeyboardEvent) => void;
8
- onInlineEnd?: (event: React.KeyboardEvent) => void;
9
- onInlineStart?: (event: React.KeyboardEvent) => void;
10
- onPageDown?: (event: React.KeyboardEvent) => void;
11
- onPageUp?: (event: React.KeyboardEvent) => void;
1
+ interface EventLike {
2
+ keyCode: number;
3
+ currentTarget: HTMLElement;
4
+ }
5
+ export default function handleKey(event: EventLike, { onActivate, onBlockEnd, onBlockStart, onEnd, onHome, onInlineEnd, onInlineStart, onPageDown, onPageUp, }: {
6
+ onActivate?: () => void;
7
+ onBlockEnd?: () => void;
8
+ onBlockStart?: () => void;
9
+ onEnd?: () => void;
10
+ onHome?: () => void;
11
+ onInlineEnd?: () => void;
12
+ onInlineStart?: () => void;
13
+ onPageDown?: () => void;
14
+ onPageUp?: () => void;
12
15
  }): void;
16
+ export {};
13
17
  //# sourceMappingURL=handle-key.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handle-key.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/handle-key.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,EACvC,EACE,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAClD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IACpD,KAAK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,32 @@ import { isRtl } from '../direction';
5
5
  export default function handleKey(event, { onActivate, onBlockEnd, onBlockStart, onEnd, onHome, onInlineEnd, onInlineStart, onPageDown, onPageUp, }) {
6
6
  switch (event.keyCode) {
7
7
  case KeyCode.down:
8
- onBlockEnd === null || onBlockEnd === void 0 ? void 0 : onBlockEnd(event);
8
+ onBlockEnd === null || onBlockEnd === void 0 ? void 0 : onBlockEnd();
9
9
  break;
10
10
  case KeyCode.end:
11
- onEnd === null || onEnd === void 0 ? void 0 : onEnd(event);
11
+ onEnd === null || onEnd === void 0 ? void 0 : onEnd();
12
12
  break;
13
13
  case KeyCode.enter:
14
14
  case KeyCode.space:
15
- onActivate === null || onActivate === void 0 ? void 0 : onActivate(event);
15
+ onActivate === null || onActivate === void 0 ? void 0 : onActivate();
16
16
  break;
17
17
  case KeyCode.home:
18
- onHome === null || onHome === void 0 ? void 0 : onHome(event);
18
+ onHome === null || onHome === void 0 ? void 0 : onHome();
19
19
  break;
20
20
  case KeyCode.left:
21
- isRtl(event.currentTarget) ? onInlineEnd === null || onInlineEnd === void 0 ? void 0 : onInlineEnd(event) : onInlineStart === null || onInlineStart === void 0 ? void 0 : onInlineStart(event);
21
+ isRtl(event.currentTarget) ? onInlineEnd === null || onInlineEnd === void 0 ? void 0 : onInlineEnd() : onInlineStart === null || onInlineStart === void 0 ? void 0 : onInlineStart();
22
22
  break;
23
23
  case KeyCode.pageDown:
24
- onPageDown === null || onPageDown === void 0 ? void 0 : onPageDown(event);
24
+ onPageDown === null || onPageDown === void 0 ? void 0 : onPageDown();
25
25
  break;
26
26
  case KeyCode.pageUp:
27
- onPageUp === null || onPageUp === void 0 ? void 0 : onPageUp(event);
27
+ onPageUp === null || onPageUp === void 0 ? void 0 : onPageUp();
28
28
  break;
29
29
  case KeyCode.right:
30
- isRtl(event.currentTarget) ? onInlineStart === null || onInlineStart === void 0 ? void 0 : onInlineStart(event) : onInlineEnd === null || onInlineEnd === void 0 ? void 0 : onInlineEnd(event);
30
+ isRtl(event.currentTarget) ? onInlineStart === null || onInlineStart === void 0 ? void 0 : onInlineStart() : onInlineEnd === null || onInlineEnd === void 0 ? void 0 : onInlineEnd();
31
31
  break;
32
32
  case KeyCode.up:
33
- onBlockStart === null || onBlockStart === void 0 ? void 0 : onBlockStart(event);
33
+ onBlockStart === null || onBlockStart === void 0 ? void 0 : onBlockStart();
34
34
  break;
35
35
  }
36
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handle-key.js","sourceRoot":"","sources":["../../../../src/internal/utils/handle-key.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAuC,EACvC,EACE,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,UAAU,EACV,QAAQ,GAWT;IAED,QAAQ,KAAK,CAAC,OAAO,EAAE;QACrB,KAAK,OAAO,CAAC,IAAI;YACf,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,KAAK,CAAC,CAAC;YACpB,MAAM;QACR,KAAK,OAAO,CAAC,GAAG;YACd,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,KAAK,CAAC,CAAC;YACf,MAAM;QACR,KAAK,OAAO,CAAC,KAAK,CAAC;QACnB,KAAK,OAAO,CAAC,KAAK;YAChB,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,KAAK,CAAC,CAAC;YACpB,MAAM;QACR,KAAK,OAAO,CAAC,IAAI;YACf,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,KAAK,CAAC,CAAC;YAChB,MAAM;QACR,KAAK,OAAO,CAAC,IAAI;YACf,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,CAAC;YAC3E,MAAM;QACR,KAAK,OAAO,CAAC,QAAQ;YACnB,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,KAAK,CAAC,CAAC;YACpB,MAAM;QACR,KAAK,OAAO,CAAC,MAAM;YACjB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,KAAK,CAAC,CAAC;YAClB,MAAM;QACR,KAAK,OAAO,CAAC,KAAK;YAChB,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,KAAK,CAAC,CAAC;YAC3E,MAAM;QACR,KAAK,OAAO,CAAC,EAAE;YACb,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,KAAK,CAAC,CAAC;YACtB,MAAM;KACT;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport { KeyCode } from '../keycode';\nimport { isRtl } from '../direction';\n\nexport default function handleKey(\n event: React.KeyboardEvent<HTMLElement>,\n {\n onActivate,\n onBlockEnd,\n onBlockStart,\n onEnd,\n onHome,\n onInlineEnd,\n onInlineStart,\n onPageDown,\n onPageUp,\n }: {\n onActivate?: (event: React.KeyboardEvent) => void;\n onBlockEnd?: (event: React.KeyboardEvent) => void;\n onBlockStart?: (event: React.KeyboardEvent) => void;\n onEnd?: (event: React.KeyboardEvent) => void;\n onHome?: (event: React.KeyboardEvent) => void;\n onInlineEnd?: (event: React.KeyboardEvent) => void;\n onInlineStart?: (event: React.KeyboardEvent) => void;\n onPageDown?: (event: React.KeyboardEvent) => void;\n onPageUp?: (event: React.KeyboardEvent) => void;\n }\n) {\n switch (event.keyCode) {\n case KeyCode.down:\n onBlockEnd?.(event);\n break;\n case KeyCode.end:\n onEnd?.(event);\n break;\n case KeyCode.enter:\n case KeyCode.space:\n onActivate?.(event);\n break;\n case KeyCode.home:\n onHome?.(event);\n break;\n case KeyCode.left:\n isRtl(event.currentTarget) ? onInlineEnd?.(event) : onInlineStart?.(event);\n break;\n case KeyCode.pageDown:\n onPageDown?.(event);\n break;\n case KeyCode.pageUp:\n onPageUp?.(event);\n break;\n case KeyCode.right:\n isRtl(event.currentTarget) ? onInlineStart?.(event) : onInlineEnd?.(event);\n break;\n case KeyCode.up:\n onBlockStart?.(event);\n break;\n }\n}\n"]}
1
+ {"version":3,"file":"handle-key.js","sourceRoot":"","sources":["../../../../src/internal/utils/handle-key.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAOrC,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAgB,EAChB,EACE,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,UAAU,EACV,QAAQ,GAWT;IAED,QAAQ,KAAK,CAAC,OAAO,EAAE;QACrB,KAAK,OAAO,CAAC,IAAI;YACf,UAAU,aAAV,UAAU,uBAAV,UAAU,EAAI,CAAC;YACf,MAAM;QACR,KAAK,OAAO,CAAC,GAAG;YACd,KAAK,aAAL,KAAK,uBAAL,KAAK,EAAI,CAAC;YACV,MAAM;QACR,KAAK,OAAO,CAAC,KAAK,CAAC;QACnB,KAAK,OAAO,CAAC,KAAK;YAChB,UAAU,aAAV,UAAU,uBAAV,UAAU,EAAI,CAAC;YACf,MAAM;QACR,KAAK,OAAO,CAAC,IAAI;YACf,MAAM,aAAN,MAAM,uBAAN,MAAM,EAAI,CAAC;YACX,MAAM;QACR,KAAK,OAAO,CAAC,IAAI;YACf,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,EAAI,CAAC,CAAC,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,EAAI,CAAC;YACjE,MAAM;QACR,KAAK,OAAO,CAAC,QAAQ;YACnB,UAAU,aAAV,UAAU,uBAAV,UAAU,EAAI,CAAC;YACf,MAAM;QACR,KAAK,OAAO,CAAC,MAAM;YACjB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,EAAI,CAAC;YACb,MAAM;QACR,KAAK,OAAO,CAAC,KAAK;YAChB,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,EAAI,CAAC,CAAC,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,EAAI,CAAC;YACjE,MAAM;QACR,KAAK,OAAO,CAAC,EAAE;YACb,YAAY,aAAZ,YAAY,uBAAZ,YAAY,EAAI,CAAC;YACjB,MAAM;KACT;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { KeyCode } from '../keycode';\nimport { isRtl } from '../direction';\n\ninterface EventLike {\n keyCode: number;\n currentTarget: HTMLElement;\n}\n\nexport default function handleKey(\n event: EventLike,\n {\n onActivate,\n onBlockEnd,\n onBlockStart,\n onEnd,\n onHome,\n onInlineEnd,\n onInlineStart,\n onPageDown,\n onPageUp,\n }: {\n onActivate?: () => void;\n onBlockEnd?: () => void;\n onBlockStart?: () => void;\n onEnd?: () => void;\n onHome?: () => void;\n onInlineEnd?: () => void;\n onInlineStart?: () => void;\n onPageDown?: () => void;\n onPageUp?: () => void;\n }\n) {\n switch (event.keyCode) {\n case KeyCode.down:\n onBlockEnd?.();\n break;\n case KeyCode.end:\n onEnd?.();\n break;\n case KeyCode.enter:\n case KeyCode.space:\n onActivate?.();\n break;\n case KeyCode.home:\n onHome?.();\n break;\n case KeyCode.left:\n isRtl(event.currentTarget) ? onInlineEnd?.() : onInlineStart?.();\n break;\n case KeyCode.pageDown:\n onPageDown?.();\n break;\n case KeyCode.pageUp:\n onPageUp?.();\n break;\n case KeyCode.right:\n isRtl(event.currentTarget) ? onInlineStart?.() : onInlineEnd?.();\n break;\n case KeyCode.up:\n onBlockStart?.();\n break;\n }\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  export interface BoundingBox {
2
- height: number;
3
- width: number;
4
- top: number;
5
- left: number;
2
+ blockSize: number;
3
+ inlineSize: number;
4
+ insetBlockStart: number;
5
+ insetInlineStart: number;
6
6
  }
7
7
  export declare const getOverflowParents: (element: HTMLElement) => HTMLElement[];
8
8
  export declare const getOverflowParentDimensions: ({ element, excludeClosestParent, expandToViewport, canExpandOutsideViewport, }: {
@@ -23,7 +23,7 @@ type ScrollIntoViewOptions = Parameters<HTMLElement['scrollIntoView']>[0];
23
23
  * @param options native options for `scrollIntoView`
24
24
  */
25
25
  export declare function scrollElementIntoView(element: HTMLElement | undefined, options?: ScrollIntoViewOptions): void;
26
- export declare function calculateScroll({ top, height }: BoundingBox): number;
26
+ export declare function calculateScroll({ insetBlockStart, blockSize }: BoundingBox): number;
27
27
  /**
28
28
  * For elements with fixed position, the browser's native scrollIntoView API doesn't work,
29
29
  * so we need to manually scroll to the element's position.
@@ -1 +1 @@
1
- {"version":3,"file":"scrollable-containers.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/scrollable-containers.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,kBAAkB,YAAa,WAAW,KAAG,WAAW,EAQpE,CAAC;AAEF,eAAO,MAAM,2BAA2B;aAM7B,WAAW;0BACE,OAAO;sBACX,OAAO;8BACC,OAAO;MAC/B,WAAW,EAqCd,CAAC;AAEF,KAAK,qBAAqB,GAAG,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,OAAO,GAAE,qBAA+D,QAGzE;AAED,wBAAgB,eAAe,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,WAAW,UAW3D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,WAAW,EAAE,gBAAgB,CAAC,EAAE,WAAW,QAKvF;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAOtF"}
1
+ {"version":3,"file":"scrollable-containers.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/scrollable-containers.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,kBAAkB,YAAa,WAAW,KAAG,WAAW,EAQpE,CAAC;AAEF,eAAO,MAAM,2BAA2B;aAM7B,WAAW;0BACE,OAAO;sBACX,OAAO;8BACC,OAAO;MAC/B,WAAW,EAqCd,CAAC;AAEF,KAAK,qBAAqB,GAAG,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,OAAO,GAAE,qBAA+D,QAGzE;AAED,wBAAgB,eAAe,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,WAAW,UAW1E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,WAAW,EAAE,gBAAgB,CAAC,EAAE,WAAW,QAKvF;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAOtF"}
@@ -17,27 +17,27 @@ export const getOverflowParentDimensions = ({ element, excludeClosestParent = fa
17
17
  return {
18
18
  // Treat the whole scrollable area as the available height
19
19
  // if we're allowed to expand past the viewport.
20
- height: canExpandOutsideViewport ? el.scrollHeight : height,
21
- width,
22
- top,
23
- left,
20
+ blockSize: canExpandOutsideViewport ? el.scrollHeight : height,
21
+ inlineSize: width,
22
+ insetBlockStart: top,
23
+ insetInlineStart: left,
24
24
  };
25
25
  });
26
26
  if (canExpandOutsideViewport && !expandToViewport) {
27
27
  const documentDimensions = document.documentElement.getBoundingClientRect();
28
28
  parents.push({
29
- width: Math.max(documentDimensions.width, document.documentElement.clientWidth),
30
- height: Math.max(documentDimensions.height, document.documentElement.clientHeight),
31
- top: documentDimensions.top,
32
- left: documentDimensions.left,
29
+ inlineSize: Math.max(documentDimensions.width, document.documentElement.clientWidth),
30
+ blockSize: Math.max(documentDimensions.height, document.documentElement.clientHeight),
31
+ insetBlockStart: documentDimensions.top,
32
+ insetInlineStart: documentDimensions.left,
33
33
  });
34
34
  }
35
35
  else {
36
36
  parents.push({
37
- height: window.innerHeight,
38
- width: window.innerWidth,
39
- top: 0,
40
- left: 0,
37
+ blockSize: window.innerHeight,
38
+ inlineSize: window.innerWidth,
39
+ insetBlockStart: 0,
40
+ insetInlineStart: 0,
41
41
  });
42
42
  }
43
43
  if (excludeClosestParent && !expandToViewport) {
@@ -59,16 +59,16 @@ export function scrollElementIntoView(element, options = { block: 'nearest', inl
59
59
  var _a;
60
60
  (_a = element === null || element === void 0 ? void 0 : element.scrollIntoView) === null || _a === void 0 ? void 0 : _a.call(element, options);
61
61
  }
62
- export function calculateScroll({ top, height }) {
63
- if (top < 0) {
64
- return top;
62
+ export function calculateScroll({ insetBlockStart, blockSize }) {
63
+ if (insetBlockStart < 0) {
64
+ return insetBlockStart;
65
65
  }
66
- else if (top + height > window.innerHeight) {
67
- if (height > window.innerHeight) {
68
- return top;
66
+ else if (insetBlockStart + blockSize > window.innerHeight) {
67
+ if (blockSize > window.innerHeight) {
68
+ return insetBlockStart;
69
69
  }
70
70
  else {
71
- return top + height - window.innerHeight;
71
+ return insetBlockStart + blockSize - window.innerHeight;
72
72
  }
73
73
  }
74
74
  return 0;