@cloudscape-design/components 3.0.388 → 3.0.389
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/anchor-navigation/index.d.ts +5 -0
- package/anchor-navigation/index.d.ts.map +1 -0
- package/anchor-navigation/index.js +14 -0
- package/anchor-navigation/index.js.map +1 -0
- package/anchor-navigation/interfaces.d.ts +67 -0
- package/anchor-navigation/interfaces.d.ts.map +1 -0
- package/anchor-navigation/interfaces.js +4 -0
- package/anchor-navigation/interfaces.js.map +1 -0
- package/anchor-navigation/internal.d.ts +5 -0
- package/anchor-navigation/internal.d.ts.map +1 -0
- package/anchor-navigation/internal.js +48 -0
- package/anchor-navigation/internal.js.map +1 -0
- package/anchor-navigation/styles.css.js +13 -0
- package/anchor-navigation/styles.scoped.css +243 -0
- package/anchor-navigation/styles.selectors.js +14 -0
- package/anchor-navigation/test-classes/styles.css.js +11 -0
- package/anchor-navigation/test-classes/styles.scoped.css +27 -0
- package/anchor-navigation/test-classes/styles.selectors.js +12 -0
- package/anchor-navigation/use-scroll-spy.d.ts +18 -0
- package/anchor-navigation/use-scroll-spy.d.ts.map +1 -0
- package/anchor-navigation/use-scroll-spy.js +74 -0
- package/anchor-navigation/use-scroll-spy.js.map +1 -0
- package/annotation-context/annotation/styles.css.js +24 -24
- package/annotation-context/annotation/styles.scoped.css +30 -30
- package/annotation-context/annotation/styles.selectors.js +24 -24
- package/app-layout/notifications/styles.css.js +3 -3
- package/app-layout/notifications/styles.scoped.css +7 -7
- package/app-layout/notifications/styles.selectors.js +3 -3
- package/app-layout/visual-refresh/styles.css.js +75 -75
- package/app-layout/visual-refresh/styles.scoped.css +295 -295
- package/app-layout/visual-refresh/styles.selectors.js +75 -75
- package/button/styles.css.js +20 -20
- package/button/styles.scoped.css +151 -152
- package/button/styles.selectors.js +20 -20
- package/button-dropdown/item-element/styles.css.js +15 -15
- package/button-dropdown/item-element/styles.scoped.css +18 -19
- package/button-dropdown/item-element/styles.selectors.js +15 -15
- package/cards/index.js +2 -2
- package/cards/index.js.map +1 -1
- package/code-editor/styles.css.js +32 -32
- package/code-editor/styles.scoped.css +129 -131
- package/code-editor/styles.selectors.js +32 -32
- package/collection-preferences/content-display/styles.css.js +11 -11
- package/collection-preferences/content-display/styles.scoped.css +17 -18
- package/collection-preferences/content-display/styles.selectors.js +11 -11
- package/collection-preferences/styles.css.js +37 -37
- package/collection-preferences/styles.scoped.css +44 -45
- package/collection-preferences/styles.selectors.js +37 -37
- package/container/index.d.ts.map +1 -1
- package/container/index.js +2 -2
- package/container/index.js.map +1 -1
- package/container/internal.d.ts +5 -1
- package/container/internal.d.ts.map +1 -1
- package/container/internal.js +7 -4
- package/container/internal.js.map +1 -1
- package/content-layout/styles.css.js +7 -7
- package/content-layout/styles.scoped.css +13 -13
- package/content-layout/styles.selectors.js +7 -7
- package/expandable-section/expandable-section-container.d.ts +5 -3
- package/expandable-section/expandable-section-container.d.ts.map +1 -1
- package/expandable-section/expandable-section-container.js +2 -2
- package/expandable-section/expandable-section-container.js.map +1 -1
- package/expandable-section/index.d.ts.map +1 -1
- package/expandable-section/index.js +8 -3
- package/expandable-section/index.js.map +1 -1
- package/expandable-section/internal.d.ts +3 -3
- package/expandable-section/internal.d.ts.map +1 -1
- package/expandable-section/internal.js +2 -2
- package/expandable-section/internal.js.map +1 -1
- package/expandable-section/styles.css.js +29 -29
- package/expandable-section/styles.scoped.css +58 -59
- package/expandable-section/styles.selectors.js +29 -29
- package/flashbar/styles.css.js +47 -47
- package/flashbar/styles.scoped.css +171 -172
- package/flashbar/styles.selectors.js +47 -47
- package/form-field/styles.css.js +19 -19
- package/form-field/styles.scoped.css +29 -30
- package/form-field/styles.selectors.js +19 -19
- package/header/styles.css.js +32 -32
- package/header/styles.scoped.css +48 -49
- package/header/styles.selectors.js +32 -32
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/internal/analytics/components/analytics-funnel.d.ts +2 -2
- package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
- package/internal/analytics/components/analytics-funnel.js +8 -2
- package/internal/analytics/components/analytics-funnel.js.map +1 -1
- package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
- package/internal/analytics/hooks/use-funnel.js +2 -1
- package/internal/analytics/hooks/use-funnel.js.map +1 -1
- package/internal/components/abstract-switch/styles.css.js +13 -13
- package/internal/components/abstract-switch/styles.scoped.css +19 -21
- package/internal/components/abstract-switch/styles.selectors.js +13 -13
- package/internal/components/dropdown/dropdown-fit-handler.d.ts +31 -2
- package/internal/components/dropdown/dropdown-fit-handler.d.ts.map +1 -1
- package/internal/components/dropdown/dropdown-fit-handler.js +49 -7
- package/internal/components/dropdown/dropdown-fit-handler.js.map +1 -1
- package/internal/components/dropdown/index.d.ts.map +1 -1
- package/internal/components/dropdown/index.js +20 -2
- package/internal/components/dropdown/index.js.map +1 -1
- package/internal/components/dropdown/styles.css.js +21 -21
- package/internal/components/dropdown/styles.scoped.css +37 -36
- package/internal/components/dropdown/styles.selectors.js +21 -21
- package/internal/components/menu-dropdown/styles.css.js +7 -7
- package/internal/components/menu-dropdown/styles.scoped.css +13 -14
- package/internal/components/menu-dropdown/styles.selectors.js +7 -7
- package/internal/components/option/styles.css.js +17 -17
- package/internal/components/option/styles.scoped.css +29 -30
- package/internal/components/option/styles.selectors.js +17 -17
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/generated/custom-css-properties/index.d.ts.map +1 -1
- package/internal/generated/custom-css-properties/index.js +40 -39
- package/internal/generated/custom-css-properties/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/internal/utils/scrollable-containers.d.ts +6 -1
- package/internal/utils/scrollable-containers.d.ts.map +1 -1
- package/internal/utils/scrollable-containers.js +1 -1
- package/internal/utils/scrollable-containers.js.map +1 -1
- package/modal/internal.d.ts.map +1 -1
- package/modal/internal.js +6 -4
- package/modal/internal.js.map +1 -1
- package/package.json +2 -1
- package/progress-bar/styles.css.js +18 -18
- package/progress-bar/styles.scoped.css +32 -33
- package/progress-bar/styles.selectors.js +18 -18
- package/property-filter/styles.css.js +30 -30
- package/property-filter/styles.scoped.css +32 -33
- package/property-filter/styles.selectors.js +30 -30
- package/side-navigation/styles.css.js +28 -28
- package/side-navigation/styles.scoped.css +38 -39
- package/side-navigation/styles.selectors.js +28 -28
- package/split-panel/styles.css.js +56 -56
- package/split-panel/styles.scoped.css +77 -78
- package/split-panel/styles.selectors.js +56 -56
- package/status-indicator/internal.d.ts.map +1 -1
- package/status-indicator/internal.js +3 -1
- package/status-indicator/internal.js.map +1 -1
- package/status-indicator/styles.css.js +22 -22
- package/status-indicator/styles.scoped.css +36 -34
- package/status-indicator/styles.selectors.js +22 -22
- package/table/header-cell/index.d.ts +0 -2
- package/table/header-cell/index.d.ts.map +1 -1
- package/table/header-cell/index.js +1 -1
- package/table/header-cell/index.js.map +1 -1
- package/table/index.d.ts.map +1 -1
- package/table/index.js +8 -4
- package/table/index.js.map +1 -1
- package/table/internal.d.ts +1 -0
- package/table/internal.d.ts.map +1 -1
- package/table/internal.js +8 -2
- package/table/internal.js.map +1 -1
- package/table/resizer/index.d.ts +3 -5
- package/table/resizer/index.d.ts.map +1 -1
- package/table/resizer/index.js +44 -66
- package/table/resizer/index.js.map +1 -1
- package/table/resizer/resizer-lookup.d.ts +8 -0
- package/table/resizer/resizer-lookup.d.ts.map +1 -0
- package/table/resizer/resizer-lookup.js +39 -0
- package/table/resizer/resizer-lookup.js.map +1 -0
- package/tabs/styles.css.js +21 -21
- package/tabs/styles.scoped.css +39 -40
- package/tabs/styles.selectors.js +21 -21
- package/test-utils/dom/anchor-navigation/index.d.ts +16 -0
- package/test-utils/dom/anchor-navigation/index.js +58 -0
- package/test-utils/dom/anchor-navigation/index.js.map +1 -0
- package/test-utils/dom/index.d.ts +3 -0
- package/test-utils/dom/index.js +10 -2
- package/test-utils/dom/index.js.map +1 -1
- package/test-utils/selectors/anchor-navigation/index.d.ts +15 -0
- package/test-utils/selectors/anchor-navigation/index.js +45 -0
- package/test-utils/selectors/anchor-navigation/index.js.map +1 -0
- package/test-utils/selectors/index.d.ts +3 -0
- package/test-utils/selectors/index.js +10 -2
- package/test-utils/selectors/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/tiles/styles.css.js +29 -29
- package/tiles/styles.scoped.css +70 -71
- package/tiles/styles.selectors.js +29 -29
- package/wizard/styles.css.js +31 -31
- package/wizard/styles.scoped.css +64 -68
- package/wizard/styles.selectors.js +31 -31
|
@@ -5,6 +5,7 @@ import { useContext } from 'react';
|
|
|
5
5
|
import { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';
|
|
6
6
|
import { DATA_ATTR_FUNNEL_INTERACTION_ID, DATA_ATTR_FUNNEL_SUBSTEP, getNameFromSelector, getSubStepAllSelector, } from '../selectors';
|
|
7
7
|
import { FunnelMetrics } from '../';
|
|
8
|
+
import { nodeBelongs } from '../../utils/node-belongs';
|
|
8
9
|
/**
|
|
9
10
|
* Custom React Hook to manage and interact with FunnelSubStep.
|
|
10
11
|
* This hook will provide necessary properties and methods required
|
|
@@ -97,7 +98,7 @@ export const useFunnelSubStep = () => {
|
|
|
97
98
|
*/
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
100
|
-
if (!subStepRef.current || !
|
|
101
|
+
if (!subStepRef.current || !event.relatedTarget || !nodeBelongs(subStepRef.current, event.relatedTarget)) {
|
|
101
102
|
isFocusedSubStep.current = false;
|
|
102
103
|
if (funnelInteractionId && subStepId && funnelState.current !== 'cancelled') {
|
|
103
104
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"use-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE,0BAA0B,EAAE,GAAG,SAAS,EAAE,CAAC;IACrF,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAC;IAEzD,MAAM,EACJ,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,GACrB,GAAG,OAAO,CAAC;IAEZ,IAAI,eAAe,EAAE;QACnB,OAAO,OAAO,CAAC;KAChB;IAED,MAAM,OAAO,GAAG,CAAO,KAAuC,EAAE,EAAE;;QAChE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC7B,kFAAkF;QAClF,MAAM,IAAI,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AE;;QACzD,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB;;;;;;eAMG;YACH,OAAO;SACR;QAED,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,EAAE;YACxG,gBAAgB,CAAC,OAAO,GAAG,KAAK,CAAC;YAEjC,IAAI,mBAAmB,IAAI,SAAS,IAAI,WAAW,CAAC,OAAO,KAAK,WAAW,EAAE;gBAC3E;;;mBAGG;gBACH,MAAA,oBAAoB,CAAC,OAAO,oEAAI,CAAC;aAClC;SACF;IACH,CAAC,CAAC;IAEF,MAAM,kBAAkB,GAAwB,mBAAmB;QACjE,CAAC,CAAC;YACE,CAAC,wBAAwB,CAAC,EAAE,SAAS;YACrC,OAAO;YACP,MAAM;SACP;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,kBAAkB,IAAK,OAAO,EAAG;AAC5C,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,WAAW,GAA0D,OAAO,CAAC,mBAAmB;QACpG,CAAC,CAAC;YACE,CAAC,+BAA+B,CAAC,EAAE,OAAO,CAAC,mBAAmB;SAC/D;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,WAAW,IAAK,OAAO,EAAG;AACrC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';\nimport {\n DATA_ATTR_FUNNEL_INTERACTION_ID,\n DATA_ATTR_FUNNEL_SUBSTEP,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../selectors';\nimport { FunnelMetrics } from '../';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\n/**\n * Custom React Hook to manage and interact with FunnelSubStep.\n * This hook will provide necessary properties and methods required\n * to track and manage interactions with a FunnelSubStep component.\n *\n * The `onFocus` method is used to track the beginning of interaction with the FunnelSubStep.\n * The `onBlur` method is used to track the completion of interaction with the FunnelSubStep.\n * The subStepId is a unique identifier for the funnel sub-step.\n * The subStepRef is a reference to the DOM element of the funnel sub-step.\n */\nexport const useFunnelSubStep = () => {\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, funnelState, latestFocusCleanupFunction } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const {\n subStepId,\n subStepSelector,\n subStepNameSelector,\n subStepRef,\n isNestedSubStep,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n } = context;\n\n if (isNestedSubStep) {\n return context;\n }\n\n const onFocus = async (event: React.FocusEvent<HTMLDivElement>) => {\n const element = event.target;\n // Ignore spurious focus events, such as when the browser window is focused again.\n await new Promise(r => setTimeout(r, 1));\n if (document.activeElement !== element) {\n return;\n }\n\n if (isFocusedSubStep.current) {\n return;\n }\n isFocusedSubStep.current = true;\n\n if (funnelInteractionId && subStepId) {\n /*\n If the previously focused substep has provided a cleanup function, we\n call it here on behalf of the previously focused substep.\n */\n latestFocusCleanupFunction.current?.();\n\n const subStepName = getNameFromSelector(subStepNameSelector);\n const stepName = getNameFromSelector(stepNameSelector);\n\n FunnelMetrics.funnelSubStepStart({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n\n /*\n This cleanup function will be called when the user leaves this substep.\n The function might be called either:\n\n - by the next focused substep as `latestFocusCleanupFunction`\n (through a separate instance of the function we're currently in), or\n\n - by the same substep as `focusCleanupFunction`\n (through the `onMouseUp` handler or the `onBlur` handler).\n */\n let cleanupFunctionHasBeenRun = false;\n focusCleanupFunction.current = () => {\n if (cleanupFunctionHasBeenRun) {\n return;\n }\n cleanupFunctionHasBeenRun = true;\n\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelSubStepComplete({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n latestFocusCleanupFunction.current = focusCleanupFunction.current;\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (mousePressed.current) {\n /*\n Ignore blur events that are caused by mouse interaction, because these events don't\n always reflect user intention. For example, clicking the label of an interactive form\n element will briefly blur it.\n The mouse-caused events are handled in the global `onMouseUp` handler of the substep\n context instead.\n */\n return;\n }\n\n if (!subStepRef.current || !event.relatedTarget || !nodeBelongs(subStepRef.current, event.relatedTarget)) {\n isFocusedSubStep.current = false;\n\n if (funnelInteractionId && subStepId && funnelState.current !== 'cancelled') {\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n }\n };\n\n const funnelSubStepProps: Record<string, any> = funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_SUBSTEP]: subStepId,\n onFocus,\n onBlur,\n }\n : {};\n\n return { funnelSubStepProps, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with FunnelStep.\n * This hook will provide necessary properties required to track\n * and manage interactions with a FunnelStep component.\n *\n * The 'data-analytics-funnel-step' property of funnelStepProps is used to track the index of the current step in the funnel.\n * The context contains additional properties of the FunnelStep.\n */\nexport const useFunnelStep = () => {\n const context = useContext(FunnelStepContext);\n return context;\n};\n\n/**\n * Custom React Hook to manage and interact with Funnel.\n * This hook will provide necessary properties required to track\n * and manage interactions with a Funnel component.\n *\n * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.\n */\nexport const useFunnel = () => {\n const context = useContext(FunnelContext);\n const funnelProps: Record<string, string | number | boolean | undefined> = context.funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_INTERACTION_ID]: context.funnelInteractionId,\n }\n : {};\n\n return { funnelProps, ...context };\n};\n"]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"content": "
|
|
5
|
-
"description": "
|
|
6
|
-
"label": "
|
|
7
|
-
"outline": "
|
|
8
|
-
"show-outline": "awsui_show-
|
|
9
|
-
"native-input": "awsui_native-
|
|
10
|
-
"wrapper": "
|
|
11
|
-
"label-wrapper": "awsui_label-
|
|
12
|
-
"empty-content": "awsui_empty-
|
|
13
|
-
"description-bottom-padding": "awsui_description-bottom-
|
|
14
|
-
"label-disabled": "awsui_label-
|
|
15
|
-
"description-disabled": "awsui_description-
|
|
16
|
-
"control": "
|
|
4
|
+
"content": "awsui_content_1wepg_1wpsv_93",
|
|
5
|
+
"description": "awsui_description_1wepg_1wpsv_94",
|
|
6
|
+
"label": "awsui_label_1wepg_1wpsv_95",
|
|
7
|
+
"outline": "awsui_outline_1wepg_1wpsv_99",
|
|
8
|
+
"show-outline": "awsui_show-outline_1wepg_1wpsv_102",
|
|
9
|
+
"native-input": "awsui_native-input_1wepg_1wpsv_106",
|
|
10
|
+
"wrapper": "awsui_wrapper_1wepg_1wpsv_110",
|
|
11
|
+
"label-wrapper": "awsui_label-wrapper_1wepg_1wpsv_116",
|
|
12
|
+
"empty-content": "awsui_empty-content_1wepg_1wpsv_127",
|
|
13
|
+
"description-bottom-padding": "awsui_description-bottom-padding_1wepg_1wpsv_137",
|
|
14
|
+
"label-disabled": "awsui_label-disabled_1wepg_1wpsv_145",
|
|
15
|
+
"description-disabled": "awsui_description-disabled_1wepg_1wpsv_146",
|
|
16
|
+
"control": "awsui_control_1wepg_1wpsv_151"
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -90,77 +90,75 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
90
90
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
91
91
|
SPDX-License-Identifier: Apache-2.0
|
|
92
92
|
*/
|
|
93
|
-
.
|
|
94
|
-
.
|
|
95
|
-
.
|
|
93
|
+
.awsui_content_1wepg_1wpsv_93:not(#\9),
|
|
94
|
+
.awsui_description_1wepg_1wpsv_94:not(#\9),
|
|
95
|
+
.awsui_label_1wepg_1wpsv_95:not(#\9) {
|
|
96
96
|
display: block;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
.
|
|
99
|
+
.awsui_outline_1wepg_1wpsv_99:not(#\9) {
|
|
100
100
|
display: none;
|
|
101
101
|
}
|
|
102
|
-
.
|
|
102
|
+
.awsui_outline_1wepg_1wpsv_99.awsui_show-outline_1wepg_1wpsv_102:not(#\9) {
|
|
103
103
|
display: block;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
body[data-awsui-focus-visible=true] .awsui_native-
|
|
106
|
+
body[data-awsui-focus-visible=true] .awsui_native-input_1wepg_1wpsv_106:not(#\9):focus + .awsui_outline_1wepg_1wpsv_99 {
|
|
107
107
|
display: block;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
.
|
|
110
|
+
.awsui_wrapper_1wepg_1wpsv_110:not(#\9) {
|
|
111
111
|
min-width: 0;
|
|
112
|
-
-ms-word-break: break-all;
|
|
113
112
|
word-break: break-word;
|
|
114
113
|
display: flex;
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
.awsui_label-
|
|
116
|
+
.awsui_label-wrapper_1wepg_1wpsv_116:not(#\9) {
|
|
118
117
|
position: relative;
|
|
119
118
|
display: flex;
|
|
120
119
|
cursor: default;
|
|
121
120
|
}
|
|
122
121
|
|
|
123
|
-
.
|
|
122
|
+
.awsui_content_1wepg_1wpsv_93:not(#\9) {
|
|
124
123
|
min-width: 0;
|
|
125
|
-
-ms-word-break: break-all;
|
|
126
124
|
word-break: break-word;
|
|
127
125
|
}
|
|
128
126
|
|
|
129
|
-
.awsui_empty-
|
|
127
|
+
.awsui_empty-content_1wepg_1wpsv_127:not(#\9) {
|
|
130
128
|
width: 0px;
|
|
131
129
|
}
|
|
132
130
|
|
|
133
|
-
.
|
|
131
|
+
.awsui_description_1wepg_1wpsv_94:not(#\9) {
|
|
134
132
|
color: var(--color-text-form-secondary-dxc248, #5f6b7a);
|
|
135
133
|
font-size: var(--font-size-body-s-asqx2i, 12px);
|
|
136
134
|
line-height: var(--line-height-body-s-7zv1j5, 16px);
|
|
137
135
|
letter-spacing: var(--letter-spacing-body-s-z9jkwp, 0.005em);
|
|
138
136
|
}
|
|
139
|
-
.awsui_description-bottom-
|
|
137
|
+
.awsui_description-bottom-padding_1wepg_1wpsv_137:not(#\9) {
|
|
140
138
|
padding-bottom: var(--space-scaled-xxs-7597g1, 4px);
|
|
141
139
|
}
|
|
142
140
|
|
|
143
|
-
.
|
|
144
|
-
.
|
|
141
|
+
.awsui_label_1wepg_1wpsv_95:not(#\9),
|
|
142
|
+
.awsui_description_1wepg_1wpsv_94:not(#\9) {
|
|
145
143
|
padding-left: var(--space-xs-zb16t3, 8px);
|
|
146
144
|
}
|
|
147
|
-
.awsui_label-
|
|
148
|
-
.awsui_description-
|
|
145
|
+
.awsui_label-disabled_1wepg_1wpsv_145:not(#\9),
|
|
146
|
+
.awsui_description-disabled_1wepg_1wpsv_146:not(#\9) {
|
|
149
147
|
color: var(--color-text-control-disabled-ircsnq, #9ba7b6);
|
|
150
148
|
}
|
|
151
149
|
|
|
152
150
|
/* stylelint-disable selector-max-type */
|
|
153
|
-
.
|
|
151
|
+
.awsui_control_1wepg_1wpsv_151:not(#\9) {
|
|
154
152
|
position: relative;
|
|
155
153
|
}
|
|
156
|
-
.
|
|
154
|
+
.awsui_control_1wepg_1wpsv_151 > input:not(#\9), .awsui_control_1wepg_1wpsv_151 > svg:not(#\9), .awsui_control_1wepg_1wpsv_151 > .awsui_outline_1wepg_1wpsv_99:not(#\9) {
|
|
157
155
|
position: absolute;
|
|
158
156
|
width: 100%;
|
|
159
157
|
height: 100%;
|
|
160
158
|
top: 0;
|
|
161
159
|
left: 0;
|
|
162
160
|
}
|
|
163
|
-
.
|
|
161
|
+
.awsui_control_1wepg_1wpsv_151 > input:not(#\9) {
|
|
164
162
|
opacity: 0;
|
|
165
163
|
z-index: 1;
|
|
166
164
|
-webkit-user-select: none;
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"content": "
|
|
6
|
-
"description": "
|
|
7
|
-
"label": "
|
|
8
|
-
"outline": "
|
|
9
|
-
"show-outline": "awsui_show-
|
|
10
|
-
"native-input": "awsui_native-
|
|
11
|
-
"wrapper": "
|
|
12
|
-
"label-wrapper": "awsui_label-
|
|
13
|
-
"empty-content": "awsui_empty-
|
|
14
|
-
"description-bottom-padding": "awsui_description-bottom-
|
|
15
|
-
"label-disabled": "awsui_label-
|
|
16
|
-
"description-disabled": "awsui_description-
|
|
17
|
-
"control": "
|
|
5
|
+
"content": "awsui_content_1wepg_1wpsv_93",
|
|
6
|
+
"description": "awsui_description_1wepg_1wpsv_94",
|
|
7
|
+
"label": "awsui_label_1wepg_1wpsv_95",
|
|
8
|
+
"outline": "awsui_outline_1wepg_1wpsv_99",
|
|
9
|
+
"show-outline": "awsui_show-outline_1wepg_1wpsv_102",
|
|
10
|
+
"native-input": "awsui_native-input_1wepg_1wpsv_106",
|
|
11
|
+
"wrapper": "awsui_wrapper_1wepg_1wpsv_110",
|
|
12
|
+
"label-wrapper": "awsui_label-wrapper_1wepg_1wpsv_116",
|
|
13
|
+
"empty-content": "awsui_empty-content_1wepg_1wpsv_127",
|
|
14
|
+
"description-bottom-padding": "awsui_description-bottom-padding_1wepg_1wpsv_137",
|
|
15
|
+
"label-disabled": "awsui_label-disabled_1wepg_1wpsv_145",
|
|
16
|
+
"description-disabled": "awsui_description-disabled_1wepg_1wpsv_146",
|
|
17
|
+
"control": "awsui_control_1wepg_1wpsv_151"
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -17,8 +17,37 @@ export interface InteriorDropdownPosition extends DropdownPosition {
|
|
|
17
17
|
top: string;
|
|
18
18
|
}
|
|
19
19
|
export declare const defaultMaxDropdownWidth: number;
|
|
20
|
-
export declare const getAvailableSpace: (trigger
|
|
21
|
-
|
|
20
|
+
export declare const getAvailableSpace: ({ trigger, overflowParents, stretchWidth, stretchHeight, isMobile, }: {
|
|
21
|
+
trigger: HTMLElement;
|
|
22
|
+
overflowParents: ReadonlyArray<Dimensions>;
|
|
23
|
+
stretchWidth?: boolean | undefined;
|
|
24
|
+
stretchHeight?: boolean | undefined;
|
|
25
|
+
isMobile?: boolean | undefined;
|
|
26
|
+
}) => AvailableSpace;
|
|
27
|
+
export declare const getInteriorAvailableSpace: ({ trigger, overflowParents, isMobile, }: {
|
|
28
|
+
trigger: HTMLElement;
|
|
29
|
+
overflowParents: ReadonlyArray<Dimensions>;
|
|
30
|
+
isMobile?: boolean | undefined;
|
|
31
|
+
}) => AvailableSpace;
|
|
32
|
+
export declare const getWidths: ({ triggerElement, dropdownElement, desiredMinWidth, stretchBeyondTriggerWidth, }: {
|
|
33
|
+
triggerElement: HTMLElement;
|
|
34
|
+
dropdownElement: HTMLElement;
|
|
35
|
+
desiredMinWidth?: number | undefined;
|
|
36
|
+
stretchBeyondTriggerWidth?: boolean | undefined;
|
|
37
|
+
}) => {
|
|
38
|
+
idealWidth: number;
|
|
39
|
+
minWidth: number;
|
|
40
|
+
triggerWidth: number;
|
|
41
|
+
};
|
|
42
|
+
export declare const hasEnoughSpaceToStretchBeyondTriggerWidth: ({ triggerElement, dropdownElement, desiredMinWidth, expandToViewport, stretchWidth, stretchHeight, isMobile, }: {
|
|
43
|
+
triggerElement: HTMLElement;
|
|
44
|
+
dropdownElement: HTMLElement;
|
|
45
|
+
desiredMinWidth?: number | undefined;
|
|
46
|
+
expandToViewport: boolean;
|
|
47
|
+
stretchWidth: boolean;
|
|
48
|
+
stretchHeight: boolean;
|
|
49
|
+
isMobile: boolean;
|
|
50
|
+
}) => boolean;
|
|
22
51
|
export declare const getDropdownPosition: ({ triggerElement, dropdownElement, overflowParents, minWidth: desiredMinWidth, preferCenter, stretchWidth, stretchHeight, isMobile, stretchBeyondTriggerWidth, }: {
|
|
23
52
|
triggerElement: HTMLElement;
|
|
24
53
|
dropdownElement: HTMLElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-fit-handler.d.ts","sourceRoot":"lib/default/","sources":["internal/components/dropdown/dropdown-fit-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAmD,MAAM,mCAAmC,CAAC;AAOhH,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAkBD,eAAO,MAAM,uBAAuB,QAA4B,CAAC;AAEjE,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"dropdown-fit-handler.d.ts","sourceRoot":"lib/default/","sources":["internal/components/dropdown/dropdown-fit-handler.ts"],"names":[],"mappings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,aACN,MAAM,8BACW,OAAO,KAClC,CAAC,gBAAgB,EAAE,OAAO,CAkC5B,CAAC"}
|
|
@@ -21,7 +21,7 @@ const getClosestParentDimensions = (element) => {
|
|
|
21
21
|
// By default, most dropdowns should expand their content as necessary, but to a maximum of 465px (the XXS breakpoint).
|
|
22
22
|
// This value was determined by UX but may be subject to change in the future, depending on the feedback.
|
|
23
23
|
export const defaultMaxDropdownWidth = getBreakpointValue('xxs');
|
|
24
|
-
export const getAvailableSpace = (trigger,
|
|
24
|
+
export const getAvailableSpace = ({ trigger, overflowParents, stretchWidth = false, stretchHeight = false, isMobile, }) => {
|
|
25
25
|
const availableSpaceReserveVertical = stretchHeight
|
|
26
26
|
? 0
|
|
27
27
|
: isMobile
|
|
@@ -47,7 +47,7 @@ export const getAvailableSpace = (trigger, dropdown, overflowParents, stretchWid
|
|
|
47
47
|
};
|
|
48
48
|
}, { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE });
|
|
49
49
|
};
|
|
50
|
-
export const getInteriorAvailableSpace = (trigger,
|
|
50
|
+
export const getInteriorAvailableSpace = ({ trigger, overflowParents, isMobile, }) => {
|
|
51
51
|
const AVAILABLE_SPACE_RESERVE_VERTICAL = isMobile
|
|
52
52
|
? AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL
|
|
53
53
|
: AVAILABLE_SPACE_RESERVE_DEFAULT;
|
|
@@ -68,9 +68,7 @@ export const getInteriorAvailableSpace = (trigger, dropdown, overflowParents, is
|
|
|
68
68
|
};
|
|
69
69
|
}, { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE });
|
|
70
70
|
};
|
|
71
|
-
export const
|
|
72
|
-
// Determine the space available around the dropdown that it can grow in
|
|
73
|
-
const availableSpace = getAvailableSpace(triggerElement, dropdownElement, overflowParents, stretchWidth, stretchHeight, isMobile);
|
|
71
|
+
export const getWidths = ({ triggerElement, dropdownElement, desiredMinWidth, stretchBeyondTriggerWidth = false, }) => {
|
|
74
72
|
// Determine the width of the trigger
|
|
75
73
|
const triggerWidth = triggerElement.getBoundingClientRect().width;
|
|
76
74
|
// Minimum width is determined by either an explicit number (desiredMinWidth) or the trigger width
|
|
@@ -81,6 +79,45 @@ export const getDropdownPosition = ({ triggerElement, dropdownElement, overflowP
|
|
|
81
79
|
const requiredWidth = dropdownElement.getBoundingClientRect().width;
|
|
82
80
|
// Try to achieve the required/desired width within the given parameters
|
|
83
81
|
const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);
|
|
82
|
+
return { idealWidth, minWidth, triggerWidth };
|
|
83
|
+
};
|
|
84
|
+
export const hasEnoughSpaceToStretchBeyondTriggerWidth = ({ triggerElement, dropdownElement, desiredMinWidth, expandToViewport, stretchWidth, stretchHeight, isMobile, }) => {
|
|
85
|
+
const overflowParents = getOverflowParentDimensions({
|
|
86
|
+
element: dropdownElement,
|
|
87
|
+
excludeClosestParent: false,
|
|
88
|
+
expandToViewport,
|
|
89
|
+
canExpandOutsideViewport: stretchHeight,
|
|
90
|
+
});
|
|
91
|
+
const { idealWidth } = getWidths({
|
|
92
|
+
triggerElement: triggerElement,
|
|
93
|
+
dropdownElement,
|
|
94
|
+
desiredMinWidth,
|
|
95
|
+
stretchBeyondTriggerWidth: true,
|
|
96
|
+
});
|
|
97
|
+
const availableSpace = getAvailableSpace({
|
|
98
|
+
trigger: triggerElement,
|
|
99
|
+
overflowParents,
|
|
100
|
+
stretchWidth,
|
|
101
|
+
stretchHeight,
|
|
102
|
+
isMobile,
|
|
103
|
+
});
|
|
104
|
+
return idealWidth <= availableSpace.left || idealWidth <= availableSpace.right;
|
|
105
|
+
};
|
|
106
|
+
export const getDropdownPosition = ({ triggerElement, dropdownElement, overflowParents, minWidth: desiredMinWidth, preferCenter = false, stretchWidth = false, stretchHeight = false, isMobile = false, stretchBeyondTriggerWidth = false, }) => {
|
|
107
|
+
// Determine the space available around the dropdown that it can grow in
|
|
108
|
+
const availableSpace = getAvailableSpace({
|
|
109
|
+
trigger: triggerElement,
|
|
110
|
+
overflowParents,
|
|
111
|
+
stretchWidth,
|
|
112
|
+
stretchHeight,
|
|
113
|
+
isMobile,
|
|
114
|
+
});
|
|
115
|
+
const { idealWidth, minWidth, triggerWidth } = getWidths({
|
|
116
|
+
triggerElement,
|
|
117
|
+
dropdownElement,
|
|
118
|
+
desiredMinWidth,
|
|
119
|
+
stretchBeyondTriggerWidth,
|
|
120
|
+
});
|
|
84
121
|
let dropLeft;
|
|
85
122
|
let left = null;
|
|
86
123
|
let width = idealWidth;
|
|
@@ -120,7 +157,7 @@ export const getDropdownPosition = ({ triggerElement, dropdownElement, overflowP
|
|
|
120
157
|
};
|
|
121
158
|
};
|
|
122
159
|
export const getInteriorDropdownPosition = (trigger, dropdown, overflowParents, isMobile) => {
|
|
123
|
-
const availableSpace = getInteriorAvailableSpace(trigger,
|
|
160
|
+
const availableSpace = getInteriorAvailableSpace({ trigger, overflowParents, isMobile });
|
|
124
161
|
const { bottom: triggerBottom, top: triggerTop, width: triggerWidth } = trigger.getBoundingClientRect();
|
|
125
162
|
const { top: parentDropdownTop, height: parentDropdownHeight } = getClosestParentDimensions(trigger);
|
|
126
163
|
let dropLeft;
|
|
@@ -163,7 +200,12 @@ export const calculatePosition = (dropdownElement, triggerElement, verticalConta
|
|
|
163
200
|
dropdownElement.classList.remove(styles['dropdown-drop-left']);
|
|
164
201
|
dropdownElement.classList.remove(styles['dropdown-drop-right']);
|
|
165
202
|
dropdownElement.classList.remove(styles['dropdown-drop-up']);
|
|
166
|
-
const overflowParents = getOverflowParentDimensions(
|
|
203
|
+
const overflowParents = getOverflowParentDimensions({
|
|
204
|
+
element: dropdownElement,
|
|
205
|
+
excludeClosestParent: interior,
|
|
206
|
+
expandToViewport,
|
|
207
|
+
canExpandOutsideViewport: stretchHeight,
|
|
208
|
+
});
|
|
167
209
|
const position = interior
|
|
168
210
|
? getInteriorDropdownPosition(triggerElement, dropdownElement, overflowParents, isMobile)
|
|
169
211
|
: getDropdownPosition({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-fit-handler.js","sourceRoot":"lib/default/","sources":["internal/components/dropdown/dropdown-fit-handler.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAc,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChH,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,EAAE;IAC/D,MAAM,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACnD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC;QAChE,OAAO;YACL,MAAM;YACN,KAAK;YACL,GAAG;YACH,IAAI;SACL,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,uHAAuH;AACvH,yGAAyG;AACzG,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAAoB,EACpB,QAAqB,EACrB,eAA0C,EAC1C,YAAY,GAAG,KAAK,EACpB,aAAa,GAAG,KAAK,EACrB,QAAkB,EACF,EAAE;IAClB,MAAM,6BAA6B,GAAG,aAAa;QACjD,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC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IAClC,eAAe,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IAEhC,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC/D,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAChE,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAE7D,MAAM,eAAe,GAAG,2BAA2B,CAAC,eAAe,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAC;IAChH,MAAM,QAAQ,GAAG,QAAQ;QACvB,CAAC,CAAC,2BAA2B,CAAC,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,CAAC;QACzF,CAAC,CAAC,mBAAmB,CAAC;YAClB,cAAc;YACd,eAAe;YACf,eAAe;YACf,QAAQ;YACR,YAAY;YACZ,YAAY;YACZ,aAAa;YACb,QAAQ;YACR,yBAAyB;SAC1B,CAAC,CAAC;IACP,MAAM,UAAU,GAAG,cAAc,CAAC,qBAAqB,EAAE,CAAC;IAC1D,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getBreakpointValue } from '../../breakpoints';\nimport { Dimensions, getOverflowParents, getOverflowParentDimensions } from '../../utils/scrollable-containers';\nimport styles from './styles.css.js';\n\nconst AVAILABLE_SPACE_RESERVE_DEFAULT = 50;\nconst AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL = 19; // 50 - 31\nconst AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL = 20;\n\ninterface AvailableSpace {\n above: number;\n below: number;\n left: number;\n right: number;\n}\nexport interface DropdownPosition {\n height: string;\n width: string;\n dropUp: boolean;\n dropLeft: boolean;\n left: string;\n}\nexport interface InteriorDropdownPosition extends DropdownPosition {\n bottom: string;\n top: string;\n}\n\nconst getClosestParentDimensions = (element: HTMLElement): any => {\n const parents = getOverflowParents(element).map(el => {\n const { height, width, top, left } = el.getBoundingClientRect();\n return {\n height,\n width,\n top,\n left,\n };\n });\n\n return parents.shift();\n};\n\n// By default, most dropdowns should expand their content as necessary, but to a maximum of 465px (the XXS breakpoint).\n// This value was determined by UX but may be subject to change in the future, depending on the feedback.\nexport const defaultMaxDropdownWidth = getBreakpointValue('xxs');\n\nexport const getAvailableSpace = (\n trigger: HTMLElement,\n dropdown: HTMLElement,\n overflowParents: ReadonlyArray<Dimensions>,\n stretchWidth = false,\n stretchHeight = false,\n isMobile?: boolean\n): AvailableSpace => {\n const availableSpaceReserveVertical = stretchHeight\n ? 0\n : isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const availableSpaceReserveHorizontal = stretchWidth\n ? 0\n : isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const { bottom: triggerBottom, left: triggerLeft, right: triggerRight } = trigger.getBoundingClientRect();\n\n return overflowParents.reduce(\n ({ above, below, left, right }, overflowParent) => {\n const offsetTop = triggerBottom - overflowParent.top;\n const currentAbove = offsetTop - trigger.offsetHeight - availableSpaceReserveVertical;\n const currentBelow = overflowParent.height - offsetTop - availableSpaceReserveVertical;\n const currentLeft = triggerRight - overflowParent.left - availableSpaceReserveHorizontal;\n const currentRight = overflowParent.left + overflowParent.width - triggerLeft - availableSpaceReserveHorizontal;\n\n return {\n above: Math.min(above, currentAbove),\n below: Math.min(below, currentBelow),\n left: Math.min(left, currentLeft),\n right: Math.min(right, currentRight),\n };\n },\n { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE }\n );\n};\n\nexport const getInteriorAvailableSpace = (\n trigger: HTMLElement,\n dropdown: HTMLElement,\n overflowParents: ReadonlyArray<Dimensions>,\n isMobile?: boolean\n): AvailableSpace => {\n const AVAILABLE_SPACE_RESERVE_VERTICAL = isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const AVAILABLE_SPACE_RESERVE_HORIZONTAL = isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const {\n bottom: triggerBottom,\n top: triggerTop,\n left: triggerLeft,\n right: triggerRight,\n } = trigger.getBoundingClientRect();\n\n return overflowParents.reduce(\n ({ above, below, left, right }, overflowParent) => {\n const currentAbove = triggerBottom - overflowParent.top - AVAILABLE_SPACE_RESERVE_VERTICAL;\n const currentBelow = overflowParent.height - triggerTop + overflowParent.top - AVAILABLE_SPACE_RESERVE_VERTICAL;\n const currentLeft = triggerLeft - overflowParent.left - AVAILABLE_SPACE_RESERVE_HORIZONTAL;\n const currentRight =\n overflowParent.left + overflowParent.width - triggerRight - AVAILABLE_SPACE_RESERVE_HORIZONTAL;\n\n return {\n above: Math.min(above, currentAbove),\n below: Math.min(below, currentBelow),\n left: Math.min(left, currentLeft),\n right: Math.min(right, currentRight),\n };\n },\n { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE }\n );\n};\n\nexport const getDropdownPosition = ({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth: desiredMinWidth,\n preferCenter = false,\n stretchWidth = false,\n stretchHeight = false,\n isMobile = false,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n overflowParents: ReadonlyArray<Dimensions>;\n minWidth?: number;\n preferCenter?: boolean;\n stretchWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n}): DropdownPosition => {\n // Determine the space available around the dropdown that it can grow in\n const availableSpace = getAvailableSpace(\n triggerElement,\n dropdownElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile\n );\n // Determine the width of the trigger\n const triggerWidth = triggerElement.getBoundingClientRect().width;\n // Minimum width is determined by either an explicit number (desiredMinWidth) or the trigger width\n const minWidth = desiredMinWidth ? Math.min(triggerWidth, desiredMinWidth) : triggerWidth;\n // If stretchBeyondTriggerWidth is true, the maximum width is the XS breakpoint (465px) or the trigger width (if bigger).\n const maxWidth = stretchBeyondTriggerWidth ? Math.max(defaultMaxDropdownWidth, triggerWidth) : Number.MAX_VALUE;\n // Determine the actual dropdown width, the size that it \"wants\" to be\n const requiredWidth = dropdownElement.getBoundingClientRect().width;\n // Try to achieve the required/desired width within the given parameters\n const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);\n\n let dropLeft: boolean;\n let left: number | null = null;\n let width = idealWidth;\n\n //1. Can it be positioned with ideal width to the right?\n if (idealWidth <= availableSpace.right) {\n dropLeft = false;\n //2. Can it be positioned with ideal width to the left?\n } else if (idealWidth <= availableSpace.left) {\n dropLeft = true;\n //3. Fit into biggest available space either on left or right\n } else {\n dropLeft = availableSpace.left > availableSpace.right;\n width = Math.max(availableSpace.left, availableSpace.right, minWidth);\n }\n\n if (preferCenter) {\n const spillOver = (idealWidth - triggerWidth) / 2;\n\n // availableSpace always includes the trigger width, but we want to exclude that\n const availableOutsideLeft = availableSpace.left - triggerWidth;\n const availableOutsideRight = availableSpace.right - triggerWidth;\n\n const fitsInCenter = availableOutsideLeft >= spillOver && availableOutsideRight >= spillOver;\n if (fitsInCenter) {\n left = -spillOver;\n }\n }\n\n const dropUp = availableSpace.below < dropdownElement.offsetHeight && availableSpace.above > availableSpace.below;\n const availableHeight = dropUp ? availableSpace.above : availableSpace.below;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropUp,\n dropLeft,\n left: left === null ? 'auto' : `${left}px`,\n height: `${croppedHeight}px`,\n width: `${width}px`,\n };\n};\n\nexport const getInteriorDropdownPosition = (\n trigger: HTMLElement,\n dropdown: HTMLElement,\n overflowParents: ReadonlyArray<Dimensions>,\n isMobile?: boolean\n): InteriorDropdownPosition => {\n const availableSpace = getInteriorAvailableSpace(trigger, dropdown, overflowParents, isMobile);\n const { bottom: triggerBottom, top: triggerTop, width: triggerWidth } = trigger.getBoundingClientRect();\n const { top: parentDropdownTop, height: parentDropdownHeight } = getClosestParentDimensions(trigger);\n\n let dropLeft;\n\n let width = dropdown.getBoundingClientRect().width;\n const top = triggerTop - parentDropdownTop;\n if (width <= availableSpace.right) {\n dropLeft = false;\n } else if (width <= availableSpace.left) {\n dropLeft = true;\n } else {\n dropLeft = availableSpace.left > availableSpace.right;\n width = Math.max(availableSpace.left, availableSpace.right);\n }\n\n const left = dropLeft ? 0 - width : triggerWidth;\n\n const dropUp = availableSpace.below < dropdown.offsetHeight && availableSpace.above > availableSpace.below;\n const bottom = dropUp ? parentDropdownTop + parentDropdownHeight - triggerBottom : 0;\n const availableHeight = dropUp ? availableSpace.above : availableSpace.below;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropUp,\n dropLeft,\n height: `${croppedHeight}px`,\n width: `${width}px`,\n top: `${top}px`,\n bottom: `${bottom}px`,\n left: `${left}px`,\n };\n};\n\nexport const calculatePosition = (\n dropdownElement: HTMLDivElement,\n triggerElement: HTMLDivElement,\n verticalContainerElement: HTMLDivElement,\n interior: boolean,\n expandToViewport: boolean,\n preferCenter: boolean,\n stretchWidth: boolean,\n stretchHeight: boolean,\n isMobile: boolean,\n minWidth?: number,\n stretchBeyondTriggerWidth?: boolean\n): [DropdownPosition, DOMRect] => {\n // cleaning previously assigned values,\n // so that they are not reused in case of screen resize and similar events\n verticalContainerElement.style.maxHeight = '';\n dropdownElement.style.width = '';\n dropdownElement.style.top = '';\n dropdownElement.style.bottom = '';\n dropdownElement.style.left = '';\n\n dropdownElement.classList.remove(styles['dropdown-drop-left']);\n dropdownElement.classList.remove(styles['dropdown-drop-right']);\n dropdownElement.classList.remove(styles['dropdown-drop-up']);\n\n const overflowParents = getOverflowParentDimensions(dropdownElement, interior, expandToViewport, stretchHeight);\n const position = interior\n ? getInteriorDropdownPosition(triggerElement, dropdownElement, overflowParents, isMobile)\n : getDropdownPosition({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n stretchBeyondTriggerWidth,\n });\n const triggerBox = triggerElement.getBoundingClientRect();\n return [position, triggerBox];\n};\n"]}
|
|
1
|
+
{"version":3,"file":"dropdown-fit-handler.js","sourceRoot":"lib/default/","sources":["internal/components/dropdown/dropdown-fit-handler.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAc,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChH,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,EAAE;IAC/D,MAAM,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACnD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC;QAChE,OAAO;YACL,MAAM;YACN,KAAK;YACL,GAAG;YACH,IAAI;SACL,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,KAA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,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;IACjC,eAAe,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;IAC/B,eAAe,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;IAClC,eAAe,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IAEhC,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC/D,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAChE,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAE7D,MAAM,eAAe,GAAG,2BAA2B,CAAC;QAClD,OAAO,EAAE,eAAe;QACxB,oBAAoB,EAAE,QAAQ;QAC9B,gBAAgB;QAChB,wBAAwB,EAAE,aAAa;KACxC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,QAAQ;QACvB,CAAC,CAAC,2BAA2B,CAAC,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,CAAC;QACzF,CAAC,CAAC,mBAAmB,CAAC;YAClB,cAAc;YACd,eAAe;YACf,eAAe;YACf,QAAQ;YACR,YAAY;YACZ,YAAY;YACZ,aAAa;YACb,QAAQ;YACR,yBAAyB;SAC1B,CAAC,CAAC;IACP,MAAM,UAAU,GAAG,cAAc,CAAC,qBAAqB,EAAE,CAAC;IAC1D,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getBreakpointValue } from '../../breakpoints';\nimport { Dimensions, getOverflowParents, getOverflowParentDimensions } from '../../utils/scrollable-containers';\nimport styles from './styles.css.js';\n\nconst AVAILABLE_SPACE_RESERVE_DEFAULT = 50;\nconst AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL = 19; // 50 - 31\nconst AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL = 20;\n\ninterface AvailableSpace {\n above: number;\n below: number;\n left: number;\n right: number;\n}\nexport interface DropdownPosition {\n height: string;\n width: string;\n dropUp: boolean;\n dropLeft: boolean;\n left: string;\n}\nexport interface InteriorDropdownPosition extends DropdownPosition {\n bottom: string;\n top: string;\n}\n\nconst getClosestParentDimensions = (element: HTMLElement): any => {\n const parents = getOverflowParents(element).map(el => {\n const { height, width, top, left } = el.getBoundingClientRect();\n return {\n height,\n width,\n top,\n left,\n };\n });\n\n return parents.shift();\n};\n\n// By default, most dropdowns should expand their content as necessary, but to a maximum of 465px (the XXS breakpoint).\n// This value was determined by UX but may be subject to change in the future, depending on the feedback.\nexport const defaultMaxDropdownWidth = getBreakpointValue('xxs');\n\nexport const getAvailableSpace = ({\n trigger,\n overflowParents,\n stretchWidth = false,\n stretchHeight = false,\n isMobile,\n}: {\n trigger: HTMLElement;\n overflowParents: ReadonlyArray<Dimensions>;\n stretchWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n}): AvailableSpace => {\n const availableSpaceReserveVertical = stretchHeight\n ? 0\n : isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const availableSpaceReserveHorizontal = stretchWidth\n ? 0\n : isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const { bottom: triggerBottom, left: triggerLeft, right: triggerRight } = trigger.getBoundingClientRect();\n\n return overflowParents.reduce(\n ({ above, below, left, right }, overflowParent) => {\n const offsetTop = triggerBottom - overflowParent.top;\n const currentAbove = offsetTop - trigger.offsetHeight - availableSpaceReserveVertical;\n const currentBelow = overflowParent.height - offsetTop - availableSpaceReserveVertical;\n const currentLeft = triggerRight - overflowParent.left - availableSpaceReserveHorizontal;\n const currentRight = overflowParent.left + overflowParent.width - triggerLeft - availableSpaceReserveHorizontal;\n\n return {\n above: Math.min(above, currentAbove),\n below: Math.min(below, currentBelow),\n left: Math.min(left, currentLeft),\n right: Math.min(right, currentRight),\n };\n },\n { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE }\n );\n};\n\nexport const getInteriorAvailableSpace = ({\n trigger,\n overflowParents,\n isMobile,\n}: {\n trigger: HTMLElement;\n overflowParents: ReadonlyArray<Dimensions>;\n isMobile?: boolean;\n}): AvailableSpace => {\n const AVAILABLE_SPACE_RESERVE_VERTICAL = isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_VERTICAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const AVAILABLE_SPACE_RESERVE_HORIZONTAL = isMobile\n ? AVAILABLE_SPACE_RESERVE_MOBILE_HORIZONTAL\n : AVAILABLE_SPACE_RESERVE_DEFAULT;\n const {\n bottom: triggerBottom,\n top: triggerTop,\n left: triggerLeft,\n right: triggerRight,\n } = trigger.getBoundingClientRect();\n\n return overflowParents.reduce(\n ({ above, below, left, right }, overflowParent) => {\n const currentAbove = triggerBottom - overflowParent.top - AVAILABLE_SPACE_RESERVE_VERTICAL;\n const currentBelow = overflowParent.height - triggerTop + overflowParent.top - AVAILABLE_SPACE_RESERVE_VERTICAL;\n const currentLeft = triggerLeft - overflowParent.left - AVAILABLE_SPACE_RESERVE_HORIZONTAL;\n const currentRight =\n overflowParent.left + overflowParent.width - triggerRight - AVAILABLE_SPACE_RESERVE_HORIZONTAL;\n\n return {\n above: Math.min(above, currentAbove),\n below: Math.min(below, currentBelow),\n left: Math.min(left, currentLeft),\n right: Math.min(right, currentRight),\n };\n },\n { above: Number.MAX_VALUE, below: Number.MAX_VALUE, left: Number.MAX_VALUE, right: Number.MAX_VALUE }\n );\n};\n\nexport const getWidths = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n stretchBeyondTriggerWidth?: boolean;\n}) => {\n // Determine the width of the trigger\n const triggerWidth = triggerElement.getBoundingClientRect().width;\n // Minimum width is determined by either an explicit number (desiredMinWidth) or the trigger width\n const minWidth = desiredMinWidth ? Math.min(triggerWidth, desiredMinWidth) : triggerWidth;\n // If stretchBeyondTriggerWidth is true, the maximum width is the XS breakpoint (465px) or the trigger width (if bigger).\n const maxWidth = stretchBeyondTriggerWidth ? Math.max(defaultMaxDropdownWidth, triggerWidth) : Number.MAX_VALUE;\n // Determine the actual dropdown width, the size that it \"wants\" to be\n const requiredWidth = dropdownElement.getBoundingClientRect().width;\n // Try to achieve the required/desired width within the given parameters\n const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);\n return { idealWidth, minWidth, triggerWidth };\n};\n\nexport const hasEnoughSpaceToStretchBeyondTriggerWidth = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n expandToViewport: boolean;\n stretchWidth: boolean;\n stretchHeight: boolean;\n isMobile: boolean;\n}) => {\n const overflowParents = getOverflowParentDimensions({\n element: dropdownElement,\n excludeClosestParent: false,\n expandToViewport,\n canExpandOutsideViewport: stretchHeight,\n });\n const { idealWidth } = getWidths({\n triggerElement: triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth: true,\n });\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n return idealWidth <= availableSpace.left || idealWidth <= availableSpace.right;\n};\n\nexport const getDropdownPosition = ({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth: desiredMinWidth,\n preferCenter = false,\n stretchWidth = false,\n stretchHeight = false,\n isMobile = false,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n overflowParents: ReadonlyArray<Dimensions>;\n minWidth?: number;\n preferCenter?: boolean;\n stretchWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n}): DropdownPosition => {\n // Determine the space available around the dropdown that it can grow in\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n const { idealWidth, minWidth, triggerWidth } = getWidths({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth,\n });\n\n let dropLeft: boolean;\n let left: number | null = null;\n let width = idealWidth;\n\n //1. Can it be positioned with ideal width to the right?\n if (idealWidth <= availableSpace.right) {\n dropLeft = false;\n //2. Can it be positioned with ideal width to the left?\n } else if (idealWidth <= availableSpace.left) {\n dropLeft = true;\n //3. Fit into biggest available space either on left or right\n } else {\n dropLeft = availableSpace.left > availableSpace.right;\n width = Math.max(availableSpace.left, availableSpace.right, minWidth);\n }\n\n if (preferCenter) {\n const spillOver = (idealWidth - triggerWidth) / 2;\n\n // availableSpace always includes the trigger width, but we want to exclude that\n const availableOutsideLeft = availableSpace.left - triggerWidth;\n const availableOutsideRight = availableSpace.right - triggerWidth;\n\n const fitsInCenter = availableOutsideLeft >= spillOver && availableOutsideRight >= spillOver;\n if (fitsInCenter) {\n left = -spillOver;\n }\n }\n\n const dropUp = availableSpace.below < dropdownElement.offsetHeight && availableSpace.above > availableSpace.below;\n const availableHeight = dropUp ? availableSpace.above : availableSpace.below;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropUp,\n dropLeft,\n left: left === null ? 'auto' : `${left}px`,\n height: `${croppedHeight}px`,\n width: `${width}px`,\n };\n};\n\nexport const getInteriorDropdownPosition = (\n trigger: HTMLElement,\n dropdown: HTMLElement,\n overflowParents: ReadonlyArray<Dimensions>,\n isMobile?: boolean\n): InteriorDropdownPosition => {\n const availableSpace = getInteriorAvailableSpace({ trigger, overflowParents, isMobile });\n const { bottom: triggerBottom, top: triggerTop, width: triggerWidth } = trigger.getBoundingClientRect();\n const { top: parentDropdownTop, height: parentDropdownHeight } = getClosestParentDimensions(trigger);\n\n let dropLeft;\n\n let width = dropdown.getBoundingClientRect().width;\n const top = triggerTop - parentDropdownTop;\n if (width <= availableSpace.right) {\n dropLeft = false;\n } else if (width <= availableSpace.left) {\n dropLeft = true;\n } else {\n dropLeft = availableSpace.left > availableSpace.right;\n width = Math.max(availableSpace.left, availableSpace.right);\n }\n\n const left = dropLeft ? 0 - width : triggerWidth;\n\n const dropUp = availableSpace.below < dropdown.offsetHeight && availableSpace.above > availableSpace.below;\n const bottom = dropUp ? parentDropdownTop + parentDropdownHeight - triggerBottom : 0;\n const availableHeight = dropUp ? availableSpace.above : availableSpace.below;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropUp,\n dropLeft,\n height: `${croppedHeight}px`,\n width: `${width}px`,\n top: `${top}px`,\n bottom: `${bottom}px`,\n left: `${left}px`,\n };\n};\n\nexport const calculatePosition = (\n dropdownElement: HTMLDivElement,\n triggerElement: HTMLDivElement,\n verticalContainerElement: HTMLDivElement,\n interior: boolean,\n expandToViewport: boolean,\n preferCenter: boolean,\n stretchWidth: boolean,\n stretchHeight: boolean,\n isMobile: boolean,\n minWidth?: number,\n stretchBeyondTriggerWidth?: boolean\n): [DropdownPosition, DOMRect] => {\n // cleaning previously assigned values,\n // so that they are not reused in case of screen resize and similar events\n verticalContainerElement.style.maxHeight = '';\n dropdownElement.style.width = '';\n dropdownElement.style.top = '';\n dropdownElement.style.bottom = '';\n dropdownElement.style.left = '';\n\n dropdownElement.classList.remove(styles['dropdown-drop-left']);\n dropdownElement.classList.remove(styles['dropdown-drop-right']);\n dropdownElement.classList.remove(styles['dropdown-drop-up']);\n\n const overflowParents = getOverflowParentDimensions({\n element: dropdownElement,\n excludeClosestParent: interior,\n expandToViewport,\n canExpandOutsideViewport: stretchHeight,\n });\n const position = interior\n ? getInteriorDropdownPosition(triggerElement, dropdownElement, overflowParents, isMobile)\n : getDropdownPosition({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n stretchBeyondTriggerWidth,\n });\n const triggerBox = triggerElement.getBoundingClientRect();\n return [position, triggerBox];\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/dropdown/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/dropdown/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAiI7C,QAAA,MAAM,QAAQ,iXA2BX,aAAa,gBA+Sf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { useMergeRefs } from '../../hooks/use-merge-refs';
|
|
|
6
6
|
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
8
|
import { fireNonCancelableEvent } from '../../events';
|
|
9
|
-
import { calculatePosition, defaultMaxDropdownWidth, } from './dropdown-fit-handler';
|
|
9
|
+
import { calculatePosition, defaultMaxDropdownWidth, hasEnoughSpaceToStretchBeyondTriggerWidth, } from './dropdown-fit-handler';
|
|
10
10
|
import { Transition } from '../transition';
|
|
11
11
|
import { useVisualRefresh } from '../../hooks/use-visual-mode';
|
|
12
12
|
import { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';
|
|
@@ -15,6 +15,7 @@ import { useMobile } from '../../hooks/use-mobile';
|
|
|
15
15
|
import TabTrap from '../tab-trap/index.js';
|
|
16
16
|
import { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';
|
|
17
17
|
import { useUniqueId } from '../../hooks/use-unique-id/index.js';
|
|
18
|
+
import customCssProps from '../../generated/custom-css-properties';
|
|
18
19
|
const DropdownContainer = ({ children, renderWithPortal = false, id, referrerId, open }) => {
|
|
19
20
|
if (renderWithPortal) {
|
|
20
21
|
if (open) {
|
|
@@ -39,7 +40,7 @@ const TransitionContent = ({ state, transitionRef, dropdownClasses, stretchWidth
|
|
|
39
40
|
[styles.refresh]: isRefresh,
|
|
40
41
|
[styles['use-portal']]: expandToViewport && !interior,
|
|
41
42
|
[styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,
|
|
42
|
-
}), ref: contentRef, id: id, role: role, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "data-open": open, "data-animating": state !== 'exited', "aria-hidden": !open, style: stretchBeyondTriggerWidth ? {
|
|
43
|
+
}), ref: contentRef, id: id, role: role, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "data-open": open, "data-animating": state !== 'exited', "aria-hidden": !open, style: stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}, onMouseDown: onMouseDown },
|
|
43
44
|
React.createElement("div", { className: clsx(styles['dropdown-content-wrapper'], isRefresh && styles.refresh) },
|
|
44
45
|
React.createElement("div", { className: styles['ie11-wrapper'] },
|
|
45
46
|
React.createElement("div", { ref: verticalContainerRef, className: styles['dropdown-content'] },
|
|
@@ -180,6 +181,23 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
|
|
|
180
181
|
// See AWSUI-13040
|
|
181
182
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
182
183
|
}, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);
|
|
184
|
+
// Prevent the dropdown width from stretching beyond the trigger width
|
|
185
|
+
// if that is going to cause the dropdown to be cropped because of overflow
|
|
186
|
+
useLayoutEffect(() => {
|
|
187
|
+
if (stretchBeyondTriggerWidth && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {
|
|
188
|
+
if (!hasEnoughSpaceToStretchBeyondTriggerWidth({
|
|
189
|
+
triggerElement: triggerRef.current,
|
|
190
|
+
dropdownElement: dropdownRef.current,
|
|
191
|
+
desiredMinWidth: minWidth,
|
|
192
|
+
expandToViewport,
|
|
193
|
+
stretchWidth,
|
|
194
|
+
stretchHeight,
|
|
195
|
+
isMobile,
|
|
196
|
+
})) {
|
|
197
|
+
dropdownRef.current.classList.remove(styles['stretch-beyond-trigger-width']);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
183
201
|
// subscribe to outside click
|
|
184
202
|
useEffect(() => {
|
|
185
203
|
if (!open) {
|