@cloudscape-design/components-themeable 3.0.974 → 3.0.976

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 (131) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/drawer/styles.scss +14 -0
  3. package/lib/internal/scss/link/styles.scss +1 -1
  4. package/lib/internal/template/annotation-context/index.js +2 -2
  5. package/lib/internal/template/annotation-context/index.js.map +1 -1
  6. package/lib/internal/template/app-layout/runtime-drawer/index.js +1 -1
  7. package/lib/internal/template/app-layout/runtime-drawer/index.js.map +1 -1
  8. package/lib/internal/template/app-layout/runtime-drawer/use-runtime-drawer-context.d.ts +6 -0
  9. package/lib/internal/template/app-layout/runtime-drawer/use-runtime-drawer-context.d.ts.map +1 -0
  10. package/lib/internal/template/app-layout/runtime-drawer/use-runtime-drawer-context.js +29 -0
  11. package/lib/internal/template/app-layout/runtime-drawer/use-runtime-drawer-context.js.map +1 -0
  12. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-drawer.d.ts.map +1 -1
  13. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-drawer.js +1 -1
  14. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-drawer.js.map +1 -1
  15. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/local-drawer.d.ts.map +1 -1
  16. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/local-drawer.js +1 -1
  17. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/local-drawer.js.map +1 -1
  18. package/lib/internal/template/app-layout/visual-refresh-toolbar/navigation/index.d.ts.map +1 -1
  19. package/lib/internal/template/app-layout/visual-refresh-toolbar/navigation/index.js +1 -1
  20. package/lib/internal/template/app-layout/visual-refresh-toolbar/navigation/index.js.map +1 -1
  21. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.d.ts.map +1 -1
  22. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js +7 -2
  23. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js.map +1 -1
  24. package/lib/internal/template/app-layout-toolbar/analytics-metadata/interfaces.d.ts +18 -0
  25. package/lib/internal/template/app-layout-toolbar/analytics-metadata/interfaces.d.ts.map +1 -0
  26. package/lib/internal/template/app-layout-toolbar/analytics-metadata/interfaces.js +4 -0
  27. package/lib/internal/template/app-layout-toolbar/analytics-metadata/interfaces.js.map +1 -0
  28. package/lib/internal/template/app-layout-toolbar/index.d.ts.map +1 -1
  29. package/lib/internal/template/app-layout-toolbar/index.js +9 -1
  30. package/lib/internal/template/app-layout-toolbar/index.js.map +1 -1
  31. package/lib/internal/template/date-input/internal.d.ts.map +1 -1
  32. package/lib/internal/template/date-input/internal.js +3 -16
  33. package/lib/internal/template/date-input/internal.js.map +1 -1
  34. package/lib/internal/template/date-input/utils.d.ts +7 -0
  35. package/lib/internal/template/date-input/utils.d.ts.map +1 -0
  36. package/lib/internal/template/date-input/utils.js +25 -0
  37. package/lib/internal/template/date-input/utils.js.map +1 -0
  38. package/lib/internal/template/date-range-picker/calendar/grids/index.js.map +1 -1
  39. package/lib/internal/template/date-range-picker/calendar/grids/interfaces.d.ts +3 -4
  40. package/lib/internal/template/date-range-picker/calendar/grids/interfaces.d.ts.map +1 -1
  41. package/lib/internal/template/date-range-picker/calendar/grids/interfaces.js.map +1 -1
  42. package/lib/internal/template/date-range-picker/calendar/header/header-button.d.ts +0 -2
  43. package/lib/internal/template/date-range-picker/calendar/header/header-button.d.ts.map +1 -1
  44. package/lib/internal/template/date-range-picker/calendar/header/header-button.js.map +1 -1
  45. package/lib/internal/template/date-range-picker/calendar/header/index.d.ts +2 -3
  46. package/lib/internal/template/date-range-picker/calendar/header/index.d.ts.map +1 -1
  47. package/lib/internal/template/date-range-picker/calendar/header/index.js.map +1 -1
  48. package/lib/internal/template/date-range-picker/calendar/index.d.ts +2 -2
  49. package/lib/internal/template/date-range-picker/calendar/index.d.ts.map +1 -1
  50. package/lib/internal/template/date-range-picker/calendar/index.js.map +1 -1
  51. package/lib/internal/template/date-range-picker/calendar/range-inputs.d.ts +3 -3
  52. package/lib/internal/template/date-range-picker/calendar/range-inputs.d.ts.map +1 -1
  53. package/lib/internal/template/date-range-picker/calendar/range-inputs.js.map +1 -1
  54. package/lib/internal/template/date-range-picker/dropdown.d.ts +2 -2
  55. package/lib/internal/template/date-range-picker/dropdown.d.ts.map +1 -1
  56. package/lib/internal/template/date-range-picker/dropdown.js.map +1 -1
  57. package/lib/internal/template/date-range-picker/interfaces.d.ts +2 -7
  58. package/lib/internal/template/date-range-picker/interfaces.d.ts.map +1 -1
  59. package/lib/internal/template/date-range-picker/interfaces.js.map +1 -1
  60. package/lib/internal/template/date-range-picker/relative-range/index.d.ts +2 -2
  61. package/lib/internal/template/date-range-picker/relative-range/index.d.ts.map +1 -1
  62. package/lib/internal/template/date-range-picker/relative-range/index.js.map +1 -1
  63. package/lib/internal/template/drawer/implementation.d.ts +1 -1
  64. package/lib/internal/template/drawer/implementation.d.ts.map +1 -1
  65. package/lib/internal/template/drawer/implementation.js +4 -2
  66. package/lib/internal/template/drawer/implementation.js.map +1 -1
  67. package/lib/internal/template/drawer/interfaces.d.ts +4 -0
  68. package/lib/internal/template/drawer/interfaces.d.ts.map +1 -1
  69. package/lib/internal/template/drawer/interfaces.js.map +1 -1
  70. package/lib/internal/template/drawer/styles.css.js +6 -5
  71. package/lib/internal/template/drawer/styles.scoped.css +23 -10
  72. package/lib/internal/template/drawer/styles.selectors.js +6 -5
  73. package/lib/internal/template/i18n/provider.js +2 -2
  74. package/lib/internal/template/i18n/provider.js.map +1 -1
  75. package/lib/internal/template/internal/components/drag-handle/index.d.ts.map +1 -1
  76. package/lib/internal/template/internal/components/drag-handle/index.js +2 -2
  77. package/lib/internal/template/internal/components/drag-handle/index.js.map +1 -1
  78. package/lib/internal/template/internal/components/drag-handle/interfaces.d.ts +2 -1
  79. package/lib/internal/template/internal/components/drag-handle/interfaces.d.ts.map +1 -1
  80. package/lib/internal/template/internal/components/drag-handle/interfaces.js.map +1 -1
  81. package/lib/internal/template/internal/components/drag-handle-wrapper/index.d.ts +1 -1
  82. package/lib/internal/template/internal/components/drag-handle-wrapper/index.d.ts.map +1 -1
  83. package/lib/internal/template/internal/components/drag-handle-wrapper/index.js +8 -2
  84. package/lib/internal/template/internal/components/drag-handle-wrapper/index.js.map +1 -1
  85. package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.d.ts +2 -0
  86. package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.d.ts.map +1 -1
  87. package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.js.map +1 -1
  88. package/lib/internal/template/internal/components/drag-handle-wrapper/portal-overlay.d.ts.map +1 -1
  89. package/lib/internal/template/internal/components/drag-handle-wrapper/portal-overlay.js +2 -1
  90. package/lib/internal/template/internal/components/drag-handle-wrapper/portal-overlay.js.map +1 -1
  91. package/lib/internal/template/internal/environment.js +1 -1
  92. package/lib/internal/template/internal/environment.json +1 -1
  93. package/lib/internal/template/internal/generated/theming/index.cjs +4 -0
  94. package/lib/internal/template/internal/generated/theming/index.cjs.d.ts +18 -0
  95. package/lib/internal/template/internal/generated/theming/index.d.ts +18 -0
  96. package/lib/internal/template/internal/generated/theming/index.js +4 -0
  97. package/lib/internal/template/internal/hooks/use-base-component/index.d.ts.map +1 -1
  98. package/lib/internal/template/internal/hooks/use-base-component/index.js +8 -5
  99. package/lib/internal/template/internal/hooks/use-base-component/index.js.map +1 -1
  100. package/lib/internal/template/internal/plugins/controllers/alert-flash-content.d.ts +2 -0
  101. package/lib/internal/template/internal/plugins/controllers/alert-flash-content.d.ts.map +1 -1
  102. package/lib/internal/template/internal/plugins/controllers/alert-flash-content.js.map +1 -1
  103. package/lib/internal/template/internal/plugins/controllers/drawers.d.ts +6 -0
  104. package/lib/internal/template/internal/plugins/controllers/drawers.d.ts.map +1 -1
  105. package/lib/internal/template/internal/plugins/controllers/drawers.js +17 -1
  106. package/lib/internal/template/internal/plugins/controllers/drawers.js.map +1 -1
  107. package/lib/internal/template/internal/plugins/helpers/use-discovered-content.d.ts +7 -7
  108. package/lib/internal/template/internal/plugins/helpers/use-discovered-content.d.ts.map +1 -1
  109. package/lib/internal/template/internal/plugins/helpers/use-discovered-content.js +5 -2
  110. package/lib/internal/template/internal/plugins/helpers/use-discovered-content.js.map +1 -1
  111. package/lib/internal/template/link/styles.css.js +20 -20
  112. package/lib/internal/template/link/styles.scoped.css +73 -71
  113. package/lib/internal/template/link/styles.selectors.js +20 -20
  114. package/lib/internal/template/popover/container.d.ts.map +1 -1
  115. package/lib/internal/template/popover/container.js +20 -7
  116. package/lib/internal/template/popover/container.js.map +1 -1
  117. package/lib/internal/template/table/body-cell/inline-editor.d.ts.map +1 -1
  118. package/lib/internal/template/table/body-cell/inline-editor.js +2 -1
  119. package/lib/internal/template/table/body-cell/inline-editor.js.map +1 -1
  120. package/lib/internal/template/test-utils/dom/drawer/index.d.ts +1 -0
  121. package/lib/internal/template/test-utils/dom/drawer/index.js +3 -0
  122. package/lib/internal/template/test-utils/dom/drawer/index.js.map +1 -1
  123. package/lib/internal/template/test-utils/selectors/drawer/index.d.ts +1 -0
  124. package/lib/internal/template/test-utils/selectors/drawer/index.js +3 -0
  125. package/lib/internal/template/test-utils/selectors/drawer/index.js.map +1 -1
  126. package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
  127. package/package.json +1 -1
  128. package/lib/internal/template/internal/hooks/use-telemetry/index.d.ts +0 -3
  129. package/lib/internal/template/internal/hooks/use-telemetry/index.d.ts.map +0 -1
  130. package/lib/internal/template/internal/hooks/use-telemetry/index.js +0 -12
  131. package/lib/internal/template/internal/hooks/use-telemetry/index.js.map +0 -1
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "edc398833b88a84cf3e399a40bab01ceeeeae075"
2
+ "commit": "955ec7c68f264db03e738d327016722472c11590"
3
3
  }
@@ -13,11 +13,14 @@
13
13
 
