@cloudscape-design/components-themeable 3.0.886 → 3.0.887

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 (72) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/attribute-editor/styles.scss +31 -29
  3. package/lib/internal/scss/top-navigation/styles.scss +1 -0
  4. package/lib/internal/template/attribute-editor/grid-defaults.d.ts +3 -0
  5. package/lib/internal/template/attribute-editor/grid-defaults.d.ts.map +1 -0
  6. package/lib/internal/template/attribute-editor/grid-defaults.js +122 -0
  7. package/lib/internal/template/attribute-editor/grid-defaults.js.map +1 -0
  8. package/lib/internal/template/attribute-editor/interfaces.d.ts +49 -2
  9. package/lib/internal/template/attribute-editor/interfaces.d.ts.map +1 -1
  10. package/lib/internal/template/attribute-editor/interfaces.js.map +1 -1
  11. package/lib/internal/template/attribute-editor/internal.d.ts.map +1 -1
  12. package/lib/internal/template/attribute-editor/internal.js +35 -15
  13. package/lib/internal/template/attribute-editor/internal.js.map +1 -1
  14. package/lib/internal/template/attribute-editor/row.d.ts +5 -3
  15. package/lib/internal/template/attribute-editor/row.d.ts.map +1 -1
  16. package/lib/internal/template/attribute-editor/row.js +29 -26
  17. package/lib/internal/template/attribute-editor/row.js.map +1 -1
  18. package/lib/internal/template/attribute-editor/styles.css.js +15 -14
  19. package/lib/internal/template/attribute-editor/styles.scoped.css +49 -41
  20. package/lib/internal/template/attribute-editor/styles.selectors.js +15 -14
  21. package/lib/internal/template/attribute-editor/utils.d.ts +11 -0
  22. package/lib/internal/template/attribute-editor/utils.d.ts.map +1 -0
  23. package/lib/internal/template/attribute-editor/utils.js +43 -0
  24. package/lib/internal/template/attribute-editor/utils.js.map +1 -0
  25. package/lib/internal/template/button-dropdown/interfaces.d.ts +6 -2
  26. package/lib/internal/template/button-dropdown/interfaces.d.ts.map +1 -1
  27. package/lib/internal/template/button-dropdown/interfaces.js.map +1 -1
  28. package/lib/internal/template/button-dropdown/internal.d.ts.map +1 -1
  29. package/lib/internal/template/button-dropdown/internal.js +11 -3
  30. package/lib/internal/template/button-dropdown/internal.js.map +1 -1
  31. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.js +1 -1
  32. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.js.map +1 -1
  33. package/lib/internal/template/button-group/item-element.d.ts.map +1 -1
  34. package/lib/internal/template/button-group/item-element.js +11 -7
  35. package/lib/internal/template/button-group/item-element.js.map +1 -1
  36. package/lib/internal/template/form-field/interfaces.d.ts +2 -1
  37. package/lib/internal/template/form-field/interfaces.d.ts.map +1 -1
  38. package/lib/internal/template/form-field/interfaces.js.map +1 -1
  39. package/lib/internal/template/form-field/internal.d.ts +1 -1
  40. package/lib/internal/template/form-field/internal.d.ts.map +1 -1
  41. package/lib/internal/template/form-field/internal.js +2 -2
  42. package/lib/internal/template/form-field/internal.js.map +1 -1
  43. package/lib/internal/template/internal/components/dropdown/dropdown-fit-handler.d.ts +2 -1
  44. package/lib/internal/template/internal/components/dropdown/dropdown-fit-handler.d.ts.map +1 -1
  45. package/lib/internal/template/internal/components/dropdown/dropdown-fit-handler.js +1 -1
  46. package/lib/internal/template/internal/components/dropdown/dropdown-fit-handler.js.map +1 -1
  47. package/lib/internal/template/internal/components/dropdown/dropdown-position.d.ts +16 -0
  48. package/lib/internal/template/internal/components/dropdown/dropdown-position.d.ts.map +1 -0
  49. package/lib/internal/template/internal/components/dropdown/dropdown-position.js +27 -0
  50. package/lib/internal/template/internal/components/dropdown/dropdown-position.js.map +1 -0
  51. package/lib/internal/template/internal/components/dropdown/index.d.ts.map +1 -1
  52. package/lib/internal/template/internal/components/dropdown/index.js +15 -31
  53. package/lib/internal/template/internal/components/dropdown/index.js.map +1 -1
  54. package/lib/internal/template/internal/environment.js +1 -1
  55. package/lib/internal/template/internal/environment.json +1 -1
  56. package/lib/internal/template/multiselect/interfaces.d.ts +4 -0
  57. package/lib/internal/template/multiselect/interfaces.d.ts.map +1 -1
  58. package/lib/internal/template/multiselect/interfaces.js.map +1 -1
  59. package/lib/internal/template/multiselect/internal.d.ts +1 -3
  60. package/lib/internal/template/multiselect/internal.d.ts.map +1 -1
  61. package/lib/internal/template/multiselect/internal.js.map +1 -1
  62. package/lib/internal/template/test-utils/dom/attribute-editor/index.d.ts +1 -0
  63. package/lib/internal/template/test-utils/dom/attribute-editor/index.js +4 -2
  64. package/lib/internal/template/test-utils/dom/attribute-editor/index.js.map +1 -1
  65. package/lib/internal/template/test-utils/selectors/attribute-editor/index.d.ts +1 -0
  66. package/lib/internal/template/test-utils/selectors/attribute-editor/index.js +4 -2
  67. package/lib/internal/template/test-utils/selectors/attribute-editor/index.js.map +1 -1
  68. package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
  69. package/lib/internal/template/top-navigation/styles.css.js +47 -47
  70. package/lib/internal/template/top-navigation/styles.scoped.css +66 -65
  71. package/lib/internal/template/top-navigation/styles.selectors.js +47 -47
  72. package/package.json +1 -1
