@cloudscape-design/components 3.0.609 → 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 (48) 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/button-dropdown/category-elements/styles.css.js +14 -14
  5. package/button-dropdown/category-elements/styles.scoped.css +25 -22
  6. package/button-dropdown/category-elements/styles.selectors.js +14 -14
  7. package/internal/components/chart-popover/index.d.ts +1 -1
  8. package/internal/components/chart-popover/index.d.ts.map +1 -1
  9. package/internal/components/chart-popover/index.js.map +1 -1
  10. package/internal/components/dropdown/dropdown-fit-handler.d.ts +12 -12
  11. package/internal/components/dropdown/dropdown-fit-handler.d.ts.map +1 -1
  12. package/internal/components/dropdown/dropdown-fit-handler.js +103 -83
  13. package/internal/components/dropdown/dropdown-fit-handler.js.map +1 -1
  14. package/internal/components/dropdown/index.d.ts.map +1 -1
  15. package/internal/components/dropdown/index.js +30 -29
  16. package/internal/components/dropdown/index.js.map +1 -1
  17. package/internal/components/tooltip/index.d.ts +1 -1
  18. package/internal/components/tooltip/index.d.ts.map +1 -1
  19. package/internal/components/tooltip/index.js.map +1 -1
  20. package/internal/direction.d.ts +14 -0
  21. package/internal/direction.d.ts.map +1 -1
  22. package/internal/direction.js +25 -0
  23. package/internal/direction.js.map +1 -1
  24. package/internal/environment.js +1 -1
  25. package/internal/environment.json +1 -1
  26. package/internal/manifest.json +1 -1
  27. package/internal/utils/scrollable-containers.d.ts +5 -5
  28. package/internal/utils/scrollable-containers.d.ts.map +1 -1
  29. package/internal/utils/scrollable-containers.js +19 -19
  30. package/internal/utils/scrollable-containers.js.map +1 -1
  31. package/package.json +1 -1
  32. package/popover/container.d.ts +1 -1
  33. package/popover/container.d.ts.map +1 -1
  34. package/popover/container.js.map +1 -1
  35. package/popover/interfaces.d.ts +4 -4
  36. package/popover/interfaces.d.ts.map +1 -1
  37. package/popover/interfaces.js.map +1 -1
  38. package/popover/styles.css.js +50 -50
  39. package/popover/styles.scoped.css +76 -64
  40. package/popover/styles.selectors.js +50 -50
  41. package/popover/use-popover-position.d.ts +1 -1
  42. package/popover/use-popover-position.d.ts.map +1 -1
  43. package/popover/use-popover-position.js +32 -29
  44. package/popover/use-popover-position.js.map +1 -1
  45. package/popover/utils/positions.d.ts +2 -2
  46. package/popover/utils/positions.d.ts.map +1 -1
  47. package/popover/utils/positions.js +74 -74
  48. package/popover/utils/positions.js.map +1 -1
@@ -1,19 +1,20 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { getBreakpointValue } from '../../breakpoints';
4
+ import { getLogicalBoundingClientRect } from '../../direction';
4
5
  import { getOverflowParents, getOverflowParentDimensions } from '../../utils/scrollable-containers';
5
6
  import styles from './styles.css.js';
6
7
  const AVAILABLE_SPACE_RESERVE_DEFAULT = 50;
7
8
  const AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL = 19; // 50 - 31
8
9
  const AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL = 20;