14
14
  .header {
15
15
  @include styles.font-panel-header;
16
+ display: flex;
17
+ justify-content: space-between;
16
18
  color: awsui.$color-text-heading-default;
17
19
  padding-block: awsui.$space-panel-header-vertical;
18
20
  padding-inline: awsui.$space-panel-side-left calc(#{awsui.$space-xl} + #{awsui.$space-scaled-xxl});
19
21
  // padding to make sure the header doesn't overlap with the close icon
20
22
  border-block-end: awsui.$border-divider-section-width solid awsui.$color-border-panel-header;
23
+
21
24
  .with-toolbar > & {
22
25
  border-color: transparent;
23
26
  margin-block-end: 0px;
@@ -36,6 +39,17 @@
36
39
  /* stylelint-enable @cloudscape-design/no-implicit-descendant, selector-max-type */
37
40
  }
38
41
 
42
+ .header-actions {
43
+ display: inline-flex;
44
+ align-items: start;
45
+ z-index: 1;
46
+ /*
47
+ Compensate for the difference between the runtime drawer's and the drawer component's heading
48
+ to ensure the header actions are vertically aligned
49
+ */
50
+ margin-block-start: -6px;
51
+ }
52
+
39
53
  .content-with-paddings:not(:empty) {
40
54
  padding-block-start: awsui.$space-panel-content-top;
41
55
  padding-inline-start: awsui.$space-panel-side-left;
@@ -17,7 +17,7 @@
17
17
 
18
18
  @each $variant in map.keys(constants.$link-variants) {
19
19
  &.variant-#{$variant} {
20
- @if $variant == 'info' {
20
+ @if $variant == 'info' or $variant == 'top-navigation' {
21
21
  @include styles.font-smoothing;
22
22
  }
23
23
  @if $variant == 'secondary' {
@@ -3,7 +3,7 @@ import { __rest } from "tslib";
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import { fireNonCancelableEvent } from '../internal/events';
6
- import { useTelemetry } from '../internal/hooks/use-telemetry';
6
+ import useBaseComponent from '../internal/hooks/use-base-component';
7
7
  import { applyDisplayName } from '../internal/utils/apply-display-name';
8
8
  import { ClosedAnnotation } from './annotation/closed-annotation';
9
9
  import { OpenAnnotation } from './annotation/open-annotation';
@@ -13,7 +13,7 @@ import { getStepInfo } from './utils';
13
13
  const emptyTasks = [];
14
14
  export default function AnnotationContext({ currentTutorial, children, onStepChange, onFinish: onFinishHandler, onStartTutorial, onExitTutorial, i18nStrings, }) {
15
15
  var _a, _b, _c, _d;
16
- useTelemetry('AnnotationContext');
16
+ useBaseComponent('AnnotationContext');
17
17
  const [open, setOpen] = useState(true);
18
18
  const [currentStepIndex, setCurrentStepIndex] = useState(0);
19
19
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/annotation-context/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAkB,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC,sDAAsD;AACtD,MAAM,UAAU,GAA+C,EAAE,CAAC;AAElE,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,QAAQ,EAAE,eAAe,EACzB,eAAe,EACf,cAAc,EACd,WAAW,GACY;;IACvB,YAAY,CAAC,mBAAmB,CAAC,CAAC;IAElC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEvC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,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, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { HotspotProps } from '../hotspot/interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { useTelemetry } from '../internal/hooks/use-telemetry';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { ClosedAnnotation } from './annotation/closed-annotation';\nimport { OpenAnnotation } from './annotation/open-annotation';\nimport { HotspotContext, hotspotContext } from './context';\nimport { AnnotationContextProps } from './interfaces';\nimport { getStepInfo } from './utils';\n\nexport { AnnotationContextProps };\n\n// constant empty array to keep hook dependency stable\nconst emptyTasks: ReadonlyArray<AnnotationContextProps.Task> = [];\n\nexport default function AnnotationContext({\n currentTutorial,\n children,\n onStepChange,\n onFinish: onFinishHandler,\n onStartTutorial,\n onExitTutorial,\n i18nStrings,\n}: AnnotationContextProps): JSX.Element {\n useTelemetry('AnnotationContext');\n\n const [open, setOpen] = useState(true);\n\n const [currentStepIndex, setCurrentStepIndex] = useState(0);\n useEffect(() => {\n // When a tutorial is started, we reset the progress to the first step.\n setCurrentStepIndex(0);\n setOpen(true);\n }, [currentTutorial, setOpen]);\n\n const [availableHotspots, setAvailableHotspots] = useState<Record<string, true | undefined>>({});\n // availableHotspots is mirrored in this ref to prevent endless loops\n // in between registerHotspot and unregisterHotspot callbacks.\n const availableHotspotsRef = useRef<Record<string, true | undefined>>(availableHotspots);\n\n const annotations = currentTutorial ? currentTutorial.tasks : emptyTasks;\n const { task, step, localIndex, taskIndex } = getStepInfo(annotations, currentStepIndex);\n const currentId = step?.hotspotId;\n const totalStepCount = annotations.map(a => a.steps.length).reduce((a, b) => a + b, 0);\n\n const id2index = useMemo(() => {\n const mapping: Record<string, number> = {};\n\n let counter = 0;\n for (const annotation of annotations) {\n for (const step of annotation.steps) {\n if (mapping[step.hotspotId] === undefined) {\n mapping[step.hotspotId] = counter;\n }\n counter++;\n }\n }\n\n return mapping;\n }, [annotations]);\n\n const openNextStep = useCallback(() => {\n const newStepIndex = Math.min(currentStepIndex + 1, totalStepCount);\n setCurrentStepIndex(newStepIndex);\n fireNonCancelableEvent(onStepChange, { step: newStepIndex, reason: 'next' });\n }, [currentStepIndex, onStepChange, totalStepCount]);\n\n const openPreviousStep = useCallback(() => {\n const newStepIndex = Math.max(currentStepIndex - 1, 0);\n setCurrentStepIndex(newStepIndex);\n fireNonCancelableEvent(onStepChange, { step: newStepIndex, reason: 'previous' });\n }, [onStepChange, currentStepIndex]);\n\n const onFinish = useCallback(() => fireNonCancelableEvent(onFinishHandler), [onFinishHandler]);\n\n /**\n * If the currently open hotspot disappears from the page (e.g. because of a react-router navigation),\n * this Effect detects the nearest available hotspot and changes to it. This allows us to e.g. automatically\n * advance to the first step on the new page (or the last step on the previous page, in case the user\n * navigates back).\n */\n const isCurrentHotspotAvailable = currentId ? availableHotspots[currentId] : null;\n useEffect(() => {\n if (!currentId || availableHotspotsRef.current[currentId]) {\n return;\n }\n\n const findNearestHotspot = () => {\n let nearestHotspot: string | undefined = undefined;\n let nearestDistance = Infinity;\n for (const hotspotId of Object.keys(availableHotspotsRef.current)) {\n const distanceFromCurrentHotspot = Math.abs(id2index[hotspotId] - currentStepIndex);\n if (distanceFromCurrentHotspot < nearestDistance) {\n nearestDistance = distanceFromCurrentHotspot;\n nearestHotspot = hotspotId;\n }\n }\n return nearestHotspot;\n };\n\n const nearestHotspot = findNearestHotspot();\n if (nearestHotspot) {\n const newStepIndex = id2index[nearestHotspot];\n setCurrentStepIndex(newStepIndex);\n setOpen(true);\n fireNonCancelableEvent(onStepChange, { step: newStepIndex, reason: 'auto-fallback' });\n }\n }, [annotations, isCurrentHotspotAvailable, currentId, currentStepIndex, id2index, onStepChange, availableHotspots]);\n\n const onDismiss = useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n\n const onOpen = useCallback(\n (stepIndex: number) => {\n setCurrentStepIndex(stepIndex);\n fireNonCancelableEvent(onStepChange, { step: stepIndex, reason: 'open' });\n setOpen(true);\n },\n [onStepChange, setOpen]\n );\n\n const idOfPreviousHotspot = getStepInfo(annotations, currentStepIndex - 1).step?.hotspotId;\n const idOfNextHotspot = getStepInfo(annotations, currentStepIndex + 1).step?.hotspotId;\n const previousHotspotIsAvailable =\n (idOfPreviousHotspot !== undefined && availableHotspots[idOfPreviousHotspot]) ?? false;\n const nextHotspotIsAvailable = (idOfNextHotspot !== undefined && availableHotspots[idOfNextHotspot]) ?? false;\n\n const getContentForId = useCallback(\n (id: string, direction: HotspotProps['direction']) => {\n if (currentTutorial?.completed) {\n return null;\n }\n\n const globalStepIndex = id2index[id];\n if (globalStepIndex === undefined) {\n // This hotspot is not used in the current tutorial.\n return null;\n }\n\n if (!task || !step || !open || id !== currentId) {\n const { task: currentTask, localIndex: currentStepIndex } = getStepInfo(annotations, globalStepIndex);\n return (\n <ClosedAnnotation\n globalStepIndex={globalStepIndex}\n i18nStrings={i18nStrings}\n onOpen={onOpen}\n focusOnRender={id === currentId}\n totalLocalSteps={currentTask ? currentTask.steps.length : 0}\n taskLocalStepIndex={currentStepIndex}\n />\n );\n }\n\n return (\n <OpenAnnotation\n i18nStrings={i18nStrings}\n direction={direction}\n title={i18nStrings.taskTitle(taskIndex, task.title)}\n content={step.content}\n alert={step.warningAlert}\n showPreviousButton={currentStepIndex !== 0}\n showFinishButton={currentStepIndex + 1 === totalStepCount}\n taskLocalStepIndex={localIndex}\n totalLocalSteps={task.steps.length}\n nextButtonEnabled={nextHotspotIsAvailable}\n onNextButtonClick={openNextStep}\n onFinish={onFinish}\n previousButtonEnabled={previousHotspotIsAvailable}\n onPreviousButtonClick={openPreviousStep}\n onDismiss={onDismiss}\n />\n );\n },\n [\n id2index,\n currentTutorial,\n task,\n step,\n open,\n currentId,\n currentStepIndex,\n i18nStrings,\n taskIndex,\n localIndex,\n totalStepCount,\n nextHotspotIsAvailable,\n openNextStep,\n onFinish,\n previousHotspotIsAvailable,\n openPreviousStep,\n onDismiss,\n onOpen,\n annotations,\n ]\n );\n\n const registerHotspot = useCallback(\n (id: string) => {\n if (!id2index || id2index[id] === undefined) {\n // This hotspot is not used in the current tutorial.\n return;\n }\n\n /*\n To ensure that all hotspots are immediately known to all triggered useEffects, we\n need to update the availableHotspotsRef BEFORE the setAvailableHotspots calls, since\n they will be batched and delayed until after the useEffects are run.\n */\n availableHotspotsRef.current = { ...availableHotspotsRef.current, [id]: true } as const;\n\n setAvailableHotspots(availableHotspots => {\n if (availableHotspots[id]) {\n return availableHotspots;\n }\n\n return { ...availableHotspots, [id]: true } as const;\n });\n },\n // We need to react on id2index changes for registering new hotspots when the map changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [id2index]\n );\n\n const unregisterHotspot = useCallback((id: string) => {\n if (!availableHotspotsRef.current[id]) {\n // Prevents unnecessary re-renders.\n return;\n }\n\n /*\n To ensure that all hotspots are immediately known to all triggered useEffects, we\n need to update the availableHotspotsRef BEFORE the setAvailableHotspots calls, since\n they will be batched and delayed until after the useEffects are run.\n */\n availableHotspotsRef.current = removeKey(id, availableHotspotsRef.current);\n\n setAvailableHotspots(availableHotspots => {\n if (!availableHotspots[id]) {\n return availableHotspots;\n }\n\n return removeKey(id, availableHotspots);\n });\n }, []);\n\n const context: HotspotContext = {\n getContentForId,\n registerHotspot,\n unregisterHotspot,\n onStartTutorial,\n onExitTutorial,\n currentStepIndex,\n currentTutorial,\n };\n\n return <hotspotContext.Provider value={context}>{children}</hotspotContext.Provider>;\n}\n\napplyDisplayName(AnnotationContext, 'AnnotationContext');\n\nfunction removeKey<T extends Record<string, unknown>>(key: keyof T, object: T) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [key]: _, ...remainingObject } = object;\n return remainingObject;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/annotation-context/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAA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SAAS,CAAC,EAAE,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAE3E,oBAAoB,CAAC,iBAAiB,CAAC,EAAE;YACvC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,EAAE;gBAC1B,OAAO,iBAAiB,CAAC;aAC1B;YAED,OAAO,SAAS,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAmB;QAC9B,eAAe;QACf,eAAe;QACf,iBAAiB;QACjB,eAAe;QACf,cAAc;QACd,gBAAgB;QAChB,eAAe;KAChB,CAAC;IAEF,OAAO,oBAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAAG,QAAQ,CAA2B,CAAC;AACvF,CAAC;AAED,gBAAgB,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;AAEzD,SAAS,SAAS,CAAoC,GAAY,EAAE,MAAS;IAC3E,6DAA6D;IAC7D,MAAyC,KAAA,MAAM,EAAvC,KAAC,GAAI,EAAE,CAAC,SAAA,EAAK,eAAe,cAA9B,uCAAgC,CAAS,CAAC;IAChD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { HotspotProps } from '../hotspot/interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { ClosedAnnotation } from './annotation/closed-annotation';\nimport { OpenAnnotation } from './annotation/open-annotation';\nimport { HotspotContext, hotspotContext } from './context';\nimport { AnnotationContextProps } from './interfaces';\nimport { getStepInfo } from './utils';\n\nexport { AnnotationContextProps };\n\n// constant empty array to keep hook dependency stable\nconst emptyTasks: ReadonlyArray<AnnotationContextProps.Task> = [];\n\nexport default function AnnotationContext({\n currentTutorial,\n children,\n onStepChange,\n onFinish: onFinishHandler,\n onStartTutorial,\n onExitTutorial,\n i18nStrings,\n}: AnnotationContextProps): JSX.Element {\n useBaseComponent('AnnotationContext');\n\n const [open, setOpen] = useState(true);\n\n const [currentStepIndex, setCurrentStepIndex] = useState(0);\n useEffect(() => {\n // When a tutorial is started, we reset the progress to the first step.\n setCurrentStepIndex(0);\n setOpen(true);\n }, [currentTutorial, setOpen]);\n\n const [availableHotspots, setAvailableHotspots] = useState<Record<string, true | undefined>>({});\n // availableHotspots is mirrored in this ref to prevent endless loops\n // in between registerHotspot and unregisterHotspot callbacks.\n const availableHotspotsRef = useRef<Record<string, true | undefined>>(availableHotspots);\n\n const annotations = currentTutorial ? currentTutorial.tasks : emptyTasks;\n const { task, step, localIndex, taskIndex } = getStepInfo(annotations, currentStepIndex);\n const currentId = step?.hotspotId;\n const totalStepCount = annotations.map(a => a.steps.length).reduce((a, b) => a + b, 0);\n\n const id2index = useMemo(() => {\n const mapping: Record<string, number> = {};\n\n let counter = 0;\n for (const annotation of annotations) {\n for (const step of annotation.steps) {\n if (mapping[step.hotspotId] === undefined) {\n mapping[step.hotspotId] = counter;\n }\n counter++;\n }\n }\n\n return mapping;\n }, [annotations]);\n\n const openNextStep = useCallback(() => {\n const newStepIndex = Math.min(currentStepIndex + 1, totalStepCount);\n setCurrentStepIndex(newStepIndex);\n fireNonCancelableEvent(onStepChange, { step: newStepIndex, reason: 'next' });\n }, [currentStepIndex, onStepChange, totalStepCount]);\n\n const openPreviousStep = useCallback(() => {\n const newStepIndex = Math.max(currentStepIndex - 1, 0);\n setCurrentStepIndex(newStepIndex);\n fireNonCancelableEvent(onStepChange, { step: newStepIndex, reason: 'previous' });\n }, [onStepChange, currentStepIndex]);\n\n const onFinish = useCallback(() => fireNonCancelableEvent(onFinishHandler), [onFinishHandler]);\n\n /**\n * If the currently open hotspot disappears from the page (e.g. because of a react-router navigation),\n * this Effect detects the nearest available hotspot and changes to it. This allows us to e.g. automatically\n * advance to the first step on the new page (or the last step on the previous page, in case the user\n * navigates back).\n */\n const isCurrentHotspotAvailable = currentId ? availableHotspots[currentId] : null;\n useEffect(() => {\n if (!currentId || availableHotspotsRef.current[currentId]) {\n return;\n }\n\n const findNearestHotspot = () => {\n let nearestHotspot: string | undefined = undefined;\n let nearestDistance = Infinity;\n for (const hotspotId of Object.keys(availableHotspotsRef.current)) {\n const distanceFromCurrentHotspot = Math.abs(id2index[hotspotId] - currentStepIndex);\n if (distanceFromCurrentHotspot < nearestDistance) {\n nearestDistance = distanceFromCurrentHotspot;\n nearestHotspot = hotspotId;\n }\n }\n return nearestHotspot;\n };\n\n const nearestHotspot = findNearestHotspot();\n if (nearestHotspot) {\n const newStepIndex = id2index[nearestHotspot];\n setCurrentStepIndex(newStepIndex);\n setOpen(true);\n fireNonCancelableEvent(onStepChange, { step: newStepIndex, reason: 'auto-fallback' });\n }\n }, [annotations, isCurrentHotspotAvailable, currentId, currentStepIndex, id2index, onStepChange, availableHotspots]);\n\n const onDismiss = useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n\n const onOpen = useCallback(\n (stepIndex: number) => {\n setCurrentStepIndex(stepIndex);\n fireNonCancelableEvent(onStepChange, { step: stepIndex, reason: 'open' });\n setOpen(true);\n },\n [onStepChange, setOpen]\n );\n\n const idOfPreviousHotspot = getStepInfo(annotations, currentStepIndex - 1).step?.hotspotId;\n const idOfNextHotspot = getStepInfo(annotations, currentStepIndex + 1).step?.hotspotId;\n const previousHotspotIsAvailable =\n (idOfPreviousHotspot !== undefined && availableHotspots[idOfPreviousHotspot]) ?? false;\n const nextHotspotIsAvailable = (idOfNextHotspot !== undefined && availableHotspots[idOfNextHotspot]) ?? false;\n\n const getContentForId = useCallback(\n (id: string, direction: HotspotProps['direction']) => {\n if (currentTutorial?.completed) {\n return null;\n }\n\n const globalStepIndex = id2index[id];\n if (globalStepIndex === undefined) {\n // This hotspot is not used in the current tutorial.\n return null;\n }\n\n if (!task || !step || !open || id !== currentId) {\n const { task: currentTask, localIndex: currentStepIndex } = getStepInfo(annotations, globalStepIndex);\n return (\n <ClosedAnnotation\n globalStepIndex={globalStepIndex}\n i18nStrings={i18nStrings}\n onOpen={onOpen}\n focusOnRender={id === currentId}\n totalLocalSteps={currentTask ? currentTask.steps.length : 0}\n taskLocalStepIndex={currentStepIndex}\n />\n );\n }\n\n return (\n <OpenAnnotation\n i18nStrings={i18nStrings}\n direction={direction}\n title={i18nStrings.taskTitle(taskIndex, task.title)}\n content={step.content}\n alert={step.warningAlert}\n showPreviousButton={currentStepIndex !== 0}\n showFinishButton={currentStepIndex + 1 === totalStepCount}\n taskLocalStepIndex={localIndex}\n totalLocalSteps={task.steps.length}\n nextButtonEnabled={nextHotspotIsAvailable}\n onNextButtonClick={openNextStep}\n onFinish={onFinish}\n previousButtonEnabled={previousHotspotIsAvailable}\n onPreviousButtonClick={openPreviousStep}\n onDismiss={onDismiss}\n />\n );\n },\n [\n id2index,\n currentTutorial,\n task,\n step,\n open,\n currentId,\n currentStepIndex,\n i18nStrings,\n taskIndex,\n localIndex,\n totalStepCount,\n nextHotspotIsAvailable,\n openNextStep,\n onFinish,\n previousHotspotIsAvailable,\n openPreviousStep,\n onDismiss,\n onOpen,\n annotations,\n ]\n );\n\n const registerHotspot = useCallback(\n (id: string) => {\n if (!id2index || id2index[id] === undefined) {\n // This hotspot is not used in the current tutorial.\n return;\n }\n\n /*\n To ensure that all hotspots are immediately known to all triggered useEffects, we\n need to update the availableHotspotsRef BEFORE the setAvailableHotspots calls, since\n they will be batched and delayed until after the useEffects are run.\n */\n availableHotspotsRef.current = { ...availableHotspotsRef.current, [id]: true } as const;\n\n setAvailableHotspots(availableHotspots => {\n if (availableHotspots[id]) {\n return availableHotspots;\n }\n\n return { ...availableHotspots, [id]: true } as const;\n });\n },\n // We need to react on id2index changes for registering new hotspots when the map changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [id2index]\n );\n\n const unregisterHotspot = useCallback((id: string) => {\n if (!availableHotspotsRef.current[id]) {\n // Prevents unnecessary re-renders.\n return;\n }\n\n /*\n To ensure that all hotspots are immediately known to all triggered useEffects, we\n need to update the availableHotspotsRef BEFORE the setAvailableHotspots calls, since\n they will be batched and delayed until after the useEffects are run.\n */\n availableHotspotsRef.current = removeKey(id, availableHotspotsRef.current);\n\n setAvailableHotspots(availableHotspots => {\n if (!availableHotspots[id]) {\n return availableHotspots;\n }\n\n return removeKey(id, availableHotspots);\n });\n }, []);\n\n const context: HotspotContext = {\n getContentForId,\n registerHotspot,\n unregisterHotspot,\n onStartTutorial,\n onExitTutorial,\n currentStepIndex,\n currentTutorial,\n };\n\n return <hotspotContext.Provider value={context}>{children}</hotspotContext.Provider>;\n}\n\napplyDisplayName(AnnotationContext, 'AnnotationContext');\n\nfunction removeKey<T extends Record<string, unknown>>(key: keyof T, object: T) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [key]: _, ...remainingObject } = object;\n return remainingObject;\n}\n"]}
@@ -28,7 +28,7 @@ function RuntimeDrawerWrapper({ mountContent, unmountContent, id }) {
28
28
  var _a;
29
29
  (_a = visibilityChangeCallback.current) === null || _a === void 0 ? void 0 : _a.call(visibilityChangeCallback, isVisible);
30
30
  }, [isVisible]);
31
- return React.createElement("div", { ref: ref, className: styles['runtime-content-wrapper'] });
31
+ return React.createElement("div", { ref: ref, className: styles['runtime-content-wrapper'], "data-awsui-runtime-drawer-root-id": id });
32
32
  }
33
33
  const mapRuntimeConfigToDrawer = (runtimeConfig) => {
34
34
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app-layout/runtime-drawer/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAA6B,MAAM,uB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IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA,CAAC;KAClE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef } from 'react';\n\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../../internal/events';\nimport {\n DrawerConfig as RuntimeDrawerConfig,\n DrawerStateChangeParams,\n} from '../../internal/plugins/controllers/drawers';\nimport { sortByPriority } from '../../internal/plugins/helpers/utils';\nimport { AppLayoutProps } from '../interfaces';\nimport { ActiveDrawersContext } from '../utils/visibility-context';\n\nimport styles from './styles.css.js';\n\nexport interface RuntimeDrawer extends AppLayoutProps.Drawer {\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n}\n\nexport interface DrawersLayout {\n global: Array<RuntimeDrawer>;\n localBefore: Array<RuntimeDrawer>;\n localAfter: Array<RuntimeDrawer>;\n}\n\ntype VisibilityCallback = (isVisible: boolean) => void;\n\ninterface RuntimeContentWrapperProps {\n id?: string;\n mountContent: RuntimeDrawerConfig['mountContent'];\n unmountContent: RuntimeDrawerConfig['unmountContent'];\n}\n\nfunction RuntimeDrawerWrapper({ mountContent, unmountContent, id }: RuntimeContentWrapperProps) {\n const ref = useRef<HTMLDivElement>(null);\n const visibilityChangeCallback = useRef<VisibilityCallback | null>(null);\n const activeDrawersIds = useContext(ActiveDrawersContext);\n const isVisible = !!id && activeDrawersIds.includes(id);\n\n useEffect(() => {\n const container = ref.current!;\n mountContent(container, {\n onVisibilityChange: cb => {\n visibilityChangeCallback.current = cb;\n },\n });\n return () => {\n unmountContent(container);\n visibilityChangeCallback.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n visibilityChangeCallback.current?.(isVisible);\n }, [isVisible]);\n\n return <div ref={ref} className={styles['runtime-content-wrapper']}></div>;\n}\n\nconst mapRuntimeConfigToDrawer = (\n runtimeConfig: RuntimeDrawerConfig\n): AppLayoutProps.Drawer & {\n orderPriority?: number;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n} => {\n const { mountContent, unmountContent, trigger, ...runtimeDrawer } = runtimeConfig;\n\n return {\n ...runtimeDrawer,\n ariaLabels: { drawerName: runtimeDrawer.ariaLabels.content ?? '', ...runtimeDrawer.ariaLabels },\n trigger: trigger\n ? {\n iconSvg: (\n // eslint-disable-next-line react/no-danger\n <span dangerouslySetInnerHTML={{ __html: trigger.iconSvg }} />\n ),\n }\n : undefined,\n content: (\n <RuntimeDrawerWrapper\n key={runtimeDrawer.id}\n mountContent={mountContent}\n unmountContent={unmountContent}\n id={runtimeDrawer.id}\n />\n ),\n onResize: event => {\n fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });\n },\n };\n};\n\nexport function convertRuntimeDrawers(\n localDrawers: Array<RuntimeDrawerConfig>,\n globalDrawers: Array<RuntimeDrawerConfig>\n): DrawersLayout {\n const converted = localDrawers.map(mapRuntimeConfigToDrawer);\n const sorted = sortByPriority(converted);\n return {\n global: sortByPriority(globalDrawers.map(mapRuntimeConfigToDrawer)),\n localBefore: sorted.filter(item => (item.orderPriority ?? 0) > 0),\n localAfter: sorted.filter(item => (item.orderPriority ?? 0) <= 0),\n };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app-layout/runtime-drawer/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAA6B,MAAM,uBAAuB,CAAC;AAK1F,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B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EAAA,CAAC;KAClE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef } from 'react';\n\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../../internal/events';\nimport {\n DrawerConfig as RuntimeDrawerConfig,\n DrawerStateChangeParams,\n} from '../../internal/plugins/controllers/drawers';\nimport { sortByPriority } from '../../internal/plugins/helpers/utils';\nimport { AppLayoutProps } from '../interfaces';\nimport { ActiveDrawersContext } from '../utils/visibility-context';\n\nimport styles from './styles.css.js';\n\nexport interface RuntimeDrawer extends AppLayoutProps.Drawer {\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n}\n\nexport interface DrawersLayout {\n global: Array<RuntimeDrawer>;\n localBefore: Array<RuntimeDrawer>;\n localAfter: Array<RuntimeDrawer>;\n}\n\ntype VisibilityCallback = (isVisible: boolean) => void;\n\ninterface RuntimeContentWrapperProps {\n id?: string;\n mountContent: RuntimeDrawerConfig['mountContent'];\n unmountContent: RuntimeDrawerConfig['unmountContent'];\n}\n\nfunction RuntimeDrawerWrapper({ mountContent, unmountContent, id }: RuntimeContentWrapperProps) {\n const ref = useRef<HTMLDivElement>(null);\n const visibilityChangeCallback = useRef<VisibilityCallback | null>(null);\n const activeDrawersIds = useContext(ActiveDrawersContext);\n const isVisible = !!id && activeDrawersIds.includes(id);\n\n useEffect(() => {\n const container = ref.current!;\n mountContent(container, {\n onVisibilityChange: cb => {\n visibilityChangeCallback.current = cb;\n },\n });\n return () => {\n unmountContent(container);\n visibilityChangeCallback.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n visibilityChangeCallback.current?.(isVisible);\n }, [isVisible]);\n\n return <div ref={ref} className={styles['runtime-content-wrapper']} data-awsui-runtime-drawer-root-id={id}></div>;\n}\n\nconst mapRuntimeConfigToDrawer = (\n runtimeConfig: RuntimeDrawerConfig\n): AppLayoutProps.Drawer & {\n orderPriority?: number;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n} => {\n const { mountContent, unmountContent, trigger, ...runtimeDrawer } = runtimeConfig;\n\n return {\n ...runtimeDrawer,\n ariaLabels: { drawerName: runtimeDrawer.ariaLabels.content ?? '', ...runtimeDrawer.ariaLabels },\n trigger: trigger\n ? {\n iconSvg: (\n // eslint-disable-next-line react/no-danger\n <span dangerouslySetInnerHTML={{ __html: trigger.iconSvg }} />\n ),\n }\n : undefined,\n content: (\n <RuntimeDrawerWrapper\n key={runtimeDrawer.id}\n mountContent={mountContent}\n unmountContent={unmountContent}\n id={runtimeDrawer.id}\n />\n ),\n onResize: event => {\n fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });\n },\n };\n};\n\nexport function convertRuntimeDrawers(\n localDrawers: Array<RuntimeDrawerConfig>,\n globalDrawers: Array<RuntimeDrawerConfig>\n): DrawersLayout {\n const converted = localDrawers.map(mapRuntimeConfigToDrawer);\n const sorted = sortByPriority(converted);\n return {\n global: sortByPriority(globalDrawers.map(mapRuntimeConfigToDrawer)),\n localBefore: sorted.filter(item => (item.orderPriority ?? 0) > 0),\n localAfter: sorted.filter(item => (item.orderPriority ?? 0) <= 0),\n };\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { RefObject } from 'react';
2
+ import { DrawerConfig } from '../../internal/plugins/controllers/drawers';
3
+ export declare const useRuntimeDrawerContext: ({ rootRef }: {
4
+ rootRef: RefObject<HTMLElement>;
5
+ }) => DrawerConfig | null;
6
+ //# sourceMappingURL=use-runtime-drawer-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-runtime-drawer-context.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/runtime-drawer/use-runtime-drawer-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAKvD,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAE1E,eAAO,MAAM,uBAAuB;aAA4B,UAAU,WAAW,CAAC;yBAyBrF,CAAC"}
@@ -0,0 +1,29 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useEffect, useState } from 'react';
4
+ import { findUpUntil } from '@cloudscape-design/component-toolkit/dom';
5
+ import { awsuiPluginsInternal } from '../../internal/plugins/api';
6
+ export const useRuntimeDrawerContext = ({ rootRef }) => {
7
+ const [drawerContext, setDrawerContext] = useState(null);
8
+ useEffect(() => {
9
+ var _a, _b;
10
+ // Determine if the hook is inside a runtime drawer.
11
+ // There’s no other reliable way to check this, since runtime drawers are separate applications rendered into specific DOM nodes.
12
+ if (!(rootRef === null || rootRef === void 0 ? void 0 : rootRef.current)) {
13
+ return;
14
+ }
15
+ const runtimeDrawerWrapper = findUpUntil(rootRef === null || rootRef === void 0 ? void 0 : rootRef.current, node => { var _a; return !!((_a = node === null || node === void 0 ? void 0 : node.dataset) === null || _a === void 0 ? void 0 : _a.awsuiRuntimeDrawerRootId); });
16
+ const drawerId = (_a = runtimeDrawerWrapper === null || runtimeDrawerWrapper === void 0 ? void 0 : runtimeDrawerWrapper.dataset) === null || _a === void 0 ? void 0 : _a.awsuiRuntimeDrawerRootId;
17
+ if (!drawerId) {
18
+ return;
19
+ }
20
+ const drawers = awsuiPluginsInternal.appLayout.getDrawersState();
21
+ setDrawerContext((_b = drawers === null || drawers === void 0 ? void 0 : drawers.find(drawer => drawer.id === drawerId)) !== null && _b !== void 0 ? _b : null);
22
+ return awsuiPluginsInternal.appLayout.onDrawersUpdated(drawers => {
23
+ var _a;
24
+ setDrawerContext((_a = drawers === null || drawers === void 0 ? void 0 : drawers.find(drawer => drawer.id === drawerId)) !== null && _a !== void 0 ? _a : null);
25
+ });
26
+ }, [rootRef]);
27
+ return drawerContext;
28
+ };
29
+ //# sourceMappingURL=use-runtime-drawer-context.js.map
@@ -0,0 +1 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CAAC;QAE1E,OAAO,oBAAoB,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE;;YAC/D,gBAAgB,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,mCAAI,IAAI,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { RefObject, useEffect, useState } from 'react';\n\nimport { findUpUntil } from '@cloudscape-design/component-toolkit/dom';\n\nimport { awsuiPluginsInternal } from '../../internal/plugins/api';\nimport { DrawerConfig } from '../../internal/plugins/controllers/drawers';\n\nexport const useRuntimeDrawerContext = ({ rootRef }: { rootRef: RefObject<HTMLElement> }) => {\n const [drawerContext, setDrawerContext] = useState<DrawerConfig | null>(null);\n\n useEffect(() => {\n // Determine if the hook is inside a runtime drawer.\n // There’s no other reliable way to check this, since runtime drawers are separate applications rendered into specific DOM nodes.\n if (!rootRef?.current) {\n return;\n }\n const runtimeDrawerWrapper = findUpUntil(rootRef?.current, node => !!node?.dataset?.awsuiRuntimeDrawerRootId);\n const drawerId = runtimeDrawerWrapper?.dataset?.awsuiRuntimeDrawerRootId;\n\n if (!drawerId) {\n return;\n }\n\n const drawers = awsuiPluginsInternal.appLayout.getDrawersState();\n setDrawerContext(drawers?.find(drawer => drawer.id === drawerId) ?? null);\n\n return awsuiPluginsInternal.appLayout.onDrawersUpdated(drawers => {\n setDrawerContext(drawers?.find(drawer => drawer.id === drawerId) ?? null);\n });\n }, [rootRef]);\n\n return drawerContext;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"global-drawer.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-drawer.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAOnE,UAAU,wCAAwC;IAChD,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,kBAAkB,EAAE,cAAc,GAAG,SAAS,CAAC;CAChD;AAED,iBAAS,mCAAmC,CAAC,EAC3C,kBAAkB,EAClB,IAAI,EACJ,kBAAkB,GACnB,EAAE,wCAAwC,eA4H1C;AAED,eAAe,mCAAmC,CAAC"}
1
+ {"version":3,"file":"global-drawer.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-drawer.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAOnE,UAAU,wCAAwC;IAChD,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,kBAAkB,EAAE,cAAc,GAAG,SAAS,CAAC;CAChD;AAED,iBAAS,mCAAmC,CAAC,EAC3C,kBAAkB,EAClB,IAAI,EACJ,kBAAkB,GACnB,EAAE,wCAAwC,eA6H1C;AAED,eAAe,mCAAmC,CAAC"}
@@ -65,7 +65,7 @@ function AppLayoutGlobalDrawerImplementation({ appLayoutInternals, show, activeG
65
65
  React.createElement("div", { className: clsx(styles['drawer-close-button']) },
66
66
  React.createElement(InternalButton, { ariaLabel: computedAriaLabels.closeButton, className: clsx({
67
67
  [testutilStyles['active-drawer-close-button']]: activeDrawerId,
68
- }), formAction: "none", iconName: isMobile ? 'close' : 'angle-right', onClick: () => onActiveGlobalDrawersChange(activeDrawerId, { initiatedByUserAction: true }), ref: refs === null || refs === void 0 ? void 0 : refs.close, variant: "icon" })),
68
+ }), formAction: "none", iconName: isMobile ? 'close' : 'angle-right', onClick: () => onActiveGlobalDrawersChange(activeDrawerId, { initiatedByUserAction: true }), ref: refs === null || refs === void 0 ? void 0 : refs.close, variant: "icon", analyticsAction: "close" })),
69
69
  React.createElement("div", { className: styles['drawer-content'], style: { blockSize: drawerHeight } }, activeGlobalDrawer === null || activeGlobalDrawer === void 0 ? void 0 : activeGlobalDrawer.content))));
70
70
  }));
71
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"global-drawer.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-drawer.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,cAAc,MAAM,mDAAmD,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,YAAY,MAAM,4BAA4B,CAAC;AACtD,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC,SAAS,mCAAmC,CAAC,EAC3C,kBAAkB,EAClB,IAAI,EACJ,kBAAkB,GACuB;;IACzC,MAAM,EACJ,UAAU,EACV,yBAAyB,EACzB,QAAQ,EACR,SAAS,EACT,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EACf,gBAAgB,GACjB,GAAG,kBAAkB,CAAC;IACvB,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,MAAA,kBAAk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AS,EAAE,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAC,iBAC9E,mCAAmC,cAAc,EAAE;gBAEhE,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;oBACjD,oBAAC,cAAc,IACb,SAAS,EAAE,kBAAkB,CAAC,WAAW,EACzC,SAAS,EAAE,IAAI,CAAC;4BACd,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC,EAAE,cAAc;yBAC/D,CAAC,EACF,UAAU,EAAC,MAAM,EACjB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,2BAA2B,CAAC,cAAc,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,EAC3F,GAAG,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,EAChB,OAAO,EAAC,MAAM,GACd,CACE;gBACN,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,IACzE,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,OAAO,CACxB,CACF,CACA,CACT,CAAC;IACJ,CAAC,CACU,CACd,CAAC;AACJ,CAAC;AAED,eAAe,mCAAmC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport { Transition } from 'react-transition-group';\nimport clsx from 'clsx';\n\nimport { InternalButton } from '../../../button/internal';\nimport PanelResizeHandle from '../../../internal/components/panel-resize-handle';\nimport customCssProps from '../../../internal/generated/custom-css-properties';\nimport { getLimitedValue } from '../../../split-panel/utils/size-utils';\nimport { getDrawerStyles } from '../compute-layout';\nimport { AppLayoutInternals, InternalDrawer } from '../interfaces';\nimport { useResize } from './use-resize';\n\nimport sharedStyles from '../../resize/styles.css.js';\nimport testutilStyles from '../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface AppLayoutGlobalDrawerImplementationProps {\n appLayoutInternals: AppLayoutInternals;\n show: boolean;\n activeGlobalDrawer: InternalDrawer | undefined;\n}\n\nfunction AppLayoutGlobalDrawerImplementation({\n appLayoutInternals,\n show,\n activeGlobalDrawer,\n}: AppLayoutGlobalDrawerImplementationProps) {\n const {\n ariaLabels,\n globalDrawersFocusControl,\n isMobile,\n placement,\n onActiveGlobalDrawersChange,\n onActiveDrawerResize,\n minGlobalDrawersSizes,\n maxGlobalDrawersSizes,\n activeGlobalDrawersSizes,\n verticalOffsets,\n drawersOpenQueue,\n } = appLayoutInternals;\n const drawerRef = useRef<HTMLDivElement>(null);\n const activeDrawerId = activeGlobalDrawer?.id ?? '';\n\n const computedAriaLabels = {\n closeButton: activeGlobalDrawer ? activeGlobalDrawer.ariaLabels?.closeButton : ariaLabels?.toolsClose,\n content: activeGlobalDrawer ? activeGlobalDrawer.ariaLabels?.drawerName : ariaLabels?.tools,\n };\n\n const { drawerTopOffset, drawerHeight } = getDrawerStyles(verticalOffsets, isMobile, placement);\n const activeDrawerSize = (activeDrawerId ? activeGlobalDrawersSizes[activeDrawerId] : 0) ?? 0;\n const minDrawerSize = (activeDrawerId ? minGlobalDrawersSizes[activeDrawerId] : 0) ?? 0;\n const maxDrawerSize = (activeDrawerId ? maxGlobalDrawersSizes[activeDrawerId] : 0) ?? 0;\n const refs = globalDrawersFocusControl.refs[activeDrawerId];\n const resizeProps = useResize({\n currentWidth: activeDrawerSize,\n minWidth: minDrawerSize,\n maxWidth: maxDrawerSize,\n panelRef: drawerRef,\n handleRef: refs?.slider,\n onResize: size => onActiveDrawerResize({ id: activeDrawerId!, size }),\n });\n const size = getLimitedValue(minDrawerSize, activeDrawerSize, maxDrawerSize);\n const lastOpenedDrawerId = drawersOpenQueue.length ? drawersOpenQueue[0] : null;\n const hasTriggerButton = !!activeGlobalDrawer?.trigger;\n const animationDisabled = activeGlobalDrawer?.defaultActive && !drawersOpenQueue.includes(activeGlobalDrawer.id);\n\n return (\n <Transition nodeRef={drawerRef} in={show} appear={show} timeout={0}>\n {state => {\n return (\n <aside\n id={activeDrawerId}\n aria-hidden={!show}\n aria-label={computedAriaLabels.content}\n className={clsx(\n styles.drawer,\n styles['drawer-global'],\n styles[state],\n !animationDisabled && sharedStyles['with-motion-horizontal'],\n {\n [styles['drawer-hidden']]: !show,\n [styles['last-opened']]: lastOpenedDrawerId === activeDrawerId,\n [testutilStyles['active-drawer']]: show,\n }\n )}\n ref={drawerRef}\n onBlur={e => {\n // Drawers with trigger buttons follow this restore focus logic:\n // If a previously focused element exists, restore focus on it; otherwise, focus on the associated trigger button.\n // This function resets the previously focused element.\n // If the drawer has no trigger button and loses focus on the previously focused element, it defaults to document.body,\n // which ideally should never happen.\n if (!hasTriggerButton) {\n return;\n }\n\n if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {\n globalDrawersFocusControl.loseFocus();\n }\n }}\n style={{\n blockSize: drawerHeight,\n insetBlockStart: drawerTopOffset,\n ...(!isMobile && {\n [customCssProps.drawerSize]: `${['entering', 'entered'].includes(state) ? size : 0}px`,\n }),\n }}\n data-testid={`awsui-app-layout-drawer-${activeDrawerId}`}\n >\n {!isMobile && activeGlobalDrawer?.resizable && (\n <div className={styles['drawer-slider']}>\n <PanelResizeHandle\n ref={refs?.slider}\n position=\"side\"\n className={testutilStyles['drawers-slider']}\n ariaLabel={activeGlobalDrawer?.ariaLabels?.resizeHandle}\n tooltipText={activeGlobalDrawer?.ariaLabels?.resizeHandleTooltipText}\n ariaValuenow={resizeProps.relativeSize}\n onKeyDown={resizeProps.onKeyDown}\n onDirectionClick={resizeProps.onDirectionClick}\n onPointerDown={resizeProps.onPointerDown}\n />\n </div>\n )}\n <div\n className={clsx(styles['drawer-content-container'], sharedStyles['with-motion-horizontal'])}\n data-testid={`awsui-app-layout-drawer-content-${activeDrawerId}`}\n >\n <div className={clsx(styles['drawer-close-button'])}>\n <InternalButton\n ariaLabel={computedAriaLabels.closeButton}\n className={clsx({\n [testutilStyles['active-drawer-close-button']]: activeDrawerId,\n })}\n formAction=\"none\"\n iconName={isMobile ? 'close' : 'angle-right'}\n onClick={() => onActiveGlobalDrawersChange(activeDrawerId, { initiatedByUserAction: true })}\n ref={refs?.close}\n variant=\"icon\"\n />\n </div>\n <div className={styles['drawer-content']} style={{ blockSize: drawerHeight }}>\n {activeGlobalDrawer?.content}\n </div>\n </div>\n </aside>\n );\n }}\n </Transition>\n );\n}\n\nexport default AppLayoutGlobalDrawerImplementation;\n"]}
1
+ {"version":3,"file":"global-drawer.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-drawer.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,cAAc,MAAM,mDAAmD,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,YAAY,MAAM,4BAA4B,CAAC;AACtD,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC,SAAS,mCAAmC,CAAC,EAC3C,kBAAkB,EAClB,IAAI,EACJ,kBAAkB,GACuB;;IACzC,MAAM,EACJ,UAAU,EACV,yBAAyB,EACzB,QAAQ,EACR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uBAAlB,kBAAkB,CAAE,UAAU,0CAAE,uBAAuB,EACpE,YAAY,EAAE,WAAW,CAAC,YAAY,EACtC,SAAS,EAAE,WAAW,CAAC,SAAS,EAChC,gBAAgB,EAAE,WAAW,CAAC,gBAAgB,EAC9C,aAAa,EAAE,WAAW,CAAC,aAAa,GACxC,CACE,CACP;YACD,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAC,iBAC9E,mCAAmC,cAAc,EAAE;gBAEhE,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;oBACjD,oBAAC,cAAc,IACb,SAAS,EAAE,kBAAkB,CAAC,WAAW,EACzC,SAAS,EAAE,IAAI,CAAC;4BACd,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC,EAAE,cAAc;yBAC/D,CAAC,EACF,UAAU,EAAC,MAAM,EACjB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,2BAA2B,CAAC,cAAc,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,EAC3F,GAAG,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,EAChB,OAAO,EAAC,MAAM,EACd,eAAe,EAAC,OAAO,GACvB,CACE;gBACN,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,IACzE,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,OAAO,CACxB,CACF,CACA,CACT,CAAC;IACJ,CAAC,CACU,CACd,CAAC;AACJ,CAAC;AAED,eAAe,mCAAmC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport { Transition } from 'react-transition-group';\nimport clsx from 'clsx';\n\nimport { InternalButton } from '../../../button/internal';\nimport PanelResizeHandle from '../../../internal/components/panel-resize-handle';\nimport customCssProps from '../../../internal/generated/custom-css-properties';\nimport { getLimitedValue } from '../../../split-panel/utils/size-utils';\nimport { getDrawerStyles } from '../compute-layout';\nimport { AppLayoutInternals, InternalDrawer } from '../interfaces';\nimport { useResize } from './use-resize';\n\nimport sharedStyles from '../../resize/styles.css.js';\nimport testutilStyles from '../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface AppLayoutGlobalDrawerImplementationProps {\n appLayoutInternals: AppLayoutInternals;\n show: boolean;\n activeGlobalDrawer: InternalDrawer | undefined;\n}\n\nfunction AppLayoutGlobalDrawerImplementation({\n appLayoutInternals,\n show,\n activeGlobalDrawer,\n}: AppLayoutGlobalDrawerImplementationProps) {\n const {\n ariaLabels,\n globalDrawersFocusControl,\n isMobile,\n placement,\n onActiveGlobalDrawersChange,\n onActiveDrawerResize,\n minGlobalDrawersSizes,\n maxGlobalDrawersSizes,\n activeGlobalDrawersSizes,\n verticalOffsets,\n drawersOpenQueue,\n } = appLayoutInternals;\n const drawerRef = useRef<HTMLDivElement>(null);\n const activeDrawerId = activeGlobalDrawer?.id ?? '';\n\n const computedAriaLabels = {\n closeButton: activeGlobalDrawer ? activeGlobalDrawer.ariaLabels?.closeButton : ariaLabels?.toolsClose,\n content: activeGlobalDrawer ? activeGlobalDrawer.ariaLabels?.drawerName : ariaLabels?.tools,\n };\n\n const { drawerTopOffset, drawerHeight } = getDrawerStyles(verticalOffsets, isMobile, placement);\n const activeDrawerSize = (activeDrawerId ? activeGlobalDrawersSizes[activeDrawerId] : 0) ?? 0;\n const minDrawerSize = (activeDrawerId ? minGlobalDrawersSizes[activeDrawerId] : 0) ?? 0;\n const maxDrawerSize = (activeDrawerId ? maxGlobalDrawersSizes[activeDrawerId] : 0) ?? 0;\n const refs = globalDrawersFocusControl.refs[activeDrawerId];\n const resizeProps = useResize({\n currentWidth: activeDrawerSize,\n minWidth: minDrawerSize,\n maxWidth: maxDrawerSize,\n panelRef: drawerRef,\n handleRef: refs?.slider,\n onResize: size => onActiveDrawerResize({ id: activeDrawerId!, size }),\n });\n const size = getLimitedValue(minDrawerSize, activeDrawerSize, maxDrawerSize);\n const lastOpenedDrawerId = drawersOpenQueue.length ? drawersOpenQueue[0] : null;\n const hasTriggerButton = !!activeGlobalDrawer?.trigger;\n const animationDisabled = activeGlobalDrawer?.defaultActive && !drawersOpenQueue.includes(activeGlobalDrawer.id);\n\n return (\n <Transition nodeRef={drawerRef} in={show} appear={show} timeout={0}>\n {state => {\n return (\n <aside\n id={activeDrawerId}\n aria-hidden={!show}\n aria-label={computedAriaLabels.content}\n className={clsx(\n styles.drawer,\n styles['drawer-global'],\n styles[state],\n !animationDisabled && sharedStyles['with-motion-horizontal'],\n {\n [styles['drawer-hidden']]: !show,\n [styles['last-opened']]: lastOpenedDrawerId === activeDrawerId,\n [testutilStyles['active-drawer']]: show,\n }\n )}\n ref={drawerRef}\n onBlur={e => {\n // Drawers with trigger buttons follow this restore focus logic:\n // If a previously focused element exists, restore focus on it; otherwise, focus on the associated trigger button.\n // This function resets the previously focused element.\n // If the drawer has no trigger button and loses focus on the previously focused element, it defaults to document.body,\n // which ideally should never happen.\n if (!hasTriggerButton) {\n return;\n }\n\n if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {\n globalDrawersFocusControl.loseFocus();\n }\n }}\n style={{\n blockSize: drawerHeight,\n insetBlockStart: drawerTopOffset,\n ...(!isMobile && {\n [customCssProps.drawerSize]: `${['entering', 'entered'].includes(state) ? size : 0}px`,\n }),\n }}\n data-testid={`awsui-app-layout-drawer-${activeDrawerId}`}\n >\n {!isMobile && activeGlobalDrawer?.resizable && (\n <div className={styles['drawer-slider']}>\n <PanelResizeHandle\n ref={refs?.slider}\n position=\"side\"\n className={testutilStyles['drawers-slider']}\n ariaLabel={activeGlobalDrawer?.ariaLabels?.resizeHandle}\n tooltipText={activeGlobalDrawer?.ariaLabels?.resizeHandleTooltipText}\n ariaValuenow={resizeProps.relativeSize}\n onKeyDown={resizeProps.onKeyDown}\n onDirectionClick={resizeProps.onDirectionClick}\n onPointerDown={resizeProps.onPointerDown}\n />\n </div>\n )}\n <div\n className={clsx(styles['drawer-content-container'], sharedStyles['with-motion-horizontal'])}\n data-testid={`awsui-app-layout-drawer-content-${activeDrawerId}`}\n >\n <div className={clsx(styles['drawer-close-button'])}>\n <InternalButton\n ariaLabel={computedAriaLabels.closeButton}\n className={clsx({\n [testutilStyles['active-drawer-close-button']]: activeDrawerId,\n })}\n formAction=\"none\"\n iconName={isMobile ? 'close' : 'angle-right'}\n onClick={() => onActiveGlobalDrawersChange(activeDrawerId, { initiatedByUserAction: true })}\n ref={refs?.close}\n variant=\"icon\"\n analyticsAction=\"close\"\n />\n </div>\n <div className={styles['drawer-content']} style={{ blockSize: drawerHeight }}>\n {activeGlobalDrawer?.content}\n </div>\n </div>\n </aside>\n );\n }}\n </Transition>\n );\n}\n\nexport default AppLayoutGlobalDrawerImplementation;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"local-drawer.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/local-drawer.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOnD,UAAU,kCAAkC;IAC1C,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;AAED,wBAAgB,6BAA6B,CAAC,EAAE,kBAAkB,EAAE,EAAE,kCAAkC,eA2HvG;AAED,eAAO,MAAM,+BAA+B,qGAA2D,CAAC"}
1
+ {"version":3,"file":"local-drawer.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/local-drawer.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOnD,UAAU,kCAAkC;IAC1C,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;AAED,wBAAgB,6BAA6B,CAAC,EAAE,kBAAkB,EAAE,EAAE,kCAAkC,eA4HvG;AAED,eAAO,MAAM,+BAA+B,qGAA2D,CAAC"}
@@ -65,7 +65,7 @@ export function AppLayoutDrawerImplementation({ appLayoutInternals }) {
65
65
  React.createElement(InternalButton, { ariaLabel: computedAriaLabels.closeButton, className: clsx({
66
66
  [testutilStyles['active-drawer-close-button']]: !isToolsDrawer && activeDrawerId,
67
67
  [testutilStyles['tools-close']]: isToolsDrawer,
68
- }), formAction: "none", iconName: isMobile ? 'close' : 'angle-right', onClick: () => onActiveDrawerChange(null, { initiatedByUserAction: true }), ref: drawersFocusControl.refs.close, variant: "icon" })),
68
+ }), formAction: "none", iconName: isMobile ? 'close' : 'angle-right', onClick: () => onActiveDrawerChange(null, { initiatedByUserAction: true }), ref: drawersFocusControl.refs.close, variant: "icon", analyticsAction: "close" })),
69
69
  React.createElement("div", { className: clsx(styles['drawer-content'], activeDrawerId !== TOOLS_DRAWER_ID && styles['drawer-content-hidden']), style: { blockSize: drawerHeight } }, toolsContent),