@@ -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,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAe,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEjH,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,OAAO,CAAC,EA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C;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 { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBreakpointValue } from '../../breakpoints';\nimport { BoundingBox, getOverflowParentDimensions, getOverflowParents } from '../../utils/scrollable-containers';\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\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\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 getWidths = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n stretchBeyondTriggerWidth?: boolean;\n}) => {\n // Determine the width of the trigger\n const { inlineSize: triggerInlineSize } = getLogicalBoundingClientRect(triggerElement);\n // Minimum width is determined by either an explicit number (desiredMinWidth) or the trigger width\n const minWidth = desiredMinWidth ? Math.min(triggerInlineSize, desiredMinWidth) : triggerInlineSize;\n // If stretchBeyondTriggerWidth is true, the maximum width is the XS breakpoint (465px) or the trigger width (if bigger).\n const maxWidth = stretchBeyondTriggerWidth ? Math.max(defaultMaxDropdownWidth, triggerInlineSize) : Number.MAX_VALUE;\n // Determine the actual dropdown width, the size that it \"wants\" to be\n const { inlineSize: requiredWidth } = getLogicalBoundingClientRect(dropdownElement);\n // Try to achieve the required/desired width within the given parameters\n const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);\n return { idealWidth, minWidth, triggerInlineSize };\n};\n\nexport const hasEnoughSpaceToStretchBeyondTriggerWidth = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n expandToViewport: boolean;\n stretchWidth: boolean;\n stretchHeight: boolean;\n isMobile: boolean;\n}) => {\n const overflowParents = getOverflowParentDimensions({\n element: dropdownElement,\n excludeClosestParent: false,\n expandToViewport,\n canExpandOutsideViewport: stretchHeight,\n });\n const { idealWidth } = getWidths({\n triggerElement: triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth: true,\n });\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n return idealWidth <= availableSpace.inlineStart || idealWidth <= availableSpace.inlineEnd;\n};\n\nexport const getDropdownPosition = ({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth: desiredMinWidth,\n preferCenter = false,\n stretchWidth = false,\n stretchHeight = false,\n isMobile = false,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n minWidth?: number;\n preferCenter?: boolean;\n stretchWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n}): DropdownPosition => {\n // Determine the space available around the dropdown that it can grow in\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n const { idealWidth, minWidth, triggerInlineSize } = getWidths({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth,\n });\n\n let dropInlineStart: boolean;\n let insetInlineStart: number | null = null;\n let inlineSize = idealWidth;\n\n //1. Can it be positioned with ideal width to the right?\n if (idealWidth <= availableSpace.inlineEnd) {\n dropInlineStart = false;\n //2. Can it be positioned with ideal width to the left?\n } else if (idealWidth <= availableSpace.inlineStart) {\n dropInlineStart = true;\n //3. Fit into biggest available space either on left or right\n } else {\n dropInlineStart = availableSpace.inlineStart > availableSpace.inlineEnd;\n inlineSize = Math.max(availableSpace.inlineStart, availableSpace.inlineEnd, minWidth);\n }\n\n if (preferCenter) {\n const spillOver = (idealWidth - triggerInlineSize) / 2;\n\n // availableSpace always includes the trigger width, but we want to exclude that\n const availableOutsideLeft = availableSpace.inlineStart - triggerInlineSize;\n const availableOutsideRight = availableSpace.inlineEnd - triggerInlineSize;\n\n const fitsInCenter = availableOutsideLeft >= spillOver && availableOutsideRight >= spillOver;\n if (fitsInCenter) {\n insetInlineStart = -spillOver;\n }\n }\n\n const dropBlockStart =\n availableSpace.blockEnd < dropdownElement.offsetHeight && availableSpace.blockStart > availableSpace.blockEnd;\n const availableHeight = dropBlockStart ? availableSpace.blockStart : availableSpace.blockEnd;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropBlockStart,\n dropInlineStart,\n insetInlineStart: insetInlineStart === null ? 'auto' : `${insetInlineStart}px`,\n blockSize: `${croppedHeight}px`,\n inlineSize: `${inlineSize}px`,\n };\n};\n\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 stretchWidth: boolean,\n stretchHeight: boolean,\n isMobile: boolean,\n minWidth?: number,\n stretchBeyondTriggerWidth?: boolean\n): [DropdownPosition, DOMRect] => {\n // cleaning previously assigned values,\n // so that they are not reused in case of screen resize and similar events\n verticalContainerElement.style.maxBlockSize = '';\n dropdownElement.style.inlineSize = '';\n dropdownElement.style.insetBlockStart = '';\n dropdownElement.style.insetBlockEnd = '';\n dropdownElement.style.insetInlineStart = '';\n\n dropdownElement.classList.remove(styles['dropdown-drop-left']);\n dropdownElement.classList.remove(styles['dropdown-drop-right']);\n dropdownElement.classList.remove(styles['dropdown-drop-up']);\n\n const overflowParents = getOverflowParentDimensions({\n element: dropdownElement,\n excludeClosestParent: interior,\n expandToViewport,\n canExpandOutsideViewport: stretchHeight,\n });\n const position = interior\n ? getInteriorDropdownPosition(triggerElement, dropdownElement, overflowParents, isMobile)\n : getDropdownPosition({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n stretchBeyondTriggerWidth,\n });\n const triggerBox = triggerElement.getBoundingClientRect();\n return [position, triggerBox];\n};\n"]}
1
+ {"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,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAe,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGjH,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,OAAO,CAAC,EAAE;QACxD,MAAM,EAAE,SAAS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AA4B,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 { getBreakpointValue } from '../../breakpoints';\nimport { BoundingBox, getOverflowParentDimensions, getOverflowParents } from '../../utils/scrollable-containers';\nimport { LogicalDOMRect } from './dropdown-position';\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\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\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 getWidths = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n stretchBeyondTriggerWidth?: boolean;\n}) => {\n // Determine the width of the trigger\n const { inlineSize: triggerInlineSize } = getLogicalBoundingClientRect(triggerElement);\n // Minimum width is determined by either an explicit number (desiredMinWidth) or the trigger width\n const minWidth = desiredMinWidth ? Math.min(triggerInlineSize, desiredMinWidth) : triggerInlineSize;\n // If stretchBeyondTriggerWidth is true, the maximum width is the XS breakpoint (465px) or the trigger width (if bigger).\n const maxWidth = stretchBeyondTriggerWidth ? Math.max(defaultMaxDropdownWidth, triggerInlineSize) : Number.MAX_VALUE;\n // Determine the actual dropdown width, the size that it \"wants\" to be\n const { inlineSize: requiredWidth } = getLogicalBoundingClientRect(dropdownElement);\n // Try to achieve the required/desired width within the given parameters\n const idealWidth = Math.min(Math.max(requiredWidth, minWidth), maxWidth);\n return { idealWidth, minWidth, triggerInlineSize };\n};\n\nexport const hasEnoughSpaceToStretchBeyondTriggerWidth = ({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n desiredMinWidth?: number;\n expandToViewport: boolean;\n stretchWidth: boolean;\n stretchHeight: boolean;\n isMobile: boolean;\n}) => {\n const overflowParents = getOverflowParentDimensions({\n element: dropdownElement,\n excludeClosestParent: false,\n expandToViewport,\n canExpandOutsideViewport: stretchHeight,\n });\n const { idealWidth } = getWidths({\n triggerElement: triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth: true,\n });\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n return idealWidth <= availableSpace.inlineStart || idealWidth <= availableSpace.inlineEnd;\n};\n\nexport const getDropdownPosition = ({\n triggerElement,\n dropdownElement,\n overflowParents,\n minWidth: desiredMinWidth,\n preferCenter = false,\n stretchWidth = false,\n stretchHeight = false,\n isMobile = false,\n stretchBeyondTriggerWidth = false,\n}: {\n triggerElement: HTMLElement;\n dropdownElement: HTMLElement;\n overflowParents: ReadonlyArray<BoundingBox>;\n minWidth?: number;\n preferCenter?: boolean;\n stretchWidth?: boolean;\n stretchHeight?: boolean;\n isMobile?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n}): DropdownPosition => {\n // Determine the space available around the dropdown that it can grow in\n const availableSpace = getAvailableSpace({\n trigger: triggerElement,\n overflowParents,\n stretchWidth,\n stretchHeight,\n isMobile,\n });\n const { idealWidth, minWidth, triggerInlineSize } = getWidths({\n triggerElement,\n dropdownElement,\n desiredMinWidth,\n stretchBeyondTriggerWidth,\n });\n\n let dropInlineStart: boolean;\n let insetInlineStart: number | null = null;\n let inlineSize = idealWidth;\n\n //1. Can it be positioned with ideal width to the right?\n if (idealWidth <= availableSpace.inlineEnd) {\n dropInlineStart = false;\n //2. Can it be positioned with ideal width to the left?\n } else if (idealWidth <= availableSpace.inlineStart) {\n dropInlineStart = true;\n //3. Fit into biggest available space either on left or right\n } else {\n dropInlineStart = availableSpace.inlineStart > availableSpace.inlineEnd;\n inlineSize = Math.max(availableSpace.inlineStart, availableSpace.inlineEnd, minWidth);\n }\n\n if (preferCenter) {\n const spillOver = (idealWidth - triggerInlineSize) / 2;\n\n // availableSpace always includes the trigger width, but we want to exclude that\n const availableOutsideLeft = availableSpace.inlineStart - triggerInlineSize;\n const availableOutsideRight = availableSpace.inlineEnd - triggerInlineSize;\n\n const fitsInCenter = availableOutsideLeft >= spillOver && availableOutsideRight >= spillOver;\n if (fitsInCenter) {\n insetInlineStart = -spillOver;\n }\n }\n\n const dropBlockStart =\n availableSpace.blockEnd < dropdownElement.offsetHeight && availableSpace.blockStart > availableSpace.blockEnd;\n const availableHeight = dropBlockStart ? availableSpace.blockStart : availableSpace.blockEnd;\n // Try and crop the bottom item when all options can't be displayed, affordance for \"there's more\"\n const croppedHeight = stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16;\n\n return {\n dropBlockStart,\n dropInlineStart,\n insetInlineStart: insetInlineStart === null ? 'auto' : `${insetInlineStart}px`,\n blockSize: `${croppedHeight}px`,\n inlineSize: `${inlineSize}px`,\n };\n};\n\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 stretchWidth: boolean,\n stretchHeight: boolean,\n isMobile: boolean,\n minWidth?: number,\n stretchBeyondTriggerWidth?: boolean\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 preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n stretchBeyondTriggerWidth,\n });\n const triggerBox = getLogicalBoundingClientRect(triggerElement);\n return [position, triggerBox];\n};\n"]}
@@ -0,0 +1,16 @@
1
+ import { DropdownPosition } from './dropdown-fit-handler';
2
+ export interface LogicalDOMRect {
3
+ blockSize: number;
4
+ inlineSize: number;
5
+ insetBlockStart: number;
6
+ insetBlockEnd: number;
7
+ insetInlineStart: number;
8
+ insetInlineEnd: number;
9
+ }
10
+ export declare function applyDropdownPositionRelativeToViewport({ position, dropdownElement, triggerRect, isMobile, }: {
11
+ position: DropdownPosition;
12
+ dropdownElement: HTMLElement;
13
+ triggerRect: LogicalDOMRect;
14
+ isMobile: boolean;
15
+ }): void;
16
+ //# sourceMappingURL=dropdown-position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown-position.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/dropdown-position.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;CACxB;AAGD,wBAAgB,uCAAuC,CAAC,EACtD,QAAQ,EACR,eAAe,EACf,WAAW,EACX,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,eAAe,EAAE,WAAW,CAAC;IAC7B,WAAW,EAAE,cAAc,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;CACnB,QAuBA"}
@@ -0,0 +1,27 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Applies its position to the dropdown element when expandToViewport is set to true.
4
+ export function applyDropdownPositionRelativeToViewport({ position, dropdownElement, triggerRect, isMobile, }) {
5
+ // Fixed positions are not respected in iOS when the virtual keyboard is being displayed.
6
+ // For this reason we use absolute positioning in mobile.
7
+ const useAbsolutePositioning = isMobile;
8
+ // Since when using expandToViewport=true the dropdown is attached to the root of the body,
9
+ // the same coordinates can be used for fixed or absolute position,
10
+ // except when using absolute position we need to take into account the scroll position of the body itself.
11
+ const verticalScrollOffset = useAbsolutePositioning ? document.documentElement.scrollTop : 0;
12
+ const horizontalScrollOffset = useAbsolutePositioning ? document.documentElement.scrollLeft : 0;
13
+ dropdownElement.style.position = useAbsolutePositioning ? 'absolute' : 'fixed';
14
+ if (position.dropBlockStart) {
15
+ dropdownElement.style.insetBlockEnd = `calc(100% - ${verticalScrollOffset + triggerRect.insetBlockStart}px)`;
16
+ }
17
+ else {
18
+ dropdownElement.style.insetBlockStart = `${verticalScrollOffset + triggerRect.insetBlockEnd}px`;
19
+ }
20
+ if (position.dropInlineStart) {
21
+ dropdownElement.style.insetInlineStart = `calc(${horizontalScrollOffset + triggerRect.insetInlineEnd}px - ${position.inlineSize})`;
22
+ }
23
+ else {
24
+ dropdownElement.style.insetInlineStart = `${horizontalScrollOffset + triggerRect.insetInlineStart}px`;
25
+ }
26
+ }
27
+ //# sourceMappingURL=dropdown-position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown-position.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/dropdown-position.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAatC,qFAAqF;AACrF,MAAM,UAAU,uCAAuC,CAAC,EACtD,QAAQ,EACR,eAAe,EACf,WAAW,EACX,QAAQ,GAMT;IACC,yFAAyF;IACzF,yDAAyD;IACzD,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAExC,2FAA2F;IAC3F,mEAAmE;IACnE,2GAA2G;IAC3G,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7F,MAAM,sBAAsB,GAAG,sBAAsB,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhG,eAAe,CAAC,KAAK,CAAC,QAAQ,GAAG,sBAAsB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;IAE/E,IAAI,QAAQ,CAAC,cAAc,EAAE;QAC3B,eAAe,CAAC,KAAK,CAAC,aAAa,GAAG,eAAe,oBAAoB,GAAG,WAAW,CAAC,eAAe,KAAK,CAAC;KAC9G;SAAM;QACL,eAAe,CAAC,KAAK,CAAC,eAAe,GAAG,GAAG,oBAAoB,GAAG,WAAW,CAAC,aAAa,IAAI,CAAC;KACjG;IACD,IAAI,QAAQ,CAAC,eAAe,EAAE;QAC5B,eAAe,CAAC,KAAK,CAAC,gBAAgB,GAAG,QAAQ,sBAAsB,GAAG,WAAW,CAAC,cAAc,QAAQ,QAAQ,CAAC,UAAU,GAAG,CAAC;KACpI;SAAM;QACL,eAAe,CAAC,KAAK,CAAC,gBAAgB,GAAG,GAAG,sBAAsB,GAAG,WAAW,CAAC,gBAAgB,IAAI,CAAC;KACvG;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { DropdownPosition } from './dropdown-fit-handler';\n\nexport interface LogicalDOMRect {\n blockSize: number;\n inlineSize: number;\n insetBlockStart: number;\n insetBlockEnd: number;\n insetInlineStart: number;\n insetInlineEnd: number;\n}\n\n// Applies its position to the dropdown element when expandToViewport is set to true.\nexport function applyDropdownPositionRelativeToViewport({\n position,\n dropdownElement,\n triggerRect,\n isMobile,\n}: {\n position: DropdownPosition;\n dropdownElement: HTMLElement;\n triggerRect: LogicalDOMRect;\n isMobile: boolean;\n}) {\n // Fixed positions are not respected in iOS when the virtual keyboard is being displayed.\n // For this reason we use absolute positioning in mobile.\n const useAbsolutePositioning = isMobile;\n\n // Since when using expandToViewport=true the dropdown is attached to the root of the body,\n // the same coordinates can be used for fixed or absolute position,\n // except when using absolute position we need to take into account the scroll position of the body itself.\n const verticalScrollOffset = useAbsolutePositioning ? document.documentElement.scrollTop : 0;\n const horizontalScrollOffset = useAbsolutePositioning ? document.documentElement.scrollLeft : 0;\n\n dropdownElement.style.position = useAbsolutePositioning ? 'absolute' : 'fixed';\n\n if (position.dropBlockStart) {\n dropdownElement.style.insetBlockEnd = `calc(100% - ${verticalScrollOffset + triggerRect.insetBlockStart}px)`;\n } else {\n dropdownElement.style.insetBlockStart = `${verticalScrollOffset + triggerRect.insetBlockEnd}px`;\n }\n if (position.dropInlineStart) {\n dropdownElement.style.insetInlineStart = `calc(${horizontalScrollOffset + triggerRect.insetInlineEnd}px - ${position.inlineSize})`;\n } else {\n dropdownElement.style.insetInlineStart = `${horizontalScrollOffset + triggerRect.insetInlineStart}px`;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":";AA4BA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA6H7C,QAAA,MAAM,QAAQ,iXA2BX,aAAa,gBAuTf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":";AA6BA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA6H7C,QAAA,MAAM,QAAQ,iXA2BX,aAAa,gBA0Sf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
@@ -18,6 +18,7 @@ import TabTrap from '../tab-trap/index.js';
18
18
  import { Transition } from '../transition';
