@cloudscape-design/components-themeable 3.0.1175 → 3.0.1176

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 (87) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/internal/components/button-trigger/styles.scss +7 -0
  3. package/lib/internal/scss/internal/components/drag-handle-wrapper/styles.scss +28 -0
  4. package/lib/internal/scss/internal/components/option/styles.scss +4 -0
  5. package/lib/internal/scss/internal/components/selectable-item/styles.scss +1 -0
  6. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  7. package/lib/internal/template/autosuggest/internal.d.ts.map +1 -1
  8. package/lib/internal/template/autosuggest/internal.js +5 -1
  9. package/lib/internal/template/autosuggest/internal.js.map +1 -1
  10. package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
  11. package/lib/internal/template/internal/components/button-trigger/index.d.ts +1 -0
  12. package/lib/internal/template/internal/components/button-trigger/index.d.ts.map +1 -1
  13. package/lib/internal/template/internal/components/button-trigger/index.js +2 -2
  14. package/lib/internal/template/internal/components/button-trigger/index.js.map +1 -1
  15. package/lib/internal/template/internal/components/button-trigger/styles.css.js +14 -13
  16. package/lib/internal/template/internal/components/button-trigger/styles.scoped.css +32 -27
  17. package/lib/internal/template/internal/components/button-trigger/styles.selectors.js +14 -13
  18. package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.d.ts +3 -1
  19. package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.d.ts.map +1 -1
  20. package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.js +2 -2
  21. package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.js.map +1 -1
  22. package/lib/internal/template/internal/components/drag-handle-wrapper/index.d.ts.map +1 -1
  23. package/lib/internal/template/internal/components/drag-handle-wrapper/index.js +30 -7
  24. package/lib/internal/template/internal/components/drag-handle-wrapper/index.js.map +1 -1
  25. package/lib/internal/template/internal/components/drag-handle-wrapper/styles.css.js +30 -21
  26. package/lib/internal/template/internal/components/drag-handle-wrapper/styles.scoped.css +75 -39
  27. package/lib/internal/template/internal/components/drag-handle-wrapper/styles.selectors.js +30 -21
  28. package/lib/internal/template/internal/components/option/index.d.ts +1 -1
  29. package/lib/internal/template/internal/components/option/index.d.ts.map +1 -1
  30. package/lib/internal/template/internal/components/option/index.js +5 -1
  31. package/lib/internal/template/internal/components/option/index.js.map +1 -1
  32. package/lib/internal/template/internal/components/option/interfaces.d.ts +2 -1
  33. package/lib/internal/template/internal/components/option/interfaces.d.ts.map +1 -1
  34. package/lib/internal/template/internal/components/option/interfaces.js.map +1 -1
  35. package/lib/internal/template/internal/components/option/styles.css.js +17 -16
  36. package/lib/internal/template/internal/components/option/styles.scoped.css +32 -28
  37. package/lib/internal/template/internal/components/option/styles.selectors.js +17 -16
  38. package/lib/internal/template/internal/environment.js +2 -2
  39. package/lib/internal/template/internal/environment.json +2 -2
  40. package/lib/internal/template/multiselect/index.d.ts.map +1 -1
  41. package/lib/internal/template/multiselect/index.js +2 -2
  42. package/lib/internal/template/multiselect/index.js.map +1 -1
  43. package/lib/internal/template/multiselect/interfaces.d.ts +37 -0
  44. package/lib/internal/template/multiselect/interfaces.d.ts.map +1 -1
  45. package/lib/internal/template/multiselect/interfaces.js.map +1 -1
  46. package/lib/internal/template/multiselect/internal.d.ts.map +1 -1
  47. package/lib/internal/template/multiselect/internal.js +8 -4
  48. package/lib/internal/template/multiselect/internal.js.map +1 -1
  49. package/lib/internal/template/select/index.d.ts.map +1 -1
  50. package/lib/internal/template/select/index.js +2 -2
  51. package/lib/internal/template/select/index.js.map +1 -1
  52. package/lib/internal/template/select/interfaces.d.ts +31 -1
  53. package/lib/internal/template/select/interfaces.d.ts.map +1 -1
  54. package/lib/internal/template/select/interfaces.js.map +1 -1
  55. package/lib/internal/template/select/internal.d.ts.map +1 -1
  56. package/lib/internal/template/select/internal.js +8 -4
  57. package/lib/internal/template/select/internal.js.map +1 -1
  58. package/lib/internal/template/select/parts/item.d.ts +13 -2
  59. package/lib/internal/template/select/parts/item.d.ts.map +1 -1
  60. package/lib/internal/template/select/parts/item.js +62 -6
  61. package/lib/internal/template/select/parts/item.js.map +1 -1
  62. package/lib/internal/template/select/parts/multiselect-item.d.ts +9 -2
  63. package/lib/internal/template/select/parts/multiselect-item.d.ts.map +1 -1
  64. package/lib/internal/template/select/parts/multiselect-item.js +79 -5
  65. package/lib/internal/template/select/parts/multiselect-item.js.map +1 -1
  66. package/lib/internal/template/select/parts/plain-list.d.ts +3 -0
  67. package/lib/internal/template/select/parts/plain-list.d.ts.map +1 -1
  68. package/lib/internal/template/select/parts/plain-list.js +2 -1
  69. package/lib/internal/template/select/parts/plain-list.js.map +1 -1
  70. package/lib/internal/template/select/parts/trigger.d.ts +1 -0
  71. package/lib/internal/template/select/parts/trigger.d.ts.map +1 -1
  72. package/lib/internal/template/select/parts/trigger.js +17 -3
  73. package/lib/internal/template/select/parts/trigger.js.map +1 -1
  74. package/lib/internal/template/select/parts/virtual-list.d.ts.map +1 -1
  75. package/lib/internal/template/select/parts/virtual-list.js +2 -1
  76. package/lib/internal/template/select/parts/virtual-list.js.map +1 -1
  77. package/lib/internal/template/select/utils/render-options.d.ts +4 -1
  78. package/lib/internal/template/select/utils/render-options.d.ts.map +1 -1
  79. package/lib/internal/template/select/utils/render-options.js +15 -4
  80. package/lib/internal/template/select/utils/render-options.js.map +1 -1
  81. package/lib/internal/template/test-utils/dom/internal/option.d.ts +4 -0
  82. package/lib/internal/template/test-utils/dom/internal/option.js +10 -1
  83. package/lib/internal/template/test-utils/dom/internal/option.js.map +1 -1
  84. package/lib/internal/template/test-utils/selectors/internal/option.d.ts +4 -0
  85. package/lib/internal/template/test-utils/selectors/internal/option.js +10 -1
  86. package/lib/internal/template/test-utils/selectors/internal/option.js.map +1 -1
  87. package/package.json +1 -1
@@ -1,13 +1,19 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import React, { useEffect, useRef, useState } from 'react';
3
+ import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
4
4
  import clsx from 'clsx';
5
5
  import { nodeContains } from '@cloudscape-design/component-toolkit/dom';