70
70
  activeDrawerId !== TOOLS_DRAWER_ID && (React.createElement("div", { className: styles['drawer-content'], style: { blockSize: drawerHeight } }, activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.content)))));
71
71
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"local-drawer.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/local-drawer.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,cAAc,MAAM,m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,EACnC,OAAO,EAAC,MAAM,GACd,CACE;gBACN,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,gBAAgB,CAAC,EACxB,cAAc,KAAK,eAAe,IAAI,MAAM,CAAC,uBAAuB,CAAC,CACtE,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,IAEjC,YAAY,CACT;gBACL,cAAc,KAAK,eAAe,IAAI,CACrC,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,IACzE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,CAClB,CACP,CACG,CACA,CACT,CAAA;KAAA,CACU,CACd,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,yBAAyB,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport { Transition } from 'react-transition-group';\nimport clsx from 'clsx';\n\nimport { InternalButton } from '../../../button/internal';\nimport PanelResizeHandle from '../../../internal/components/panel-resize-handle';\nimport customCssProps from '../../../internal/generated/custom-css-properties';\nimport { createWidgetizedComponent } from '../../../internal/widgets';\nimport { getLimitedValue } from '../../../split-panel/utils/size-utils';\nimport { TOOLS_DRAWER_ID } from '../../utils/use-drawers';\nimport { getDrawerStyles } from '../compute-layout';\nimport { AppLayoutInternals } from '../interfaces';\nimport { useResize } from './use-resize';\n\nimport sharedStyles from '../../resize/styles.css.js';\nimport testutilStyles from '../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface AppLayoutDrawerImplementationProps {\n appLayoutInternals: AppLayoutInternals;\n}\n\nexport function AppLayoutDrawerImplementation({ appLayoutInternals }: AppLayoutDrawerImplementationProps) {\n const {\n activeDrawer,\n minDrawerSize,\n activeDrawerSize,\n maxDrawerSize,\n ariaLabels,\n drawers,\n drawersFocusControl,\n isMobile,\n placement,\n verticalOffsets,\n drawersOpenQueue,\n onActiveDrawerChange,\n onActiveDrawerResize,\n } = appLayoutInternals;\n const drawerRef = useRef<HTMLDivElement>(null);\n const activeDrawerId = activeDrawer?.id;\n\n const computedAriaLabels = {\n closeButton: activeDrawer ? activeDrawer.ariaLabels?.closeButton : ariaLabels?.toolsClose,\n content: activeDrawer ? activeDrawer.ariaLabels?.drawerName : ariaLabels?.tools,\n };\n\n const { drawerTopOffset, drawerHeight } = getDrawerStyles(verticalOffsets, isMobile, placement);\n const toolsOnlyMode = drawers.length === 1 && drawers[0].id === TOOLS_DRAWER_ID;\n const isToolsDrawer = activeDrawer?.id === TOOLS_DRAWER_ID || toolsOnlyMode;\n const toolsContent = drawers?.find(drawer => drawer.id === TOOLS_DRAWER_ID)?.content;\n const resizeProps = useResize({\n currentWidth: activeDrawerSize,\n minWidth: minDrawerSize,\n maxWidth: maxDrawerSize,\n panelRef: drawerRef,\n handleRef: drawersFocusControl.refs.slider,\n onResize: size => onActiveDrawerResize({ id: activeDrawerId!, size }),\n });\n // temporary handle a situation when app-layout is old, but this component come as a widget\n const isLegacyDrawer = drawersOpenQueue === undefined;\n const size = getLimitedValue(minDrawerSize, activeDrawerSize, maxDrawerSize);\n const lastOpenedDrawerId = drawersOpenQueue?.length ? drawersOpenQueue[0] : activeDrawerId;\n const animationDisabled = activeDrawer?.defaultActive && !drawersOpenQueue.includes(activeDrawer.id);\n\n return (\n <Transition nodeRef={drawerRef} in={!!activeDrawer} appear={true} timeout={0}>\n {state => (\n <aside\n id={activeDrawerId}\n aria-hidden={!activeDrawer}\n aria-label={computedAriaLabels.content}\n className={clsx(styles.drawer, {\n [sharedStyles['with-motion-horizontal']]: !animationDisabled,\n [styles['last-opened']]: lastOpenedDrawerId === activeDrawerId,\n [styles.legacy]: isLegacyDrawer,\n [testutilStyles['active-drawer']]: !toolsOnlyMode && activeDrawerId,\n [testutilStyles.tools]: isToolsDrawer,\n [styles['drawer-hidden']]: !activeDrawer,\n [testutilStyles['drawer-closed']]: !activeDrawer,\n })}\n ref={drawerRef}\n onBlur={e => {\n if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {\n drawersFocusControl.loseFocus();\n }\n }}\n style={{\n blockSize: drawerHeight,\n insetBlockStart: drawerTopOffset,\n ...(!isMobile &&\n !isLegacyDrawer && {\n [customCssProps.drawerSize]: `${['entering', 'entered'].includes(state) ? size : 0}px`,\n }),\n }}\n data-testid={activeDrawerId && `awsui-app-layout-drawer-${activeDrawerId}`}\n >\n {!isMobile && activeDrawer?.resizable && (\n <div className={styles['drawer-slider']}>\n <PanelResizeHandle\n ref={drawersFocusControl.refs.slider}\n position=\"side\"\n className={testutilStyles['drawers-slider']}\n ariaLabel={activeDrawer?.ariaLabels?.resizeHandle}\n tooltipText={activeDrawer?.ariaLabels?.resizeHandleTooltipText}\n ariaValuenow={resizeProps.relativeSize}\n onKeyDown={resizeProps.onKeyDown}\n onPointerDown={resizeProps.onPointerDown}\n onDirectionClick={resizeProps.onDirectionClick}\n />\n </div>\n )}\n <div className={clsx(styles['drawer-content-container'], sharedStyles['with-motion-horizontal'])}>\n <div className={clsx(styles['drawer-close-button'])}>\n <InternalButton\n ariaLabel={computedAriaLabels.closeButton}\n className={clsx({\n [testutilStyles['active-drawer-close-button']]: !isToolsDrawer && activeDrawerId,\n [testutilStyles['tools-close']]: isToolsDrawer,\n })}\n formAction=\"none\"\n iconName={isMobile ? 'close' : 'angle-right'}\n onClick={() => onActiveDrawerChange(null, { initiatedByUserAction: true })}\n ref={drawersFocusControl.refs.close}\n variant=\"icon\"\n />\n </div>\n <div\n className={clsx(\n styles['drawer-content'],\n activeDrawerId !== TOOLS_DRAWER_ID && styles['drawer-content-hidden']\n )}\n style={{ blockSize: drawerHeight }}\n >\n {toolsContent}\n </div>\n {activeDrawerId !== TOOLS_DRAWER_ID && (\n <div className={styles['drawer-content']} style={{ blockSize: drawerHeight }}>\n {activeDrawer?.content}\n </div>\n )}\n </div>\n </aside>\n )}\n </Transition>\n );\n}\n\nexport const createWidgetizedAppLayoutDrawer = createWidgetizedComponent(AppLayoutDrawerImplementation);\n"]}
1
+ {"version":3,"file":"local-drawer.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/local-drawer.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,cAAc,MAAM,mDAAmD,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,YAAY,MAAM,4BAA4B,CAAC;AACtD,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAMrC,MAAM,UAAU,6BAA6B,CAAC,EAAE,kBAAkB,EAAsC;;IACtG,MAAM,EACJ,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,GACrB,GAAG,kBAAkB,CAAC;IACvB,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,YAAY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qBAAqB,CAAC,CAAC;oBACjD,oBAAC,cAAc,IACb,SAAS,EAAE,kBAAkB,CAAC,WAAW,EACzC,SAAS,EAAE,IAAI,CAAC;4BACd,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC,EAAE,CAAC,aAAa,IAAI,cAAc;4BAChF,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,EAAE,aAAa;yBAC/C,CAAC,EACF,UAAU,EAAC,MAAM,EACjB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,IAAI,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,EAC1E,GAAG,EAAE,mBAAmB,CAAC,IAAI,CAAC,KAAK,EACnC,OAAO,EAAC,MAAM,EACd,eAAe,EAAC,OAAO,GACvB,CACE;gBACN,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,gBAAgB,CAAC,EACxB,cAAc,KAAK,eAAe,IAAI,MAAM,CAAC,uBAAuB,CAAC,CACtE,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,IAEjC,YAAY,CACT;gBACL,cAAc,KAAK,eAAe,IAAI,CACrC,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,IACzE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,CAClB,CACP,CACG,CACA,CACT,CAAA;KAAA,CACU,CACd,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,yBAAyB,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport { Transition } from 'react-transition-group';\nimport clsx from 'clsx';\n\nimport { InternalButton } from '../../../button/internal';\nimport PanelResizeHandle from '../../../internal/components/panel-resize-handle';\nimport customCssProps from '../../../internal/generated/custom-css-properties';\nimport { createWidgetizedComponent } from '../../../internal/widgets';\nimport { getLimitedValue } from '../../../split-panel/utils/size-utils';\nimport { TOOLS_DRAWER_ID } from '../../utils/use-drawers';\nimport { getDrawerStyles } from '../compute-layout';\nimport { AppLayoutInternals } from '../interfaces';\nimport { useResize } from './use-resize';\n\nimport sharedStyles from '../../resize/styles.css.js';\nimport testutilStyles from '../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface AppLayoutDrawerImplementationProps {\n appLayoutInternals: AppLayoutInternals;\n}\n\nexport function AppLayoutDrawerImplementation({ appLayoutInternals }: AppLayoutDrawerImplementationProps) {\n const {\n activeDrawer,\n minDrawerSize,\n activeDrawerSize,\n maxDrawerSize,\n ariaLabels,\n drawers,\n drawersFocusControl,\n isMobile,\n placement,\n verticalOffsets,\n drawersOpenQueue,\n onActiveDrawerChange,\n onActiveDrawerResize,\n } = appLayoutInternals;\n const drawerRef = useRef<HTMLDivElement>(null);\n const activeDrawerId = activeDrawer?.id;\n\n const computedAriaLabels = {\n closeButton: activeDrawer ? activeDrawer.ariaLabels?.closeButton : ariaLabels?.toolsClose,\n content: activeDrawer ? activeDrawer.ariaLabels?.drawerName : ariaLabels?.tools,\n };\n\n const { drawerTopOffset, drawerHeight } = getDrawerStyles(verticalOffsets, isMobile, placement);\n const toolsOnlyMode = drawers.length === 1 && drawers[0].id === TOOLS_DRAWER_ID;\n const isToolsDrawer = activeDrawer?.id === TOOLS_DRAWER_ID || toolsOnlyMode;\n const toolsContent = drawers?.find(drawer => drawer.id === TOOLS_DRAWER_ID)?.content;\n const resizeProps = useResize({\n currentWidth: activeDrawerSize,\n minWidth: minDrawerSize,\n maxWidth: maxDrawerSize,\n panelRef: drawerRef,\n handleRef: drawersFocusControl.refs.slider,\n onResize: size => onActiveDrawerResize({ id: activeDrawerId!, size }),\n });\n // temporary handle a situation when app-layout is old, but this component come as a widget\n const isLegacyDrawer = drawersOpenQueue === undefined;\n const size = getLimitedValue(minDrawerSize, activeDrawerSize, maxDrawerSize);\n const lastOpenedDrawerId = drawersOpenQueue?.length ? drawersOpenQueue[0] : activeDrawerId;\n const animationDisabled = activeDrawer?.defaultActive && !drawersOpenQueue.includes(activeDrawer.id);\n\n return (\n <Transition nodeRef={drawerRef} in={!!activeDrawer} appear={true} timeout={0}>\n {state => (\n <aside\n id={activeDrawerId}\n aria-hidden={!activeDrawer}\n aria-label={computedAriaLabels.content}\n className={clsx(styles.drawer, {\n [sharedStyles['with-motion-horizontal']]: !animationDisabled,\n [styles['last-opened']]: lastOpenedDrawerId === activeDrawerId,\n [styles.legacy]: isLegacyDrawer,\n [testutilStyles['active-drawer']]: !toolsOnlyMode && activeDrawerId,\n [testutilStyles.tools]: isToolsDrawer,\n [styles['drawer-hidden']]: !activeDrawer,\n [testutilStyles['drawer-closed']]: !activeDrawer,\n })}\n ref={drawerRef}\n onBlur={e => {\n if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {\n drawersFocusControl.loseFocus();\n }\n }}\n style={{\n blockSize: drawerHeight,\n insetBlockStart: drawerTopOffset,\n ...(!isMobile &&\n !isLegacyDrawer && {\n [customCssProps.drawerSize]: `${['entering', 'entered'].includes(state) ? size : 0}px`,\n }),\n }}\n data-testid={activeDrawerId && `awsui-app-layout-drawer-${activeDrawerId}`}\n >\n {!isMobile && activeDrawer?.resizable && (\n <div className={styles['drawer-slider']}>\n <PanelResizeHandle\n ref={drawersFocusControl.refs.slider}\n position=\"side\"\n className={testutilStyles['drawers-slider']}\n ariaLabel={activeDrawer?.ariaLabels?.resizeHandle}\n tooltipText={activeDrawer?.ariaLabels?.resizeHandleTooltipText}\n ariaValuenow={resizeProps.relativeSize}\n onKeyDown={resizeProps.onKeyDown}\n onPointerDown={resizeProps.onPointerDown}\n onDirectionClick={resizeProps.onDirectionClick}\n />\n </div>\n )}\n <div className={clsx(styles['drawer-content-container'], sharedStyles['with-motion-horizontal'])}>\n <div className={clsx(styles['drawer-close-button'])}>\n <InternalButton\n ariaLabel={computedAriaLabels.closeButton}\n className={clsx({\n [testutilStyles['active-drawer-close-button']]: !isToolsDrawer && activeDrawerId,\n [testutilStyles['tools-close']]: isToolsDrawer,\n })}\n formAction=\"none\"\n iconName={isMobile ? 'close' : 'angle-right'}\n onClick={() => onActiveDrawerChange(null, { initiatedByUserAction: true })}\n ref={drawersFocusControl.refs.close}\n variant=\"icon\"\n analyticsAction=\"close\"\n />\n </div>\n <div\n className={clsx(\n styles['drawer-content'],\n activeDrawerId !== TOOLS_DRAWER_ID && styles['drawer-content-hidden']\n )}\n style={{ blockSize: drawerHeight }}\n >\n {toolsContent}\n </div>\n {activeDrawerId !== TOOLS_DRAWER_ID && (\n <div className={styles['drawer-content']} style={{ blockSize: drawerHeight }}>\n {activeDrawer?.content}\n </div>\n )}\n </div>\n </aside>\n )}\n </Transition>\n );\n}\n\nexport const createWidgetizedAppLayoutDrawer = createWidgetizedComponent(AppLayoutDrawerImplementation);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/navigation/index.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOnD,UAAU,sCAAsC;IAC9C,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;AAED,wBAAgB,iCAAiC,CAAC,EAAE,kBAAkB,EAAE,EAAE,sCAAsC,eA8D/G;AAED,eAAO,MAAM,mCAAmC,6GAG/C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/navigation/index.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOnD,UAAU,sCAAsC;IAC9C,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;AAED,wBAAgB,iCAAiC,CAAC,EAAE,kBAAkB,EAAE,EAAE,sCAAsC,eA+D/G;AAED,eAAO,MAAM,mCAAmC,6GAG/C,CAAC"}
@@ -31,7 +31,7 @@ export function AppLayoutNavigationImplementation({ appLayoutInternals }) {
31
31
  [testutilStyles['drawer-closed']]: !navigationOpen,
32
32
  }, testutilStyles.navigation), "aria-hidden": !navigationOpen, onClick: onNavigationClick },