9
10
  const getClosestParentDimensions = (element) => {
10
- const parents = getOverflowParents(element).map(el => {
11
- const { height, width, top, left } = el.getBoundingClientRect();
11
+ const parents = getOverflowParents(element).map(element => {
12
+ const { blockSize, inlineSize, insetBlockStart, insetInlineStart } = getLogicalBoundingClientRect(element);
12
13
  return {
13
- height,
14
- width,
15
- top,
16
- left,
14
+ blockSize,
15
+ inlineSize,
16
+ insetBlockStart,
17
+ insetInlineStart,
17
18
  };
18
19
  });
19
20
  return parents.shift();
@@ -32,20 +33,28 @@ export const getAvailableSpace = ({ trigger, overflowParents, stretchWidth = fal
32
33
  : isMobile
33
34
  ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL
34
35
  : AVAILABLE_SPACE_RESERVE_DEFAULT;
35
- const { bottom: triggerBottom, left: triggerLeft, right: triggerRight } = trigger.getBoundingClientRect();
36
- return overflowParents.reduce(({ above, below, left, right }, overflowParent) => {
37
- const offsetTop = triggerBottom - overflowParent.top;
38
- const currentAbove = offsetTop - trigger.offsetHeight - availableSpaceReserveVertical;
39
- const currentBelow = overflowParent.height - offsetTop - availableSpaceReserveVertical;
40
- const currentLeft = triggerRight - overflowParent.left - availableSpaceReserveHorizontal;
41
- const currentRight = overflowParent.left + overflowParent.width - triggerLeft - availableSpaceReserveHorizontal;
36
+ const { insetBlockEnd: triggerBlockEnd, insetInlineStart: triggerInlineStart, insetInlineEnd: triggerInlineEnd, } = getLogicalBoundingClientRect(trigger);
37
+ return overflowParents.reduce(({ blockStart, blockEnd, inlineStart, inlineEnd }, overflowParent) => {
38
+ const offsetTop = triggerBlockEnd - overflowParent.insetBlockStart;
39
+ const currentBlockStart = offsetTop - trigger.offsetHeight - availableSpaceReserveVertical;
40
+ const currentBlockEnd = overflowParent.blockSize - offsetTop - availableSpaceReserveVertical;
41
+ const currentInlineStart = triggerInlineEnd - overflowParent.insetInlineStart - availableSpaceReserveHorizontal;
42
+ const currentInlineEnd = overflowParent.insetInlineStart +
43
+ overflowParent.inlineSize -
44
+ triggerInlineStart -
45
+ availableSpaceReserveHorizontal;
42
46
  return {
43
- above: Math.min(above, currentAbove),
44
- below: Math.min(below, currentBelow),
45
- left: Math.min(left, currentLeft),
46
- right: Math.min(right, currentRight),
47
+ blockStart: Math.min(blockStart, currentBlockStart),
48
+ blockEnd: Math.min(blockEnd, currentBlockEnd),
49
+ inlineStart: Math.min(inlineStart, currentInlineStart),
50
+ inlineEnd: Math.min(inlineEnd, currentInlineEnd),
47
51
  };
48
- }, { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE });
52
+ }, {
53
+ blockStart: Number.MAX_VALUE,
54
+ blockEnd: Number.MAX_VALUE,
55
+ inlineStart: Number.MAX_VALUE,
56
+ inlineEnd: Number.MAX_VALUE,
57
+ });
49
58
  };
50
59
  export const getInteriorAvailableSpace = ({ trigger, overflowParents, isMobile, }) => {
51
60
  const AVAILABLE_SPACE_RESERVE_VERTICAL = isMobile
@@ -54,32 +63,43 @@ export const getInteriorAvailableSpace = ({ trigger, overflowParents, isMobile,
54
63
  const AVAILABLE_SPACE_RESERVE_HORIZONTAL = isMobile
55
64
  ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL
56
65
  : AVAILABLE_SPACE_RESERVE_DEFAULT;
57
- const { bottom: triggerBottom, top: triggerTop, left: triggerLeft, right: triggerRight, } = trigger.getBoundingClientRect();
58
- return overflowParents.reduce(({ above, below, left, right }, overflowParent) => {
59
- const currentAbove = triggerBottom - overflowParent.top - AVAILABLE_SPACE_RESERVE_VERTICAL;
60
- const currentBelow = overflowParent.height - triggerTop + overflowParent.top - AVAILABLE_SPACE_RESERVE_VERTICAL;
61
- const currentLeft = triggerLeft - overflowParent.left - AVAILABLE_SPACE_RESERVE_HORIZONTAL;
62
- const currentRight = overflowParent.left + overflowParent.width - triggerRight - AVAILABLE_SPACE_RESERVE_HORIZONTAL;
66
+ const { insetBlockEnd: triggerBlockEnd, insetBlockStart: triggerBlockStart, insetInlineStart: triggerInlineStart, insetInlineEnd: triggerInlineEnd, } = getLogicalBoundingClientRect(trigger);
67
+ return overflowParents.reduce(({ blockStart, blockEnd, inlineStart, inlineEnd }, overflowParent) => {
68
+ const currentBlockStart = triggerBlockEnd - overflowParent.insetBlockStart - AVAILABLE_SPACE_RESERVE_VERTICAL;
69
+ const currentBlockEnd = overflowParent.blockSize -
70
+ triggerBlockStart +
71
+ overflowParent.insetBlockStart -
72
+ AVAILABLE_SPACE_RESERVE_VERTICAL;
73
+ const currentInlineStart = triggerInlineStart - overflowParent.insetInlineStart - AVAILABLE_SPACE_RESERVE_HORIZONTAL;
74
+ const currentInlineEnd = overflowParent.insetInlineStart +
75
+ overflowParent.inlineSize -
76
+ triggerInlineEnd -
77
+ AVAILABLE_SPACE_RESERVE_HORIZONTAL;
63
78
  return {
64
- above: Math.min(above, currentAbove),
65
- below: Math.min(below, currentBelow),
66
- left: Math.min(left, currentLeft),
67
- right: Math.min(right, currentRight),
79
+ blockStart: Math.min(blockStart, currentBlockStart),
80
+ blockEnd: Math.min(blockEnd, currentBlockEnd),
81
+ inlineStart: Math.min(inlineStart, currentInlineStart),
82
+ inlineEnd: Math.min(inlineEnd, currentInlineEnd),
68
83
  };
69
- }, { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE });
84
+ }, {
85
+ blockStart: Number.MAX_VALUE,
86
+ blockEnd: Number.MAX_VALUE,
87
+ inlineStart: Number.MAX_VALUE,
88
+ inlineEnd: Number.MAX_VALUE,
89
+ });
70
90
  };
71
91
  export const getWidths = ({ triggerElement, dropdownElement, desiredMinWidth, stretchBeyondTriggerWidth = false, }) => {
72
92
  // Determine the width of the trigger
73
- const triggerWidth = triggerElement.getBoundingClientRect().width;
93
+ const { inlineSize: triggerInlineSize } = getLogicalBoundingClientRect(triggerElement);
74
94
  // Minimum width is determined by either an explicit number (desiredMinWidth) or the trigger width
75
- const minWidth = desiredMinWidth ? Math.min(triggerWidth, desiredMinWidth) : triggerWidth;
95
+ const minWidth = desiredMinWidth ? Math.min(triggerInlineSize, desiredMinWidth) : triggerInlineSize;
76
96
  // If stretchBeyondTriggerWidth is true, the maximum width is the XS breakpoint (465px) or the trigger width (if bigger).
77
- const maxWidth = stretchBeyondTriggerWidth ? Math.max(defaultMaxDropdownWidth, triggerWidth) : Number.MAX_VALUE;
97
+ const maxWidth = stretchBeyondTriggerWidth ? Math.max(defaultMaxDropdownWidth, triggerInlineSize) : Number.MAX_VALUE;
78
98
  // Determine the actual dropdown width, the size that it "wants" to be
79
- const requiredWidth = dropdownElement.getBoundingClientRect().width;
99
+ const { inlineSize: requiredWidth } = getLogicalBoundingClientRect(dropdownElement);
80
100
  // Try to achieve the required/desired width within the given parameters
81
101
  const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);
82
- return { idealWidth, minWidth, triggerWidth };
102
+ return { idealWidth, minWidth, triggerInlineSize };
83
103
  };
84
104
  export const hasEnoughSpaceToStretchBeyondTriggerWidth = ({ triggerElement, dropdownElement, desiredMinWidth, expandToViewport, stretchWidth, stretchHeight, isMobile, }) => {
85
105
  const overflowParents = getOverflowParentDimensions({
@@ -101,7 +121,7 @@ export const hasEnoughSpaceToStretchBeyondTriggerWidth = ({ triggerElement, drop
101
121
  stretchHeight,
102
122
  isMobile,
103
123
  });
104
- return idealWidth <= availableSpace.left || idealWidth <= availableSpace.right;
124
+ return idealWidth <= availableSpace.inlineStart || idealWidth <= availableSpace.inlineEnd;
105
125
  };
106
126
  export const getDropdownPosition = ({ triggerElement, dropdownElement, overflowParents, minWidth: desiredMinWidth, preferCenter = false, stretchWidth = false, stretchHeight = false, isMobile = false, stretchBeyondTriggerWidth = false, }) => {
107
127
  // Determine the space available around the dropdown that it can grow in
@@ -112,91 +132,91 @@ export const getDropdownPosition = ({ triggerElement, dropdownElement, overflowP
112
132
  stretchHeight,
113
133
  isMobile,
114
134
  });
115
- const { idealWidth, minWidth, triggerWidth } = getWidths({
135
+ const { idealWidth, minWidth, triggerInlineSize } = getWidths({
116
136
  triggerElement,
117
137
  dropdownElement,
118
138
  desiredMinWidth,
119
139
  stretchBeyondTriggerWidth,
120
140
  });
121
- let dropLeft;
122
- let left = null;
123
- let width = idealWidth;
141
+ let dropInlineStart;
142
+ let insetInlineStart = null;
143
+ let inlineSize = idealWidth;
124
144
  //1. Can it be positioned with ideal width to the right?
125
- if (idealWidth <= availableSpace.right) {
126
- dropLeft = false;
145
+ if (idealWidth <= availableSpace.inlineEnd) {
146
+ dropInlineStart = false;
127
147
  //2. Can it be positioned with ideal width to the left?
128
148
  }
129
- else if (idealWidth <= availableSpace.left) {
130
- dropLeft = true;
149
+ else if (idealWidth <= availableSpace.inlineStart) {
150
+ dropInlineStart = true;
131
151
  //3. Fit into biggest available space either on left or right
132
152
  }
133
153
  else {
134
- dropLeft = availableSpace.left > availableSpace.right;
135
- width = Math.max(availableSpace.left, availableSpace.right, minWidth);
154
+ dropInlineStart = availableSpace.inlineStart > availableSpace.inlineEnd;
155
+ inlineSize = Math.max(availableSpace.inlineStart, availableSpace.inlineEnd, minWidth);
136
156
  }
137
157
  if (preferCenter) {
138
- const spillOver = (idealWidth - triggerWidth) / 2;
158
+ const spillOver = (idealWidth - triggerInlineSize) / 2;
139
159
  // availableSpace always includes the trigger width, but we want to exclude that
140
- const availableOutsideLeft = availableSpace.left - triggerWidth;
141
- const availableOutsideRight = availableSpace.right - triggerWidth;
160
+ const availableOutsideLeft = availableSpace.inlineStart - triggerInlineSize;
161
+ const availableOutsideRight = availableSpace.inlineEnd - triggerInlineSize;
142
162
  const fitsInCenter = availableOutsideLeft >= spillOver && availableOutsideRight >= spillOver;
143
163
  if (fitsInCenter) {
144
- left = -spillOver;
164
+ insetInlineStart = -spillOver;
145
165
  }
146
166
  }
147
- const dropUp = availableSpace.below < dropdownElement.offsetHeight && availableSpace.above > availableSpace.below;
148
- const availableHeight = dropUp ? availableSpace.above : availableSpace.below;
167
+ const dropBlockStart = availableSpace.blockEnd < dropdownElement.offsetHeight && availableSpace.blockStart > availableSpace.blockEnd;
168
+ const availableHeight = dropBlockStart ? availableSpace.blockStart : availableSpace.blockEnd;
149
169
  // Try and crop the bottom item when all options can't be displayed, affordance for "there's more"
150
170
  const croppedHeight = stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16;
151
171
  return {
152
- dropUp,
153
- dropLeft,
154
- left: left === null ? 'auto' : `${left}px`,
155
- height: `${croppedHeight}px`,
156
- width: `${width}px`,
172
+ dropBlockStart,
173
+ dropInlineStart,
174
+ insetInlineStart: insetInlineStart === null ? 'auto' : `${insetInlineStart}px`,
175
+ blockSize: `${croppedHeight}px`,
176
+ inlineSize: `${inlineSize}px`,
157
177
  };
158
178
  };
159
179
  export const getInteriorDropdownPosition = (trigger, dropdown, overflowParents, isMobile) => {
160
180
  const availableSpace = getInteriorAvailableSpace({ trigger, overflowParents, isMobile });
161
- const { bottom: triggerBottom, top: triggerTop, width: triggerWidth } = trigger.getBoundingClientRect();
162
- const { top: parentDropdownTop, height: parentDropdownHeight } = getClosestParentDimensions(trigger);
163
- let dropLeft;
164
- let width = dropdown.getBoundingClientRect().width;
165
- const top = triggerTop - parentDropdownTop;
166
- if (width <= availableSpace.right) {
167
- dropLeft = false;
181
+ const { insetBlockEnd: triggerBlockEnd, insetBlockStart: triggerBlockStart, inlineSize: triggerInlineSize, } = getLogicalBoundingClientRect(trigger);
182
+ const { insetBlockStart: parentDropdownBlockStart, blockSize: parentDropdownHeight } = getClosestParentDimensions(trigger);
183
+ let dropInlineStart;
184
+ let { inlineSize } = getLogicalBoundingClientRect(dropdown);
185
+ const insetBlockStart = triggerBlockStart - parentDropdownBlockStart;
186
+ if (inlineSize <= availableSpace.inlineEnd) {
187
+ dropInlineStart = false;
168
188
  }
169
- else if (width <= availableSpace.left) {
170
- dropLeft = true;
189
+ else if (inlineSize <= availableSpace.inlineStart) {
190
+ dropInlineStart = true;
171
191
  }
172
192
  else {
173
- dropLeft = availableSpace.left > availableSpace.right;
174
- width = Math.max(availableSpace.left, availableSpace.right);
193
+ dropInlineStart = availableSpace.inlineStart > availableSpace.inlineEnd;
194
+ inlineSize = Math.max(availableSpace.inlineStart, availableSpace.inlineEnd);
175
195
  }
176
- const left = dropLeft ? 0 - width : triggerWidth;
177
- const dropUp = availableSpace.below < dropdown.offsetHeight && availableSpace.above > availableSpace.below;
178
- const bottom = dropUp ? parentDropdownTop + parentDropdownHeight - triggerBottom : 0;
179
- const availableHeight = dropUp ? availableSpace.above : availableSpace.below;
196
+ const insetInlineStart = dropInlineStart ? 0 - inlineSize : triggerInlineSize;
197
+ const dropBlockStart = availableSpace.blockEnd < dropdown.offsetHeight && availableSpace.blockStart > availableSpace.blockEnd;
198
+ const insetBlockEnd = dropBlockStart ? parentDropdownBlockStart + parentDropdownHeight - triggerBlockEnd : 0;
199
+ const availableHeight = dropBlockStart ? availableSpace.blockStart : availableSpace.blockEnd;
180
200
  // Try and crop the bottom item when all options can't be displayed, affordance for "there's more"
181
201
  const croppedHeight = Math.floor(availableHeight / 31) * 31 + 16;
182
202
  return {
183
- dropUp,
184
- dropLeft,
185
- height: `${croppedHeight}px`,
186
- width: `${width}px`,
187
- top: `${top}px`,
188
- bottom: `${bottom}px`,
189
- left: `${left}px`,
203
+ dropBlockStart,
204
+ dropInlineStart,
205
+ blockSize: `${croppedHeight}px`,
206
+ inlineSize: `${inlineSize}px`,
207
+ insetBlockStart: `${insetBlockStart}px`,
208
+ insetBlockEnd: `${insetBlockEnd}px`,
209
+ insetInlineStart: `${insetInlineStart}px`,
190
210
  };
191
211
  };
192
212
  export const calculatePosition = (dropdownElement, triggerElement, verticalContainerElement, interior, expandToViewport, preferCenter, stretchWidth, stretchHeight, isMobile, minWidth, stretchBeyondTriggerWidth) => {
193
213
  // cleaning previously assigned values,
194
214
  // so that they are not reused in case of screen resize and similar events
195
- verticalContainerElement.style.maxHeight = '';
196
- dropdownElement.style.width = '';
197
- dropdownElement.style.top = '';
198
- dropdownElement.style.bottom = '';
199
- dropdownElement.style.left = '';
215
+ verticalContainerElement.style.maxBlockSize = '';
216
+ dropdownElement.style.inlineSize = '';
217
+ dropdownElement.style.insetBlockStart = '';
218
+ dropdownElement.style.insetBlockEnd = '';
219
+ dropdownElement.style.insetInlineStart = '';
200
220
  dropdownElement.classList.remove(styles['dropdown-drop-left']);
201
221
  dropdownElement.classList.remove(styles['dropdown-drop-right']);
202
222
  dropdownElement.classList.remove(styles['dropdown-drop-up']);
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown-fit-handler.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/dropdown-fit-handler.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;A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,CAAC,CAAC,2BAA2B,CAAC,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,CAAC;QACzF,CAAC,CAAC,mBAAmB,CAAC;YAClB,cAAc;YACd,eAAe;YACf,eAAe;YACf,QAAQ;YACR,YAAY;YACZ,YAAY;YACZ,aAAa;YACb,QAAQ;YACR,yBAAyB;SAC1B,CAAC,CAAC;IACP,MAAM,UAAU,GAAG,cAAc,CAAC,qBAAqB,EAAE,CAAC;IAC1D,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getBreakpointValue } from '../../breakpoints';\nimport { BoundingBox, getOverflowParents, getOverflowParentDimensions } from '../../utils/scrollable-containers';\nimport styles from './styles.css.js';\n\nconst AVAILABLE_SPACE_RESERVE_DEFAULT = 50;\nconst AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL = 19; // 50 - 31\nconst AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL = 20;\n\ninterface AvailableSpace {\n above: number;\n below: number;\n left: number;\n right: number;\n}\nexport interface DropdownPosition {\n height: string;\n width: string;\n dropUp: boolean;\n dropLeft: boolean;\n left: string;\n}\nexport interface InteriorDropdownPosition extends DropdownPosition {\n bottom: string;\n top: string;\n}\n\nconst getClosestParentDimensions = (element: HTMLElement): any => {\n const parents = getOverflowParents(element).map(el => {\n const { height, width, top, left } = el.getBoundingClientRect();\n return {\n height,\n width,\n top,\n left,\n };\n });\n\n return parents.shift();\n};\n\n// By default, most dropdowns should expand their content as necessary, but to a maximum of 465px (the XXS breakpoint).\n// This value was determined by UX but may be subject to change in the future, depending on the feedback.\nexport const defaultMaxDropdownWidth = getBreakpointValue('xxs');\n\nexport const getAvailableSpace = ({\n trigger,\n overflowParents,\n stretchWidth = false,\n stretchHeight = false,\n isMobile,\n}: {\n trigger: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n stretchWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n}): AvailableSpace => {\n const availableSpaceReserveVertical = stretchHeight\n ? 0\n : isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const availableSpaceReserveHorizontal = stretchWidth\n ? 0\n : isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const { bottom: triggerBottom, left: triggerLeft, right: triggerRight } = trigger.getBoundingClientRect();\n\n return overflowParents.reduce(\n ({ above, below, left, right }, overflowParent) => {\n const offsetTop = triggerBottom - overflowParent.top;\n const currentAbove = offsetTop - trigger.offsetHeight - availableSpaceReserveVertical;\n const currentBelow = overflowParent.height - offsetTop - availableSpaceReserveVertical;\n const currentLeft = triggerRight - overflowParent.left - availableSpaceReserveHorizontal;\n const currentRight = overflowParent.left + overflowParent.width - triggerLeft - availableSpaceReserveHorizontal;\n\n return {\n above: Math.min(above, currentAbove),\n below: Math.min(below, currentBelow),\n left: Math.min(left, currentLeft),\n right: Math.min(right, currentRight),\n };\n },\n { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE }\n );\n};\n\nexport const getInteriorAvailableSpace = ({\n trigger,\n overflowParents,\n isMobile,\n}: {\n trigger: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n isMobile?: boolean;\n}): AvailableSpace => {\n const AVAILABLE_SPACE_RESERVE_VERTICAL = isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const AVAILABLE_SPACE_RESERVE_HORIZONTAL = isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const {\n bottom: triggerBottom,\n top: triggerTop,\n left: triggerLeft,\n right: triggerRight,\n } = trigger.getBoundingClientRect();\n\n return overflowParents.reduce(\n ({ above, below, left, right }, overflowParent) => {\n const currentAbove = triggerBottom - overflowParent.top - AVAILABLE_SPACE_RESERVE_VERTICAL;\n const currentBelow = overflowParent.height - triggerTop + overflowParent.top - AVAILABLE_SPACE_RESERVE_VERTICAL;\n const currentLeft = triggerLeft - overflowParent.left - AVAILABLE_SPACE_RESERVE_HORIZONTAL;\n const currentRight =\n overflowParent.left + overflowParent.width - triggerRight - AVAILABLE_SPACE_RESERVE_HORIZONTAL;\n\n return {\n above: Math.min(above, currentAbove),\n below: Math.min(below, currentBelow),\n left: Math.min(left, currentLeft),\n right: Math.min(right, currentRight),\n };\n },\n { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE }\n );\n};\n\nexport const getWidths = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n stretchBeyondTriggerWidth?: boolean;\n}) => {\n // Determine the width of the trigger\n const triggerWidth = triggerElement.getBoundingClientRect().width;\n // Minimum width is determined by either an explicit number (desiredMinWidth) or the trigger width\n const minWidth = desiredMinWidth ? Math.min(triggerWidth, desiredMinWidth) : triggerWidth;\n // If stretchBeyondTriggerWidth is true, the maximum width is the XS breakpoint (465px) or the trigger width (if bigger).\n const maxWidth = stretchBeyondTriggerWidth ? Math.max(defaultMaxDropdownWidth, triggerWidth) : Number.MAX_VALUE;\n // Determine the actual dropdown width, the size that it \"wants\" to be\n const requiredWidth = dropdownElement.getBoundingClientRect().width;\n // Try to achieve the required/desired width within the given parameters\n const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);\n return { idealWidth, minWidth, triggerWidth };\n};\n\nexport const hasEnoughSpaceToStretchBeyondTriggerWidth = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n expandToViewport: boolean;\n stretchWidth: boolean;\n stretchHeight: boolean;\n isMobile: boolean;\n}) => {\n const overflowParents = getOverflowParentDimensions({\n element: dropdownElement,\n excludeClosestParent: false,\n expandToViewport,\n canExpandOutsideViewport: stretchHeight,\n });\n const { idealWidth } = getWidths({\n triggerElement: triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth: true,\n });\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n return idealWidth <= availableSpace.left || idealWidth <= availableSpace.right;\n};\n\nexport const getDropdownPosition = ({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth: desiredMinWidth,\n preferCenter = false,\n stretchWidth = false,\n stretchHeight = false,\n isMobile = false,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n minWidth?: number;\n preferCenter?: boolean;\n stretchWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n}): DropdownPosition => {\n // Determine the space available around the dropdown that it can grow in\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n const { idealWidth, minWidth, triggerWidth } = getWidths({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth,\n });\n\n let dropLeft: boolean;\n let left: number | null = null;\n let width = idealWidth;\n\n //1. Can it be positioned with ideal width to the right?\n if (idealWidth <= availableSpace.right) {\n dropLeft = false;\n //2. Can it be positioned with ideal width to the left?\n } else if (idealWidth <= availableSpace.left) {\n dropLeft = true;\n //3. Fit into biggest available space either on left or right\n } else {\n dropLeft = availableSpace.left > availableSpace.right;\n width = Math.max(availableSpace.left, availableSpace.right, minWidth);\n }\n\n if (preferCenter) {\n const spillOver = (idealWidth - triggerWidth) / 2;\n\n // availableSpace always includes the trigger width, but we want to exclude that\n const availableOutsideLeft = availableSpace.left - triggerWidth;\n const availableOutsideRight = availableSpace.right - triggerWidth;\n\n const fitsInCenter = availableOutsideLeft >= spillOver && availableOutsideRight >= spillOver;\n if (fitsInCenter) {\n left = -spillOver;\n }\n }\n\n const dropUp = availableSpace.below < dropdownElement.offsetHeight && availableSpace.above > availableSpace.below;\n const availableHeight = dropUp ? availableSpace.above : availableSpace.below;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropUp,\n dropLeft,\n left: left === null ? 'auto' : `${left}px`,\n height: `${croppedHeight}px`,\n width: `${width}px`,\n };\n};\n\nexport const getInteriorDropdownPosition = (\n trigger: HTMLElement,\n dropdown: HTMLElement,\n overflowParents: ReadonlyArray<BoundingBox>,\n isMobile?: boolean\n): InteriorDropdownPosition => {\n const availableSpace = getInteriorAvailableSpace({ trigger, overflowParents, isMobile });\n const { bottom: triggerBottom, top: triggerTop, width: triggerWidth } = trigger.getBoundingClientRect();\n const { top: parentDropdownTop, height: parentDropdownHeight } = getClosestParentDimensions(trigger);\n\n let dropLeft;\n\n let width = dropdown.getBoundingClientRect().width;\n const top = triggerTop - parentDropdownTop;\n if (width <= availableSpace.right) {\n dropLeft = false;\n } else if (width <= availableSpace.left) {\n dropLeft = true;\n } else {\n dropLeft = availableSpace.left > availableSpace.right;\n width = Math.max(availableSpace.left, availableSpace.right);\n }\n\n const left = dropLeft ? 0 - width : triggerWidth;\n\n const dropUp = availableSpace.below < dropdown.offsetHeight && availableSpace.above > availableSpace.below;\n const bottom = dropUp ? parentDropdownTop + parentDropdownHeight - triggerBottom : 0;\n const availableHeight = dropUp ? availableSpace.above : availableSpace.below;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropUp,\n dropLeft,\n height: `${croppedHeight}px`,\n width: `${width}px`,\n top: `${top}px`,\n bottom: `${bottom}px`,\n left: `${left}px`,\n };\n};\n\nexport const calculatePosition = (\n dropdownElement: HTMLDivElement,\n triggerElement: HTMLDivElement,\n verticalContainerElement: HTMLDivElement,\n interior: boolean,\n expandToViewport: boolean,\n preferCenter: boolean,\n stretchWidth: boolean,\n stretchHeight: boolean,\n isMobile: boolean,\n minWidth?: number,\n stretchBeyondTriggerWidth?: boolean\n): [DropdownPosition, DOMRect] => {\n // cleaning previously assigned values,\n // so that they are not reused in case of screen resize and similar events\n verticalContainerElement.style.maxHeight = '';\n dropdownElement.style.width = '';\n dropdownElement.style.top = '';\n dropdownElement.style.bottom = '';\n dropdownElement.style.left = '';\n\n dropdownElement.classList.remove(styles['dropdown-drop-left']);\n dropdownElement.classList.remove(styles['dropdown-drop-right']);\n dropdownElement.classList.remove(styles['dropdown-drop-up']);\n\n const overflowParents = getOverflowParentDimensions({\n element: dropdownElement,\n excludeClosestParent: interior,\n expandToViewport,\n canExpandOutsideViewport: stretchHeight,\n });\n const position = interior\n ? getInteriorDropdownPosition(triggerElement, dropdownElement, overflowParents, isMobile)\n : getDropdownPosition({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n stretchBeyondTriggerWidth,\n });\n const triggerBox = triggerElement.getBoundingClientRect();\n return [position, triggerBox];\n};\n"]}
1
+ {"version":3,"file":"dropdown-fit-handler.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/dropdown-fit-handler.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAe,kBAAkB,EAAE,2BAA2B,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;QAClD,OAAO,EAAE,eAAe;QACxB,oBAAoB,EAAE,QAAQ;QAC9B,gBAAgB;QAChB,wBAAwB,EAAE,aAAa;KACxC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,QAAQ;QACvB,CAAC,CAAC,2BAA2B,CAAC,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,CAAC;QACzF,CAAC,CAAC,mBAAmB,CAAC;YAClB,cAAc;YACd,eAAe;YACf,eAAe;YACf,QAAQ;YACR,YAAY;YACZ,YAAY;YACZ,aAAa;YACb,QAAQ;YACR,yBAAyB;SAC1B,CAAC,CAAC;IACP,MAAM,UAAU,GAAG,cAAc,CAAC,qBAAqB,EAAE,CAAC;IAC1D,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getBreakpointValue } from '../../breakpoints';\nimport { getLogicalBoundingClientRect } from '../../direction';\nimport { BoundingBox, getOverflowParents, getOverflowParentDimensions } from '../../utils/scrollable-containers';\nimport styles from './styles.css.js';\n\nconst AVAILABLE_SPACE_RESERVE_DEFAULT = 50;\nconst AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL = 19; // 50 - 31\nconst AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL = 20;\n\ninterface AvailableSpace {\n blockStart: number;\n blockEnd: number;\n inlineStart: number;\n inlineEnd: number;\n}\nexport interface DropdownPosition {\n blockSize: string;\n inlineSize: string;\n dropBlockStart: boolean;\n dropInlineStart: boolean;\n insetInlineStart: string;\n}\nexport interface InteriorDropdownPosition extends DropdownPosition {\n insetBlockEnd: string;\n insetBlockStart: string;\n}\n\nconst getClosestParentDimensions = (element: HTMLElement): any => {\n const parents = getOverflowParents(element).map(element => {\n const { blockSize, inlineSize, insetBlockStart, insetInlineStart } = getLogicalBoundingClientRect(element);\n return {\n blockSize,\n inlineSize,\n insetBlockStart,\n insetInlineStart,\n };\n });\n\n return parents.shift();\n};\n\n// By default, most dropdowns should expand their content as necessary, but to a maximum of 465px (the XXS breakpoint).\n// This value was determined by UX but may be subject to change in the future, depending on the feedback.\nexport const defaultMaxDropdownWidth = getBreakpointValue('xxs');\n\nexport const getAvailableSpace = ({\n trigger,\n overflowParents,\n stretchWidth = false,\n stretchHeight = false,\n isMobile,\n}: {\n trigger: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n stretchWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n}): AvailableSpace => {\n const availableSpaceReserveVertical = stretchHeight\n ? 0\n : isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const availableSpaceReserveHorizontal = stretchWidth\n ? 0\n : isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const {\n insetBlockEnd: triggerBlockEnd,\n insetInlineStart: triggerInlineStart,\n insetInlineEnd: triggerInlineEnd,\n } = getLogicalBoundingClientRect(trigger);\n\n return overflowParents.reduce(\n ({ blockStart, blockEnd, inlineStart, inlineEnd }, overflowParent) => {\n const offsetTop = triggerBlockEnd - overflowParent.insetBlockStart;\n const currentBlockStart = offsetTop - trigger.offsetHeight - availableSpaceReserveVertical;\n const currentBlockEnd = overflowParent.blockSize - offsetTop - availableSpaceReserveVertical;\n const currentInlineStart = triggerInlineEnd - overflowParent.insetInlineStart - availableSpaceReserveHorizontal;\n const currentInlineEnd =\n overflowParent.insetInlineStart +\n overflowParent.inlineSize -\n triggerInlineStart -\n availableSpaceReserveHorizontal;\n\n return {\n blockStart: Math.min(blockStart, currentBlockStart),\n blockEnd: Math.min(blockEnd, currentBlockEnd),\n inlineStart: Math.min(inlineStart, currentInlineStart),\n inlineEnd: Math.min(inlineEnd, currentInlineEnd),\n };\n },\n {\n blockStart: Number.MAX_VALUE,\n blockEnd: Number.MAX_VALUE,\n inlineStart: Number.MAX_VALUE,\n inlineEnd: Number.MAX_VALUE,\n }\n );\n};\n\nexport const getInteriorAvailableSpace = ({\n trigger,\n overflowParents,\n isMobile,\n}: {\n trigger: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n isMobile?: boolean;\n}): AvailableSpace => {\n const AVAILABLE_SPACE_RESERVE_VERTICAL = isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const AVAILABLE_SPACE_RESERVE_HORIZONTAL = isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const {\n insetBlockEnd: triggerBlockEnd,\n insetBlockStart: triggerBlockStart,\n insetInlineStart: triggerInlineStart,\n insetInlineEnd: triggerInlineEnd,\n } = getLogicalBoundingClientRect(trigger);\n\n return overflowParents.reduce(\n ({ blockStart, blockEnd, inlineStart, inlineEnd }, overflowParent) => {\n const currentBlockStart = triggerBlockEnd - overflowParent.insetBlockStart - AVAILABLE_SPACE_RESERVE_VERTICAL;\n const currentBlockEnd =\n overflowParent.blockSize -\n triggerBlockStart +\n overflowParent.insetBlockStart -\n AVAILABLE_SPACE_RESERVE_VERTICAL;\n const currentInlineStart =\n triggerInlineStart - overflowParent.insetInlineStart - AVAILABLE_SPACE_RESERVE_HORIZONTAL;\n const currentInlineEnd =\n overflowParent.insetInlineStart +\n overflowParent.inlineSize -\n triggerInlineEnd -\n AVAILABLE_SPACE_RESERVE_HORIZONTAL;\n\n return {\n blockStart: Math.min(blockStart, currentBlockStart),\n blockEnd: Math.min(blockEnd, currentBlockEnd),\n inlineStart: Math.min(inlineStart, currentInlineStart),\n inlineEnd: Math.min(inlineEnd, currentInlineEnd),\n };\n },\n {\n blockStart: Number.MAX_VALUE,\n blockEnd: Number.MAX_VALUE,\n inlineStart: Number.MAX_VALUE,\n inlineEnd: Number.MAX_VALUE,\n }\n );\n};\n\nexport const getWidths = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n stretchBeyondTriggerWidth?: boolean;\n}) => {\n // Determine the width of the trigger\n const { inlineSize: triggerInlineSize } = getLogicalBoundingClientRect(triggerElement);\n // Minimum width is determined by either an explicit number (desiredMinWidth) or the trigger width\n const minWidth = desiredMinWidth ? Math.min(triggerInlineSize, desiredMinWidth) : triggerInlineSize;\n // If stretchBeyondTriggerWidth is true, the maximum width is the XS breakpoint (465px) or the trigger width (if bigger).\n const maxWidth = stretchBeyondTriggerWidth ? Math.max(defaultMaxDropdownWidth, triggerInlineSize) : Number.MAX_VALUE;\n // Determine the actual dropdown width, the size that it \"wants\" to be\n const { inlineSize: requiredWidth } = getLogicalBoundingClientRect(dropdownElement);\n // Try to achieve the required/desired width within the given parameters\n const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);\n return { idealWidth, minWidth, triggerInlineSize };\n};\n\nexport const hasEnoughSpaceToStretchBeyondTriggerWidth = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n expandToViewport: boolean;\n stretchWidth: boolean;\n stretchHeight: boolean;\n isMobile: boolean;\n}) => {\n const overflowParents = getOverflowParentDimensions({\n element: dropdownElement,\n excludeClosestParent: false,\n expandToViewport,\n canExpandOutsideViewport: stretchHeight,\n });\n const { idealWidth } = getWidths({\n triggerElement: triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth: true,\n });\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n return idealWidth <= availableSpace.inlineStart || idealWidth <= availableSpace.inlineEnd;\n};\n\nexport const getDropdownPosition = ({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth: desiredMinWidth,\n preferCenter = false,\n stretchWidth = false,\n stretchHeight = false,\n isMobile = false,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n minWidth?: number;\n preferCenter?: boolean;\n stretchWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n}): DropdownPosition => {\n // Determine the space available around the dropdown that it can grow in\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n const { idealWidth, minWidth, triggerInlineSize } = getWidths({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth,\n });\n\n let dropInlineStart: boolean;\n let insetInlineStart: number | null = null;\n let inlineSize = idealWidth;\n\n //1. Can it be positioned with ideal width to the right?\n if (idealWidth <= availableSpace.inlineEnd) {\n dropInlineStart = false;\n //2. Can it be positioned with ideal width to the left?\n } else if (idealWidth <= availableSpace.inlineStart) {\n dropInlineStart = true;\n //3. Fit into biggest available space either on left or right\n } else {\n dropInlineStart = availableSpace.inlineStart > availableSpace.inlineEnd;\n inlineSize = Math.max(availableSpace.inlineStart, availableSpace.inlineEnd, minWidth);\n }\n\n if (preferCenter) {\n const spillOver = (idealWidth - triggerInlineSize) / 2;\n\n // availableSpace always includes the trigger width, but we want to exclude that\n const availableOutsideLeft = availableSpace.inlineStart - triggerInlineSize;\n const availableOutsideRight = availableSpace.inlineEnd - triggerInlineSize;\n\n const fitsInCenter = availableOutsideLeft >= spillOver && availableOutsideRight >= spillOver;\n if (fitsInCenter) {\n insetInlineStart = -spillOver;\n }\n }\n\n const dropBlockStart =\n availableSpace.blockEnd < dropdownElement.offsetHeight && availableSpace.blockStart > availableSpace.blockEnd;\n const availableHeight = dropBlockStart ? availableSpace.blockStart : availableSpace.blockEnd;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropBlockStart,\n dropInlineStart,\n insetInlineStart: insetInlineStart === null ? 'auto' : `${insetInlineStart}px`,\n blockSize: `${croppedHeight}px`,\n inlineSize: `${inlineSize}px`,\n };\n};\n\nexport const getInteriorDropdownPosition = (\n trigger: HTMLElement,\n dropdown: HTMLElement,\n overflowParents: ReadonlyArray<BoundingBox>,\n isMobile?: boolean\n): InteriorDropdownPosition => {\n const availableSpace = getInteriorAvailableSpace({ trigger, overflowParents, isMobile });\n const {\n insetBlockEnd: triggerBlockEnd,\n insetBlockStart: triggerBlockStart,\n inlineSize: triggerInlineSize,\n } = getLogicalBoundingClientRect(trigger);\n const { insetBlockStart: parentDropdownBlockStart, blockSize: parentDropdownHeight } =\n getClosestParentDimensions(trigger);\n\n let dropInlineStart;\n\n let { inlineSize } = getLogicalBoundingClientRect(dropdown);\n const insetBlockStart = triggerBlockStart - parentDropdownBlockStart;\n if (inlineSize <= availableSpace.inlineEnd) {\n dropInlineStart = false;\n } else if (inlineSize <= availableSpace.inlineStart) {\n dropInlineStart = true;\n } else {\n dropInlineStart = availableSpace.inlineStart > availableSpace.inlineEnd;\n inlineSize = Math.max(availableSpace.inlineStart, availableSpace.inlineEnd);\n }\n\n const insetInlineStart = dropInlineStart ? 0 - inlineSize : triggerInlineSize;\n\n const dropBlockStart =\n availableSpace.blockEnd < dropdown.offsetHeight && availableSpace.blockStart > availableSpace.blockEnd;\n const insetBlockEnd = dropBlockStart ? parentDropdownBlockStart + parentDropdownHeight - triggerBlockEnd : 0;\n const availableHeight = dropBlockStart ? availableSpace.blockStart : availableSpace.blockEnd;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropBlockStart,\n dropInlineStart,\n blockSize: `${croppedHeight}px`,\n inlineSize: `${inlineSize}px`,\n insetBlockStart: `${insetBlockStart}px`,\n insetBlockEnd: `${insetBlockEnd}px`,\n insetInlineStart: `${insetInlineStart}px`,\n };\n};\n\nexport const calculatePosition = (\n dropdownElement: HTMLDivElement,\n triggerElement: HTMLDivElement,\n verticalContainerElement: HTMLDivElement,\n interior: boolean,\n expandToViewport: boolean,\n preferCenter: boolean,\n stretchWidth: boolean,\n stretchHeight: boolean,\n isMobile: boolean,\n minWidth?: number,\n stretchBeyondTriggerWidth?: boolean\n): [DropdownPosition, DOMRect] => {\n // cleaning previously assigned values,\n // so that they are not reused in case of screen resize and similar events\n verticalContainerElement.style.maxBlockSize = '';\n dropdownElement.style.inlineSize = '';\n dropdownElement.style.insetBlockStart = '';\n dropdownElement.style.insetBlockEnd = '';\n dropdownElement.style.insetInlineStart = '';\n\n dropdownElement.classList.remove(styles['dropdown-drop-left']);\n dropdownElement.classList.remove(styles['dropdown-drop-right']);\n dropdownElement.classList.remove(styles['dropdown-drop-up']);\n\n const overflowParents = getOverflowParentDimensions({\n element: dropdownElement,\n excludeClosestParent: interior,\n expandToViewport,\n canExpandOutsideViewport: stretchHeight,\n });\n const position = interior\n ? getInteriorDropdownPosition(triggerElement, dropdownElement, overflowParents, isMobile)\n : getDropdownPosition({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n stretchBeyondTriggerWidth,\n });\n const triggerBox = triggerElement.getBoundingClientRect();\n return [position, triggerBox];\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;AAsI7C,QAAA,MAAM,QAAQ,iXA2BX,aAAa,gBAqTf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
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;AAuI7C,QAAA,MAAM,QAAQ,iXA2BX,aAAa,gBAqTf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
@@ -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