19
19
  import { DropdownContextProvider } from './context';
20
20
  import { calculatePosition, defaultMaxDropdownWidth, hasEnoughSpaceToStretchBeyondTriggerWidth, } from './dropdown-fit-handler';
21
+ import { applyDropdownPositionRelativeToViewport } from './dropdown-position';
21
22
  import styles from './styles.css.js';
22
23
  const DropdownContainer = ({ triggerRef, children, renderWithPortal, id, referrerId, open, }) => {
23
24
  var _a, _b;
@@ -93,19 +94,12 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
93
94
  }
94
95
  // Position normal overflow dropdowns with fixed positioning relative to viewport
95
96
  if (expandToViewport && !interior) {
96
- target.style.position = 'fixed';
97
- if (position.dropBlockStart) {
98
- target.style.insetBlockEnd = `calc(100% - ${triggerBox.top}px)`;
99
- }
100
- else {
101
- target.style.insetBlockStart = `${triggerBox.bottom}px`;
102
- }
103
- if (position.dropInlineStart) {
104
- target.style.insetInlineStart = `calc(${triggerBox.right}px - ${position.inlineSize})`;
105
- }
106
- else {
107
- target.style.insetInlineStart = `${triggerBox.left}px`;
108
- }
97
+ applyDropdownPositionRelativeToViewport({
98
+ position,
99
+ dropdownElement: target,
100
+ triggerRect: triggerBox,
101
+ isMobile,
102
+ });
109
103
  // Keep track of the initial dropdown position and direction.
110
104
  // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.
111
105
  fixedPosition.current = position;
@@ -224,23 +218,13 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
224
218
  return;
225
219
  }