33
33
  React.createElement("div", { className: clsx(styles['hide-navigation']) },
34
- React.createElement(InternalButton, { ariaLabel: (_b = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.navigationClose) !== null && _b !== void 0 ? _b : undefined, iconName: isMobile ? 'close' : 'angle-left', onClick: () => onNavigationToggle(false), variant: "icon", formAction: "none", className: testutilStyles['navigation-close'], ref: navigationFocusControl.refs.close })),
34
+ React.createElement(InternalButton, { ariaLabel: (_b = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.navigationClose) !== null && _b !== void 0 ? _b : undefined, iconName: isMobile ? 'close' : 'angle-left', onClick: () => onNavigationToggle(false), variant: "icon", formAction: "none", className: testutilStyles['navigation-close'], ref: navigationFocusControl.refs.close, analyticsAction: "close" })),
35
35
  navigation)));
36
36
  }
37
37
  export const createWidgetizedAppLayoutNavigation = createWidgetizedComponent(AppLayoutNavigationImplementation, NotificationsSlot);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/navigation/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EA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EACD,cAAc,CAAC,UAAU,CAC1B,iBACY,CAAC,cAAc,EAC5B,OAAO,EAAE,iBAAiB;YAE1B,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;gBAC7C,oBAAC,cAAc,IACb,SAAS,EAAE,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,eAAe,mCAAI,SAAS,EACnD,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,EAC3C,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EACxC,OAAO,EAAC,MAAM,EACd,UAAU,EAAC,MAAM,EACjB,SAAS,EAAE,cAAc,CAAC,kBAAkB,CAAC,EAC7C,GAAG,EAAE,sBAAsB,CAAC,IAAI,CAAC,KAAK,GACtC,CACE;YACL,UAAU,CACP,CACF,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,mCAAmC,GAAG,yBAAyB,CAC1E,iCAAiC,EACjC,iBAAiB,CAClB,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 { findUpUntil } from '@cloudscape-design/component-toolkit/dom';\n\nimport { InternalButton } from '../../../button/internal';\nimport { createWidgetizedComponent } from '../../../internal/widgets';\nimport { getDrawerStyles } from '../compute-layout';\nimport { AppLayoutInternals } from '../interfaces';\nimport { NotificationsSlot } from '../skeleton/slot-wrappers';\n\nimport sharedStyles from '../../resize/styles.css.js';\nimport testutilStyles from '../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface AppLayoutNavigationImplementationProps {\n appLayoutInternals: AppLayoutInternals;\n}\n\nexport function AppLayoutNavigationImplementation({ appLayoutInternals }: AppLayoutNavigationImplementationProps) {\n const {\n ariaLabels,\n onNavigationToggle,\n isMobile,\n navigationOpen,\n navigation,\n navigationFocusControl,\n placement,\n verticalOffsets,\n } = appLayoutInternals;\n\n const { drawerTopOffset, drawerHeight } = getDrawerStyles(verticalOffsets, isMobile, placement);\n\n // Close the Navigation drawer on mobile when a user clicks a link inside.\n const onNavigationClick = (event: React.MouseEvent) => {\n const hasLink = findUpUntil(\n event.target as HTMLElement,\n node => node.tagName === 'A' && !!(node as HTMLAnchorElement).href\n );\n if (hasLink && isMobile) {\n onNavigationToggle(false);\n }\n };\n\n return (\n <div\n className={clsx(styles['navigation-container'], sharedStyles['with-motion-horizontal'], {\n [styles['is-navigation-open']]: navigationOpen,\n })}\n style={{\n blockSize: drawerHeight,\n insetBlockStart: drawerTopOffset,\n }}\n >\n <nav\n aria-label={ariaLabels?.navigation ?? undefined}\n className={clsx(\n styles.navigation,\n {\n [testutilStyles['drawer-closed']]: !navigationOpen,\n },\n testutilStyles.navigation\n )}\n aria-hidden={!navigationOpen}\n onClick={onNavigationClick}\n >\n <div className={clsx(styles['hide-navigation'])}>\n <InternalButton\n ariaLabel={ariaLabels?.navigationClose ?? undefined}\n iconName={isMobile ? 'close' : 'angle-left'}\n onClick={() => onNavigationToggle(false)}\n variant=\"icon\"\n formAction=\"none\"\n className={testutilStyles['navigation-close']}\n ref={navigationFocusControl.refs.close}\n />\n </div>\n {navigation}\n </nav>\n </div>\n );\n}\n\nexport const createWidgetizedAppLayoutNavigation = createWidgetizedComponent(\n AppLayoutNavigationImplementation,\n NotificationsSlot\n);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/navigation/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE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AM,CAAC,UAAU,EACjB;gBACE,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,cAAc;aACnD,EACD,cAAc,CAAC,UAAU,CAC1B,iBACY,CAAC,cAAc,EAC5B,OAAO,EAAE,iBAAiB;YAE1B,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;gBAC7C,oBAAC,cAAc,IACb,SAAS,EAAE,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,eAAe,mCAAI,SAAS,EACnD,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,EAC3C,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EACxC,OAAO,EAAC,MAAM,EACd,UAAU,EAAC,MAAM,EACjB,SAAS,EAAE,cAAc,CAAC,kBAAkB,CAAC,EAC7C,GAAG,EAAE,sBAAsB,CAAC,IAAI,CAAC,KAAK,EACtC,eAAe,EAAC,OAAO,GACvB,CACE;YACL,UAAU,CACP,CACF,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,mCAAmC,GAAG,yBAAyB,CAC1E,iCAAiC,EACjC,iBAAiB,CAClB,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 { findUpUntil } from '@cloudscape-design/component-toolkit/dom';\n\nimport { InternalButton } from '../../../button/internal';\nimport { createWidgetizedComponent } from '../../../internal/widgets';\nimport { getDrawerStyles } from '../compute-layout';\nimport { AppLayoutInternals } from '../interfaces';\nimport { NotificationsSlot } from '../skeleton/slot-wrappers';\n\nimport sharedStyles from '../../resize/styles.css.js';\nimport testutilStyles from '../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface AppLayoutNavigationImplementationProps {\n appLayoutInternals: AppLayoutInternals;\n}\n\nexport function AppLayoutNavigationImplementation({ appLayoutInternals }: AppLayoutNavigationImplementationProps) {\n const {\n ariaLabels,\n onNavigationToggle,\n isMobile,\n navigationOpen,\n navigation,\n navigationFocusControl,\n placement,\n verticalOffsets,\n } = appLayoutInternals;\n\n const { drawerTopOffset, drawerHeight } = getDrawerStyles(verticalOffsets, isMobile, placement);\n\n // Close the Navigation drawer on mobile when a user clicks a link inside.\n const onNavigationClick = (event: React.MouseEvent) => {\n const hasLink = findUpUntil(\n event.target as HTMLElement,\n node => node.tagName === 'A' && !!(node as HTMLAnchorElement).href\n );\n if (hasLink && isMobile) {\n onNavigationToggle(false);\n }\n };\n\n return (\n <div\n className={clsx(styles['navigation-container'], sharedStyles['with-motion-horizontal'], {\n [styles['is-navigation-open']]: navigationOpen,\n })}\n style={{\n blockSize: drawerHeight,\n insetBlockStart: drawerTopOffset,\n }}\n >\n <nav\n aria-label={ariaLabels?.navigation ?? undefined}\n className={clsx(\n styles.navigation,\n {\n [testutilStyles['drawer-closed']]: !navigationOpen,\n },\n testutilStyles.navigation\n )}\n aria-hidden={!navigationOpen}\n onClick={onNavigationClick}\n >\n <div className={clsx(styles['hide-navigation'])}>\n <InternalButton\n ariaLabel={ariaLabels?.navigationClose ?? undefined}\n iconName={isMobile ? 'close' : 'angle-left'}\n onClick={() => onNavigationToggle(false)}\n variant=\"icon\"\n formAction=\"none\"\n className={testutilStyles['navigation-close']}\n ref={navigationFocusControl.refs.close}\n analyticsAction=\"close\"\n />\n </div>\n {navigation}\n </nav>\n </div>\n );\n}\n\nexport const createWidgetizedAppLayoutNavigation = createWidgetizedComponent(\n AppLayoutNavigationImplementation,\n NotificationsSlot\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiE,MAAM,OAAO,CAAC;AAGtF,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAOxD,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAEpD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;;AAmLD,wBAA+C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiE,MAAM,OAAO,CAAC;AAStF,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAOxD,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAEpD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;;AA2LD,wBAA+C"}
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import clsx from 'clsx';
5
+ import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
5
6
  import Icon from '../../../../icon/internal';
6
7
  import Tooltip from '../../../../internal/components/tooltip';
7
8
  import testutilStyles from '../../../test-classes/styles.css.js';
@@ -92,17 +93,21 @@ function TriggerButton({ ariaLabel, className, iconName, iconSvg, ariaExpanded,
92
93
  }
93
94
  }
94
95
  }, [containerRef, hasTooltip, tooltipValue]);
