@cloudscape-design/components-themeable 3.0.1254 → 3.0.1256

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 (24) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  3. package/lib/internal/template/i18n/providers/remote-provider.d.ts.map +1 -1
  4. package/lib/internal/template/i18n/providers/remote-provider.js +10 -1
  5. package/lib/internal/template/i18n/providers/remote-provider.js.map +1 -1
  6. package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
  7. package/lib/internal/template/internal/components/dropdown/dropdown-fit-handler.d.ts +3 -2
  8. package/lib/internal/template/internal/components/dropdown/dropdown-fit-handler.d.ts.map +1 -1
  9. package/lib/internal/template/internal/components/dropdown/dropdown-fit-handler.js +5 -3
  10. package/lib/internal/template/internal/components/dropdown/dropdown-fit-handler.js.map +1 -1
  11. package/lib/internal/template/internal/components/dropdown/index.d.ts +1 -1
  12. package/lib/internal/template/internal/components/dropdown/index.d.ts.map +1 -1
  13. package/lib/internal/template/internal/components/dropdown/index.js +10 -7
  14. package/lib/internal/template/internal/components/dropdown/index.js.map +1 -1
  15. package/lib/internal/template/internal/components/dropdown/interfaces.d.ts +16 -0
  16. package/lib/internal/template/internal/components/dropdown/interfaces.d.ts.map +1 -1
  17. package/lib/internal/template/internal/components/dropdown/interfaces.js.map +1 -1
  18. package/lib/internal/template/internal/environment.js +2 -2
  19. package/lib/internal/template/internal/environment.json +2 -2
  20. package/lib/internal/template/mixed-line-bar-chart/hooks/use-mouse-hover.d.ts +1 -1
  21. package/lib/internal/template/mixed-line-bar-chart/hooks/use-mouse-hover.d.ts.map +1 -1
  22. package/lib/internal/template/mixed-line-bar-chart/hooks/use-mouse-hover.js +13 -5
  23. package/lib/internal/template/mixed-line-bar-chart/hooks/use-mouse-hover.js.map +1 -1
  24. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "8a33d63ffb172a5c01f6e222c130d4d7554fd57c"
2
+ "commit": "00b00b517ff58f0dd56cd8a565dac35b9306e04c"
3
3
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Build environment
3
- $awsui-commit-hash: "8a33d63f";
3
+ $awsui-commit-hash: "00b00b51";
4
4
  // Manually managed CSS-variables
5
5
  $maxContentWidth: --awsui-max-content-width-n6lfw8;
6
6
  $minContentWidth: --awsui-min-content-width-n6lfw8;