226
220
  const updateDropdownPosition = () => {
227
- if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {
228
- const triggerRect = getLogicalBoundingClientRect(triggerRef.current);
229
- const target = dropdownRef.current;
230
- if (fixedPosition.current) {
231
- if (fixedPosition.current.dropBlockStart) {
232
- dropdownRef.current.style.insetBlockEnd = `calc(100% - ${triggerRect.insetBlockStart}px)`;
233
- }
234
- else {
235
- target.style.insetBlockStart = `${triggerRect.insetBlockEnd}px`;
236
- }
237
- if (fixedPosition.current.dropInlineStart) {
238
- target.style.insetInlineStart = `calc(${triggerRect.insetInlineEnd}px - ${fixedPosition.current.inlineSize})`;
239
- }
240
- else {
241
- target.style.insetInlineStart = `${triggerRect.insetInlineStart}px`;
242
- }
243
- }
221
+ if (triggerRef.current && dropdownRef.current && verticalContainerRef.current && fixedPosition.current) {
222
+ applyDropdownPositionRelativeToViewport({
223
+ position: fixedPosition.current,
224
+ dropdownElement: dropdownRef.current,
225
+ triggerRect: getLogicalBoundingClientRect(triggerRef.current),
226
+ isMobile,
227
+ });
244
228
  }
245
229
  };
246
230
  updateDropdownPosition();
@@ -250,7 +234,7 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
250
234
  return () => {
251
235
  controller.abort();
252
236
  };
253
- }, [open, expandToViewport]);
237
+ }, [open, expandToViewport, isMobile]);
254
238
  const referrerId = useUniqueId();