6
+ import { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';
6
7
  import Tooltip from '../tooltip';
7
8
  import DirectionButton from './direction-button';
8
9
  import PortalOverlay from './portal-overlay';
9
10
  import styles from './styles.css.js';
10
11
  import testUtilsStyles from './test-classes/styles.css.js';
12
+ // The UAP buttons are forced to top/bottom position if the handle is close to the screen edge.
13
+ const FORCED_POSITION_PROXIMITY_PX = 50;
14
+ // Approximate UAP button size with margins to decide forced direction.
15
+ const UAP_BUTTON_SIZE_PX = 40;
16
+ const DIRECTIONS_ORDER = ['block-end', 'block-start', 'inline-end', 'inline-start'];
11
17
  export default function DragHandleWrapper({ directions, tooltipText, children, onDirectionClick, triggerMode = 'focus', initialShowButtons = false, controlledShowButtons = false, wrapperClassName, hideButtonsOnDrag, clickDragThreshold, }) {
12
18
  const wrapperRef = useRef(null);
13
19
  const dragHandleRef = useRef(null);
@@ -112,7 +118,7 @@ export default function DragHandleWrapper({ directions, tooltipText, children, o
112
118
  }
113
119
  else if (triggerMode === 'keyboard-activate' && (event.key === 'Enter' || event.key === ' ')) {
114
120
  // toggle buttons when Enter or space is pressed in 'keyboard-activate' triggerMode
115
- setUncontrolledShowButtons(prevshowButtons => !prevshowButtons);
121
+ setUncontrolledShowButtons(prevShowButtons => !prevShowButtons);
116
122
  }
117
123
  else if (event.key !== 'Alt' &&
118
124
  event.key !== 'Control' &&
@@ -125,6 +131,27 @@ export default function DragHandleWrapper({ directions, tooltipText, children, o
125
131
  }
126
132
  };
127
133
  const showButtons = triggerMode === 'controlled' ? controlledShowButtons : uncontrolledShowButtons;
134
+ const [forcedPosition, setForcedPosition] = useState(null);
135
+ const directionsOrder = forcedPosition === 'bottom' ? [...DIRECTIONS_ORDER].reverse() : DIRECTIONS_ORDER;
136
+ const visibleDirections = directionsOrder.filter(dir => directions[dir]);
137
+ useLayoutEffect(() => {
138
+ if (showButtons && dragHandleRef.current) {
139
+ const rect = getLogicalBoundingClientRect(dragHandleRef.current);
140
+ const conflicts = {
141
+ 'block-start': rect.insetBlockStart < FORCED_POSITION_PROXIMITY_PX,
142
+ 'block-end': window.innerHeight - rect.insetBlockEnd < FORCED_POSITION_PROXIMITY_PX,
143
+ 'inline-start': rect.insetInlineStart < FORCED_POSITION_PROXIMITY_PX,
144
+ 'inline-end': window.innerWidth - rect.insetInlineEnd < FORCED_POSITION_PROXIMITY_PX,
145
+ };
146
+ if (visibleDirections.some(direction => conflicts[direction])) {
147
+ const hasEnoughSpaceAbove = rect.insetBlockStart > visibleDirections.length * UAP_BUTTON_SIZE_PX;
148
+ setForcedPosition(hasEnoughSpaceAbove ? 'top' : 'bottom');
149
+ }
150
+ else {
151
+ setForcedPosition(null);
152
+ }
153
+ }
154
+ }, [showButtons, visibleDirections]);
128
155
  return (React.createElement(React.Fragment, null,
129
156
  React.createElement("div", { className: clsx(testUtilsStyles.root, styles.contents), ref: wrapperRef, onFocus: onWrapperFocusIn, onBlur: onWrapperFocusOut },
130
157
  React.createElement("div", { className: styles.contents, onPointerEnter: onTooltipGroupPointerEnter, onPointerLeave: onTooltipGroupPointerLeave },
@@ -133,10 +160,6 @@ export default function DragHandleWrapper({ directions, tooltipText, children, o
133
160
  // Rendered in a portal but pointerenter/pointerleave events still propagate
134
161
  // up the React DOM tree, which is why it's placed in this nested context.
135
162
  React.createElement(Tooltip, { trackRef: dragHandleRef, value: tooltipText, onDismiss: () => setShowTooltip(false) })))),
136
- React.createElement(PortalOverlay, { track: dragHandleRef, isDisabled: !showButtons },
137
- directions['block-start'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "block-start", state: directions['block-start'], onClick: () => onDirectionClick === null || onDirectionClick === void 0 ? void 0 : onDirectionClick('block-start') })),
138
- directions['block-end'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "block-end", state: directions['block-end'], onClick: () => onDirectionClick === null || onDirectionClick === void 0 ? void 0 : onDirectionClick('block-end') })),
139
- directions['inline-start'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "inline-start", state: directions['inline-start'], onClick: () => onDirectionClick === null || onDirectionClick === void 0 ? void 0 : onDirectionClick('inline-start') })),
140
- directions['inline-end'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "inline-end", state: directions['inline-end'], onClick: () => onDirectionClick === null || onDirectionClick === void 0 ? void 0 : onDirectionClick('inline-end') })))));
163
+ React.createElement(PortalOverlay, { track: dragHandleRef, isDisabled: !showButtons }, visibleDirections.map((direction, index) => directions[direction] && (React.createElement(DirectionButton, { key: direction, show: !isDisabled && showButtons, direction: direction, state: directions[direction], onClick: () => onDirectionClick === null || onDirectionClick === void 0 ? void 0 : onDirectionClick(direction), forcedPosition: forcedPosition, forcedIndex: index }))))));
141
164
  }