96
+ const triggerEventMetadata = {
97
+ action: selected ? 'close' : 'open',
98
+ detail: { label: { root: 'self' } },
99
+ };
95
100
  return (React.createElement("div", Object.assign({ ref: containerRef }, (hasTooltip && {
96
101
  onPointerEnter: () => handlePointerEnter(),
97
102
  onPointerLeave: () => handleBlur(true),
98
103
  onFocus: e => handleOnFocus(e),
99
104
  onBlur: () => handleBlur(true),
100
105
  }), { className: styles['trigger-wrapper'] }),
101
- React.createElement("button", { "aria-expanded": ariaExpanded, "aria-controls": ariaControls, "aria-haspopup": true, "aria-label": ariaLabel, "aria-disabled": disabled, disabled: disabled, className: clsx(styles.trigger, styles['trigger-button-styles'], {
106
+ React.createElement("button", Object.assign({ "aria-expanded": ariaExpanded, "aria-controls": ariaControls, "aria-haspopup": true, "aria-label": ariaLabel, "aria-disabled": disabled, disabled: disabled, className: clsx(styles.trigger, styles['trigger-button-styles'], {
102
107
  [styles.selected]: selected,
103
108
  [styles.badge]: badge,
104
109
  [testutilStyles['drawers-trigger-with-badge']]: badge,
105
- }, className), onClick: handleTriggerClick, ref: ref, type: "button", "data-testid": testId, "data-shift-focus": "awsui-layout-drawer-trigger" },
110
+ }, className), onClick: handleTriggerClick, ref: ref, type: "button", "data-testid": testId, "data-shift-focus": "awsui-layout-drawer-trigger" }, getAnalyticsMetadataAttribute(triggerEventMetadata)),
106
111
  React.createElement("span", { className: clsx(badge && clsx(styles['trigger-badge-wrapper'], styles['trigger-button-styles'])) }, (iconName || iconSvg) && React.createElement(Icon, { name: iconName, svg: iconSvg }))),
107
112
  badge && React.createElement("div", { className: styles.dot }),
108
113
  tooltipVisible && (React.createElement(Tooltip, { trackRef: containerRef, value: tooltipValue, className: testutilStyles['trigger-tooltip'], onDismiss: () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAA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;QACR,KAAK,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,GAAG,GAAI;QACvC,cAAc,IAAI,CACjB,oBAAC,OAAO,IACN,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,cAAc,CAAC,iBAAiB,CAAC,EAC5C,SAAS,EAAE,GAAG,EAAE;gBACd,cAAc,CAAC,KAAK,CAAC,CAAC;gBACtB,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC,GACD,CACH,CACG,CACP,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { ButtonProps } from '../../../../button/interfaces';\nimport { IconProps } from '../../../../icon/interfaces';\nimport Icon from '../../../../icon/internal';\nimport Tooltip from '../../../../internal/components/tooltip';\n\nimport testutilStyles from '../../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\nexport interface TriggerButtonProps {\n ariaLabel?: string;\n className?: string;\n iconName?: IconProps.Name;\n iconSvg?: React.ReactNode;\n ariaExpanded: boolean | undefined;\n ariaControls?: string;\n disabled?: boolean;\n /**\n * Ovewrwrites any internal testIds when provided\n */\n testId?: string;\n /**\n * If button is selected. Used only for desktop and applies a selected class\n */\n selected?: boolean;\n onClick: React.MouseEventHandler<HTMLButtonElement>;\n\n badge?: boolean;\n /**\n * If the button is expected to have a tooltip. When false it will not set the event listeners\n *\n * defaults to false\n */\n hasTooltip?: boolean;\n /**\n * This text allows for a customized tooltip.\n *\n * When falsy, the tooltip will parse the tooltip form the aria-lable\n */\n tooltipText?: string;\n hasOpenDrawer?: boolean;\n /**\n * If the AppLayout is in mobile mode\n * Used to determine if and where to render tooltips\n */\n isMobile?: boolean;\n /**\n * set to true if the trigger button was used to open the last active drawer\n * this is also used to hide the tooltip should the focus be set programmatically\n * on focus from a drawer close using this\n */\n isForPreviousActiveDrawer?: boolean;\n /**\n * if the trigger button is for the split panel\n */\n isForSplitPanel?: boolean;\n tabIndex?: number | undefined;\n}\n\nfunction TriggerButton(\n {\n ariaLabel,\n className,\n iconName,\n iconSvg,\n ariaExpanded,\n ariaControls,\n onClick,\n testId,\n disabled = false,\n badge,\n selected = false,\n hasTooltip = false,\n tooltipText,\n hasOpenDrawer = false,\n isMobile = false,\n isForPreviousActiveDrawer = false,\n isForSplitPanel = false,\n }: TriggerButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n) {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const tooltipValue = tooltipText ? tooltipText : ariaLabel ? ariaLabel : '';\n const [showTooltip, setShowTooltip] = useState<boolean>(false);\n const [suppressTooltip, setSupressTooltip] = useState<boolean>(false);\n\n const handleTriggerClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation(); // Stop the event from propagating to the badge icon\n setShowTooltip(false);\n setSupressTooltip(true);\n onClick(event);\n };\n\n const handleBlur = (keepSupressed = false) => {\n setSupressTooltip(keepSupressed);\n setShowTooltip(false);\n };\n\n const handlePointerEnter = () => {\n setSupressTooltip(false);\n setShowTooltip(true);\n };\n\n /**\n * Takes the drawer being closed and the data-shift-focus value from a close button on that drawer that persists\n * on the event relatedTarget to determine not to show the tooltip\n * @param event\n */\n const handleOnFocus = useCallback(\n (event: FocusEvent) => {\n let shouldShowTooltip = false;\n const eventWithRelatedTarget = event as any;\n const relatedTarget = eventWithRelatedTarget?.relatedTarget;\n const isFromAnotherTrigger = relatedTarget?.dataset?.shiftFocus === 'awsui-layout-drawer-trigger';\n if (\n (isForSplitPanel && !!relatedTarget) || // relatedTarget is null when split panel is closed\n (!isForSplitPanel &&\n (isFromAnotherTrigger || // for key navigation from another trigger button\n !isForPreviousActiveDrawer)) // for when the drawer was not opened recently\n ) {\n shouldShowTooltip = true;\n }\n setSupressTooltip(!shouldShowTooltip);\n setShowTooltip(true);\n },\n [\n // To assert reference equality check\n isForPreviousActiveDrawer,\n isForSplitPanel,\n ]\n );\n\n const tooltipVisible = useMemo(() => {\n return (\n hasTooltip &&\n showTooltip &&\n !suppressTooltip &&\n !!containerRef?.current &&\n tooltipValue &&\n !(isMobile && hasOpenDrawer)\n );\n }, [hasTooltip, showTooltip, containerRef, tooltipValue, isMobile, hasOpenDrawer, suppressTooltip]);\n\n useEffect(() => {\n if (hasTooltip && tooltipValue) {\n const close = () => {\n setShowTooltip(false);\n setSupressTooltip(false);\n };\n\n const shouldCloseTooltip = (event: PointerEvent) => {\n if (event.target && containerRef && (containerRef.current as any)?.contains(event.target as HTMLElement)) {\n return false;\n }\n return true;\n };\n\n const handlePointerDownEvent = (event: PointerEvent) => {\n if (shouldCloseTooltip(event)) {\n close();\n }\n };\n\n const handleKeyDownEvent = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n close();\n }\n };\n\n const wrapperDiv = containerRef.current;\n if (wrapperDiv) {\n const controller = new AbortController();\n wrapperDiv.addEventListener('pointerdown', handlePointerDownEvent, { signal: controller.signal });\n wrapperDiv.addEventListener('keydown', handleKeyDownEvent, { signal: controller.signal });\n\n return () => {\n controller.abort();\n };\n }\n }\n }, [containerRef, hasTooltip, tooltipValue]);\n\n return (\n <div\n ref={containerRef}\n {...(hasTooltip && {\n onPointerEnter: () => handlePointerEnter(),\n onPointerLeave: () => handleBlur(true),\n onFocus: e => handleOnFocus(e as any),\n onBlur: () => handleBlur(true),\n })}\n className={styles['trigger-wrapper']}\n >\n <button\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-haspopup={true}\n aria-label={ariaLabel}\n aria-disabled={disabled}\n disabled={disabled}\n className={clsx(\n styles.trigger,\n styles['trigger-button-styles'],\n {\n [styles.selected]: selected,\n [styles.badge]: badge,\n [testutilStyles['drawers-trigger-with-badge']]: badge,\n },\n className\n )}\n onClick={handleTriggerClick}\n ref={ref as Ref<HTMLButtonElement>}\n type=\"button\"\n data-testid={testId}\n data-shift-focus=\"awsui-layout-drawer-trigger\"\n >\n <span className={clsx(badge && clsx(styles['trigger-badge-wrapper'], styles['trigger-button-styles']))}>\n {(iconName || iconSvg) && <Icon name={iconName} svg={iconSvg} />}\n </span>\n </button>\n {badge && <div className={styles.dot} />}\n {tooltipVisible && (\n <Tooltip\n trackRef={containerRef}\n value={tooltipValue}\n className={testutilStyles['trigger-tooltip']}\n onDismiss={() => {\n setShowTooltip(false);\n setSupressTooltip(false);\n }}\n />\n )}\n </div>\n );\n}\n\nexport default React.forwardRef(TriggerButton);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAQjH,OAAO,IAAI,MAAM,2BAA2B,CAAC;AAC7C,OAAO,OAAO,MAAM,yCAAyC,CAAC;AAE9D,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAoDrC,SAAS,aAAa,CACpB,EACE,SAAS,EACT,SAAS,EACT,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,UAAU,GAAG,KAAK,EAClB,WAAW,EACX,aAAa,GAAG,KAAK,EACrB,QAAQ,GAAG,KAAK,EAChB,yBAAyB,GAAG,KAAK,EACjC,eAAe,GAAG,KAAK,GACJ,EACrB,GAA+B;IAE/B,MAAM,YAAY,GAAG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":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport {\n GeneratedAnalyticsMetadataAppLayoutToolbarClose,\n GeneratedAnalyticsMetadataAppLayoutToolbarOpen,\n} from '../../../../app-layout-toolbar/analytics-metadata/interfaces';\nimport { ButtonProps } from '../../../../button/interfaces';\nimport { IconProps } from '../../../../icon/interfaces';\nimport Icon from '../../../../icon/internal';\nimport Tooltip from '../../../../internal/components/tooltip';\n\nimport testutilStyles from '../../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\nexport interface TriggerButtonProps {\n ariaLabel?: string;\n className?: string;\n iconName?: IconProps.Name;\n iconSvg?: React.ReactNode;\n ariaExpanded: boolean | undefined;\n ariaControls?: string;\n disabled?: boolean;\n /**\n * Ovewrwrites any internal testIds when provided\n */\n testId?: string;\n /**\n * If button is selected. Used only for desktop and applies a selected class\n */\n selected?: boolean;\n onClick: React.MouseEventHandler<HTMLButtonElement>;\n\n badge?: boolean;\n /**\n * If the button is expected to have a tooltip. When false it will not set the event listeners\n *\n * defaults to false\n */\n hasTooltip?: boolean;\n /**\n * This text allows for a customized tooltip.\n *\n * When falsy, the tooltip will parse the tooltip form the aria-lable\n */\n tooltipText?: string;\n hasOpenDrawer?: boolean;\n /**\n * If the AppLayout is in mobile mode\n * Used to determine if and where to render tooltips\n */\n isMobile?: boolean;\n /**\n * set to true if the trigger button was used to open the last active drawer\n * this is also used to hide the tooltip should the focus be set programmatically\n * on focus from a drawer close using this\n */\n isForPreviousActiveDrawer?: boolean;\n /**\n * if the trigger button is for the split panel\n */\n isForSplitPanel?: boolean;\n tabIndex?: number | undefined;\n}\n\nfunction TriggerButton(\n {\n ariaLabel,\n className,\n iconName,\n iconSvg,\n ariaExpanded,\n ariaControls,\n onClick,\n testId,\n disabled = false,\n badge,\n selected = false,\n hasTooltip = false,\n tooltipText,\n hasOpenDrawer = false,\n isMobile = false,\n isForPreviousActiveDrawer = false,\n isForSplitPanel = false,\n }: TriggerButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n) {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const tooltipValue = tooltipText ? tooltipText : ariaLabel ? ariaLabel : '';\n const [showTooltip, setShowTooltip] = useState<boolean>(false);\n const [suppressTooltip, setSupressTooltip] = useState<boolean>(false);\n\n const handleTriggerClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation(); // Stop the event from propagating to the badge icon\n setShowTooltip(false);\n setSupressTooltip(true);\n onClick(event);\n };\n\n const handleBlur = (keepSupressed = false) => {\n setSupressTooltip(keepSupressed);\n setShowTooltip(false);\n };\n\n const handlePointerEnter = () => {\n setSupressTooltip(false);\n setShowTooltip(true);\n };\n\n /**\n * Takes the drawer being closed and the data-shift-focus value from a close button on that drawer that persists\n * on the event relatedTarget to determine not to show the tooltip\n * @param event\n */\n const handleOnFocus = useCallback(\n (event: FocusEvent) => {\n let shouldShowTooltip = false;\n const eventWithRelatedTarget = event as any;\n const relatedTarget = eventWithRelatedTarget?.relatedTarget;\n const isFromAnotherTrigger = relatedTarget?.dataset?.shiftFocus === 'awsui-layout-drawer-trigger';\n if (\n (isForSplitPanel && !!relatedTarget) || // relatedTarget is null when split panel is closed\n (!isForSplitPanel &&\n (isFromAnotherTrigger || // for key navigation from another trigger button\n !isForPreviousActiveDrawer)) // for when the drawer was not opened recently\n ) {\n shouldShowTooltip = true;\n }\n setSupressTooltip(!shouldShowTooltip);\n setShowTooltip(true);\n },\n [\n // To assert reference equality check\n isForPreviousActiveDrawer,\n isForSplitPanel,\n ]\n );\n\n const tooltipVisible = useMemo(() => {\n return (\n hasTooltip &&\n showTooltip &&\n !suppressTooltip &&\n !!containerRef?.current &&\n tooltipValue &&\n !(isMobile && hasOpenDrawer)\n );\n }, [hasTooltip, showTooltip, containerRef, tooltipValue, isMobile, hasOpenDrawer, suppressTooltip]);\n\n useEffect(() => {\n if (hasTooltip && tooltipValue) {\n const close = () => {\n setShowTooltip(false);\n setSupressTooltip(false);\n };\n\n const shouldCloseTooltip = (event: PointerEvent) => {\n if (event.target && containerRef && (containerRef.current as any)?.contains(event.target as HTMLElement)) {\n return false;\n }\n return true;\n };\n\n const handlePointerDownEvent = (event: PointerEvent) => {\n if (shouldCloseTooltip(event)) {\n close();\n }\n };\n\n const handleKeyDownEvent = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n close();\n }\n };\n\n const wrapperDiv = containerRef.current;\n if (wrapperDiv) {\n const controller = new AbortController();\n wrapperDiv.addEventListener('pointerdown', handlePointerDownEvent, { signal: controller.signal });\n wrapperDiv.addEventListener('keydown', handleKeyDownEvent, { signal: controller.signal });\n\n return () => {\n controller.abort();\n };\n }\n }\n }, [containerRef, hasTooltip, tooltipValue]);\n\n const triggerEventMetadata:\n | GeneratedAnalyticsMetadataAppLayoutToolbarClose\n | GeneratedAnalyticsMetadataAppLayoutToolbarOpen = {\n action: selected ? 'close' : 'open',\n detail: { label: { root: 'self' } },\n };\n\n return (\n <div\n ref={containerRef}\n {...(hasTooltip && {\n onPointerEnter: () => handlePointerEnter(),\n onPointerLeave: () => handleBlur(true),\n onFocus: e => handleOnFocus(e as any),\n onBlur: () => handleBlur(true),\n })}\n className={styles['trigger-wrapper']}\n >\n <button\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-haspopup={true}\n aria-label={ariaLabel}\n aria-disabled={disabled}\n disabled={disabled}\n className={clsx(\n styles.trigger,\n styles['trigger-button-styles'],\n {\n [styles.selected]: selected,\n [styles.badge]: badge,\n [testutilStyles['drawers-trigger-with-badge']]: badge,\n },\n className\n )}\n onClick={handleTriggerClick}\n ref={ref as Ref<HTMLButtonElement>}\n type=\"button\"\n data-testid={testId}\n data-shift-focus=\"awsui-layout-drawer-trigger\"\n {...getAnalyticsMetadataAttribute(triggerEventMetadata)}\n >\n <span className={clsx(badge && clsx(styles['trigger-badge-wrapper'], styles['trigger-button-styles']))}>\n {(iconName || iconSvg) && <Icon name={iconName} svg={iconSvg} />}\n </span>\n </button>\n {badge && <div className={styles.dot} />}\n {tooltipVisible && (\n <Tooltip\n trackRef={containerRef}\n value={tooltipValue}\n className={testutilStyles['trigger-tooltip']}\n onDismiss={() => {\n setShowTooltip(false);\n setSupressTooltip(false);\n }}\n />\n )}\n </div>\n );\n}\n\nexport default React.forwardRef(TriggerButton);\n"]}
@@ -0,0 +1,18 @@
1
+ import { LabelIdentifier } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
2
+ export interface GeneratedAnalyticsMetadataAppLayoutToolbarOpen {
3
+ action: 'open';
4
+ detail: {
5
+ label: string | LabelIdentifier;
6
+ };
7
+ }
8
+ export interface GeneratedAnalyticsMetadataAppLayoutToolbarClose {
9
+ action: 'close';
10
+ detail: {
11
+ label: string | LabelIdentifier;
12
+ };
13
+ }
14
+ export interface GeneratedAnalyticsMetadataAppLayoutToolbarComponent {
15
+ name: 'awsui.AppLayoutToolbar';
16
+ label: LabelIdentifier;
17
+ }
18
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/app-layout-toolbar/analytics-metadata/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,kEAAkE,CAAC;AAEnG,MAAM,WAAW,8CAA8C;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC;KACjC,CAAC;CACH;AAED,MAAM,WAAW,+CAA+C;IAC9D,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC;KACjC,CAAC;CACH;AAED,MAAM,WAAW,mDAAmD;IAClE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,KAAK,EAAE,eAAe,CAAC;CACxB"}
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
4
+ //# sourceMappingURL=interfaces.js.map