255
239
  return (React.createElement("div", { className: clsx(styles.root, interior && styles.interior, stretchTriggerHeight && styles['stretch-trigger-height']), ref: wrapperRef, onFocus: focusHandler, onBlur: blurHandler },
256
240
  React.createElement("div", { id: referrerId, className: clsx(stretchTriggerHeight && styles['stretch-trigger-height']), ref: triggerRef }, trigger),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AAAA,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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 { useResizeObserver } 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 { useMergeRefs } from '../../hooks/use-merge-refs';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useUniqueId } from '../../hooks/use-unique-id/index.js';\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 defaultMaxDropdownWidth,\n DropdownPosition,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\n InteriorDropdownPosition,\n} from './dropdown-fit-handler';\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 stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: DOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;\n } else {\n verticalContainer.style.maxBlockSize = position.blockSize;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.inlineSize = position.inlineSize;\n }\n\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropBlockStart && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.insetBlockEnd = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.insetInlineStart && position.insetInlineStart !== 'auto') {\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n target.style.position = 'fixed';\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = `calc(100% - ${triggerBox.top}px)`;\n } else {\n target.style.insetBlockStart = `${triggerBox.bottom}px`;\n }\n if (position.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerBox.right}px - ${position.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerBox.left}px`;\n }\n // Keep track of the initial dropdown position and direction.\n // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.\n fixedPosition.current = position;\n return;\n }\n\n // For an interior dropdown (the fly out) we need exact values for positioning\n // and classes are not enough\n // usage of relative position is impossible due to overwrite of overflow-x\n if (interior && isInteriorPosition(position)) {\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = position.insetBlockEnd;\n } else {\n target.style.insetBlockStart = position.insetBlockStart;\n }\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n if (position.dropBlockStart && position.dropInlineStart) {\n setPosition('top-left');\n } else if (position.dropBlockStart) {\n setPosition('top-right');\n } else if (position.dropInlineStart) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n const isOutsideDropdown = (element: Element) =>\n (!wrapperRef.current || !nodeBelongs(wrapperRef.current, element)) &&\n (!dropdownContainerRef.current || !nodeBelongs(dropdownContainerRef.current, element));\n\n const focusHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onFocus, event);\n }\n };\n\n const blurHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onBlur, event);\n }\n };\n\n // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth,\n stretchBeyondTriggerWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (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(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {\n const triggerRect = getLogicalBoundingClientRect(triggerRef.current);\n const target = dropdownRef.current;\n if (fixedPosition.current) {\n if (fixedPosition.current.dropBlockStart) {\n dropdownRef.current.style.insetBlockEnd = `calc(100% - ${triggerRect.insetBlockStart}px)`;\n } else {\n target.style.insetBlockStart = `${triggerRect.insetBlockEnd}px`;\n }\n if (fixedPosition.current.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerRect.insetInlineEnd}px - ${fixedPosition.current.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerRect.insetInlineStart}px`;\n }\n }\n }\n };\n\n updateDropdownPosition();\n\n 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]);\n\n const referrerId = useUniqueId();\n\n return (\n <div\n className={clsx(\n styles.root,\n interior && styles.interior,\n stretchTriggerHeight && styles['stretch-trigger-height']\n )}\n ref={wrapperRef}\n onFocus={focusHandler}\n onBlur={blurHandler}\n >\n <div id={referrerId} className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}>\n {trigger}\n </div>\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <DropdownContainer\n 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 stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).insetBlockEnd !== undefined;\n\nexport default Dropdown;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[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EAClB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,yBAAyB,EAAE,yBAAyB,EACpD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,mBAAmB,EACzB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,IAE/B,QAAQ,CACS;gBAEpB,oBAAC,OAAO,IACN,iBAAiB,EAAE,GAAG,EAAE,WAAC,OAAA,UAAU,CAAC,OAAO,KAAI,MAAA,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC7F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B,CACE,CACP,CACU,CACK,CAChB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,QAAqD,EACf,EAAE,CAAE,QAAqC,CAAC,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 { useResizeObserver } 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 { useMergeRefs } from '../../hooks/use-merge-refs';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useUniqueId } from '../../hooks/use-unique-id/index.js';\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 defaultMaxDropdownWidth,\n DropdownPosition,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\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 stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: LogicalDOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;\n } else {\n verticalContainer.style.maxBlockSize = position.blockSize;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.inlineSize = position.inlineSize;\n }\n\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropBlockStart && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.insetBlockEnd = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.insetInlineStart && position.insetInlineStart !== 'auto') {\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n 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 // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth,\n stretchBeyondTriggerWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (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(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current && 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 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 stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).insetBlockEnd !== undefined;\n\nexport default Dropdown;\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (372abbda)";
2
+ export var PACKAGE_VERSION = "3.0.0 (76a85a0a)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (372abbda)",
3
+ "PACKAGE_VERSION": "3.0.0 (76a85a0a)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -20,6 +20,10 @@ export interface MultiselectProps extends BaseSelectProps {
20
20
  * Only use this if the selected options are displayed elsewhere on the page.
21
21
  */
22
22
  hideTokens?: boolean;
23
+ /**
24
+ * Shows tokens inside the trigger instead of below it.
25
+ */
26
+ inlineTokens?: boolean;
23
27
  /**
24
28
  * Specifies an `aria-label` for the token deselection button.
25
29
  * @i18n
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/multiselect/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,IAAI,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD;;;OAGG;IACH,eAAe,EAAE,aAAa,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACxD;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,iBAAiB,CAAC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/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { OptionDefinition, OptionGroup as OptionGroupDefinition } from '../internal/components/option/interfaces';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { BaseSelectProps } from '../select/interfaces';\n\nexport interface MultiselectProps extends BaseSelectProps {\n /**\n * Specifies the currently selected options.\n * Provide an empty array to clear the selection.\n */\n selectedOptions: ReadonlyArray<MultiselectProps.Option>;\n /**\n * Determines whether the dropdown list stays open after the user selects an item.\n */\n keepOpen?: boolean;\n /**\n * Specifies the maximum number of displayed tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Hides the tokens displayed underneath the component.\n * Only use this if the selected options are displayed elsewhere on the page.\n */\n hideTokens?: boolean;\n /**\n * Specifies an `aria-label` for the token deselection button.\n * @i18n\n */\n deselectAriaLabel?: MultiselectProps.DeselectAriaLabelFunction;\n /**\n * An object containing all the localized strings required by the component.\n * Note that the string for `tokenLimitShowMore` should not contain the number of hidden tokens\n * because it will be added by the component automatically.\n */\n i18nStrings?: MultiselectProps.I18nStrings;\n /**\n * Called when the user selects or deselects an option.\n * The event `detail` contains the current `selectedOptions`.\n */\n onChange?: NonCancelableEventHandler<MultiselectProps.MultiselectChangeDetail>;\n\n /**\n * Automatically focuses the trigger when component is mounted.\n */\n autoFocus?: boolean;\n\n /**\n * Adds an aria-label to the \"Show fewer\" button for the token group control.\n * Use to assign unique labels when there are multiple token groups with the same `tokenLimitShowFewer` label on one page.\n */\n tokenLimitShowFewerAriaLabel?: string;\n /**\n * Adds an aria-label to the \"Show more\" button for the token group control.\n * Use to assign unique labels when there are multiple token groups with the same `tokenLimitShowMore` label on one page.\n */\n tokenLimitShowMoreAriaLabel?: string;\n}\n\nexport namespace MultiselectProps {\n export type Option = OptionDefinition;\n export type OptionGroup = OptionGroupDefinition;\n export type Options = ReadonlyArray<Option | OptionGroup>;\n export type DeselectAriaLabelFunction = (option: Option) => string;\n export type TriggerVariant = 'placeholder' | 'tokens';\n\n export interface I18nStrings {\n tokenLimitShowFewer?: string;\n tokenLimitShowMore?: string;\n }\n\n export interface MultiselectChangeDetail {\n selectedOptions: ReadonlyArray<Option>;\n }\n\n export interface Ref {\n /**\n * Sets focus on the element without opening the dropdown or showing a visual focus indicator.\n */\n focus(): void;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/multiselect/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { OptionDefinition, OptionGroup as OptionGroupDefinition } from '../internal/components/option/interfaces';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { BaseSelectProps } from '../select/interfaces';\n\nexport interface MultiselectProps extends BaseSelectProps {\n /**\n * Specifies the currently selected options.\n * Provide an empty array to clear the selection.\n */\n selectedOptions: ReadonlyArray<MultiselectProps.Option>;\n /**\n * Determines whether the dropdown list stays open after the user selects an item.\n */\n keepOpen?: boolean;\n /**\n * Specifies the maximum number of displayed tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Hides the tokens displayed underneath the component.\n * Only use this if the selected options are displayed elsewhere on the page.\n */\n hideTokens?: boolean;\n /**\n * Shows tokens inside the trigger instead of below it.\n */\n inlineTokens?: boolean;\n /**\n * Specifies an `aria-label` for the token deselection button.\n * @i18n\n */\n deselectAriaLabel?: MultiselectProps.DeselectAriaLabelFunction;\n /**\n * An object containing all the localized strings required by the component.\n * Note that the string for `tokenLimitShowMore` should not contain the number of hidden tokens\n * because it will be added by the component automatically.\n */\n i18nStrings?: MultiselectProps.I18nStrings;\n /**\n * Called when the user selects or deselects an option.\n * The event `detail` contains the current `selectedOptions`.\n */\n onChange?: NonCancelableEventHandler<MultiselectProps.MultiselectChangeDetail>;\n\n /**\n * Automatically focuses the trigger when component is mounted.\n */\n autoFocus?: boolean;\n\n /**\n * Adds an aria-label to the \"Show fewer\" button for the token group control.\n * Use to assign unique labels when there are multiple token groups with the same `tokenLimitShowFewer` label on one page.\n */\n tokenLimitShowFewerAriaLabel?: string;\n /**\n * Adds an aria-label to the \"Show more\" button for the token group control.\n * Use to assign unique labels when there are multiple token groups with the same `tokenLimitShowMore` label on one page.\n */\n tokenLimitShowMoreAriaLabel?: string;\n}\n\nexport namespace MultiselectProps {\n export type Option = OptionDefinition;\n export type OptionGroup = OptionGroupDefinition;\n export type Options = ReadonlyArray<Option | OptionGroup>;\n export type DeselectAriaLabelFunction = (option: Option) => string;\n export type TriggerVariant = 'placeholder' | 'tokens';\n\n export interface I18nStrings {\n tokenLimitShowFewer?: string;\n tokenLimitShowMore?: string;\n }\n\n export interface MultiselectChangeDetail {\n selectedOptions: ReadonlyArray<Option>;\n }\n\n export interface Ref {\n /**\n * Sets focus on the element without opening the dropdown or showing a visual focus indicator.\n */\n focus(): void;\n }\n}\n"]}
@@ -8,8 +8,6 @@ declare const InternalMultiselect: React.ForwardRefExoticComponent<MultiselectPr
8
8
  selectedOptions: readonly import("../internal/components/option/interfaces").OptionDefinition[];
9
9
  keepOpen: boolean;
10
10
  hideTokens: boolean;
11
- } & InternalBaseComponentProps<any> & {
12
- inlineTokens?: boolean | undefined;
13
- } & React.RefAttributes<MultiselectProps.Ref>>;
11
+ } & InternalBaseComponentProps<any> & React.RefAttributes<MultiselectProps.Ref>>;
14
12
  export default InternalMultiselect;