142
165
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAW,GAAG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I,CAC3B,oBAAC,eAAe,IACd,IAAI,EAAE,CAAC,UAAU,IAAI,WAAW,EAChC,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,EAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,YAAY,CAAC,GAC/C,CACH,CACa,CACf,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport Tooltip from '../tooltip';\nimport DirectionButton from './direction-button';\nimport { DragHandleWrapperProps } from './interfaces';\nimport PortalOverlay from './portal-overlay';\n\nimport styles from './styles.css.js';\nimport testUtilsStyles from './test-classes/styles.css.js';\n\nexport default function DragHandleWrapper({\n directions,\n tooltipText,\n children,\n onDirectionClick,\n triggerMode = 'focus',\n initialShowButtons = false,\n controlledShowButtons = false,\n wrapperClassName,\n hideButtonsOnDrag,\n clickDragThreshold,\n}: DragHandleWrapperProps) {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const dragHandleRef = useRef<HTMLDivElement | null>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n const [uncontrolledShowButtons, setUncontrolledShowButtons] = useState(initialShowButtons);\n\n const isPointerDown = useRef(false);\n const initialPointerPosition = useRef<{ x: number; y: number } | undefined>();\n const didPointerDrag = useRef(false);\n\n // The tooltip (\"Drag or select to move/resize\") shouldn't show if clicking\n // on the handle wouldn't do anything.\n const isDisabled =\n !directions['block-start'] && !directions['block-end'] && !directions['inline-start'] && !directions['inline-end'];\n\n const onWrapperFocusIn: React.FocusEventHandler = event => {\n // The drag handle is focused when it's either tabbed to, or the pointer\n // is pressed on it. We exclude handling the pointer press in this handler,\n // since it could be the start of a drag event - the pointer stuff is\n // handled in the \"pointerup\" listener instead. In cases where focus is moved\n // to the button (by manually calling `.focus()`), the buttons should only appear\n // if the action that triggered the focus move was the result of a keypress.\n if (document.body.dataset.awsuiFocusVisible && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setShowTooltip(false);\n if (triggerMode === 'focus') {\n setUncontrolledShowButtons(true);\n }\n }\n };\n\n const onWrapperFocusOut: React.FocusEventHandler = event => {\n // Close the directional buttons when the focus leaves the drag handle.\n // \"focusout\" is also triggered when the user switches to another tab, but\n // since it'll be returned when they switch back anyway, we exclude that\n // case by checking for `document.hasFocus()`.\n if (document.hasFocus() && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setUncontrolledShowButtons(false);\n }\n };\n\n useEffect(() => {\n const controller = new AbortController();\n\n // We need to differentiate between a \"click\" and a \"drag\" action.\n // We can say a \"click\" happens when a \"pointerdown\" is followed by\n // a \"pointerup\" with no \"pointermove\" between the two.\n // However, it would be a poor usability experience if a \"click\" isn't\n // registered because, while pressing my mouse, I moved it by just one\n // pixel, making it a \"drag\" instead. So we allow the pointer to move by\n // `clickDragThreshold` pixels before setting `didPointerDrag` to true.\n document.addEventListener(\n 'pointermove',\n event => {\n if (\n isPointerDown.current &&\n initialPointerPosition.current &&\n (event.clientX > initialPointerPosition.current.x + clickDragThreshold ||\n event.clientX < initialPointerPosition.current.x - clickDragThreshold ||\n event.clientY > initialPointerPosition.current.y + clickDragThreshold ||\n event.clientY < initialPointerPosition.current.y - clickDragThreshold)\n ) {\n didPointerDrag.current = true;\n if (hideButtonsOnDrag) {\n setUncontrolledShowButtons(false);\n }\n }\n },\n { signal: controller.signal }\n );\n\n // Shared behavior when a \"pointerdown\" state ends. This is shared so it\n // can be called for both \"pointercancel\" and \"pointerup\" events.\n const resetPointerDownState = () => {\n isPointerDown.current = false;\n initialPointerPosition.current = undefined;\n };\n\n document.addEventListener(\n 'pointercancel',\n () => {\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n document.addEventListener(\n 'pointerup',\n () => {\n if (isPointerDown.current && !didPointerDrag.current) {\n // The cursor didn't move much between \"pointerdown\" and \"pointerup\".\n // Handle this as a \"click\" instead of a \"drag\".\n setUncontrolledShowButtons(true);\n }\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n return () => controller.abort();\n }, [clickDragThreshold, hideButtonsOnDrag]);\n\n const onHandlePointerDown: React.PointerEventHandler = event => {\n // Tooltip behavior: the tooltip should appear on hover, but disappear when\n // the pointer starts dragging (having the tooltip get in the way while\n // you're trying to drag upwards is annoying). Additionally, the tooltip\n // shouldn't reappear when dragging ends, but only when the pointer leaves\n // the drag handle and comes back.\n\n isPointerDown.current = true;\n didPointerDrag.current = false;\n initialPointerPosition.current = { x: event.clientX, y: event.clientY };\n setShowTooltip(false);\n };\n\n // Tooltip behavior: the tooltip should stay open when the cursor moves\n // from the drag handle into the tooltip content itself. This is why the\n // handler is set on the wrapper for both the drag handle and the tooltip.\n const onTooltipGroupPointerEnter: React.PointerEventHandler = () => {\n if (!isPointerDown.current) {\n setShowTooltip(true);\n }\n };\n const onTooltipGroupPointerLeave: React.PointerEventHandler = () => {\n setShowTooltip(false);\n };\n\n const onDragHandleKeyDown: React.KeyboardEventHandler = event => {\n // For accessibility reasons, pressing escape should always close the floating controls.\n if (event.key === 'Escape') {\n setUncontrolledShowButtons(false);\n } else if (triggerMode === 'keyboard-activate' && (event.key === 'Enter' || event.key === ' ')) {\n // toggle buttons when Enter or space is pressed in 'keyboard-activate' triggerMode\n setUncontrolledShowButtons(prevshowButtons => !prevshowButtons);\n } else if (\n event.key !== 'Alt' &&\n event.key !== 'Control' &&\n event.key !== 'Meta' &&\n event.key !== 'Shift' &&\n triggerMode === 'focus'\n ) {\n // Pressing any other key will display the focus-visible ring around the\n // drag handle if it's in focus, so we should also show the buttons now.\n setUncontrolledShowButtons(true);\n }\n };\n\n const showButtons = triggerMode === 'controlled' ? controlledShowButtons : uncontrolledShowButtons;\n\n return (\n <>\n {/* Wrapper for focus detection. The buttons are shown when any element inside this wrapper is\n focused, either via the keyboard or a pointer press. The UAP buttons will never receive focus. */}\n <div\n className={clsx(testUtilsStyles.root, styles.contents)}\n ref={wrapperRef}\n onFocus={onWrapperFocusIn}\n onBlur={onWrapperFocusOut}\n >\n {/* Wrapper for pointer detection. Determines whether or not the tooltip should be shown. */}\n <div\n className={styles.contents}\n onPointerEnter={onTooltipGroupPointerEnter}\n onPointerLeave={onTooltipGroupPointerLeave}\n >\n {/* Position tracking wrapper used to position the tooltip and drag buttons accurately.\n Its dimensions must match the inner button's dimensions. */}\n <div\n className={clsx(styles['drag-handle'], wrapperClassName)}\n ref={dragHandleRef}\n onPointerDown={onHandlePointerDown}\n onKeyDown={onDragHandleKeyDown}\n >\n {children}\n </div>\n\n {!isDisabled && !showButtons && showTooltip && tooltipText && (\n // Rendered in a portal but pointerenter/pointerleave events still propagate\n // up the React DOM tree, which is why it's placed in this nested context.\n <Tooltip trackRef={dragHandleRef} value={tooltipText} onDismiss={() => setShowTooltip(false)} />\n )}\n </div>\n </div>\n\n <PortalOverlay track={dragHandleRef} isDisabled={!showButtons}>\n {directions['block-start'] && (\n <DirectionButton\n show={!isDisabled && showButtons}\n direction=\"block-start\"\n state={directions['block-start']}\n onClick={() => onDirectionClick?.('block-start')}\n />\n )}\n {directions['block-end'] && (\n <DirectionButton\n show={!isDisabled && showButtons}\n direction=\"block-end\"\n state={directions['block-end']}\n onClick={() => onDirectionClick?.('block-end')}\n />\n )}\n {directions['inline-start'] && (\n <DirectionButton\n show={!isDisabled && showButtons}\n direction=\"inline-start\"\n state={directions['inline-start']}\n onClick={() => onDirectionClick?.('inline-start')}\n />\n )}\n {directions['inline-end'] && (\n <DirectionButton\n show={!isDisabled && showButtons}\n direction=\"inline-end\"\n state={directions['inline-end']}\n onClick={() => onDirectionClick?.('inline-end')}\n />\n )}\n </PortalOverlay>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/index.tsx"],"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B,UAAU,CAAC,SAAS,CAAC,IAAI,CACvB,oBAAC,eAAe,IACd,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,CAAC,UAAU,IAAI,WAAW,EAChC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,SAAS,CAAC,EAC5C,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,KAAK,GAClB,CACH,CACJ,CACa,CACf,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport Tooltip from '../tooltip';\nimport DirectionButton from './direction-button';\nimport { Direction, DragHandleWrapperProps } from './interfaces';\nimport PortalOverlay from './portal-overlay';\n\nimport styles from './styles.css.js';\nimport testUtilsStyles from './test-classes/styles.css.js';\n\n// The UAP buttons are forced to top/bottom position if the handle is close to the screen edge.\nconst FORCED_POSITION_PROXIMITY_PX = 50;\n// Approximate UAP button size with margins to decide forced direction.\nconst UAP_BUTTON_SIZE_PX = 40;\nconst DIRECTIONS_ORDER: Direction[] = ['block-end', 'block-start', 'inline-end', 'inline-start'];\n\nexport default function DragHandleWrapper({\n directions,\n tooltipText,\n children,\n onDirectionClick,\n triggerMode = 'focus',\n initialShowButtons = false,\n controlledShowButtons = false,\n wrapperClassName,\n hideButtonsOnDrag,\n clickDragThreshold,\n}: DragHandleWrapperProps) {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const dragHandleRef = useRef<HTMLDivElement | null>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n const [uncontrolledShowButtons, setUncontrolledShowButtons] = useState(initialShowButtons);\n\n const isPointerDown = useRef(false);\n const initialPointerPosition = useRef<{ x: number; y: number } | undefined>();\n const didPointerDrag = useRef(false);\n\n // The tooltip (\"Drag or select to move/resize\") shouldn't show if clicking\n // on the handle wouldn't do anything.\n const isDisabled =\n !directions['block-start'] && !directions['block-end'] && !directions['inline-start'] && !directions['inline-end'];\n\n const onWrapperFocusIn: React.FocusEventHandler = event => {\n // The drag handle is focused when it's either tabbed to, or the pointer\n // is pressed on it. We exclude handling the pointer press in this handler,\n // since it could be the start of a drag event - the pointer stuff is\n // handled in the \"pointerup\" listener instead. In cases where focus is moved\n // to the button (by manually calling `.focus()`), the buttons should only appear\n // if the action that triggered the focus move was the result of a keypress.\n if (document.body.dataset.awsuiFocusVisible && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setShowTooltip(false);\n if (triggerMode === 'focus') {\n setUncontrolledShowButtons(true);\n }\n }\n };\n\n const onWrapperFocusOut: React.FocusEventHandler = event => {\n // Close the directional buttons when the focus leaves the drag handle.\n // \"focusout\" is also triggered when the user switches to another tab, but\n // since it'll be returned when they switch back anyway, we exclude that\n // case by checking for `document.hasFocus()`.\n if (document.hasFocus() && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setUncontrolledShowButtons(false);\n }\n };\n\n useEffect(() => {\n const controller = new AbortController();\n\n // We need to differentiate between a \"click\" and a \"drag\" action.\n // We can say a \"click\" happens when a \"pointerdown\" is followed by\n // a \"pointerup\" with no \"pointermove\" between the two.\n // However, it would be a poor usability experience if a \"click\" isn't\n // registered because, while pressing my mouse, I moved it by just one\n // pixel, making it a \"drag\" instead. So we allow the pointer to move by\n // `clickDragThreshold` pixels before setting `didPointerDrag` to true.\n document.addEventListener(\n 'pointermove',\n event => {\n if (\n isPointerDown.current &&\n initialPointerPosition.current &&\n (event.clientX > initialPointerPosition.current.x + clickDragThreshold ||\n event.clientX < initialPointerPosition.current.x - clickDragThreshold ||\n event.clientY > initialPointerPosition.current.y + clickDragThreshold ||\n event.clientY < initialPointerPosition.current.y - clickDragThreshold)\n ) {\n didPointerDrag.current = true;\n if (hideButtonsOnDrag) {\n setUncontrolledShowButtons(false);\n }\n }\n },\n { signal: controller.signal }\n );\n\n // Shared behavior when a \"pointerdown\" state ends. This is shared so it\n // can be called for both \"pointercancel\" and \"pointerup\" events.\n const resetPointerDownState = () => {\n isPointerDown.current = false;\n initialPointerPosition.current = undefined;\n };\n\n document.addEventListener(\n 'pointercancel',\n () => {\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n document.addEventListener(\n 'pointerup',\n () => {\n if (isPointerDown.current && !didPointerDrag.current) {\n // The cursor didn't move much between \"pointerdown\" and \"pointerup\".\n // Handle this as a \"click\" instead of a \"drag\".\n setUncontrolledShowButtons(true);\n }\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n return () => controller.abort();\n }, [clickDragThreshold, hideButtonsOnDrag]);\n\n const onHandlePointerDown: React.PointerEventHandler = event => {\n // Tooltip behavior: the tooltip should appear on hover, but disappear when\n // the pointer starts dragging (having the tooltip get in the way while\n // you're trying to drag upwards is annoying). Additionally, the tooltip\n // shouldn't reappear when dragging ends, but only when the pointer leaves\n // the drag handle and comes back.\n\n isPointerDown.current = true;\n didPointerDrag.current = false;\n initialPointerPosition.current = { x: event.clientX, y: event.clientY };\n setShowTooltip(false);\n };\n\n // Tooltip behavior: the tooltip should stay open when the cursor moves\n // from the drag handle into the tooltip content itself. This is why the\n // handler is set on the wrapper for both the drag handle and the tooltip.\n const onTooltipGroupPointerEnter: React.PointerEventHandler = () => {\n if (!isPointerDown.current) {\n setShowTooltip(true);\n }\n };\n const onTooltipGroupPointerLeave: React.PointerEventHandler = () => {\n setShowTooltip(false);\n };\n\n const onDragHandleKeyDown: React.KeyboardEventHandler = event => {\n // For accessibility reasons, pressing escape should always close the floating controls.\n if (event.key === 'Escape') {\n setUncontrolledShowButtons(false);\n } else if (triggerMode === 'keyboard-activate' && (event.key === 'Enter' || event.key === ' ')) {\n // toggle buttons when Enter or space is pressed in 'keyboard-activate' triggerMode\n setUncontrolledShowButtons(prevShowButtons => !prevShowButtons);\n } else if (\n event.key !== 'Alt' &&\n event.key !== 'Control' &&\n event.key !== 'Meta' &&\n event.key !== 'Shift' &&\n triggerMode === 'focus'\n ) {\n // Pressing any other key will display the focus-visible ring around the\n // drag handle if it's in focus, so we should also show the buttons now.\n setUncontrolledShowButtons(true);\n }\n };\n\n const showButtons = triggerMode === 'controlled' ? controlledShowButtons : uncontrolledShowButtons;\n\n const [forcedPosition, setForcedPosition] = useState<null | 'top' | 'bottom'>(null);\n const directionsOrder = forcedPosition === 'bottom' ? [...DIRECTIONS_ORDER].reverse() : DIRECTIONS_ORDER;\n const visibleDirections = directionsOrder.filter(dir => directions[dir]);\n\n useLayoutEffect(() => {\n if (showButtons && dragHandleRef.current) {\n const rect = getLogicalBoundingClientRect(dragHandleRef.current);\n const conflicts = {\n 'block-start': rect.insetBlockStart < FORCED_POSITION_PROXIMITY_PX,\n 'block-end': window.innerHeight - rect.insetBlockEnd < FORCED_POSITION_PROXIMITY_PX,\n 'inline-start': rect.insetInlineStart < FORCED_POSITION_PROXIMITY_PX,\n 'inline-end': window.innerWidth - rect.insetInlineEnd < FORCED_POSITION_PROXIMITY_PX,\n };\n if (visibleDirections.some(direction => conflicts[direction])) {\n const hasEnoughSpaceAbove = rect.insetBlockStart > visibleDirections.length * UAP_BUTTON_SIZE_PX;\n setForcedPosition(hasEnoughSpaceAbove ? 'top' : 'bottom');\n } else {\n setForcedPosition(null);\n }\n }\n }, [showButtons, visibleDirections]);\n\n return (\n <>\n {/* Wrapper for focus detection. The buttons are shown when any element inside this wrapper is\n focused, either via the keyboard or a pointer press. The UAP buttons will never receive focus. */}\n <div\n className={clsx(testUtilsStyles.root, styles.contents)}\n ref={wrapperRef}\n onFocus={onWrapperFocusIn}\n onBlur={onWrapperFocusOut}\n >\n {/* Wrapper for pointer detection. Determines whether or not the tooltip should be shown. */}\n <div\n className={styles.contents}\n onPointerEnter={onTooltipGroupPointerEnter}\n onPointerLeave={onTooltipGroupPointerLeave}\n >\n {/* Position tracking wrapper used to position the tooltip and drag buttons accurately.\n Its dimensions must match the inner button's dimensions. */}\n <div\n className={clsx(styles['drag-handle'], wrapperClassName)}\n ref={dragHandleRef}\n onPointerDown={onHandlePointerDown}\n onKeyDown={onDragHandleKeyDown}\n >\n {children}\n </div>\n\n {!isDisabled && !showButtons && showTooltip && tooltipText && (\n // Rendered in a portal but pointerenter/pointerleave events still propagate\n // up the React DOM tree, which is why it's placed in this nested context.\n <Tooltip trackRef={dragHandleRef} value={tooltipText} onDismiss={() => setShowTooltip(false)} />\n )}\n </div>\n </div>\n\n <PortalOverlay track={dragHandleRef} isDisabled={!showButtons}>\n {visibleDirections.map(\n (direction, index) =>\n directions[direction] && (\n <DirectionButton\n key={direction}\n show={!isDisabled && showButtons}\n direction={direction}\n state={directions[direction]}\n onClick={() => onDirectionClick?.(direction)}\n forcedPosition={forcedPosition}\n forcedIndex={index}\n />\n )\n )}\n </PortalOverlay>\n </>\n );\n}\n"]}
@@ -1,26 +1,35 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "direction-button-wrapper": "awsui_direction-button-wrapper_155yk_1njrl_169",
5
- "direction-button-wrapper-motion-enter": "awsui_direction-button-wrapper-motion-enter_155yk_1njrl_189",
6
- "direction-button-wrapper-motion-entering": "awsui_direction-button-wrapper-motion-entering_155yk_1njrl_189",
7
- "direction-button-wrapper-motion-exit": "awsui_direction-button-wrapper-motion-exit_155yk_1njrl_189",
8
- "direction-button-wrapper-motion-exiting": "awsui_direction-button-wrapper-motion-exiting_155yk_1njrl_189",
9
- "drag-handle-entry": "awsui_drag-handle-entry_155yk_1njrl_1",
10
- "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_155yk_1njrl_1",
11
- "drag-handle-exit": "awsui_drag-handle-exit_155yk_1njrl_1",
12
- "awsui-motion-fade-out-0": "awsui_awsui-motion-fade-out-0_155yk_1njrl_1",
13
- "direction-button-wrapper-block-start": "awsui_direction-button-wrapper-block-start_155yk_1njrl_229",
14
- "direction-button-wrapper-block-end": "awsui_direction-button-wrapper-block-end_155yk_1njrl_233",
15
- "direction-button-wrapper-inline-start": "awsui_direction-button-wrapper-inline-start_155yk_1njrl_237",
16
- "direction-button-wrapper-inline-end": "awsui_direction-button-wrapper-inline-end_155yk_1njrl_248",
17
- "contents": "awsui_contents_155yk_1njrl_259",
18
- "portal-overlay": "awsui_portal-overlay_155yk_1njrl_263",
19
- "portal-overlay-disabled": "awsui_portal-overlay-disabled_155yk_1njrl_271",
20
- "portal-overlay-contents": "awsui_portal-overlay-contents_155yk_1njrl_275",
21
- "drag-handle": "awsui_drag-handle_155yk_1njrl_279",
22
- "direction-button-wrapper-hidden": "awsui_direction-button-wrapper-hidden_155yk_1njrl_292",
23
- "direction-button": "awsui_direction-button_155yk_1njrl_169",
24
- "direction-button-disabled": "awsui_direction-button-disabled_155yk_1njrl_335"
4
+ "direction-button-wrapper": "awsui_direction-button-wrapper_155yk_1u2kp_169",
5
+ "direction-button-wrapper-motion-enter": "awsui_direction-button-wrapper-motion-enter_155yk_1u2kp_189",
6
+ "direction-button-wrapper-motion-entering": "awsui_direction-button-wrapper-motion-entering_155yk_1u2kp_189",
7
+ "direction-button-wrapper-motion-exit": "awsui_direction-button-wrapper-motion-exit_155yk_1u2kp_189",
8
+ "direction-button-wrapper-motion-exiting": "awsui_direction-button-wrapper-motion-exiting_155yk_1u2kp_189",
9
+ "drag-handle-entry": "awsui_drag-handle-entry_155yk_1u2kp_1",
10
+ "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_155yk_1u2kp_1",
11
+ "drag-handle-exit": "awsui_drag-handle-exit_155yk_1u2kp_1",
12
+ "awsui-motion-fade-out-0": "awsui_awsui-motion-fade-out-0_155yk_1u2kp_1",
13
+ "direction-button-wrapper-block-start": "awsui_direction-button-wrapper-block-start_155yk_1u2kp_229",
14
+ "direction-button-wrapper-block-end": "awsui_direction-button-wrapper-block-end_155yk_1u2kp_233",
15
+ "direction-button-wrapper-inline-start": "awsui_direction-button-wrapper-inline-start_155yk_1u2kp_237",
16
+ "direction-button-wrapper-inline-end": "awsui_direction-button-wrapper-inline-end_155yk_1u2kp_248",
17
+ "contents": "awsui_contents_155yk_1u2kp_259",
18
+ "portal-overlay": "awsui_portal-overlay_155yk_1u2kp_263",
19
+ "portal-overlay-disabled": "awsui_portal-overlay-disabled_155yk_1u2kp_271",
20
+ "portal-overlay-contents": "awsui_portal-overlay-contents_155yk_1u2kp_275",
21
+ "drag-handle": "awsui_drag-handle_155yk_1u2kp_279",
22
+ "direction-button-wrapper-hidden": "awsui_direction-button-wrapper-hidden_155yk_1u2kp_292",
23
+ "direction-button-wrapper-forced": "awsui_direction-button-wrapper-forced_155yk_1u2kp_316",
24
+ "direction-button-wrapper-forced-top-0": "awsui_direction-button-wrapper-forced-top-0_155yk_1u2kp_320",
25
+ "direction-button-wrapper-forced-top-1": "awsui_direction-button-wrapper-forced-top-1_155yk_1u2kp_324",
26
+ "direction-button-wrapper-forced-top-2": "awsui_direction-button-wrapper-forced-top-2_155yk_1u2kp_328",
27
+ "direction-button-wrapper-forced-top-3": "awsui_direction-button-wrapper-forced-top-3_155yk_1u2kp_332",
28
+ "direction-button-wrapper-forced-bottom-0": "awsui_direction-button-wrapper-forced-bottom-0_155yk_1u2kp_336",
29
+ "direction-button-wrapper-forced-bottom-1": "awsui_direction-button-wrapper-forced-bottom-1_155yk_1u2kp_340",
30
+ "direction-button-wrapper-forced-bottom-2": "awsui_direction-button-wrapper-forced-bottom-2_155yk_1u2kp_344",
31
+ "direction-button-wrapper-forced-bottom-3": "awsui_direction-button-wrapper-forced-bottom-3_155yk_1u2kp_348",
32
+ "direction-button": "awsui_direction-button_155yk_1u2kp_169",
33
+ "direction-button-disabled": "awsui_direction-button-disabled_155yk_1u2kp_371"
25
34
  };