@@ -1 +1 @@
1
- {"version":3,"file":"remote-provider.d.ts","sourceRoot":"","sources":["../../../../src/i18n/providers/remote-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAK/D,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AAGjE,UAAU,sBAAsB;IAC9B,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAEpF,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,uBAAuB,eA+B9F"}
1
+ {"version":3,"file":"remote-provider.d.ts","sourceRoot":"","sources":["../../../../src/i18n/providers/remote-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AAGjE,UAAU,sBAAsB;IAC9B,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAEpF,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,uBAAuB,eAuC9F"}
@@ -1,6 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import React, { useContext, useEffect, useState } from 'react';
4
+ import { getGlobalFlag } from '@cloudscape-design/component-toolkit/internal';
4
5
  // NOTE: Ensure that direct or transitive dependencies never pull in
5
6
  // intl-messageformat or any `@formatjs` dependencies! Otherwise, it
6
7
  // would harm any bundle size improvements this component brings.
@@ -21,13 +22,18 @@ export default function RemoteI18nProvider({ loadFormatter, children }) {
21
22
  const [locale] = useState(() => determineAppLocale());
22
23
  const [staticLoadFormatter] = useState(() => loadFormatter);
23
24
  useEffect(() => {
25
+ let mounted = true;
24
26
  // Translations are already provided from a local provider, so skip.
25
27
  if (hasWrapperContext) {
26
28
  return;
27
29
  }
30
+ // Skip trying to load remote provider if the app layout widget is not available
31
+ if (!getGlobalFlag('appLayoutWidget')) {
32
+ return;
33
+ }
28
34
  staticLoadFormatter({ locale })
29
35
  .then(formatter => {
30
- if (formatter) {
36
+ if (formatter && mounted) {
31
37
  setFormatFunction(() => formatter.format.bind(formatter));
32
38
  }
33
39
  // If formatter isn't available, do nothing.
@@ -35,6 +41,9 @@ export default function RemoteI18nProvider({ loadFormatter, children }) {
35
41
  .catch(() => {
36
42
  // Do nothing. Failure in fetching the formatter should not be fatal.
37
43
  });
44
+ return () => {
45
+ mounted = false;
46
+ };
38
47
  }, [hasWrapperContext, locale, staticLoadFormatter]);
39
48
  const value = wrapperContext || (formatFunction && { locale, format: formatFunction });
40
49
  return React.createElement(InternalI18nContext.Provider, { value: value }, children);
@@ -1 +1 @@
1
- {"version":3,"file":"remote-provider.js","sourceRoot":"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AC;IACP,CAAC,EAAE,CAAC,iBAAiB,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAErD,MAAM,KAAK,GAAG,cAAc,IAAI,CAAC,cAAc,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IACvF,OAAO,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAgC,CAAC;AAC/F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useState } from 'react';\n\n// NOTE: Ensure that direct or transitive dependencies never pull in\n// intl-messageformat or any `@formatjs` dependencies! Otherwise, it\n// would harm any bundle size improvements this component brings.\nimport { FormatFunction, InternalI18nContext } from '../context';\nimport { determineAppLocale } from '../utils/locales';\n\ninterface I18nFormatterInterface {\n format: FormatFunction;\n}\n\nexport interface RemoteI18nProviderProps {\n /**\n * A format function, loaded dynamically from the result of this callback. If\n * the callback returns null, it means that the provider isn't available for\n * whatever reason, and nothing happens.\n */\n loadFormatter: (args: { locale: string }) => Promise<I18nFormatterInterface | null>;\n\n children: React.ReactNode;\n}\n\n/**\n * A lightweight implementation of the I18nProvider context wrapper that expects both the\n * messages and the formatting logic to be provided from a remote source. Explicitly does\n * nothing if it's wrapped by a LocalI18nProvider.\n */\nexport default function RemoteI18nProvider({ loadFormatter, children }: RemoteI18nProviderProps) {\n const wrapperContext = useContext(InternalI18nContext);\n const [formatFunction, setFormatFunction] = useState<FormatFunction | undefined>();\n\n // Ensure that every dependency of the effect below can never change.\n // The locale comes from the document, and the formatter only depends on that,\n // so it should never need to update either.\n const hasWrapperContext = !!wrapperContext;\n const [locale] = useState(() => determineAppLocale());\n const [staticLoadFormatter] = useState(() => loadFormatter);\n\n useEffect(() => {\n // Translations are already provided from a local provider, so skip.\n if (hasWrapperContext) {\n return;\n }\n\n staticLoadFormatter({ locale })\n .then(formatter => {\n if (formatter) {\n setFormatFunction(() => formatter.format.bind(formatter));\n }\n // If formatter isn't available, do nothing.\n })\n .catch(() => {\n // Do nothing. Failure in fetching the formatter should not be fatal.\n });\n }, [hasWrapperContext, locale, staticLoadFormatter]);\n\n const value = wrapperContext || (formatFunction && { locale, format: formatFunction });\n return <InternalI18nContext.Provider value={value}>{children}</InternalI18nContext.Provider>;\n}\n"]}
1
+ {"version":3,"file":"remote-provider.js","sourceRoot":"","sources":["../../../../src/i18n/providers/remote-provider.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAE9E,oEAAoE;AACpE,oEAAoE;AACpE,iEAAiE;AACjE,OAAO,EAAkB,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAiBtD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,aAAa,EAAE,QAAQ,EAA2B;IAC7F,MAAM,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IACvD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAA8B,CAAC;IAEnF,qEAAqE;IACrE,8EAA8E;IAC9E,4CAA4C;IAC5C,MAAM,iBAAiB,GAAG,CAAC,CAAC,cAAc,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACtD,MAAM,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;IAE5D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,oEAAoE;QACpE,IAAI,iBAAiB,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QACD,gFAAgF;QAChF,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACtC,OAAO;QACT,CAAC;QAED,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;aAC5B,IAAI,CAAC,SAAS,CAAC,EAAE;YAChB,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;gBACzB,iBAAiB,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YAC5D,CAAC;YACD,4CAA4C;QAC9C,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,qEAAqE;QACvE,CAAC,CAAC,CAAC;QACL,OAAO,GAAG,EAAE;YACV,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,iBAAiB,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAErD,MAAM,KAAK,GAAG,cAAc,IAAI,CAAC,cAAc,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IACvF,OAAO,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAgC,CAAC;AAC/F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useState } from 'react';\n\nimport { getGlobalFlag } from '@cloudscape-design/component-toolkit/internal';\n\n// NOTE: Ensure that direct or transitive dependencies never pull in\n// intl-messageformat or any `@formatjs` dependencies! Otherwise, it\n// would harm any bundle size improvements this component brings.\nimport { FormatFunction, InternalI18nContext } from '../context';\nimport { determineAppLocale } from '../utils/locales';\n\ninterface I18nFormatterInterface {\n format: FormatFunction;\n}\n\nexport interface RemoteI18nProviderProps {\n /**\n * A format function, loaded dynamically from the result of this callback. If\n * the callback returns null, it means that the provider isn't available for\n * whatever reason, and nothing happens.\n */\n loadFormatter: (args: { locale: string }) => Promise<I18nFormatterInterface | null>;\n\n children: React.ReactNode;\n}\n\n/**\n * A lightweight implementation of the I18nProvider context wrapper that expects both the\n * messages and the formatting logic to be provided from a remote source. Explicitly does\n * nothing if it's wrapped by a LocalI18nProvider.\n */\nexport default function RemoteI18nProvider({ loadFormatter, children }: RemoteI18nProviderProps) {\n const wrapperContext = useContext(InternalI18nContext);\n const [formatFunction, setFormatFunction] = useState<FormatFunction | undefined>();\n\n // Ensure that every dependency of the effect below can never change.\n // The locale comes from the document, and the formatter only depends on that,\n // so it should never need to update either.\n const hasWrapperContext = !!wrapperContext;\n const [locale] = useState(() => determineAppLocale());\n const [staticLoadFormatter] = useState(() => loadFormatter);\n\n useEffect(() => {\n let mounted = true;\n // Translations are already provided from a local provider, so skip.\n if (hasWrapperContext) {\n return;\n }\n // Skip trying to load remote provider if the app layout widget is not available\n if (!getGlobalFlag('appLayoutWidget')) {\n return;\n }\n\n staticLoadFormatter({ locale })\n .then(formatter => {\n if (formatter && mounted) {\n setFormatFunction(() => formatter.format.bind(formatter));\n }\n // If formatter isn't available, do nothing.\n })\n .catch(() => {\n // Do nothing. Failure in fetching the formatter should not be fatal.\n });\n return () => {\n mounted = false;\n };\n }, [hasWrapperContext, locale, staticLoadFormatter]);\n\n const value = wrapperContext || (formatFunction && { locale, format: formatFunction });\n return <InternalI18nContext.Provider value={value}>{children}</InternalI18nContext.Provider>;\n}\n"]}
@@ -3818,5 +3818,5 @@ body {
3818
3818
  }
3819
3819
  }
3820
3820
  :root {
3821
- --awsui-version-info-8a33d63f: true;
3821
+ --awsui-version-info-00b00b51: true;
3822
3822
  }
@@ -21,7 +21,7 @@ export declare const hasEnoughSpaceForFlexibleWidth: ({ triggerElement, dropdown
21
21
  stretchHeight: boolean;
22
22
  isMobile: boolean;
23
23
  }) => boolean;
24
- export declare const getDropdownPosition: ({ triggerElement, dropdownElement, overflowParents, minWidth: minWidthConstraint, maxWidth: maxWidthConstraint, preferCenter, matchTriggerWidth, stretchHeight, isMobile, }: {
24
+ export declare const getDropdownPosition: ({ triggerElement, dropdownElement, overflowParents, minWidth: minWidthConstraint, maxWidth: maxWidthConstraint, preferCenter, matchTriggerWidth, stretchHeight, isMobile, maxHeight, }: {
25
25
  triggerElement: HTMLElement;
26
26
  dropdownElement: HTMLElement;
27
27
  overflowParents: ReadonlyArray<BoundingBox>;
@@ -31,6 +31,7 @@ export declare const getDropdownPosition: ({ triggerElement, dropdownElement, ov
31
31
  matchTriggerWidth?: boolean;
32
32
  stretchHeight?: boolean;
33
33
  isMobile?: boolean;
34
+ maxHeight?: number;
34
35
  }) => DropdownPosition;
35
- export declare const calculatePosition: (dropdownElement: HTMLDivElement, triggerElement: HTMLDivElement, verticalContainerElement: HTMLDivElement, interior: boolean, expandToViewport: boolean, preferCenter: boolean, matchTriggerWidth: boolean, stretchHeight: boolean, isMobile: boolean, minWidth?: DropdownWidthConstraint, maxWidth?: DropdownWidthConstraint) => [DropdownPosition, LogicalDOMRect];
36
+ export declare const calculatePosition: (dropdownElement: HTMLDivElement, triggerElement: HTMLElement, verticalContainerElement: HTMLDivElement, interior: boolean, expandToViewport: boolean, preferCenter: boolean, matchTriggerWidth: boolean, stretchHeight: boolean, isMobile: boolean, minWidth?: DropdownWidthConstraint, maxWidth?: DropdownWidthConstraint, maxHeight?: number) => [DropdownPosition, LogicalDOMRect];
36
37
  //# sourceMappingURL=dropdown-fit-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown-fit-handler.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/dropdown-fit-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAmD,MAAM,mCAAmC,CAAC;AACjH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAcvD,MA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AW,uBAAuB,KACjC,CAAC,gBAAgB,EAAE,cAAc,CAkCnC,CAAC"}
1
+ {"version":3,"file":"dropdown-fit-handler.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/dropdown-fit-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAmD,MAAM,mCAAmC,CAAC;AACjH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAcvD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AACD,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAChE,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB;AAkKD,eAAO,MAAM,8BAA8B,GAAI,yHAQ5C;IACD,cAAc,EAAE,WAAW,CAAC;IAC5B,eAAe,EAAE,WAAW,CAAC;IAC7B,kBAAkB,CAAC,EAAE,uBAAuB,CAAC;IAC7C,kBAAkB,CAAC,EAAE,uBAAuB,CAAC;IAC7C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB,YAoBA,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,wLAWjC;IACD,cAAc,EAAE,WAAW,CAAC;IAC5B,eAAe,EAAE,WAAW,CAAC;IAC7B,eAAe,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,KAAG,gBA4DH,CAAC;AAkDF,eAAO,MAAM,iBAAiB,GAC5B,iBAAiB,cAAc,EAC/B,gBAAgB,WAAW,EAC3B,0BAA0B,cAAc,EACxC,UAAU,OAAO,EACjB,kBAAkB,OAAO,EACzB,cAAc,OAAO,EACrB,mBAAmB,OAAO,EAC1B,eAAe,OAAO,EACtB,UAAU,OAAO,EACjB,WAAW,uBAAuB,EAClC,WAAW,uBAAuB,EAClC,YAAY,MAAM,KACjB,CAAC,gBAAgB,EAAE,cAAc,CAoCnC,CAAC"}
@@ -122,7 +122,7 @@ export const hasEnoughSpaceForFlexibleWidth = ({ triggerElement, dropdownElement
122
122
  });
123
123
  return idealWidth <= availableSpace.inlineStart || idealWidth <= availableSpace.inlineEnd;
124
124
  };
125
- export const getDropdownPosition = ({ triggerElement, dropdownElement, overflowParents, minWidth: minWidthConstraint, maxWidth: maxWidthConstraint, preferCenter = false, matchTriggerWidth = false, stretchHeight = false, isMobile = false, }) => {
125
+ export const getDropdownPosition = ({ triggerElement, dropdownElement, overflowParents, minWidth: minWidthConstraint, maxWidth: maxWidthConstraint, preferCenter = false, matchTriggerWidth = false, stretchHeight = false, isMobile = false, maxHeight, }) => {
126
126
  // Determine the space available around the dropdown that it can grow in
127
127
  const availableSpace = getAvailableSpace({
128
128
  trigger: triggerElement,
@@ -167,11 +167,12 @@ export const getDropdownPosition = ({ triggerElement, dropdownElement, overflowP
167
167
  const availableHeight = dropBlockStart ? availableSpace.blockStart : availableSpace.blockEnd;
168
168
  // Try and crop the bottom item when all options can't be displayed, affordance for "there's more"
169
169
  const croppedHeight = Math.max(stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16, 15);
170
+ const blockSize = maxHeight ? `min(${croppedHeight}px, ${maxHeight}px)` : `${croppedHeight}px`;
170
171
  return {
171
172
  dropBlockStart,
172
173
  dropInlineStart,
173
174
  insetInlineStart: insetInlineStart === null ? 'auto' : `${insetInlineStart}px`,
174
- blockSize: `${croppedHeight}px`,
175
+ blockSize,
175
176
  inlineSize: `${inlineSize}px`,
176
177
  };
177
178
  };
@@ -208,7 +209,7 @@ const getInteriorDropdownPosition = (trigger, dropdown, overflowParents, isMobil
208
209
  insetInlineStart: `${insetInlineStart}px`,
209
210
  };
210
211
  };
211
- export const calculatePosition = (dropdownElement, triggerElement, verticalContainerElement, interior, expandToViewport, preferCenter, matchTriggerWidth, stretchHeight, isMobile, minWidth, maxWidth) => {
212
+ export const calculatePosition = (dropdownElement, triggerElement, verticalContainerElement, interior, expandToViewport, preferCenter, matchTriggerWidth, stretchHeight, isMobile, minWidth, maxWidth, maxHeight) => {
212
213
  // cleaning previously assigned values,
213
214
  // so that they are not reused in case of screen resize and similar events
214
215
  verticalContainerElement.style.maxBlockSize = '';
@@ -237,6 +238,7 @@ export const calculatePosition = (dropdownElement, triggerElement, verticalConta
237
238
  matchTriggerWidth,
238
239
  stretchHeight,
239
240
  isMobile,
241
+ maxHeight,
240
242
  });
241
243
  const triggerBox = getLogicalBoundingClientRect(triggerElement);
242
244
  return [position, triggerBox];
@@ -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,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAe,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAIjH,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAC3C,MAAM,uCAAuC,GAAG,EAAE,CAAC,CAAC,UAAU;AAC9D,MAAM,yCAAyC,GAAG,EAAE,CAAC;AAoBrD,MAAM,0BAA0B,GAAG,CAAC,OAAoB,E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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,QAAQ;YACR,YAAY;YACZ,iBAAiB;YACjB,aAAa;YACb,QAAQ;SACT,CAAC,CAAC;IACP,MAAM,UAAU,GAAG,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAChE,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 { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { BoundingBox, getOverflowParentDimensions, getOverflowParents } from '../../utils/scrollable-containers';\nimport { LogicalDOMRect } from './dropdown-position';\nimport { DropdownWidthConstraint } from './interfaces';\n\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\nconst 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\nconst 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\nconst resolveWidthConstraint = (\n constraint: DropdownWidthConstraint | undefined,\n triggerWidth: number,\n fallback: number\n): number => {\n if (constraint === 'trigger') {\n return triggerWidth;\n }\n if (typeof constraint === 'number') {\n return constraint;\n }\n return fallback;\n};\n\nconst getWidths = ({\n triggerElement,\n dropdownElement,\n minWidthConstraint,\n maxWidthConstraint,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n minWidthConstraint?: DropdownWidthConstraint;\n maxWidthConstraint?: DropdownWidthConstraint;\n}) => {\n const { inlineSize: triggerInlineSize } = getLogicalBoundingClientRect(triggerElement);\n const { inlineSize: requiredWidth } = getLogicalBoundingClientRect(dropdownElement);\n\n const minWidth = resolveWidthConstraint(minWidthConstraint, triggerInlineSize, 0);\n const maxWidth = resolveWidthConstraint(maxWidthConstraint, triggerInlineSize, Number.MAX_VALUE);\n\n const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);\n return { idealWidth, minWidth, triggerInlineSize };\n};\n\nexport const hasEnoughSpaceForFlexibleWidth = ({\n triggerElement,\n dropdownElement,\n minWidthConstraint,\n maxWidthConstraint,\n expandToViewport,\n stretchHeight,\n isMobile,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n minWidthConstraint?: DropdownWidthConstraint;\n maxWidthConstraint?: DropdownWidthConstraint;\n expandToViewport: 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 minWidthConstraint,\n maxWidthConstraint,\n });\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\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: minWidthConstraint,\n maxWidth: maxWidthConstraint,\n preferCenter = false,\n matchTriggerWidth = false,\n stretchHeight = false,\n isMobile = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n minWidth?: DropdownWidthConstraint;\n maxWidth?: DropdownWidthConstraint;\n preferCenter?: boolean;\n matchTriggerWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: 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: matchTriggerWidth,\n stretchHeight,\n isMobile,\n });\n const { idealWidth, minWidth, triggerInlineSize } = getWidths({\n triggerElement,\n dropdownElement,\n minWidthConstraint,\n maxWidthConstraint,\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 = Math.max(stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16, 15);\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\nconst 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 matchTriggerWidth: boolean,\n stretchHeight: boolean,\n isMobile: boolean,\n minWidth?: DropdownWidthConstraint,\n maxWidth?: DropdownWidthConstraint\n): [DropdownPosition, LogicalDOMRect] => {\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 maxWidth,\n preferCenter,\n matchTriggerWidth,\n stretchHeight,\n isMobile,\n });\n const triggerBox = getLogicalBoundingClientRect(triggerElement);\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,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAe,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAIjH,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAC3C,MAAM,uCAAuC,GAAG,EAAE,CAAC,CAAC,UAAU;AAC9D,MAAM,yCAAyC,GAAG,EAAE,CAAC;AAoBrD,MAAM,0BAA0B,GAAG,CAAC,OAAoB,EAAO,EA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O,EAAE,eAAe;QACxB,oBAAoB,EAAE,QAAQ;QAC9B,gBAAgB;QAChB,wBAAwB,EAAE,aAAa;KACxC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAgD,QAAQ;QACpE,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,QAAQ;YACR,YAAY;YACZ,iBAAiB;YACjB,aAAa;YACb,QAAQ;YACR,SAAS;SACV,CAAC,CAAC;IAEP,MAAM,UAAU,GAAG,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAChE,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 { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { BoundingBox, getOverflowParentDimensions, getOverflowParents } from '../../utils/scrollable-containers';\nimport { LogicalDOMRect } from './dropdown-position';\nimport { DropdownWidthConstraint } from './interfaces';\n\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\nconst 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\nconst 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\nconst resolveWidthConstraint = (\n constraint: DropdownWidthConstraint | undefined,\n triggerWidth: number,\n fallback: number\n): number => {\n if (constraint === 'trigger') {\n return triggerWidth;\n }\n if (typeof constraint === 'number') {\n return constraint;\n }\n return fallback;\n};\n\nconst getWidths = ({\n triggerElement,\n dropdownElement,\n minWidthConstraint,\n maxWidthConstraint,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n minWidthConstraint?: DropdownWidthConstraint;\n maxWidthConstraint?: DropdownWidthConstraint;\n}) => {\n const { inlineSize: triggerInlineSize } = getLogicalBoundingClientRect(triggerElement);\n const { inlineSize: requiredWidth } = getLogicalBoundingClientRect(dropdownElement);\n\n const minWidth = resolveWidthConstraint(minWidthConstraint, triggerInlineSize, 0);\n const maxWidth = resolveWidthConstraint(maxWidthConstraint, triggerInlineSize, Number.MAX_VALUE);\n\n const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);\n return { idealWidth, minWidth, triggerInlineSize };\n};\n\nexport const hasEnoughSpaceForFlexibleWidth = ({\n triggerElement,\n dropdownElement,\n minWidthConstraint,\n maxWidthConstraint,\n expandToViewport,\n stretchHeight,\n isMobile,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n minWidthConstraint?: DropdownWidthConstraint;\n maxWidthConstraint?: DropdownWidthConstraint;\n expandToViewport: 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 minWidthConstraint,\n maxWidthConstraint,\n });\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\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: minWidthConstraint,\n maxWidth: maxWidthConstraint,\n preferCenter = false,\n matchTriggerWidth = false,\n stretchHeight = false,\n isMobile = false,\n maxHeight,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n minWidth?: DropdownWidthConstraint;\n maxWidth?: DropdownWidthConstraint;\n preferCenter?: boolean;\n matchTriggerWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n maxHeight?: number;\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: matchTriggerWidth,\n stretchHeight,\n isMobile,\n });\n const { idealWidth, minWidth, triggerInlineSize } = getWidths({\n triggerElement,\n dropdownElement,\n minWidthConstraint,\n maxWidthConstraint,\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 = Math.max(stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16, 15);\n\n const blockSize = maxHeight ? `min(${croppedHeight}px, ${maxHeight}px)` : `${croppedHeight}px`;\n\n return {\n dropBlockStart,\n dropInlineStart,\n insetInlineStart: insetInlineStart === null ? 'auto' : `${insetInlineStart}px`,\n blockSize,\n inlineSize: `${inlineSize}px`,\n };\n};\n\nconst 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: HTMLElement,\n verticalContainerElement: HTMLDivElement,\n interior: boolean,\n expandToViewport: boolean,\n preferCenter: boolean,\n matchTriggerWidth: boolean,\n stretchHeight: boolean,\n isMobile: boolean,\n minWidth?: DropdownWidthConstraint,\n maxWidth?: DropdownWidthConstraint,\n maxHeight?: number\n): [DropdownPosition, LogicalDOMRect] => {\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: DropdownPosition | InteriorDropdownPosition = interior\n ? getInteriorDropdownPosition(triggerElement, dropdownElement, overflowParents, isMobile)\n : getDropdownPosition({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth,\n maxWidth,\n preferCenter,\n matchTriggerWidth,\n stretchHeight,\n isMobile,\n maxHeight,\n });\n\n const triggerBox = getLogicalBoundingClientRect(triggerElement);\n return [position, triggerBox];\n};\n"]}
@@ -1,4 +1,4 @@
1
1
  import { DropdownProps } from './interfaces';
2
- declare const Dropdown: ({ content, trigger, open, onOutsideClick, onMouseDown, header, footer, dropdownId, stretchTriggerHeight, stretchHeight, minWidth, maxWidth, hideBlockBorder, expandToViewport, preferredAlignment, interior, scrollable, loopFocus, onFocus, onBlur, onFocusEnter, onFocusLeave, onEscape, contentKey, dropdownContentId, ariaRole, ariaLabel, ariaLabelledby, ariaDescribedby, }: DropdownProps) => JSX.Element;
2
+ declare const Dropdown: ({ content, trigger, triggerRef: externalTriggerRef, triggerId: externalTriggerId, open, onOutsideClick, onMouseDown, header, footer, dropdownId, stretchTriggerHeight, stretchHeight, minWidth, maxWidth, maxHeight, hideBlockBorder, expandToViewport, preferredAlignment, interior, scrollable, loopFocus, onFocus, onBlur, onFocusEnter, onFocusLeave, onEscape, contentKey, dropdownContentId, ariaRole, ariaLabel, ariaLabelledby, ariaDescribedby, }: DropdownProps) => JSX.Element;
3
3
  export default Dropdown;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA+I7C,QAAA,MAAM,QAAQ,GAAI,mXA8Bf,aAAa,gBAyWf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA+I7C,QAAA,MAAM,QAAQ,GAAI,4bAiCf,aAAa,gBAoXf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
@@ -54,14 +54,16 @@ const TransitionContent = ({ state, transitionRef, dropdownClasses, matchTrigger
54
54
  content,
55
55
  footer)))));
56
56
  };
57
- const Dropdown = ({ content, trigger, open, onOutsideClick, onMouseDown, header, footer, dropdownId, stretchTriggerHeight = false, stretchHeight = false, minWidth, maxWidth, hideBlockBorder = true, expandToViewport = false, preferredAlignment = 'start', interior = false, scrollable = true, loopFocus = expandToViewport, onFocus, onBlur, onFocusEnter, onFocusLeave, onEscape, contentKey, dropdownContentId, ariaRole, ariaLabel, ariaLabelledby, ariaDescribedby, }) => {
57
+ const Dropdown = ({ content, trigger, triggerRef: externalTriggerRef, triggerId: externalTriggerId, open, onOutsideClick, onMouseDown, header, footer, dropdownId, stretchTriggerHeight = false, stretchHeight = false, minWidth, maxWidth, maxHeight, hideBlockBorder = true, expandToViewport = false, preferredAlignment = 'start', interior = false, scrollable = true, loopFocus = expandToViewport, onFocus, onBlur, onFocusEnter, onFocusLeave, onEscape, contentKey, dropdownContentId, ariaRole, ariaLabel, ariaLabelledby, ariaDescribedby, }) => {
58
58
  const wrapperRef = useRef(null);
59
- const triggerRef = useRef(null);
59
+ const internalTriggerRef = useRef(null);
60
60
  const dropdownRef = useRef(null);
61
61
  const dropdownContainerRef = useRef(null);
62
62
  const verticalContainerRef = useRef(null);
63
63
  // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning
64
64
  const fixedPosition = useRef(null);
65
+ // Use external trigger ref if provided, otherwise use internal ref
66
+ const triggerRef = externalTriggerRef || internalTriggerRef;
65
67
  const isRefresh = useVisualRefresh();
66
68
  const dropdownClasses = usePortalModeClasses(triggerRef);
67
69
  const [position, setPosition] = useState('bottom-right');
@@ -182,7 +184,7 @@ const Dropdown = ({ content, trigger, open, onOutsideClick, onMouseDown, header,
182
184
  if (scrollable) {
183
185
  dropdownRef.current.classList.add(styles.nowrap);
184
186
  }
185
- setDropdownPosition(...calculatePosition(dropdownRef.current, triggerRef.current, verticalContainerRef.current, interior, expandToViewport, preferCenter, matchTriggerWidth, stretchHeight, isMobile, minWidth, maxWidth), dropdownRef.current, verticalContainerRef.current);
187
+ setDropdownPosition(...calculatePosition(dropdownRef.current, triggerRef.current, verticalContainerRef.current, interior, expandToViewport, preferCenter, matchTriggerWidth, stretchHeight, isMobile, minWidth, maxWidth, maxHeight), dropdownRef.current, verticalContainerRef.current);
186
188
  if (scrollable) {
187
189
  dropdownRef.current.classList.remove(styles.nowrap);
188
190
  }
@@ -222,7 +224,7 @@ const Dropdown = ({ content, trigger, open, onOutsideClick, onMouseDown, header,
222
224
  return () => {
223
225
  window.removeEventListener('click', clickListener, true);
224
226
  };
225
- }, [open, onOutsideClick]);
227
+ }, [open, onOutsideClick, triggerRef]);
226
228
  // subscribe to Escape key press
227
229
  useEffect(() => {
228
230
  // Only add the listener if onEscape callback is provided
@@ -263,8 +265,9 @@ const Dropdown = ({ content, trigger, open, onOutsideClick, onMouseDown, header,
263
265
  return () => {
264
266
  controller.abort();
265
267
  };
266
- }, [open, expandToViewport, isMobile]);
267
- const referrerId = useUniqueId();
268
+ }, [open, expandToViewport, isMobile, triggerRef]);
269
+ const generatedReferrerId = useUniqueId();
270
+ const referrerId = externalTriggerId || generatedReferrerId;
268
271
  // Compute CSS variable values for min/max width
269
272
  // These will be used by the use-flexible-width CSS class
270
273
  const getMinWidthCssValue = () => {
@@ -288,7 +291,7 @@ const Dropdown = ({ content, trigger, open, onOutsideClick, onMouseDown, header,
288
291
  return '100%';
289
292
  };
290
293
  return (React.createElement("div", { className: clsx(styles.root, interior && styles.interior, stretchTriggerHeight && styles['stretch-trigger-height']), ref: wrapperRef, onFocus: focusHandler, onBlur: blurHandler },
291
- React.createElement("div", { id: referrerId, className: clsx(stretchTriggerHeight && styles['stretch-trigger-height']), ref: triggerRef }, trigger),
294
+ !externalTriggerRef && (React.createElement("div", { id: referrerId, className: clsx(stretchTriggerHeight && styles['stretch-trigger-height']), ref: internalTriggerRef }, trigger)),
292
295
  React.createElement(TabTrap, { focusNextCallback: () => { var _a; return dropdownRef.current && ((_a = getFirstFocusable(dropdownRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !loopFocus }),
293
296
  React.createElement(DropdownContainer, { triggerRef: triggerRef, renderWithPortal: expandToViewport && !interior, id: dropdownId, referrerId: referrerId, open: open },
294
297
  React.createElement(Transition, { in: open !== null && open !== void 0 ? open : false, exit: false }, (state, ref) => (React.createElement("div", { ref: dropdownContainerRef },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],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EAAE,WAAW,EACxB,YAAY,EAAE,iBAAiB,EAC/B,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,iBAAiB,EACrB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,GAChC;gBAEF,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,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 React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useResizeObserver, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../events';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\nimport TabTrap from '../tab-trap/index.js';\nimport { Transition, TransitionStatus } from '../transition';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport {\n calculatePosition,\n DropdownPosition,\n hasEnoughSpaceForFlexibleWidth,\n InteriorDropdownPosition,\n} from './dropdown-fit-handler';\nimport { applyDropdownPositionRelativeToViewport, LogicalDOMRect } from './dropdown-position';\nimport { DropdownProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface DropdownContainerProps {\n triggerRef: React.RefObject<HTMLElement>;\n children?: React.ReactNode;\n renderWithPortal: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({\n triggerRef,\n children,\n renderWithPortal,\n id,\n referrerId,\n open,\n}: DropdownContainerProps) => {\n if (!renderWithPortal) {\n return <>{children}</>;\n }\n if (!open) {\n return null;\n }\n const currentDocument = triggerRef.current?.ownerDocument ?? document;\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n currentDocument.body\n );\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n matchTriggerWidth: boolean;\n hideBlockBorder: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n minWidth?: string;\n maxWidth?: string;\n header?: React.ReactNode;\n content?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n onFocusEnter?: React.FocusEventHandler<Element>;\n onFocusLeave?: React.FocusEventHandler<Element>;\n id?: string;\n ariaRole?: string;\n ariaLabel?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n matchTriggerWidth,\n hideBlockBorder,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n minWidth,\n maxWidth,\n header,\n content,\n footer,\n position,\n open,\n onMouseDown,\n onFocusEnter,\n onFocusLeave,\n id,\n ariaRole,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n const dropdownStyles: Record<string, string> = {};\n if (minWidth) {\n dropdownStyles[customCssProps.dropdownDefaultMinWidth] = minWidth;\n }\n if (maxWidth) {\n dropdownStyles[customCssProps.dropdownDefaultMaxWidth] = maxWidth;\n }\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !matchTriggerWidth,\n [styles['hide-block-border']]: hideBlockBorder,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['use-flexible-width']]: !matchTriggerWidth && !interior,\n })}\n ref={contentRef}\n id={id}\n role={ariaRole}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={dropdownStyles}\n onMouseDown={onMouseDown}\n onFocus={onFocusEnter}\n onBlur={onFocusLeave}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !content && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {content}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n content,\n trigger,\n open,\n onOutsideClick,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchHeight = false,\n minWidth,\n maxWidth,\n hideBlockBorder = true,\n expandToViewport = false,\n preferredAlignment = 'start',\n interior = false,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n onFocusEnter,\n onFocusLeave,\n onEscape,\n contentKey,\n dropdownContentId,\n ariaRole,\n ariaLabel,\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 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 // Derive if dropdown should match trigger width exactly\n // This happens when both minWidth and maxWidth are explicitly set to 'trigger'\n const matchTriggerWidth = minWidth === 'trigger' && maxWidth === 'trigger';\n\n // Convert preferredAlignment to boolean for internal positioning logic\n const preferCenter = preferredAlignment === 'center';\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: LogicalDOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n verticalContainer.style.maxBlockSize = position.blockSize;\n\n // Only apply occupy-entire-width when matching trigger width exactly and not in portal mode\n if (!interior && matchTriggerWidth && !expandToViewport) {\n target.classList.add(styles['occupy-entire-width']);\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 applyDropdownPositionRelativeToViewport({\n position,\n dropdownElement: target,\n triggerRect: triggerBox,\n isMobile,\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 const isOutsideDropdownContent = (element: Element) =>\n !dropdownRef.current || !nodeBelongs(dropdownRef.current, element);\n\n const focusEnterHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdownContent(event.relatedTarget)) {\n fireNonCancelableEvent(onFocusEnter, event);\n }\n };\n\n const focusLeaveHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdownContent(event.relatedTarget)) {\n fireNonCancelableEvent(onFocusLeave, event);\n }\n };\n\n // Check if the dropdown has enough space to fit with its desired width constraints\n // If not, remove the class that allows flexible width sizing\n const fixStretching = () => {\n const classNameToRemove = styles['use-flexible-width'];\n if (\n open &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceForFlexibleWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n minWidthConstraint: minWidth,\n maxWidthConstraint: maxWidth,\n expandToViewport,\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 if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n matchTriggerWidth,\n stretchHeight,\n isMobile,\n minWidth,\n maxWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\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, matchTriggerWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (event: MouseEvent) => {\n // Since the listener is registered on the window, `event.target` will incorrectly point at the\n // shadow root if the component is rendered inside shadow DOM.\n const target = event.composedPath ? event.composedPath()[0] : event.target;\n if (!nodeBelongs(dropdownRef.current, target) && !nodeBelongs(triggerRef.current, target)) {\n fireNonCancelableEvent(onOutsideClick);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onOutsideClick]);\n\n // subscribe to Escape key press\n useEffect(() => {\n // Only add the listener if onEscape callback is provided\n if (!open || !onEscape) {\n return;\n }\n const keydownListener = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n // Prevent any surrounding modals or dialogs from acting on this Escape key\n event.stopPropagation();\n fireNonCancelableEvent(onEscape);\n }\n };\n window.addEventListener('keydown', keydownListener, true);\n\n return () => {\n window.removeEventListener('keydown', keydownListener, true);\n };\n }, [open, onEscape]);\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 && fixedPosition.current) {\n applyDropdownPositionRelativeToViewport({\n position: fixedPosition.current,\n dropdownElement: dropdownRef.current,\n triggerRect: getLogicalBoundingClientRect(triggerRef.current),\n isMobile,\n });\n }\n };\n\n updateDropdownPosition();\n\n const controller = new AbortController();\n window.addEventListener('scroll', updateDropdownPosition, { capture: true, signal: controller.signal });\n window.addEventListener('resize', updateDropdownPosition, { capture: true, signal: controller.signal });\n return () => {\n controller.abort();\n };\n }, [open, expandToViewport, isMobile]);\n\n const referrerId = useUniqueId();\n\n // Compute CSS variable values for min/max width\n // These will be used by the use-flexible-width CSS class\n const getMinWidthCssValue = (): string | undefined => {\n if (minWidth === undefined) {\n return undefined;\n }\n if (typeof minWidth === 'number') {\n return `${minWidth}px`;\n }\n // 'trigger' maps to 100% (relative to parent)\n return '100%';\n };\n\n const getMaxWidthCssValue = (): string | undefined => {\n if (maxWidth === undefined) {\n return 'none';\n }\n if (typeof maxWidth === 'number') {\n return `${maxWidth}px`;\n }\n // 'trigger' maps to 100% (relative to parent)\n return '100%';\n };\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 triggerRef={triggerRef}\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 matchTriggerWidth={matchTriggerWidth}\n hideBlockBorder={hideBlockBorder}\n interior={interior}\n header={header}\n content={content}\n expandToViewport={expandToViewport}\n minWidth={getMinWidthCssValue()}\n maxWidth={getMaxWidthCssValue()}\n footer={footer}\n onMouseDown={onMouseDown}\n onFocusEnter={focusEnterHandler}\n onFocusLeave={focusLeaveHandler}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n ariaRole={ariaRole}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n />\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
+ {"version":3,"file":"index.js","sourceRoot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,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,iBAAiB,EAAE,iBAAiB,EACpC,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,iBAAiB,EAC/B,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,iBAAiB,EACrB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,GAChC;gBAEF,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,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 React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useResizeObserver, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../events';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\nimport TabTrap from '../tab-trap/index.js';\nimport { Transition, TransitionStatus } from '../transition';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport {\n calculatePosition,\n DropdownPosition,\n hasEnoughSpaceForFlexibleWidth,\n InteriorDropdownPosition,\n} from './dropdown-fit-handler';\nimport { applyDropdownPositionRelativeToViewport, LogicalDOMRect } from './dropdown-position';\nimport { DropdownProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface DropdownContainerProps {\n triggerRef: React.RefObject<HTMLElement>;\n children?: React.ReactNode;\n renderWithPortal: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({\n triggerRef,\n children,\n renderWithPortal,\n id,\n referrerId,\n open,\n}: DropdownContainerProps) => {\n if (!renderWithPortal) {\n return <>{children}</>;\n }\n if (!open) {\n return null;\n }\n const currentDocument = triggerRef.current?.ownerDocument ?? document;\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n currentDocument.body\n );\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n matchTriggerWidth: boolean;\n hideBlockBorder: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n minWidth?: string;\n maxWidth?: string;\n header?: React.ReactNode;\n content?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n onFocusEnter?: React.FocusEventHandler<Element>;\n onFocusLeave?: React.FocusEventHandler<Element>;\n id?: string;\n ariaRole?: string;\n ariaLabel?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n matchTriggerWidth,\n hideBlockBorder,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n minWidth,\n maxWidth,\n header,\n content,\n footer,\n position,\n open,\n onMouseDown,\n onFocusEnter,\n onFocusLeave,\n id,\n ariaRole,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n const dropdownStyles: Record<string, string> = {};\n if (minWidth) {\n dropdownStyles[customCssProps.dropdownDefaultMinWidth] = minWidth;\n }\n if (maxWidth) {\n dropdownStyles[customCssProps.dropdownDefaultMaxWidth] = maxWidth;\n }\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !matchTriggerWidth,\n [styles['hide-block-border']]: hideBlockBorder,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['use-flexible-width']]: !matchTriggerWidth && !interior,\n })}\n ref={contentRef}\n id={id}\n role={ariaRole}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={dropdownStyles}\n onMouseDown={onMouseDown}\n onFocus={onFocusEnter}\n onBlur={onFocusLeave}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !content && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {content}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n content,\n trigger,\n triggerRef: externalTriggerRef,\n triggerId: externalTriggerId,\n open,\n onOutsideClick,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchHeight = false,\n minWidth,\n maxWidth,\n maxHeight,\n hideBlockBorder = true,\n expandToViewport = false,\n preferredAlignment = 'start',\n interior = false,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n onFocusEnter,\n onFocusLeave,\n onEscape,\n contentKey,\n dropdownContentId,\n ariaRole,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const internalTriggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\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 // Use external trigger ref if provided, otherwise use internal ref\n const triggerRef = externalTriggerRef || internalTriggerRef;\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 // Derive if dropdown should match trigger width exactly\n // This happens when both minWidth and maxWidth are explicitly set to 'trigger'\n const matchTriggerWidth = minWidth === 'trigger' && maxWidth === 'trigger';\n\n // Convert preferredAlignment to boolean for internal positioning logic\n const preferCenter = preferredAlignment === 'center';\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: LogicalDOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n verticalContainer.style.maxBlockSize = position.blockSize;\n\n // Only apply occupy-entire-width when matching trigger width exactly and not in portal mode\n if (!interior && matchTriggerWidth && !expandToViewport) {\n target.classList.add(styles['occupy-entire-width']);\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 applyDropdownPositionRelativeToViewport({\n position,\n dropdownElement: target,\n triggerRect: triggerBox,\n isMobile,\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 const isOutsideDropdownContent = (element: Element) =>\n !dropdownRef.current || !nodeBelongs(dropdownRef.current, element);\n\n const focusEnterHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdownContent(event.relatedTarget)) {\n fireNonCancelableEvent(onFocusEnter, event);\n }\n };\n\n const focusLeaveHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdownContent(event.relatedTarget)) {\n fireNonCancelableEvent(onFocusLeave, event);\n }\n };\n\n // Check if the dropdown has enough space to fit with its desired width constraints\n // If not, remove the class that allows flexible width sizing\n const fixStretching = () => {\n const classNameToRemove = styles['use-flexible-width'];\n if (\n open &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceForFlexibleWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n minWidthConstraint: minWidth,\n maxWidthConstraint: maxWidth,\n expandToViewport,\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 if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n matchTriggerWidth,\n stretchHeight,\n isMobile,\n minWidth,\n maxWidth,\n maxHeight\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\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, matchTriggerWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (event: MouseEvent) => {\n // Since the listener is registered on the window, `event.target` will incorrectly point at the\n // shadow root if the component is rendered inside shadow DOM.\n const target = event.composedPath ? event.composedPath()[0] : event.target;\n if (!nodeBelongs(dropdownRef.current, target) && !nodeBelongs(triggerRef.current, target)) {\n fireNonCancelableEvent(onOutsideClick);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onOutsideClick, triggerRef]);\n\n // subscribe to Escape key press\n useEffect(() => {\n // Only add the listener if onEscape callback is provided\n if (!open || !onEscape) {\n return;\n }\n const keydownListener = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n // Prevent any surrounding modals or dialogs from acting on this Escape key\n event.stopPropagation();\n fireNonCancelableEvent(onEscape);\n }\n };\n window.addEventListener('keydown', keydownListener, true);\n\n return () => {\n window.removeEventListener('keydown', keydownListener, true);\n };\n }, [open, onEscape]);\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 && fixedPosition.current) {\n applyDropdownPositionRelativeToViewport({\n position: fixedPosition.current,\n dropdownElement: dropdownRef.current,\n triggerRect: getLogicalBoundingClientRect(triggerRef.current),\n isMobile,\n });\n }\n };\n\n updateDropdownPosition();\n\n const controller = new AbortController();\n window.addEventListener('scroll', updateDropdownPosition, { capture: true, signal: controller.signal });\n window.addEventListener('resize', updateDropdownPosition, { capture: true, signal: controller.signal });\n return () => {\n controller.abort();\n };\n }, [open, expandToViewport, isMobile, triggerRef]);\n\n const generatedReferrerId = useUniqueId();\n const referrerId = externalTriggerId || generatedReferrerId;\n\n // Compute CSS variable values for min/max width\n // These will be used by the use-flexible-width CSS class\n const getMinWidthCssValue = (): string | undefined => {\n if (minWidth === undefined) {\n return undefined;\n }\n if (typeof minWidth === 'number') {\n return `${minWidth}px`;\n }\n // 'trigger' maps to 100% (relative to parent)\n return '100%';\n };\n\n const getMaxWidthCssValue = (): string | undefined => {\n if (maxWidth === undefined) {\n return 'none';\n }\n if (typeof maxWidth === 'number') {\n return `${maxWidth}px`;\n }\n // 'trigger' maps to 100% (relative to parent)\n return '100%';\n };\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 {!externalTriggerRef && (\n <div\n id={referrerId}\n className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])}\n ref={internalTriggerRef}\n >\n {trigger}\n </div>\n )}\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <DropdownContainer\n triggerRef={triggerRef}\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 matchTriggerWidth={matchTriggerWidth}\n hideBlockBorder={hideBlockBorder}\n interior={interior}\n header={header}\n content={content}\n expandToViewport={expandToViewport}\n minWidth={getMinWidthCssValue()}\n maxWidth={getMaxWidthCssValue()}\n footer={footer}\n onMouseDown={onMouseDown}\n onFocusEnter={focusEnterHandler}\n onFocusLeave={focusLeaveHandler}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n ariaRole={ariaRole}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n />\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"]}
@@ -50,6 +50,17 @@ export interface DropdownProps extends ExpandToViewport {
50
50
  * Trigger element.
51
51
  */
52
52
  trigger: React.ReactNode;
53
+ /**
54
+ * Optional ref to an external element used for positioning calculations.
55
+ * When provided, the `trigger` prop is not rendered and this ref's element
56
+ * is used as the positioning anchor for the dropdown instead.
57
+ */
58
+ triggerRef?: React.RefObject<HTMLElement>;
59
+ /**
60
+ * Explicit ID for the trigger element, used as the referrer ID for portal mode.
61
+ * Use this when `triggerRef` is provided.
62
+ */
63
+ triggerId?: string;
53
64
  /**
54
65
  * "Sticky" header of the dropdown content
55
66
  */
@@ -106,6 +117,11 @@ export interface DropdownProps extends ExpandToViewport {
106
117
  * - undefined: fit to content width (no max constraint)
107
118
  */
108
119
  maxWidth?: DropdownWidthConstraint;
120
+ /**
121
+ * Maximum height constraint for the dropdown content in pixels.
122
+ * When set, constrains the calculated height to not exceed this value.
123
+ */
124
+ maxHeight?: number;
109
125
  /**
110
126
  * Preferred alignment of the dropdown relative to its trigger.
111
127
  * The dropdown will attempt this alignment first, but will automatically
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/interfaces.ts"],"names":[],"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AE,QAAQ,GAAG,eAAe,CAAC,CAAC,CAAC;IAE7F;;;;OAIG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IAErC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { NonCancelableEventHandler } from '../../events';\n\nexport type OptionsFilteringType = 'none' | 'auto' | 'manual';\n\n/**\n * Alignment of the dropdown relative to its trigger.\n */\nexport type DropdownAlignment =\n | 'start' // Aligns to the start edge of trigger (default)\n | 'center'; // Centers dropdown on trigger\n\n/**\n * Width constraint for the dropdown.\n * - 'trigger': references the trigger element's width\n * - number: width in pixels\n */\nexport type DropdownWidthConstraint = 'trigger' | number;\n\nexport interface OptionsLoadItemsDetail {\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n}\n\nexport interface BaseDropdownHostProps extends ExpandToViewport {\n /**\n * If you have more than 500 options, enable this flag to apply a performance optimization\n * that makes the filtering experience smoother. We don't recommend enabling the feature if you\n * have less than 500 options, because the improvements to performance are offset by a\n * visible scrolling lag.\n *\n * When you set this flag to `true`, it removes options that are not currently in view from the DOM.\n * If your test accesses such options, you need to first scroll the options container\n * to the correct offset, before performing any operations on them. Use the element returned\n * by the `findOptionsContainer` test utility for this.\n */\n virtualScroll?: boolean;\n\n /**\n * Use this event to implement the asynchronous behavior for the component.\n *\n * The event is called in the following situations:\n * * The user scrolls to the end of the list of options, if `statusType` is set to `pending`.\n * * The user clicks on the recovery button in the error state.\n * * The user types inside the input field.\n * * The user focuses the input field.\n *\n * The detail object contains the following properties:\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n **/\n onLoadItems?: NonCancelableEventHandler<OptionsLoadItemsDetail>;\n}\n\nexport interface DropdownProps extends ExpandToViewport {\n /**\n * Trigger element.\n */\n trigger: React.ReactNode;\n\n /**\n * \"Sticky\" header of the dropdown content\n */\n header?: React.ReactNode;\n\n /**\n * Footer slot fixed at the bottom of the dropdown\n */\n footer?: React.ReactNode;\n\n /**\n * Dropdown content elements.\n */\n content?: React.ReactNode;\n\n /**\n * Updating content key triggers dropdown position re-evaluation.\n */\n contentKey?: string;\n\n /**\n * Open state of the dropdown.\n */\n open?: boolean;\n\n /**\n * Called when the user clicks outside the dropdown and trigger.\n * The dropdown does not close automatically - the parent component\n * must update the `open` prop to close the dropdown.\n */\n onOutsideClick?: NonCancelableEventHandler<null>;\n\n /**\n * Called when a mouse button is pressed inside the dropdown content.\n */\n onMouseDown?: React.MouseEventHandler;\n\n /**\n * Dropdown id\n */\n dropdownId?: string;\n\n /**\n * Stretches dropdown to occupy entire height.\n */\n stretchHeight?: boolean;\n\n /**\n * Stretches the trigger to the height of the dropdown container.\n */\n stretchTriggerHeight?: boolean;\n\n /**\n * Minimum width constraint for the dropdown.\n * - Number: minimum width in pixels\n * - 'trigger': dropdown will be at least as wide as the trigger\n * - undefined: no minimum constraint (fits content)\n */\n minWidth?: DropdownWidthConstraint;\n\n /**\n * Maximum width constraint for the dropdown.\n * - Number: maximum width in pixels\n * - 'trigger': dropdown cannot exceed the trigger width\n * - undefined: fit to content width (no max constraint)\n */\n maxWidth?: DropdownWidthConstraint;\n\n /**\n * Preferred alignment of the dropdown relative to its trigger.\n * The dropdown will attempt this alignment first, but will automatically\n * adjust if there's insufficient space on the preferred side.\n */\n preferredAlignment?: DropdownAlignment;\n\n /**\n * Hides the block (top/bottom) borders of the dropdown content wrapper.\n */\n hideBlockBorder?: boolean;\n\n /**\n * Indicates if this dropdown lies within a parent dropdown and positions itself relative to it (as a fly out).\n */\n interior?: boolean;\n\n /**\n * Whether the dropdown will have a scrollbar or not\n */\n scrollable?: boolean;\n\n /**\n * Whether the dropdown will have a focus loop including trigger, header, content and footer.\n */\n loopFocus?: boolean;\n\n /**\n * Called when focus enters the trigger or dropdown content.\n */\n onFocus?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when focus leaves the trigger or dropdown content.\n */\n onBlur?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when focus enters the dropdown content from outside.\n * This fires only once when focus moves into the dropdown, not when moving between elements within it.\n */\n onFocusEnter?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when focus leaves the dropdown content entirely.\n */\n onFocusLeave?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when the user presses the Escape key while the dropdown is open.\n * The dropdown does not close automatically - the parent component\n * must update the `open` prop to close the dropdown.\n */\n onEscape?: NonCancelableEventHandler;\n\n /**\n * ID for the dropdown content wrapper\n */\n dropdownContentId?: string;\n\n /**\n * HTML role for the dropdown content wrapper\n */\n ariaRole?: string;\n\n /**\n * Aria label for the dropdown content wrapper\n */\n ariaLabel?: string;\n\n /**\n * Labelledby for the dropdown (required when role=\"dialog\")\n */\n ariaLabelledby?: string;\n\n /**\n * Describedby for the dropdown (recommended when role=\"dialog\")\n */\n ariaDescribedby?: string;\n}\n\nexport interface ExpandToViewport {\n /**\n * By default, the dropdown height is constrained to fit inside the height of its next scrollable container element.\n * Enabling this property will allow the dropdown to extend beyond that container by using fixed positioning and\n * [React Portals](https://reactjs.org/docs/portals.html).\n *\n * Set this property if the dropdown would otherwise be constrained by a scrollable container,\n * for example inside table and split view layouts.\n *\n * We recommend you use discretion, and don't enable this property unless necessary\n * because fixed positioning results in a slight, visible lag when scrolling complex pages.\n */\n expandToViewport?: boolean;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { NonCancelableEventHandler } from '../../events';\n\nexport type OptionsFilteringType = 'none' | 'auto' | 'manual';\n\n/**\n * Alignment of the dropdown relative to its trigger.\n */\nexport type DropdownAlignment =\n | 'start' // Aligns to the start edge of trigger (default)\n | 'center'; // Centers dropdown on trigger\n\n/**\n * Width constraint for the dropdown.\n * - 'trigger': references the trigger element's width\n * - number: width in pixels\n */\nexport type DropdownWidthConstraint = 'trigger' | number;\n\nexport interface OptionsLoadItemsDetail {\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n}\n\nexport interface BaseDropdownHostProps extends ExpandToViewport {\n /**\n * If you have more than 500 options, enable this flag to apply a performance optimization\n * that makes the filtering experience smoother. We don't recommend enabling the feature if you\n * have less than 500 options, because the improvements to performance are offset by a\n * visible scrolling lag.\n *\n * When you set this flag to `true`, it removes options that are not currently in view from the DOM.\n * If your test accesses such options, you need to first scroll the options container\n * to the correct offset, before performing any operations on them. Use the element returned\n * by the `findOptionsContainer` test utility for this.\n */\n virtualScroll?: boolean;\n\n /**\n * Use this event to implement the asynchronous behavior for the component.\n *\n * The event is called in the following situations:\n * * The user scrolls to the end of the list of options, if `statusType` is set to `pending`.\n * * The user clicks on the recovery button in the error state.\n * * The user types inside the input field.\n * * The user focuses the input field.\n *\n * The detail object contains the following properties:\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n **/\n onLoadItems?: NonCancelableEventHandler<OptionsLoadItemsDetail>;\n}\n\nexport interface DropdownProps extends ExpandToViewport {\n /**\n * Trigger element.\n */\n trigger: React.ReactNode;\n\n /**\n * Optional ref to an external element used for positioning calculations.\n * When provided, the `trigger` prop is not rendered and this ref's element\n * is used as the positioning anchor for the dropdown instead.\n */\n triggerRef?: React.RefObject<HTMLElement>;\n\n /**\n * Explicit ID for the trigger element, used as the referrer ID for portal mode.\n * Use this when `triggerRef` is provided.\n */\n triggerId?: string;\n\n /**\n * \"Sticky\" header of the dropdown content\n */\n header?: React.ReactNode;\n\n /**\n * Footer slot fixed at the bottom of the dropdown\n */\n footer?: React.ReactNode;\n\n /**\n * Dropdown content elements.\n */\n content?: React.ReactNode;\n\n /**\n * Updating content key triggers dropdown position re-evaluation.\n */\n contentKey?: string;\n\n /**\n * Open state of the dropdown.\n */\n open?: boolean;\n\n /**\n * Called when the user clicks outside the dropdown and trigger.\n * The dropdown does not close automatically - the parent component\n * must update the `open` prop to close the dropdown.\n */\n onOutsideClick?: NonCancelableEventHandler<null>;\n\n /**\n * Called when a mouse button is pressed inside the dropdown content.\n */\n onMouseDown?: React.MouseEventHandler;\n\n /**\n * Dropdown id\n */\n dropdownId?: string;\n\n /**\n * Stretches dropdown to occupy entire height.\n */\n stretchHeight?: boolean;\n\n /**\n * Stretches the trigger to the height of the dropdown container.\n */\n stretchTriggerHeight?: boolean;\n\n /**\n * Minimum width constraint for the dropdown.\n * - Number: minimum width in pixels\n * - 'trigger': dropdown will be at least as wide as the trigger\n * - undefined: no minimum constraint (fits content)\n */\n minWidth?: DropdownWidthConstraint;\n\n /**\n * Maximum width constraint for the dropdown.\n * - Number: maximum width in pixels\n * - 'trigger': dropdown cannot exceed the trigger width\n * - undefined: fit to content width (no max constraint)\n */\n maxWidth?: DropdownWidthConstraint;\n\n /**\n * Maximum height constraint for the dropdown content in pixels.\n * When set, constrains the calculated height to not exceed this value.\n */\n maxHeight?: number;\n\n /**\n * Preferred alignment of the dropdown relative to its trigger.\n * The dropdown will attempt this alignment first, but will automatically\n * adjust if there's insufficient space on the preferred side.\n */\n preferredAlignment?: DropdownAlignment;\n\n /**\n * Hides the block (top/bottom) borders of the dropdown content wrapper.\n */\n hideBlockBorder?: boolean;\n\n /**\n * Indicates if this dropdown lies within a parent dropdown and positions itself relative to it (as a fly out).\n */\n interior?: boolean;\n\n /**\n * Whether the dropdown will have a scrollbar or not\n */\n scrollable?: boolean;\n\n /**\n * Whether the dropdown will have a focus loop including trigger, header, content and footer.\n */\n loopFocus?: boolean;\n\n /**\n * Called when focus enters the trigger or dropdown content.\n */\n onFocus?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when focus leaves the trigger or dropdown content.\n */\n onBlur?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when focus enters the dropdown content from outside.\n * This fires only once when focus moves into the dropdown, not when moving between elements within it.\n */\n onFocusEnter?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when focus leaves the dropdown content entirely.\n */\n onFocusLeave?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when the user presses the Escape key while the dropdown is open.\n * The dropdown does not close automatically - the parent component\n * must update the `open` prop to close the dropdown.\n */\n onEscape?: NonCancelableEventHandler;\n\n /**\n * ID for the dropdown content wrapper\n */\n dropdownContentId?: string;\n\n /**\n * HTML role for the dropdown content wrapper\n */\n ariaRole?: string;\n\n /**\n * Aria label for the dropdown content wrapper\n */\n ariaLabel?: string;\n\n /**\n * Labelledby for the dropdown (required when role=\"dialog\")\n */\n ariaLabelledby?: string;\n\n /**\n * Describedby for the dropdown (recommended when role=\"dialog\")\n */\n ariaDescribedby?: string;\n}\n\nexport interface ExpandToViewport {\n /**\n * By default, the dropdown height is constrained to fit inside the height of its next scrollable container element.\n * Enabling this property will allow the dropdown to extend beyond that container by using fixed positioning and\n * [React Portals](https://reactjs.org/docs/portals.html).\n *\n * Set this property if the dropdown would otherwise be constrained by a scrollable container,\n * for example inside table and split view layouts.\n *\n * We recommend you use discretion, and don't enable this property unless necessary\n * because fixed positioning results in a slight, visible lag when scrolling complex pages.\n */\n expandToViewport?: boolean;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (8a33d63f)";
3
- export var GIT_SHA = "8a33d63f";
2
+ export var PACKAGE_VERSION = "3.0.0 (00b00b51)";
3
+ export var GIT_SHA = "00b00b51";
4
4
  export var THEME = "open-source-visual-refresh";
5
5
  export var SYSTEM = "core";
6
6
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (8a33d63f)",
4
- "GIT_SHA": "8a33d63f",
3
+ "PACKAGE_VERSION": "3.0.0 (00b00b51)",
4
+ "GIT_SHA": "00b00b51",
5
5
  "THEME": "default",
6
6
  "SYSTEM": "core",
7
7
  "ALWAYS_VISUAL_REFRESH": false
@@ -17,6 +17,6 @@ export interface UseMouseHoverProps<T> {
17
17
  export declare function useMouseHover<T>({ plotRef, popoverRef, scaledSeries, barGroups, highlightPoint, highlightGroup, clearHighlightedSeries, isGroupNavigation, isHandlersDisabled, highlightX, }: UseMouseHoverProps<T>): {
18
18
  onSVGMouseMove: (event: React.MouseEvent<SVGElement, MouseEvent>) => void;
19
19
  onSVGMouseOut: (event: React.MouseEvent<SVGElement, MouseEvent>) => void;
20
- onPopoverLeave: (event: React.MouseEvent) => void;
20
+ onPopoverLeave: () => void;
21
21
  };
22
22
  //# sourceMappingURL=use-mouse-hover.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-mouse-hover.d.ts","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-mouse-hover.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAQpD,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACvC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACzC,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/B,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,sBAAsB,EAAE,MAAM,IAAI,CAAC;IACnC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,UAAU,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAC/B,OAAO,EACP,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,GACX,EAAE,kBAAkB,CAAC,CAAC,CAAC;4BAyES,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAA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;4BAyES,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC;2BAUzC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC;;EA8BvE"}
@@ -76,7 +76,14 @@ export function useMouseHover({ plotRef, popoverRef, scaledSeries, barGroups, hi
76
76
  }
77
77
  };
78
78
  const onSVGMouseOut = (event) => {
79
- if (isHandlersDisabled || isMouseOverPopover(event)) {
79
+ var _a;
80
+ if (isHandlersDisabled) {
81
+ return;
82
+ }
83
+ // If the mouse is moving into the popover or its container (transition wrapper),
84
+ // let onPopoverLeave handle cleanup.
85
+ const popoverContainer = (_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.parentElement;
86
+ if (event.relatedTarget && popoverContainer && nodeContains(popoverContainer, event.relatedTarget)) {
80
87
  return;
81
88
  }
82
89
  if (!nodeContains(plotRef.current.svg, event.relatedTarget) ||
@@ -85,11 +92,12 @@ export function useMouseHover({ plotRef, popoverRef, scaledSeries, barGroups, hi
85
92
  clearHighlightedSeries();
86
93
  }
87
94
  };
88
- const onPopoverLeave = (event) => {
89
- if (!isHandlersDisabled && nodeContains(plotRef.current.svg, event.relatedTarget)) {
90
- highlightX(null);
91
- clearHighlightedSeries();
95
+ const onPopoverLeave = () => {
96
+ if (isHandlersDisabled) {
97
+ return;
92
98
  }
99
+ highlightX(null);
100
+ clearHighlightedSeries();
93
101
  };
94
102
  return { onSVGMouseMove, onSVGMouseOut, onPopoverLeave };
95
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-mouse-hover.js","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-mouse-hover.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAMxE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,MAAM,gBAAgB,GAAG,CAAC,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ent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport { ChartPlotRef } from '../../internal/components/chart-plot';\nimport { VerticalMarkerX } from '../interfaces';\nimport { ScaledBarGroup } from '../make-scaled-bar-groups';\nimport { ScaledPoint } from '../make-scaled-series';\nimport { isYThreshold } from '../utils';\n\nimport styles from '../styles.css.js';\n\nconst MAX_HOVER_MARGIN = 6;\nconst POPOVER_DEADZONE = 12;\n\nexport interface UseMouseHoverProps<T> {\n plotRef: React.RefObject<ChartPlotRef>;\n popoverRef: React.RefObject<HTMLElement>;\n scaledSeries: ReadonlyArray<ScaledPoint<T>>;\n barGroups: ScaledBarGroup<T>[];\n highlightPoint: (point: ScaledPoint<T> | null) => void;\n highlightGroup: (groupIndex: number) => void;\n clearHighlightedSeries: () => void;\n isGroupNavigation: boolean;\n isHandlersDisabled: boolean;\n highlightX: (verticalMarker: VerticalMarkerX<T> | null) => void;\n}\n\nexport function useMouseHover<T>({\n plotRef,\n popoverRef,\n scaledSeries,\n barGroups,\n highlightPoint,\n highlightGroup,\n clearHighlightedSeries,\n isGroupNavigation,\n isHandlersDisabled,\n highlightX,\n}: UseMouseHoverProps<T>) {\n const isMouseOverPopover = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (popoverRef.current?.firstChild) {\n const popoverPosition = (popoverRef.current.firstChild as HTMLElement).getBoundingClientRect();\n if (\n event.clientX > popoverPosition.x - POPOVER_DEADZONE &&\n event.clientX < popoverPosition.x + popoverPosition.width + POPOVER_DEADZONE &&\n event.clientY > popoverPosition.y - POPOVER_DEADZONE &&\n event.clientY < popoverPosition.y + popoverPosition.height + POPOVER_DEADZONE\n ) {\n return true;\n }\n }\n return false;\n };\n\n const onSeriesMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n\n const closestX = scaledSeries\n .map(v => v.x)\n .reduce((prev, curr) => (Math.abs(curr - offsetX) < Math.abs(prev - offsetX) ? curr : prev), -Infinity);\n\n if (isFinite(closestX)) {\n const offsetY = event.clientY - svgRect.top;\n const closestY = scaledSeries\n .filter(v => v.x === closestX || isYThreshold(v.series))\n .map(v => v.y)\n .reduce((prev, curr) => (Math.abs(curr - offsetY) < Math.abs(prev - offsetY) ? curr : prev), -Infinity);\n\n if (\n isFinite(closestY) &&\n Math.abs(offsetX - closestX) < MAX_HOVER_MARGIN &&\n Math.abs(offsetY - closestY) < MAX_HOVER_MARGIN\n ) {\n const [{ color, datum, series }] = scaledSeries.filter(\n s => (s.x === closestX || isYThreshold(s.series)) && s.y === closestY\n );\n highlightPoint({ x: closestX, y: closestY, color, datum, series });\n } else {\n let datumX = null;\n for (const point of scaledSeries) {\n if (point.x === closestX) {\n datumX = point.datum?.x ?? null;\n break;\n }\n }\n highlightX({ scaledX: closestX, label: datumX });\n }\n }\n };\n\n const onGroupMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n const offsetY = event.clientY - svgRect.top;\n\n // If hovering over some group - highlight it.\n for (let groupIndex = 0; groupIndex < barGroups.length; groupIndex++) {\n const {\n position: { x, y, width, height },\n } = barGroups[groupIndex];\n\n if (x <= offsetX && offsetX <= x + width && y <= offsetY && offsetY <= y + height) {\n highlightGroup(groupIndex);\n return;\n }\n }\n // Otherwise - clear the highlight.\n clearHighlightedSeries();\n };\n\n const onSVGMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (event.target === plotRef.current!.svg && !isHandlersDisabled && !isMouseOverPopover(event)) {\n if (isGroupNavigation) {\n onGroupMouseMove(event);\n } else if (scaledSeries.length > 0) {\n onSeriesMouseMove(event);\n }\n }\n };\n\n const onSVGMouseOut = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (isHandlersDisabled || isMouseOverPopover(event)) {\n return;\n }\n if (\n !nodeContains(plotRef.current!.svg, event.relatedTarget) ||\n (event.relatedTarget && (event.relatedTarget as Element).classList.contains(styles.series))\n ) {\n highlightX(null);\n clearHighlightedSeries();\n }\n };\n\n const onPopoverLeave = (event: React.MouseEvent) => {\n if (!isHandlersDisabled && nodeContains(plotRef.current!.svg, event.relatedTarget)) {\n highlightX(null);\n clearHighlightedSeries();\n }\n };\n\n return { onSVGMouseMove, onSVGMouseOut, onPopoverLeave };\n}\n"]}
1
+ {"version":3,"file":"use-mouse-hover.js","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-mouse-hover.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAMxE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAe5B,MAAM,UAAU,aAAa,CAAI,EAC/B,OAAO,EACP,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,GACY;IACtB,MAAM,kBAAkB,GAAG,CAAC,KAA+C,EAAE,EAAE;;QAC7E,IAAI,MAAA,UAAU,CAAC,OAAO,0CAAE,UAAU,EAAE,CAAC;YACnC,MAAM,eAAe,GAAI,UAAU,CAAC,OAAO,CAAC,UAA0B,CAAC,qBAAqB,EAAE,CAAC;YAC/F,IACE,KAAK,CAAC,OAAO,GAAG,eAAe,CAAC,CAAC,GAAG,gBAAgB;gBACpD,KAAK,CAAC,OAAO,GAAG,eAAe,CAAC,CAAC,GAAG,eAAe,CAAC,KAAK,GAAG,gBAAgB;gBAC5E,KAAK,CAAC,OAAO,GAAG,eAAe,CAAC,CAA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AAA,UAAU,CAAC,OAAO,0CAAE,aAAa,CAAC;QAC3D,IAAI,KAAK,CAAC,aAAa,IAAI,gBAAgB,IAAI,YAAY,CAAC,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YACnG,OAAO;QACT,CAAC;QAED,IACE,CAAC,YAAY,CAAC,OAAO,CAAC,OAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC;YACxD,CAAC,KAAK,CAAC,aAAa,IAAK,KAAK,CAAC,aAAyB,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAC3F,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,sBAAsB,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,GAAG,EAAE;QAC1B,IAAI,kBAAkB,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,sBAAsB,EAAE,CAAC;IAC3B,CAAC,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport { ChartPlotRef } from '../../internal/components/chart-plot';\nimport { VerticalMarkerX } from '../interfaces';\nimport { ScaledBarGroup } from '../make-scaled-bar-groups';\nimport { ScaledPoint } from '../make-scaled-series';\nimport { isYThreshold } from '../utils';\n\nimport styles from '../styles.css.js';\n\nconst MAX_HOVER_MARGIN = 6;\nconst POPOVER_DEADZONE = 12;\n\nexport interface UseMouseHoverProps<T> {\n plotRef: React.RefObject<ChartPlotRef>;\n popoverRef: React.RefObject<HTMLElement>;\n scaledSeries: ReadonlyArray<ScaledPoint<T>>;\n barGroups: ScaledBarGroup<T>[];\n highlightPoint: (point: ScaledPoint<T> | null) => void;\n highlightGroup: (groupIndex: number) => void;\n clearHighlightedSeries: () => void;\n isGroupNavigation: boolean;\n isHandlersDisabled: boolean;\n highlightX: (verticalMarker: VerticalMarkerX<T> | null) => void;\n}\n\nexport function useMouseHover<T>({\n plotRef,\n popoverRef,\n scaledSeries,\n barGroups,\n highlightPoint,\n highlightGroup,\n clearHighlightedSeries,\n isGroupNavigation,\n isHandlersDisabled,\n highlightX,\n}: UseMouseHoverProps<T>) {\n const isMouseOverPopover = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (popoverRef.current?.firstChild) {\n const popoverPosition = (popoverRef.current.firstChild as HTMLElement).getBoundingClientRect();\n if (\n event.clientX > popoverPosition.x - POPOVER_DEADZONE &&\n event.clientX < popoverPosition.x + popoverPosition.width + POPOVER_DEADZONE &&\n event.clientY > popoverPosition.y - POPOVER_DEADZONE &&\n event.clientY < popoverPosition.y + popoverPosition.height + POPOVER_DEADZONE\n ) {\n return true;\n }\n }\n return false;\n };\n\n const onSeriesMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n\n const closestX = scaledSeries\n .map(v => v.x)\n .reduce((prev, curr) => (Math.abs(curr - offsetX) < Math.abs(prev - offsetX) ? curr : prev), -Infinity);\n\n if (isFinite(closestX)) {\n const offsetY = event.clientY - svgRect.top;\n const closestY = scaledSeries\n .filter(v => v.x === closestX || isYThreshold(v.series))\n .map(v => v.y)\n .reduce((prev, curr) => (Math.abs(curr - offsetY) < Math.abs(prev - offsetY) ? curr : prev), -Infinity);\n\n if (\n isFinite(closestY) &&\n Math.abs(offsetX - closestX) < MAX_HOVER_MARGIN &&\n Math.abs(offsetY - closestY) < MAX_HOVER_MARGIN\n ) {\n const [{ color, datum, series }] = scaledSeries.filter(\n s => (s.x === closestX || isYThreshold(s.series)) && s.y === closestY\n );\n highlightPoint({ x: closestX, y: closestY, color, datum, series });\n } else {\n let datumX = null;\n for (const point of scaledSeries) {\n if (point.x === closestX) {\n datumX = point.datum?.x ?? null;\n break;\n }\n }\n highlightX({ scaledX: closestX, label: datumX });\n }\n }\n };\n\n const onGroupMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n const offsetY = event.clientY - svgRect.top;\n\n // If hovering over some group - highlight it.\n for (let groupIndex = 0; groupIndex < barGroups.length; groupIndex++) {\n const {\n position: { x, y, width, height },\n } = barGroups[groupIndex];\n\n if (x <= offsetX && offsetX <= x + width && y <= offsetY && offsetY <= y + height) {\n highlightGroup(groupIndex);\n return;\n }\n }\n // Otherwise - clear the highlight.\n clearHighlightedSeries();\n };\n\n const onSVGMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (event.target === plotRef.current!.svg && !isHandlersDisabled && !isMouseOverPopover(event)) {\n if (isGroupNavigation) {\n onGroupMouseMove(event);\n } else if (scaledSeries.length > 0) {\n onSeriesMouseMove(event);\n }\n }\n };\n\n const onSVGMouseOut = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (isHandlersDisabled) {\n return;\n }\n\n // If the mouse is moving into the popover or its container (transition wrapper),\n // let onPopoverLeave handle cleanup.\n const popoverContainer = popoverRef.current?.parentElement;\n if (event.relatedTarget && popoverContainer && nodeContains(popoverContainer, event.relatedTarget)) {\n return;\n }\n\n if (\n !nodeContains(plotRef.current!.svg, event.relatedTarget) ||\n (event.relatedTarget && (event.relatedTarget as Element).classList.contains(styles.series))\n ) {\n highlightX(null);\n clearHighlightedSeries();\n }\n };\n\n const onPopoverLeave = () => {\n if (isHandlersDisabled) {\n return;\n }\n highlightX(null);\n clearHighlightedSeries();\n };\n\n return { onSVGMouseMove, onSVGMouseOut, onPopoverLeave };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudscape-design/components-themeable",
3
- "version": "3.0.1254",
3
+ "version": "3.0.1256",
4
4
  "files": [
5
5
  "lib"
6
6
  ],