15
13
  //# sourceMappingURL=internal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/multiselect/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AASxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAU3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAWhD,QAAA,MAAM,mBAAmB;;;;;;;;;8CA2KxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/multiselect/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AASxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAU3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAWhD,QAAA,MAAM,mBAAmB;;;;;;;gFA2KxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/multiselect/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,cAAc,MAAM,iDAAiD,CAAC;AAC7E,OAAO,gBAAgB,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,SAAS,MAAM,4BAA4B,CAAC;AACnD,OAAO,OAAO,MAAM,yBAAyB,CAAC;AAC9C,OAAO,WAAW,MAAM,8BAA8B,CAAC;AAEvD,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC,M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CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport Dropdown from '../internal/components/dropdown';\nimport DropdownFooter from '../internal/components/dropdown-footer/index.js';\nimport ScreenreaderOnly from '../internal/components/screenreader-only';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { SomeRequired } from '../internal/types';\nimport { joinStrings } from '../internal/utils/strings';\nimport Filter from '../select/parts/filter';\nimport PlainList from '../select/parts/plain-list';\nimport Trigger from '../select/parts/trigger';\nimport VirtualList from '../select/parts/virtual-list';\nimport { TokenGroupProps } from '../token-group/interfaces';\nimport InternalTokenGroup from '../token-group/internal';\nimport { MultiselectProps } from './interfaces';\nimport { useMultiselect } from './use-multiselect';\n\nimport styles from './styles.css.js';\n\ntype InternalMultiselectProps = SomeRequired<\n MultiselectProps,\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType' | 'keepOpen' | 'hideTokens'\n> &\n InternalBaseComponentProps & { inlineTokens?: boolean };\n\nconst InternalMultiselect = React.forwardRef(\n (\n {\n options,\n filteringType,\n filteringPlaceholder,\n filteringAriaLabel,\n filteringClearAriaLabel,\n ariaRequired,\n placeholder,\n disabled,\n readOnly,\n ariaLabel,\n selectedOptions,\n deselectAriaLabel,\n tokenLimit,\n i18nStrings,\n virtualScroll,\n inlineTokens = false,\n hideTokens,\n expandToViewport,\n tokenLimitShowFewerAriaLabel,\n tokenLimitShowMoreAriaLabel,\n __internalRootRef = null,\n autoFocus,\n ...restProps\n }: InternalMultiselectProps,\n externalRef: React.Ref<MultiselectProps.Ref>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n const i18n = useInternalI18n('multiselect');\n\n const selfControlId = useUniqueId('trigger');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const ariaLabelId = useUniqueId('multiselect-ariaLabel-');\n const footerId = useUniqueId('multiselect-footer-');\n\n const [filteringValue, setFilteringValue] = useState('');\n const multiselectProps = useMultiselect({\n options,\n selectedOptions,\n filteringType,\n disabled,\n deselectAriaLabel,\n controlId,\n ariaLabelId,\n footerId,\n filteringValue,\n setFilteringValue,\n externalRef,\n ...restProps,\n });\n\n const filter = (\n <Filter\n clearAriaLabel={filteringClearAriaLabel}\n filteringType={filteringType}\n placeholder={filteringPlaceholder}\n ariaLabel={filteringAriaLabel}\n ariaRequired={ariaRequired}\n value={filteringValue}\n {...multiselectProps.getFilterProps()}\n />\n );\n\n const trigger = (\n <Trigger\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n triggerProps={multiselectProps.getTriggerProps(disabled, autoFocus)}\n selectedOption={null}\n selectedOptions={selectedOptions}\n triggerVariant={inlineTokens ? 'tokens' : 'placeholder'}\n isOpen={multiselectProps.isOpen}\n {...formFieldContext}\n controlId={controlId}\n ariaLabelledby={joinStrings(formFieldContext.ariaLabelledby, ariaLabelId)}\n />\n );\n\n const tokens: TokenGroupProps['items'] = selectedOptions.map(option => ({\n label: option.label,\n disabled: disabled || option.disabled,\n labelTag: option.labelTag,\n description: option.description,\n iconAlt: option.iconAlt,\n iconName: option.iconName,\n iconUrl: option.iconUrl,\n iconSvg: option.iconSvg,\n tags: option.tags,\n dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel?.(option), format =>\n format({ option__label: option.label ?? '' })\n ),\n }));\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const showTokens = !hideTokens && !inlineTokens && tokens.length > 0;\n\n const tokenGroupI18nStrings: TokenGroupProps.I18nStrings = {\n limitShowFewer: i18nStrings?.tokenLimitShowFewer,\n limitShowMore: i18nStrings?.tokenLimitShowMore,\n };\n\n const dropdownStatus = multiselectProps.dropdownStatus;\n const dropdownProps = multiselectProps.getDropdownProps();\n\n return (\n <div\n {...baseProps}\n ref={__internalRootRef}\n className={clsx(styles.root, baseProps.className)}\n {...multiselectProps.getWrapperProps()}\n >\n <Dropdown\n {...dropdownProps}\n ariaLabelledby={dropdownProps.dropdownContentRole ? joinStrings(ariaLabelId, controlId) : undefined}\n ariaDescribedby={\n dropdownProps.dropdownContentRole ? (dropdownStatus.content ? footerId : undefined) : undefined\n }\n open={multiselectProps.isOpen}\n trigger={trigger}\n header={filter}\n footer={\n dropdownStatus.isSticky ? (\n <DropdownFooter content={multiselectProps.isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={true}\n >\n <ListComponent\n listBottom={\n !dropdownStatus.isSticky ? (\n <DropdownFooter content={multiselectProps.isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n menuProps={multiselectProps.getMenuProps()}\n getOptionProps={multiselectProps.getOptionProps}\n filteredOptions={multiselectProps.filteredOptions}\n filteringValue={filteringValue}\n ref={multiselectProps.scrollToIndex}\n hasDropdownStatus={dropdownStatus.content !== null}\n checkboxes={true}\n useInteractiveGroups={true}\n screenReaderContent={multiselectProps.announcement}\n highlightType={multiselectProps.highlightType}\n />\n </Dropdown>\n\n {showTokens && (\n <InternalTokenGroup\n {...multiselectProps.getTokenProps()}\n className={styles.tokens}\n alignment=\"horizontal\"\n limit={tokenLimit}\n items={tokens}\n i18nStrings={tokenGroupI18nStrings}\n limitShowMoreAriaLabel={tokenLimitShowMoreAriaLabel}\n limitShowFewerAriaLabel={tokenLimitShowFewerAriaLabel}\n disableOuterPadding={true}\n readOnly={readOnly}\n />\n )}\n\n <ScreenreaderOnly id={ariaLabelId}>{ariaLabel}</ScreenreaderOnly>\n </div>\n );\n }\n);\n\nexport default InternalMultiselect;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/multiselect/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;A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EAC1C,cAAc,EAAE,gBAAgB,CAAC,cAAc,EAC/C,eAAe,EAAE,gBAAgB,CAAC,eAAe,EACjD,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,gBAAgB,CAAC,aAAa,EACnC,iBAAiB,EAAE,cAAc,CAAC,OAAO,KAAK,IAAI,EAClD,UAAU,EAAE,IAAI,EAChB,oBAAoB,EAAE,IAAI,EAC1B,mBAAmB,EAAE,gBAAgB,CAAC,YAAY,EAClD,aAAa,EAAE,gBAAgB,CAAC,aAAa,GAC7C,CACO;QAEV,UAAU,IAAI,CACb,oBAAC,kBAAkB,oBACb,gBAAgB,CAAC,aAAa,EAAE,IACpC,SAAS,EAAE,MAAM,CAAC,MAAM,EACxB,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,qBAAqB,EAClC,sBAAsB,EAAE,2BAA2B,EACnD,uBAAuB,EAAE,4BAA4B,EACrD,mBAAmB,EAAE,IAAI,EACzB,QAAQ,EAAE,QAAQ,IAClB,CACH;QAED,oBAAC,gBAAgB,IAAC,EAAE,EAAE,WAAW,IAAG,SAAS,CAAoB,CAC7D,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport Dropdown from '../internal/components/dropdown';\nimport DropdownFooter from '../internal/components/dropdown-footer/index.js';\nimport ScreenreaderOnly from '../internal/components/screenreader-only';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { SomeRequired } from '../internal/types';\nimport { joinStrings } from '../internal/utils/strings';\nimport Filter from '../select/parts/filter';\nimport PlainList from '../select/parts/plain-list';\nimport Trigger from '../select/parts/trigger';\nimport VirtualList from '../select/parts/virtual-list';\nimport { TokenGroupProps } from '../token-group/interfaces';\nimport InternalTokenGroup from '../token-group/internal';\nimport { MultiselectProps } from './interfaces';\nimport { useMultiselect } from './use-multiselect';\n\nimport styles from './styles.css.js';\n\ntype InternalMultiselectProps = SomeRequired<\n MultiselectProps,\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType' | 'keepOpen' | 'hideTokens'\n> &\n InternalBaseComponentProps;\n\nconst InternalMultiselect = React.forwardRef(\n (\n {\n options,\n filteringType,\n filteringPlaceholder,\n filteringAriaLabel,\n filteringClearAriaLabel,\n ariaRequired,\n placeholder,\n disabled,\n readOnly,\n ariaLabel,\n selectedOptions,\n deselectAriaLabel,\n tokenLimit,\n i18nStrings,\n virtualScroll,\n inlineTokens = false,\n hideTokens,\n expandToViewport,\n tokenLimitShowFewerAriaLabel,\n tokenLimitShowMoreAriaLabel,\n __internalRootRef = null,\n autoFocus,\n ...restProps\n }: InternalMultiselectProps,\n externalRef: React.Ref<MultiselectProps.Ref>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n const i18n = useInternalI18n('multiselect');\n\n const selfControlId = useUniqueId('trigger');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const ariaLabelId = useUniqueId('multiselect-ariaLabel-');\n const footerId = useUniqueId('multiselect-footer-');\n\n const [filteringValue, setFilteringValue] = useState('');\n const multiselectProps = useMultiselect({\n options,\n selectedOptions,\n filteringType,\n disabled,\n deselectAriaLabel,\n controlId,\n ariaLabelId,\n footerId,\n filteringValue,\n setFilteringValue,\n externalRef,\n ...restProps,\n });\n\n const filter = (\n <Filter\n clearAriaLabel={filteringClearAriaLabel}\n filteringType={filteringType}\n placeholder={filteringPlaceholder}\n ariaLabel={filteringAriaLabel}\n ariaRequired={ariaRequired}\n value={filteringValue}\n {...multiselectProps.getFilterProps()}\n />\n );\n\n const trigger = (\n <Trigger\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n triggerProps={multiselectProps.getTriggerProps(disabled, autoFocus)}\n selectedOption={null}\n selectedOptions={selectedOptions}\n triggerVariant={inlineTokens ? 'tokens' : 'placeholder'}\n isOpen={multiselectProps.isOpen}\n {...formFieldContext}\n controlId={controlId}\n ariaLabelledby={joinStrings(formFieldContext.ariaLabelledby, ariaLabelId)}\n />\n );\n\n const tokens: TokenGroupProps['items'] = selectedOptions.map(option => ({\n label: option.label,\n disabled: disabled || option.disabled,\n labelTag: option.labelTag,\n description: option.description,\n iconAlt: option.iconAlt,\n iconName: option.iconName,\n iconUrl: option.iconUrl,\n iconSvg: option.iconSvg,\n tags: option.tags,\n dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel?.(option), format =>\n format({ option__label: option.label ?? '' })\n ),\n }));\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const showTokens = !hideTokens && !inlineTokens && tokens.length > 0;\n\n const tokenGroupI18nStrings: TokenGroupProps.I18nStrings = {\n limitShowFewer: i18nStrings?.tokenLimitShowFewer,\n limitShowMore: i18nStrings?.tokenLimitShowMore,\n };\n\n const dropdownStatus = multiselectProps.dropdownStatus;\n const dropdownProps = multiselectProps.getDropdownProps();\n\n return (\n <div\n {...baseProps}\n ref={__internalRootRef}\n className={clsx(styles.root, baseProps.className)}\n {...multiselectProps.getWrapperProps()}\n >\n <Dropdown\n {...dropdownProps}\n ariaLabelledby={dropdownProps.dropdownContentRole ? joinStrings(ariaLabelId, controlId) : undefined}\n ariaDescribedby={\n dropdownProps.dropdownContentRole ? (dropdownStatus.content ? footerId : undefined) : undefined\n }\n open={multiselectProps.isOpen}\n trigger={trigger}\n header={filter}\n footer={\n dropdownStatus.isSticky ? (\n <DropdownFooter content={multiselectProps.isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={true}\n >\n <ListComponent\n listBottom={\n !dropdownStatus.isSticky ? (\n <DropdownFooter content={multiselectProps.isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n menuProps={multiselectProps.getMenuProps()}\n getOptionProps={multiselectProps.getOptionProps}\n filteredOptions={multiselectProps.filteredOptions}\n filteringValue={filteringValue}\n ref={multiselectProps.scrollToIndex}\n hasDropdownStatus={dropdownStatus.content !== null}\n checkboxes={true}\n useInteractiveGroups={true}\n screenReaderContent={multiselectProps.announcement}\n highlightType={multiselectProps.highlightType}\n />\n </Dropdown>\n\n {showTokens && (\n <InternalTokenGroup\n {...multiselectProps.getTokenProps()}\n className={styles.tokens}\n alignment=\"horizontal\"\n limit={tokenLimit}\n items={tokens}\n i18nStrings={tokenGroupI18nStrings}\n limitShowMoreAriaLabel={tokenLimitShowMoreAriaLabel}\n limitShowFewerAriaLabel={tokenLimitShowFewerAriaLabel}\n disableOuterPadding={true}\n readOnly={readOnly}\n />\n )}\n\n <ScreenreaderOnly id={ariaLabelId}>{ariaLabel}</ScreenreaderOnly>\n </div>\n );\n }\n);\n\nexport default InternalMultiselect;\n"]}