26
35
 
@@ -150,7 +150,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
150
150
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
151
151
  SPDX-License-Identifier: Apache-2.0
152
152
  */
153
- @keyframes awsui_drag-handle-entry_155yk_1njrl_1 {
153
+ @keyframes awsui_drag-handle-entry_155yk_1u2kp_1 {
154
154
  from {
155
155
  transform: translate(var(--awsui-drag-handle-animation-inline-offset-rhu47t), var(--awsui-drag-handle-animation-block-offset-rhu47t));
156
156
  }
@@ -158,7 +158,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
158
158
  transform: translate(0, 0);
159
159
  }
160
160
  }
161
- @keyframes awsui_drag-handle-exit_155yk_1njrl_1 {
161
+ @keyframes awsui_drag-handle-exit_155yk_1u2kp_1 {
162
162
  from {
163
163
  transform: translate(0, 0);
164
164
  }
@@ -166,11 +166,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
166
166
  transform: translate(var(--awsui-drag-handle-animation-inline-offset-rhu47t), var(--awsui-drag-handle-animation-block-offset-rhu47t));
167
167
  }
168
168
  }
169
- .awsui_direction-button-wrapper_155yk_1njrl_169:not(#\9) {
169
+ .awsui_direction-button-wrapper_155yk_1u2kp_169:not(#\9) {
170
170
  --awsui-drag-handle-animation-inline-offset-rhu47t: 0;
171
171
  --awsui-drag-handle-animation-block-offset-rhu47t: 0;
172
172
  }
173
- @keyframes awsui_awsui-motion-fade-in_155yk_1njrl_1 {
173
+ @keyframes awsui_awsui-motion-fade-in_155yk_1u2kp_1 {
174
174
  from {
175
175
  opacity: 0.2;
176
176
  }
@@ -178,7 +178,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
178
178
  opacity: 1;
179
179
  }
180
180
  }
181
- @keyframes awsui_awsui-motion-fade-out-0_155yk_1njrl_1 {
181
+ @keyframes awsui_awsui-motion-fade-out-0_155yk_1u2kp_1 {
182
182
  from {
183
183
  opacity: 1;
184
184
  }
@@ -186,81 +186,81 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
186
186
  opacity: 0;
187
187
  }
188
188
  }
189
- .awsui_direction-button-wrapper-motion-enter_155yk_1njrl_189:not(#\9), .awsui_direction-button-wrapper-motion-entering_155yk_1njrl_189:not(#\9), .awsui_direction-button-wrapper-motion-exit_155yk_1njrl_189:not(#\9), .awsui_direction-button-wrapper-motion-exiting_155yk_1njrl_189:not(#\9) {
189
+ .awsui_direction-button-wrapper-motion-enter_155yk_1u2kp_189:not(#\9), .awsui_direction-button-wrapper-motion-entering_155yk_1u2kp_189:not(#\9), .awsui_direction-button-wrapper-motion-exit_155yk_1u2kp_189:not(#\9), .awsui_direction-button-wrapper-motion-exiting_155yk_1u2kp_189:not(#\9) {
190
190
  pointer-events: none;
191
191
  }
192
- .awsui_direction-button-wrapper-motion-entering_155yk_1njrl_189:not(#\9) {
193
- animation: awsui_drag-handle-entry_155yk_1njrl_1 var(--motion-duration-complex-hv88cf, 270ms) var(--motion-easing-responsive-dxkfpl, ease-out), awsui_awsui-motion-fade-in_155yk_1njrl_1 var(--motion-duration-complex-hv88cf, 270ms) var(--motion-easing-responsive-dxkfpl, ease-out);
192
+ .awsui_direction-button-wrapper-motion-entering_155yk_1u2kp_189:not(#\9) {
193
+ animation: awsui_drag-handle-entry_155yk_1u2kp_1 var(--motion-duration-complex-hv88cf, 270ms) var(--motion-easing-responsive-dxkfpl, ease-out), awsui_awsui-motion-fade-in_155yk_1u2kp_1 var(--motion-duration-complex-hv88cf, 270ms) var(--motion-easing-responsive-dxkfpl, ease-out);
194
194
  }
195
195
  @media (prefers-reduced-motion: reduce) {
196
- .awsui_direction-button-wrapper-motion-entering_155yk_1njrl_189:not(#\9) {
196
+ .awsui_direction-button-wrapper-motion-entering_155yk_1u2kp_189:not(#\9) {
197
197
  animation: none;
198
198
  transition: none;
199
199
  }
200
200
  }
201
- .awsui-motion-disabled .awsui_direction-button-wrapper-motion-entering_155yk_1njrl_189:not(#\9), .awsui-mode-entering .awsui_direction-button-wrapper-motion-entering_155yk_1njrl_189:not(#\9) {
201
+ .awsui-motion-disabled .awsui_direction-button-wrapper-motion-entering_155yk_1u2kp_189:not(#\9), .awsui-mode-entering .awsui_direction-button-wrapper-motion-entering_155yk_1u2kp_189:not(#\9) {
202
202
  animation: none;
203
203
  transition: none;
204
204
  }
205
- .awsui_direction-button-wrapper-motion-exiting_155yk_1njrl_189:not(#\9) {
206
- animation: awsui_drag-handle-exit_155yk_1njrl_1 var(--motion-duration-complex-hv88cf, 270ms) var(--motion-easing-responsive-dxkfpl, ease-out) forwards, awsui_awsui-motion-fade-out-0_155yk_1njrl_1 var(--motion-duration-complex-hv88cf, 270ms) var(--motion-easing-responsive-dxkfpl, ease-out) forwards;
205
+ .awsui_direction-button-wrapper-motion-exiting_155yk_1u2kp_189:not(#\9) {
206
+ animation: awsui_drag-handle-exit_155yk_1u2kp_1 var(--motion-duration-complex-hv88cf, 270ms) var(--motion-easing-responsive-dxkfpl, ease-out) forwards, awsui_awsui-motion-fade-out-0_155yk_1u2kp_1 var(--motion-duration-complex-hv88cf, 270ms) var(--motion-easing-responsive-dxkfpl, ease-out) forwards;
207
207
  }
208
208
  @media (prefers-reduced-motion: reduce) {
209
- .awsui_direction-button-wrapper-motion-exiting_155yk_1njrl_189:not(#\9) {
209
+ .awsui_direction-button-wrapper-motion-exiting_155yk_1u2kp_189:not(#\9) {
210
210
  animation: none;
211
211
  transition: none;
212
212
  }
213
213
  }
214
- .awsui-motion-disabled .awsui_direction-button-wrapper-motion-exiting_155yk_1njrl_189:not(#\9), .awsui-mode-entering .awsui_direction-button-wrapper-motion-exiting_155yk_1njrl_189:not(#\9) {
214
+ .awsui-motion-disabled .awsui_direction-button-wrapper-motion-exiting_155yk_1u2kp_189:not(#\9), .awsui-mode-entering .awsui_direction-button-wrapper-motion-exiting_155yk_1u2kp_189:not(#\9) {
215
215
  animation: none;
216
216
  transition: none;
217
217
  }
218
218
  @media (prefers-reduced-motion: reduce) {
219
- .awsui_direction-button-wrapper_155yk_1njrl_169:not(#\9) {
219
+ .awsui_direction-button-wrapper_155yk_1u2kp_169:not(#\9) {
220
220
  animation: none;
221
221
  transition: none;
222
222
  }
223
223
  }
224
- .awsui-motion-disabled .awsui_direction-button-wrapper_155yk_1njrl_169:not(#\9), .awsui-mode-entering .awsui_direction-button-wrapper_155yk_1njrl_169:not(#\9) {
224
+ .awsui-motion-disabled .awsui_direction-button-wrapper_155yk_1u2kp_169:not(#\9), .awsui-mode-entering .awsui_direction-button-wrapper_155yk_1u2kp_169:not(#\9) {
225
225
  animation: none;
226
226
  transition: none;
227
227
  }
228
228
 
229
- .awsui_direction-button-wrapper-block-start_155yk_1njrl_229:not(#\9) {
229
+ .awsui_direction-button-wrapper-block-start_155yk_1u2kp_229:not(#\9) {
230
230
  --awsui-drag-handle-animation-block-offset-rhu47t: 20px;
231
231
  }
232
232
 
233
- .awsui_direction-button-wrapper-block-end_155yk_1njrl_233:not(#\9) {
233
+ .awsui_direction-button-wrapper-block-end_155yk_1u2kp_233:not(#\9) {
234
234
  --awsui-drag-handle-animation-block-offset-rhu47t: -20px;
235
235
  }
236
236
 
237
- .awsui_direction-button-wrapper-inline-start_155yk_1njrl_237:not(#\9) {
237
+ .awsui_direction-button-wrapper-inline-start_155yk_1u2kp_237:not(#\9) {
238
238
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
239
239
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
240
240
  }
241
- .awsui_direction-button-wrapper-inline-start_155yk_1njrl_237:not(#\9):dir(ltr) {
241
+ .awsui_direction-button-wrapper-inline-start_155yk_1u2kp_237:not(#\9):dir(ltr) {
242
242
  --awsui-drag-handle-animation-inline-offset-rhu47t: 20px;
243
243
  }
244
- .awsui_direction-button-wrapper-inline-start_155yk_1njrl_237:not(#\9):dir(rtl) {
244
+ .awsui_direction-button-wrapper-inline-start_155yk_1u2kp_237:not(#\9):dir(rtl) {
245
245
  --awsui-drag-handle-animation-inline-offset-rhu47t: -20px;
246
246
  }
247
247
 
248
- .awsui_direction-button-wrapper-inline-end_155yk_1njrl_248:not(#\9) {
248
+ .awsui_direction-button-wrapper-inline-end_155yk_1u2kp_248:not(#\9) {
249
249
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
250
250
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
251
251
  }
252
- .awsui_direction-button-wrapper-inline-end_155yk_1njrl_248:not(#\9):dir(ltr) {
252
+ .awsui_direction-button-wrapper-inline-end_155yk_1u2kp_248:not(#\9):dir(ltr) {
253
253
  --awsui-drag-handle-animation-inline-offset-rhu47t: -20px;
254
254
  }
255
- .awsui_direction-button-wrapper-inline-end_155yk_1njrl_248:not(#\9):dir(rtl) {
255
+ .awsui_direction-button-wrapper-inline-end_155yk_1u2kp_248:not(#\9):dir(rtl) {
256
256
  --awsui-drag-handle-animation-inline-offset-rhu47t: 20px;
257
257
  }
258
258
 
259
- .awsui_contents_155yk_1njrl_259:not(#\9) {
259
+ .awsui_contents_155yk_1u2kp_259:not(#\9) {
260
260
  display: contents;
261
261
  }
262
262
 
263
- .awsui_portal-overlay_155yk_1njrl_263:not(#\9) {
263
+ .awsui_portal-overlay_155yk_1u2kp_263:not(#\9) {
264
264
  position: absolute;
265
265
  inset-block-start: 0;
266
266
  inset-inline-start: 0;
@@ -268,20 +268,20 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
268
268
  z-index: 7000;
269
269
  }
270
270
 
271
- .awsui_portal-overlay-disabled_155yk_1njrl_271:not(#\9) {
271
+ .awsui_portal-overlay-disabled_155yk_1u2kp_271:not(#\9) {
272
272
  display: none;
273
273
  }
274
274
 
275
- .awsui_portal-overlay-contents_155yk_1njrl_275:not(#\9) {
275
+ .awsui_portal-overlay-contents_155yk_1u2kp_275:not(#\9) {
276
276
  pointer-events: auto;
277
277
  }
278
278
 
279
- .awsui_drag-handle_155yk_1njrl_279:not(#\9) {
279
+ .awsui_drag-handle_155yk_1u2kp_279:not(#\9) {
280
280
  position: relative;
281
281
  display: inline-flex;
282
282
  }
283
283
 
284
- .awsui_direction-button-wrapper_155yk_1njrl_169:not(#\9) {
284
+ .awsui_direction-button-wrapper_155yk_1u2kp_169:not(#\9) {
285
285
  position: absolute;
286
286
  block-size: var(--space-static-xl-pek4x1, 24px);
287
287
  inline-size: var(--space-static-xl-pek4x1, 24px);
@@ -289,31 +289,67 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
289
289
  padding-inline: var(--space-static-xxs-0cgyf1, 4px);
290
290
  }
291
291
 
292
- .awsui_direction-button-wrapper-hidden_155yk_1njrl_292:not(#\9) {
292
+ .awsui_direction-button-wrapper-hidden_155yk_1u2kp_292:not(#\9) {
293
293
  display: none;
294
294
  }
295
295
 
296
- .awsui_direction-button-wrapper-block-start_155yk_1njrl_229:not(#\9) {
296
+ .awsui_direction-button-wrapper-block-start_155yk_1u2kp_229:not(#\9) {
297
297
  inset-block-start: calc(-1 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)));
298
298
  inset-inline-start: calc(50% - (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)) / 2);
299
299
  }
300
300
 
301
- .awsui_direction-button-wrapper-block-end_155yk_1njrl_233:not(#\9) {
301
+ .awsui_direction-button-wrapper-block-end_155yk_1u2kp_233:not(#\9) {
302
302
  inset-block-end: calc(-1 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)));
303
303
  inset-inline-start: calc(50% - (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)) / 2);
304
304
  }
305
305
 
306
- .awsui_direction-button-wrapper-inline-start_155yk_1njrl_237:not(#\9) {
306
+ .awsui_direction-button-wrapper-inline-start_155yk_1u2kp_237:not(#\9) {
307
307
  inset-inline-start: calc(-1 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)));
308
308
  inset-block-start: calc(50% - (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)) / 2);
309
309
  }
310
310
 
311
- .awsui_direction-button-wrapper-inline-end_155yk_1njrl_248:not(#\9) {
311
+ .awsui_direction-button-wrapper-inline-end_155yk_1u2kp_248:not(#\9) {
312
312
  inset-inline-end: calc(-1 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)));
313
313
  inset-block-start: calc(50% - (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)) / 2);
314
314
  }
315
315
 
316
- .awsui_direction-button_155yk_1njrl_169:not(#\9) {
316
+ .awsui_direction-button-wrapper-forced_155yk_1u2kp_316:not(#\9) {
317
+ inset-inline-start: calc(50% - (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)) / 2);
318
+ }
319
+
320
+ .awsui_direction-button-wrapper-forced-top-0_155yk_1u2kp_320:not(#\9) {
321
+ inset-block-start: calc(-1 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)));
322
+ }
323
+
324
+ .awsui_direction-button-wrapper-forced-top-1_155yk_1u2kp_324:not(#\9) {
325
+ inset-block-start: calc(-2 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)));
326
+ }
327
+
328
+ .awsui_direction-button-wrapper-forced-top-2_155yk_1u2kp_328:not(#\9) {
329
+ inset-block-start: calc(-3 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)));
330
+ }
331
+
332
+ .awsui_direction-button-wrapper-forced-top-3_155yk_1u2kp_332:not(#\9) {
333
+ inset-block-start: calc(-4 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)));
334
+ }
335
+
336
+ .awsui_direction-button-wrapper-forced-bottom-0_155yk_1u2kp_336:not(#\9) {
337
+ inset-block-start: calc(1 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)) - 50%);
338
+ }
339
+
340
+ .awsui_direction-button-wrapper-forced-bottom-1_155yk_1u2kp_340:not(#\9) {
341
+ inset-block-start: calc(2 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)) - 50%);
342
+ }
343
+
344
+ .awsui_direction-button-wrapper-forced-bottom-2_155yk_1u2kp_344:not(#\9) {
345
+ inset-block-start: calc(3 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)) - 50%);
346
+ }
347
+
348
+ .awsui_direction-button-wrapper-forced-bottom-3_155yk_1u2kp_348:not(#\9) {
349
+ inset-block-start: calc(4 * (var(--space-static-xl-pek4x1, 24px) + 2 * var(--space-static-xxs-0cgyf1, 4px)) - 50%);
350
+ }
351
+
352
+ .awsui_direction-button_155yk_1u2kp_169:not(#\9) {
317
353
  position: absolute;
318
354
  border-width: 0;
319
355
  cursor: pointer;
@@ -332,14 +368,14 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
332
368
  color: var(--color-text-direction-button-default-dkices, #ffffff);
333
369
  box-shadow: var(--shadow-dropdown-skxpuu, 0 1px 1px 0 rgba(0, 28, 36, 0.3), 1px 1px 1px 0 rgba(0, 28, 36, 0.15), -1px 1px 1px 0 rgba(0, 28, 36, 0.15));
334
370
  }
335
- .awsui_direction-button_155yk_1njrl_169:not(#\9):not(.awsui_direction-button-disabled_155yk_1njrl_335):hover {
371
+ .awsui_direction-button_155yk_1u2kp_169:not(#\9):not(.awsui_direction-button-disabled_155yk_1u2kp_371):hover {
336
372
  background-color: var(--color-background-direction-button-hover-v5bxfc, #414750);
337
373
  }
338
- .awsui_direction-button_155yk_1njrl_169:not(#\9):not(.awsui_direction-button-disabled_155yk_1njrl_335):active {
374
+ .awsui_direction-button_155yk_1u2kp_169:not(#\9):not(.awsui_direction-button-disabled_155yk_1u2kp_371):active {
339
375
  background-color: var(--color-background-direction-button-active-wn6s2j, #2a2e33);
340
376
  }
341
377
 
342
- .awsui_direction-button-disabled_155yk_1njrl_335:not(#\9) {
378
+ .awsui_direction-button-disabled_155yk_1u2kp_371:not(#\9) {
343
379
  cursor: default;
344
380
  background-color: var(--color-background-direction-button-disabled-rcznmi, #eaeded);
345
381
  color: var(--color-text-direction-button-disabled-596cgx, #aab7b8);
@@ -2,26 +2,35 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "direction-button-wrapper": "awsui_direction-button-wrapper_155yk_1njrl_169",
6
- "direction-button-wrapper-motion-enter": "awsui_direction-button-wrapper-motion-enter_155yk_1njrl_189",
7
- "direction-button-wrapper-motion-entering": "awsui_direction-button-wrapper-motion-entering_155yk_1njrl_189",
8
- "direction-button-wrapper-motion-exit": "awsui_direction-button-wrapper-motion-exit_155yk_1njrl_189",
9
- "direction-button-wrapper-motion-exiting": "awsui_direction-button-wrapper-motion-exiting_155yk_1njrl_189",
10
- "drag-handle-entry": "awsui_drag-handle-entry_155yk_1njrl_1",
11
- "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_155yk_1njrl_1",
12
- "drag-handle-exit": "awsui_drag-handle-exit_155yk_1njrl_1",
13
- "awsui-motion-fade-out-0": "awsui_awsui-motion-fade-out-0_155yk_1njrl_1",
14
- "direction-button-wrapper-block-start": "awsui_direction-button-wrapper-block-start_155yk_1njrl_229",
15
- "direction-button-wrapper-block-end": "awsui_direction-button-wrapper-block-end_155yk_1njrl_233",
16
- "direction-button-wrapper-inline-start": "awsui_direction-button-wrapper-inline-start_155yk_1njrl_237",
17
- "direction-button-wrapper-inline-end": "awsui_direction-button-wrapper-inline-end_155yk_1njrl_248",
18
- "contents": "awsui_contents_155yk_1njrl_259",
19
- "portal-overlay": "awsui_portal-overlay_155yk_1njrl_263",
20
- "portal-overlay-disabled": "awsui_portal-overlay-disabled_155yk_1njrl_271",
21
- "portal-overlay-contents": "awsui_portal-overlay-contents_155yk_1njrl_275",
22
- "drag-handle": "awsui_drag-handle_155yk_1njrl_279",
23
- "direction-button-wrapper-hidden": "awsui_direction-button-wrapper-hidden_155yk_1njrl_292",
24
- "direction-button": "awsui_direction-button_155yk_1njrl_169",
25
- "direction-button-disabled": "awsui_direction-button-disabled_155yk_1njrl_335"
5
+ "direction-button-wrapper": "awsui_direction-button-wrapper_155yk_1u2kp_169",
6
+ "direction-button-wrapper-motion-enter": "awsui_direction-button-wrapper-motion-enter_155yk_1u2kp_189",
7
+ "direction-button-wrapper-motion-entering": "awsui_direction-button-wrapper-motion-entering_155yk_1u2kp_189",
8
+ "direction-button-wrapper-motion-exit": "awsui_direction-button-wrapper-motion-exit_155yk_1u2kp_189",
9
+ "direction-button-wrapper-motion-exiting": "awsui_direction-button-wrapper-motion-exiting_155yk_1u2kp_189",
10
+ "drag-handle-entry": "awsui_drag-handle-entry_155yk_1u2kp_1",
11
+ "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_155yk_1u2kp_1",
12
+ "drag-handle-exit": "awsui_drag-handle-exit_155yk_1u2kp_1",
13
+ "awsui-motion-fade-out-0": "awsui_awsui-motion-fade-out-0_155yk_1u2kp_1",
14
+ "direction-button-wrapper-block-start": "awsui_direction-button-wrapper-block-start_155yk_1u2kp_229",
15
+ "direction-button-wrapper-block-end": "awsui_direction-button-wrapper-block-end_155yk_1u2kp_233",
16
+ "direction-button-wrapper-inline-start": "awsui_direction-button-wrapper-inline-start_155yk_1u2kp_237",
17
+ "direction-button-wrapper-inline-end": "awsui_direction-button-wrapper-inline-end_155yk_1u2kp_248",
18
+ "contents": "awsui_contents_155yk_1u2kp_259",
19
+ "portal-overlay": "awsui_portal-overlay_155yk_1u2kp_263",
20
+ "portal-overlay-disabled": "awsui_portal-overlay-disabled_155yk_1u2kp_271",
21
+ "portal-overlay-contents": "awsui_portal-overlay-contents_155yk_1u2kp_275",
22
+ "drag-handle": "awsui_drag-handle_155yk_1u2kp_279",
23
+ "direction-button-wrapper-hidden": "awsui_direction-button-wrapper-hidden_155yk_1u2kp_292",
24
+ "direction-button-wrapper-forced": "awsui_direction-button-wrapper-forced_155yk_1u2kp_316",
25
+ "direction-button-wrapper-forced-top-0": "awsui_direction-button-wrapper-forced-top-0_155yk_1u2kp_320",
26
+ "direction-button-wrapper-forced-top-1": "awsui_direction-button-wrapper-forced-top-1_155yk_1u2kp_324",
27
+ "direction-button-wrapper-forced-top-2": "awsui_direction-button-wrapper-forced-top-2_155yk_1u2kp_328",
28
+ "direction-button-wrapper-forced-top-3": "awsui_direction-button-wrapper-forced-top-3_155yk_1u2kp_332",
29
+ "direction-button-wrapper-forced-bottom-0": "awsui_direction-button-wrapper-forced-bottom-0_155yk_1u2kp_336",
30
+ "direction-button-wrapper-forced-bottom-1": "awsui_direction-button-wrapper-forced-bottom-1_155yk_1u2kp_340",
31
+ "direction-button-wrapper-forced-bottom-2": "awsui_direction-button-wrapper-forced-bottom-2_155yk_1u2kp_344",
32
+ "direction-button-wrapper-forced-bottom-3": "awsui_direction-button-wrapper-forced-bottom-3_155yk_1u2kp_348",
33
+ "direction-button": "awsui_direction-button_155yk_1u2kp_169",
34
+ "direction-button-disabled": "awsui_direction-button-disabled_155yk_1u2kp_371"
26
35
  };
27
36
 
@@ -1,5 +1,5 @@
1
1
  import { OptionProps } from './interfaces';
2
2
  export { OptionProps };
3
- declare const Option: ({ option, highlightText, triggerVariant, isGroupOption, highlightedOption, selectedOption, disableTitleTooltip, labelContainerRef, labelRef, labelId, ...restProps }: OptionProps) => JSX.Element | null;
3
+ declare const Option: ({ option, highlightText, triggerVariant, isGroupOption, highlightedOption, selectedOption, disableTitleTooltip, labelContainerRef, labelRef, labelId, customContent, ...restProps }: OptionProps) => JSX.Element | null;
4
4
  export default Option;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/option/index.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAM3C,OAAO,EAAE,WAAW,EAAE,CAAC;AAWvB,QAAA,MAAM,MAAM,GAAI,sKAYb,WAAW,uBAyFb,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/option/index.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAM3C,OAAO,EAAE,WAAW,EAAE,CAAC;AAWvB,QAAA,MAAM,MAAM,GAAI,qLAab,WAAW,uBAgGb,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -13,11 +13,15 @@ function validateStringValue(value, propertyName) {
13
13
  warnOnce('DropdownOption', `This component only supports string values, but "option.${propertyName}" has ${typeof value} type. The component may work incorrectly.`);
14
14
  }
15
15
  }
16
- const Option = ({ option, highlightText, triggerVariant = false, isGroupOption = false, highlightedOption = false, selectedOption = false, disableTitleTooltip = false, labelContainerRef, labelRef, labelId, ...restProps }) => {
16
+ const Option = ({ option, highlightText, triggerVariant = false, isGroupOption = false, highlightedOption = false, selectedOption = false, disableTitleTooltip = false, labelContainerRef, labelRef, labelId, customContent, ...restProps }) => {
17
17
  var _a, _b, _c, _d;
18
18
  if (!option) {
19
19
  return null;
20
20
  }
21
+ if (customContent) {
22
+ return (React.createElement("div", { "data-value": option.value, className: clsx(styles.option) },
23
+ React.createElement("div", { className: clsx(styles['custom-content']) }, customContent)));
24
+ }
21
25
  const { disabled } = option;
22
26
  const baseProps = getBaseProps(restProps);
23
27
  const SpanOrDivTag = option.labelContent ? 'div' : 'span';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/option/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC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cAAc,EAAE,cAAc,GAC9B,CACW,CACF,CAChB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../../base-component';\nimport { isDevelopment } from '../../is-development';\nimport { OptionProps } from './interfaces';\nimport { Description, FilteringTags, Label, LabelTag, OptionIcon, Tags } from './option-parts';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\nexport { OptionProps };\n\nfunction validateStringValue(value: string | undefined, propertyName: string) {\n if (typeof value !== 'undefined' && typeof value !== 'string') {\n warnOnce(\n 'DropdownOption',\n `This component only supports string values, but \"option.${propertyName}\" has ${typeof value} type. The component may work incorrectly.`\n );\n }\n}\n\nconst Option = ({\n option,\n highlightText,\n triggerVariant = false,\n isGroupOption = false,\n highlightedOption = false,\n selectedOption = false,\n disableTitleTooltip = false,\n labelContainerRef,\n labelRef,\n labelId,\n ...restProps\n}: OptionProps) => {\n if (!option) {\n return null;\n }\n const { disabled } = option;\n const baseProps = getBaseProps(restProps);\n const SpanOrDivTag = option.labelContent ? 'div' : 'span';\n\n if (isDevelopment) {\n validateStringValue(option.label, 'label');\n validateStringValue(option.description, 'description');\n validateStringValue(option.labelTag, 'labelTag');\n option.tags?.forEach((tag, index) => {\n validateStringValue(tag, `tags[${index}]`);\n });\n option.filteringTags?.forEach((tag, index) => {\n validateStringValue(tag, `filteringTags[${index}]`);\n });\n }\n\n const className = clsx(\n styles.option,\n disabled && styles.disabled,\n isGroupOption && styles.parent,\n highlightedOption && styles.highlighted,\n baseProps.className\n );\n\n const icon = option.__customIcon || (\n <OptionIcon\n name={option.iconName}\n url={option.iconUrl}\n svg={option.iconSvg}\n alt={option.iconAlt}\n ariaLabel={option.iconAriaLabel}\n size=\"normal\"\n />\n );\n\n return (\n <SpanOrDivTag\n {...baseProps}\n data-value={option.value}\n className={className}\n lang={option.lang}\n title={!disableTitleTooltip ? (option.label ?? option.value) : undefined}\n >\n {icon}\n <SpanOrDivTag className={styles.content}>\n <SpanOrDivTag className={styles['label-content']}>\n {option.labelContent ? (\n <SpanOrDivTag className={clsx(styles.label, analyticsSelectors.label)}>{option.labelContent}</SpanOrDivTag>\n ) : (\n <Label\n labelContainerRef={labelContainerRef}\n labelRef={labelRef}\n labelId={labelId}\n label={option.label ?? option.value}\n prefix={option.__labelPrefix}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n )}\n <LabelTag labelTag={option.labelTag} highlightText={highlightText} triggerVariant={triggerVariant} />\n </SpanOrDivTag>\n <Description\n description={option.description}\n highlightedOption={highlightedOption}\n selectedOption={selectedOption}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n <Tags\n tags={option.tags}\n highlightedOption={highlightedOption}\n selectedOption={selectedOption}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n <FilteringTags\n filteringTags={option.filteringTags}\n highlightedOption={highlightedOption}\n selectedOption={selectedOption}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n </SpanOrDivTag>\n </SpanOrDivTag>\n );\n};\n\nexport default Option;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/option/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAA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C;AAEF,eAAe,MAAM,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../../base-component';\nimport { isDevelopment } from '../../is-development';\nimport { OptionProps } from './interfaces';\nimport { Description, FilteringTags, Label, LabelTag, OptionIcon, Tags } from './option-parts';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\nexport { OptionProps };\n\nfunction validateStringValue(value: string | undefined, propertyName: string) {\n if (typeof value !== 'undefined' && typeof value !== 'string') {\n warnOnce(\n 'DropdownOption',\n `This component only supports string values, but \"option.${propertyName}\" has ${typeof value} type. The component may work incorrectly.`\n );\n }\n}\n\nconst Option = ({\n option,\n highlightText,\n triggerVariant = false,\n isGroupOption = false,\n highlightedOption = false,\n selectedOption = false,\n disableTitleTooltip = false,\n labelContainerRef,\n labelRef,\n labelId,\n customContent,\n ...restProps\n}: OptionProps) => {\n if (!option) {\n return null;\n }\n if (customContent) {\n return (\n <div data-value={option.value} className={clsx(styles.option)}>\n <div className={clsx(styles['custom-content'])}>{customContent}</div>\n </div>\n );\n }\n\n const { disabled } = option;\n const baseProps = getBaseProps(restProps);\n const SpanOrDivTag = option.labelContent ? 'div' : 'span';\n\n if (isDevelopment) {\n validateStringValue(option.label, 'label');\n validateStringValue(option.description, 'description');\n validateStringValue(option.labelTag, 'labelTag');\n option.tags?.forEach((tag, index) => {\n validateStringValue(tag, `tags[${index}]`);\n });\n option.filteringTags?.forEach((tag, index) => {\n validateStringValue(tag, `filteringTags[${index}]`);\n });\n }\n const className = clsx(\n styles.option,\n disabled && styles.disabled,\n isGroupOption && styles.parent,\n highlightedOption && styles.highlighted,\n baseProps.className\n );\n\n const icon = option.__customIcon || (\n <OptionIcon\n name={option.iconName}\n url={option.iconUrl}\n svg={option.iconSvg}\n alt={option.iconAlt}\n ariaLabel={option.iconAriaLabel}\n size=\"normal\"\n />\n );\n\n return (\n <SpanOrDivTag\n {...baseProps}\n data-value={option.value}\n className={className}\n lang={option.lang}\n title={!disableTitleTooltip ? (option.label ?? option.value) : undefined}\n >\n {icon}\n <SpanOrDivTag className={styles.content}>\n <SpanOrDivTag className={styles['label-content']}>\n {option.labelContent ? (\n <SpanOrDivTag className={clsx(styles.label, analyticsSelectors.label)}>{option.labelContent}</SpanOrDivTag>\n ) : (\n <Label\n labelContainerRef={labelContainerRef}\n labelRef={labelRef}\n labelId={labelId}\n label={option.label ?? option.value}\n prefix={option.__labelPrefix}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n )}\n <LabelTag labelTag={option.labelTag} highlightText={highlightText} triggerVariant={triggerVariant} />\n </SpanOrDivTag>\n <Description\n description={option.description}\n highlightedOption={highlightedOption}\n selectedOption={selectedOption}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n <Tags\n tags={option.tags}\n highlightedOption={highlightedOption}\n selectedOption={selectedOption}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n <FilteringTags\n filteringTags={option.filteringTags}\n highlightedOption={highlightedOption}\n selectedOption={selectedOption}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n </SpanOrDivTag>\n </SpanOrDivTag>\n );\n};\n\nexport default Option;\n"]}