@@ -13,6 +13,7 @@ export declare class AttributeEditorRowWrapper extends ElementWrapper {
13
13
  */
14
14
  findField(column: number): FormFieldWrapper | null;
15
15
  findRemoveButton(): ButtonWrapper | null;
16
+ findCustomAction(): ElementWrapper | null;
16
17
  }
17
18
  export default class AttributeEditorWrapper extends ComponentWrapper {
18
19
  static rootSelector: string;
@@ -7,7 +7,6 @@ const dom_1 = require("@cloudscape-design/test-utils-core/dom");
7
7
  const button_1 = require("../button");
8
8
  const form_field_1 = require("../form-field");
9
9
  const styles_selectors_js_1 = require("../../../attribute-editor/styles.selectors.js");
10
- const styles_selectors_js_2 = require("../../../grid/styles.selectors.js");
11
10
  class AttributeEditorRowWrapper extends dom_1.ElementWrapper {
12
11
  /**
13
12
  * Returns all fields. Fields are supplied in the `definition` property of the component.
@@ -21,11 +20,14 @@ class AttributeEditorRowWrapper extends dom_1.ElementWrapper {
21
20
  * @param column 1-based column index
22
21
  */
23
22
  findField(column) {
24
- return this.findComponent(`.${styles_selectors_js_1.default['row-control']} > .${styles_selectors_js_2.default.grid} > .${styles_selectors_js_2.default['grid-column']}:nth-child(${column}) > div > .${styles_selectors_js_1.default.field}`, form_field_1.default);
23
+ return this.findComponent(`.${styles_selectors_js_1.default.field}:nth-child(${column})`, form_field_1.default);
25
24
  }
26
25
  findRemoveButton() {
27
26
  return this.findComponent(`.${styles_selectors_js_1.default['remove-button']}`, button_1.default);
28
27
  }
28
+ findCustomAction() {
29
+ return this.findComponent(`.${styles_selectors_js_1.default['remove-button-container']}`, dom_1.ElementWrapper);
30
+ }
29
31
  }
30
32
  exports.AttributeEditorRowWrapper = AttributeEditorRowWrapper;
31
33
  class AttributeEditorWrapper extends dom_1.ComponentWrapper {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/test-utils/dom/attribute-editor/index.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,gEAA0F;AAE1F,sCAAsC;AACtC,8CAA6C;AAE7C,uFAAmE;AACnE,2EAA2D;AAE3D,MAAa,yBAA0B,SAAQ,oBAAc;IAC3D;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,kBAAkB,CAAC,6BAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,oBAAgB,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,MAAc;QACtB,OAAO,IAAI,CAAC,aAAa,CACvB,IAAI,6BAAM,CAAC,aAAa,CAAC,OAAO,6BAAU,CAAC,IAAI,OAAO,6BAAU,CAAC,aAAa,CAAC,cAAc,MAAM,cAAc,6BAAM,CAAC,KAAK,EAAE,EAC/H,oBAAgB,CACjB,CAAC;IACJ,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,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CQ,mCAAY,GAAW,6BAAM,CAAC,IAAI,CAAC"}
@@ -13,6 +13,7 @@ export declare class AttributeEditorRowWrapper extends ElementWrapper {
13
13
  */
14
14
  findField(column: number): FormFieldWrapper;
15
15
  findRemoveButton(): ButtonWrapper;
16
+ findCustomAction(): ElementWrapper;
16
17
  }
17
18
  export default class AttributeEditorWrapper extends ComponentWrapper {
18
19
  static rootSelector: string;