@cloudscape-design/components 3.0.872 → 3.0.874
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js +4 -4
- package/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js.map +1 -1
- package/button-group/item-element.js +4 -4
- package/button-group/item-element.js.map +1 -1
- package/code-editor/resizable-box/index.js +4 -4
- package/code-editor/resizable-box/index.js.map +1 -1
- package/container/use-sticky-header.js +4 -4
- package/container/use-sticky-header.js.map +1 -1
- package/file-dropzone/use-files-dragging.d.ts.map +1 -1
- package/file-dropzone/use-files-dragging.js +5 -6
- package/file-dropzone/use-files-dragging.js.map +1 -1
- package/form-field/styles.css.js +24 -24
- package/form-field/styles.scoped.css +40 -38
- package/form-field/styles.selectors.js +24 -24
- package/internal/analytics/components/analytics-funnel.js +4 -4
- package/internal/analytics/components/analytics-funnel.js.map +1 -1
- package/internal/animate.js +1 -1
- package/internal/animate.js.map +1 -1
- package/internal/components/chart-plot/focus-outline.js +4 -4
- package/internal/components/chart-plot/focus-outline.js.map +1 -1
- package/internal/components/dropdown/index.js +4 -4
- package/internal/components/dropdown/index.js.map +1 -1
- package/internal/components/transition/index.js +4 -4
- package/internal/components/transition/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/focus-tracker.d.ts +1 -0
- package/internal/focus-tracker.d.ts.map +1 -1
- package/internal/focus-tracker.js +4 -4
- package/internal/focus-tracker.js.map +1 -1
- package/internal/hooks/use-mouse-down-target.js +4 -4
- package/internal/hooks/use-mouse-down-target.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/popover/container.d.ts.map +1 -1
- package/popover/container.js +5 -6
- package/popover/container.js.map +1 -1
- package/table/resizer/index.d.ts.map +1 -1
- package/table/resizer/index.js +5 -6
- package/table/resizer/index.js.map +1 -1
- package/table/table-role/grid-navigation.js +5 -6
- package/table/table-role/grid-navigation.js.map +1 -1
- package/test-utils/dom/index.d.ts +78 -78
- package/test-utils/dom/index.js +9 -3
- package/test-utils/dom/index.js.map +1 -1
- package/test-utils/selectors/index.d.ts +78 -78
- package/test-utils/selectors/index.js +5 -1
- package/test-utils/selectors/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
|
@@ -477,11 +477,11 @@ export const AnalyticsFunnelSubStep = ({ children, subStepIdentifier, subStepErr
|
|
|
477
477
|
(_a = focusCleanupFunction.current) === null || _a === void 0 ? void 0 : _a.call(focusCleanupFunction);
|
|
478
478
|
}
|
|
479
479
|
});
|
|
480
|
-
|
|
481
|
-
window.addEventListener('
|
|
480
|
+
const controller = new AbortController();
|
|
481
|
+
window.addEventListener('mousedown', onMouseDown, { signal: controller.signal });
|
|
482
|
+
window.addEventListener('mouseup', onMouseUp, { signal: controller.signal });
|
|
482
483
|
return () => {
|
|
483
|
-
|
|
484
|
-
window.removeEventListener('mouseup', onMouseUp);
|
|
484
|
+
controller.abort();
|
|
485
485
|
};
|
|
486
486
|
}, [
|
|
487
487
|
funnelInteractionId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-funnel.js","sourceRoot":"","sources":["../../../../../src/internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EACL,aAAa,EAGb,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BAAmB;QACnB,eAAe;QACf,oBAAoB;QACpB,QAAQ;QACR,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAC1C,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAChC,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef, useState } from 'react';\n\nimport { PACKAGE_VERSION } from '../../environment';\nimport { useDebounceCallback } from '../../hooks/use-debounce-callback';\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport {\n FunnelContext,\n FunnelContextValue,\n FunnelState,\n FunnelStepContext,\n FunnelStepContextValue,\n FunnelSubStepContext,\n FunnelSubStepContextValue,\n} from '../context/analytics-context';\nimport { useFunnel, useFunnelStep } from '../hooks/use-funnel';\nimport { FunnelMetrics, PerformanceMetrics } from '../index';\nimport {\n AnalyticsMetadata,\n FunnelStartProps,\n FunnelStepProps,\n StepConfiguration,\n SubStepConfiguration,\n TaskCompletionDataProps,\n} from '../interfaces';\nimport {\n DATA_ATTR_FUNNEL_STEP,\n DATA_ATTR_RESOURCE_TYPE,\n getFunnelNameSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n getTextFromSelector,\n} from '../selectors';\n\nconst FUNNEL_VERSION = '1.4';\n\ninterface AnalyticsFunnelProps {\n mounted?: boolean;\n children?: React.ReactNode;\n stepConfiguration?: StepConfiguration[];\n funnelNameSelectors?: () => string[];\n funnelType: FunnelStartProps['funnelType'];\n optionalStepNumbers: FunnelStartProps['optionalStepNumbers'];\n totalFunnelSteps: FunnelStartProps['totalFunnelSteps'];\n funnelIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n funnelFlowType?: AnalyticsMetadata['flowType'];\n funnelErrorContext?: AnalyticsMetadata['errorContext'];\n funnelResourceType?: AnalyticsMetadata['resourceType'];\n}\n\nexport const AnalyticsFunnel = (props: AnalyticsFunnelProps) => {\n const { isInFunnel } = useFunnel();\n /*\n If the current funnel component is a Form (i.e. single-page funnel), it should\n defer its funnel-handling to a parent Form element, if present.\n Wizards (i.e. multi-page funnels) always take highest precedence for handling funnels,\n and do not defer to any other element.\n */\n if (isInFunnel && props.funnelType === 'single-page') {\n return <>{props.children}</>;\n }\n\n return <InnerAnalyticsFunnel {...props} />;\n};\n\nexport const CREATION_EDIT_FLOW_DONE_EVENT_NAME = 'awsui-creation-edit-flow-done';\nconst dispatchCreateEditFlowDoneEvent = () => {\n try {\n window.top?.document.dispatchEvent(new Event(CREATION_EDIT_FLOW_DONE_EVENT_NAME));\n } catch {\n // probably because of cross-origin error, then do not dispatch the event\n }\n};\n\nconst onFunnelCancelled = ({\n funnelInteractionId,\n funnelIdentifier,\n}: {\n funnelInteractionId: string;\n funnelIdentifier?: string;\n}) => {\n FunnelMetrics.funnelCancelled({ funnelInteractionId, funnelIdentifier });\n};\n\nconst onFunnelComplete = (taskCompletionDataProps: TaskCompletionDataProps) => {\n FunnelMetrics.funnelComplete({\n funnelInteractionId: taskCompletionDataProps.taskInteractionId,\n funnelIdentifier: taskCompletionDataProps.taskIdentifier,\n });\n PerformanceMetrics.taskCompletionData(taskCompletionDataProps);\n dispatchCreateEditFlowDoneEvent();\n};\n\nfunction evaluateSelectors(selectors: string[], defaultSelector: string) {\n for (const selector of selectors) {\n const element = document.querySelector(selector);\n if (element) {\n return selector;\n }\n }\n\n return defaultSelector;\n}\n\nconst InnerAnalyticsFunnel = ({ mounted = true, children, stepConfiguration, ...props }: AnalyticsFunnelProps) => {\n const [funnelInteractionId, setFunnelInteractionId] = useState<string>('');\n const [submissionAttempt, setSubmissionAttempt] = useState(0);\n const isVisualRefresh = useVisualRefresh();\n const funnelState = useRef<FunnelState>('default');\n const funnelNameSelector = useRef<string>(getFunnelNameSelector());\n const errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\n const wizardCount = useRef<number>(0);\n const latestFocusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n const formSubmitStartTime = useRef<number>(0);\n // This useEffect hook is run once on component mount to initiate the funnel analytics.\n // It first calls the 'funnelStart' method from FunnelMetrics, providing all necessary details\n // about the funnel, and receives a unique interaction id.\n // This unique interaction id is then stored in the state for further use.\n //\n // On component unmount, it checks whether the funnel was successfully completed.\n // Based on this, it either calls 'funnelComplete' or 'funnelCancelled' method from FunnelMetrics.\n //\n // The eslint-disable is required as we deliberately want this effect to run only once on mount and unmount,\n // hence we do not provide any dependencies.\n useEffect(() => {\n if (!mounted) {\n return;\n }\n\n /*\n We run this effect with a delay, in order to detect whether this funnel contains a Wizard.\n If it does contain a Wizard, that Wizard should take precedence for handling the funnel, and\n this current funnel component should do nothing.\n */\n let funnelInteractionId: string;\n const handle = setTimeout(() => {\n funnelNameSelector.current = evaluateSelectors(props.funnelNameSelectors?.() || [], getFunnelNameSelector());\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n // Reset the state, in case the component was re-mounted.\n funnelState.current = 'default';\n const funnelName = getTextFromSelector(funnelNameSelector.current) ?? '';\n\n const singleStepFlowStepConfiguration = [\n {\n number: 1,\n isOptional: false,\n name: funnelName,\n stepIdentifier: props.funnelIdentifier,\n },\n ];\n\n funnelInteractionId = FunnelMetrics.funnelStart({\n funnelName,\n funnelIdentifier: props.funnelIdentifier,\n flowType: props.funnelFlowType,\n funnelNameSelector: funnelNameSelector.current,\n optionalStepNumbers: props.optionalStepNumbers,\n funnelType: props.funnelType,\n totalFunnelSteps: props.totalFunnelSteps,\n componentVersion: PACKAGE_VERSION,\n componentTheme: isVisualRefresh ? 'vr' : 'classic',\n funnelVersion: FUNNEL_VERSION,\n stepConfiguration: stepConfiguration ?? singleStepFlowStepConfiguration,\n resourceType: props.funnelResourceType || getTextFromSelector(`[${DATA_ATTR_RESOURCE_TYPE}]`),\n });\n\n setFunnelInteractionId(funnelInteractionId);\n }, 1);\n\n /*\n A funnel counts as \"successful\" if it is unmounted after being \"complete\".\n */\n /* eslint-disable react-hooks/exhaustive-deps */\n return () => {\n clearTimeout(handle);\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n if (funnelState.current === 'validating') {\n // Finish the validation phase early.\n const taskCompletionDataProps: TaskCompletionDataProps = {\n taskIdentifier: props.funnelIdentifier,\n taskType: props.funnelType,\n timeToRespondAfterFormSubmit: performance.now() - formSubmitStartTime.current,\n taskInteractionId: funnelInteractionId,\n taskFlowType: props.funnelFlowType,\n };\n onFunnelComplete(taskCompletionDataProps);\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId, funnelIdentifier: props.funnelIdentifier });\n } else {\n funnelState.current = 'cancelled';\n onFunnelCancelled({ funnelInteractionId, funnelIdentifier: props.funnelIdentifier });\n }\n };\n }, [mounted]);\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const funnelSubmit = () => {\n funnelState.current = 'validating';\n formSubmitStartTime.current = performance.now();\n /*\n When the user attempts to submit the form, we wait for 50 milliseconds before checking\n if any form validation errors are present. This value was chosen to give enough time\n for validation and rerendering to occur, but be low enough that the user will not\n be able to take further action in the meantime.\n */\n const VALIDATION_WAIT_DELAY = 50;\n /*\n Loading is expected to take longer than validation, so we can keep the pressure on the CPU low.\n */\n const LOADING_WAIT_DELAY = 100;\n\n const checkForCompleteness = () => {\n if (funnelState.current === 'complete') {\n return;\n }\n\n if (loadingButtonCount.current > 0) {\n setTimeout(checkForCompleteness, LOADING_WAIT_DELAY);\n return;\n }\n\n if (errorCount.current === 0) {\n /*\n If no validation errors are rendered, we treat the funnel as complete.\n */\n const taskCompletionDataProps: TaskCompletionDataProps = {\n taskIdentifier: props.funnelIdentifier,\n taskType: props.funnelType,\n timeToRespondAfterFormSubmit: performance.now() - formSubmitStartTime.current,\n taskInteractionId: funnelInteractionId,\n taskFlowType: props.funnelFlowType,\n };\n onFunnelComplete(taskCompletionDataProps);\n funnelState.current = 'complete';\n } else {\n funnelState.current = 'default';\n }\n };\n setTimeout(checkForCompleteness, VALIDATION_WAIT_DELAY);\n };\n\n const funnelNextOrSubmitAttempt = () => setSubmissionAttempt(i => i + 1);\n\n const funnelCancel = () => {};\n\n const funnelContextValue: FunnelContextValue = {\n funnelInteractionId,\n funnelIdentifier: props.funnelIdentifier,\n funnelFlowType: props.funnelFlowType,\n funnelErrorContext: props.funnelErrorContext,\n setFunnelInteractionId,\n funnelType: props.funnelType,\n optionalStepNumbers: props.optionalStepNumbers,\n totalFunnelSteps: props.totalFunnelSteps,\n funnelNameSelector: funnelNameSelector.current,\n funnelSubmit,\n funnelCancel,\n submissionAttempt,\n funnelNextOrSubmitAttempt,\n funnelState,\n errorCount,\n loadingButtonCount,\n latestFocusCleanupFunction,\n isInFunnel: true,\n wizardCount,\n };\n\n return <FunnelContext.Provider value={funnelContextValue}>{children}</FunnelContext.Provider>;\n};\n\ninterface AnalyticsFunnelStepProps {\n mounted?: boolean;\n stepIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n stepErrorContext?: AnalyticsMetadata['errorContext'];\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n stepNameSelector?: FunnelStepProps['stepNameSelector'];\n stepNumber: FunnelStepProps['stepNumber'];\n}\n\nexport const AnalyticsFunnelStep = (props: AnalyticsFunnelStepProps) => {\n /*\n This wrapper is used to apply a `key` property to the actual (inner) AnalyticsFunnelStep\n element. This allows us to keep the state and effects separate per step.\n */\n return <InnerAnalyticsFunnelStep {...props} key={props.stepNumber} />;\n};\n\nfunction getSubStepConfiguration(): SubStepConfiguration[] {\n const subSteps = Array.from(document.querySelectorAll<HTMLElement>(getSubStepAllSelector()));\n\n const subStepConfiguration = subSteps.map((substep, index) => {\n const subStepIdentifier = (substep as any)?.__awsuiMetadata__?.analytics?.instanceIdentifier;\n const name = substep.querySelector<HTMLElement>(getSubStepNameSelector())?.innerText?.trim() ?? '';\n\n return {\n name,\n number: index + 1,\n subStepIdentifier,\n };\n });\n return subStepConfiguration;\n}\n\nfunction useStepChangeListener(stepNumber: number, handler: (stepConfiguration: SubStepConfiguration[]) => void) {\n const subStepConfiguration = useRef(new Map<number, SubStepConfiguration[] | undefined>());\n /*\n Chosen so that it's hopefully shorter than a user interaction, but gives enough time for the\n amount of containers to stabilise.\n */\n const SUBSTEP_CHANGE_DEBOUNCE = 50;\n\n const listenForSubStepChanges = useRef(false);\n useEffect(() => {\n // We prevent emitting the event on the first render.\n const handle = setTimeout(() => (listenForSubStepChanges.current = true), SUBSTEP_CHANGE_DEBOUNCE);\n\n return () => {\n clearTimeout(handle);\n listenForSubStepChanges.current = false;\n };\n }, []);\n\n useEffect(() => {\n const handle = setTimeout(\n () => subStepConfiguration.current.set(stepNumber, getSubStepConfiguration()),\n SUBSTEP_CHANGE_DEBOUNCE\n );\n return () => {\n clearTimeout(handle);\n };\n }, [stepNumber]);\n\n /* We debounce this handler, so that multiple containers can change at once without causing\n too many events. */\n const stepChangeCallback = useDebounceCallback(() => {\n // We don't want to emit the event after the component has been unmounted.\n if (!listenForSubStepChanges.current) {\n return;\n }\n\n subStepConfiguration.current.set(stepNumber, getSubStepConfiguration());\n handler(subStepConfiguration.current.get(stepNumber)!);\n }, SUBSTEP_CHANGE_DEBOUNCE);\n\n return { onStepChange: stepChangeCallback, subStepConfiguration };\n}\n\nconst InnerAnalyticsFunnelStep = ({\n mounted = true,\n children,\n stepNumber,\n stepIdentifier,\n stepErrorContext,\n ...rest\n}: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, funnelIdentifier, funnelNameSelector, funnelState, funnelType } = useFunnel();\n const parentStep = useFunnelStep();\n const parentStepExists = parentStep.isInStep;\n const parentStepFunnelInteractionId = parentStep.funnelInteractionId;\n\n const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };\n\n const subStepCount = useRef<number>(0);\n\n const stepNameSelector = rest.stepNameSelector || funnelNameSelector;\n const { onStepChange, subStepConfiguration } = useStepChangeListener(stepNumber, subStepConfiguration => {\n if (!funnelInteractionId) {\n return;\n }\n\n FunnelMetrics.funnelStepChange({\n stepIdentifier,\n funnelIdentifier,\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration,\n });\n });\n\n useEffect(() => {\n if (!funnelInteractionId) {\n // This step is not inside an active funnel.\n return;\n }\n\n if (mounted) {\n return;\n }\n\n const stepName = getTextFromSelector(stepNameSelector);\n const handler = setTimeout(() => {\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n funnelIdentifier,\n funnelInteractionId,\n stepIdentifier,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n });\n }\n }, 0);\n\n return () => {\n clearTimeout(handler);\n };\n }, [\n stepIdentifier,\n funnelIdentifier,\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n funnelState,\n parentStepExists,\n funnelType,\n parentStepFunnelInteractionId,\n mounted,\n ]);\n\n // This useEffect hook is used to track the start and completion of interaction with the step.\n // On mount, if there is a valid funnel interaction id, it calls the 'funnelStepStart' method from FunnelMetrics\n // to record the beginning of the interaction with the current step.\n // On unmount, it does a similar thing but this time calling 'funnelStepComplete' to record the completion of the interaction.\n useEffect(() => {\n if (!funnelInteractionId) {\n // This step is not inside an active funnel.\n return;\n }\n\n if (parentStepExists && parentStepFunnelInteractionId) {\n /*\n This step is inside another step, which already reports events as\n part of an active funnel (i.e. that step is not a parent of a Wizard).\n Thus, this current step does not need to report any events.\n */\n return;\n }\n\n const stepName = getTextFromSelector(stepNameSelector);\n\n if (funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n stepIdentifier,\n funnelIdentifier,\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration: getSubStepConfiguration(),\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n funnelIdentifier,\n funnelInteractionId,\n stepIdentifier,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n totalSubSteps: subStepCount.current,\n });\n }\n };\n }, [\n stepIdentifier,\n funnelIdentifier,\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n funnelState,\n parentStepExists,\n funnelType,\n parentStepFunnelInteractionId,\n ]);\n\n const contextValue: FunnelStepContextValue = {\n stepIdentifier,\n stepNumber,\n stepNameSelector,\n funnelStepProps,\n subStepCount,\n isInStep: true,\n funnelInteractionId,\n onStepChange,\n subStepConfiguration,\n stepErrorContext,\n };\n\n /*\n If this step is inside another step which already reports events as part of an active\n funnel (i.e. that step is not a parent of a Wizard), the current step becomes invisible\n in the hierarchy by passing the context of its parent through.\n */\n const effectiveContextValue = parentStepExists && parentStepFunnelInteractionId ? parentStep : contextValue;\n\n return (\n <FunnelStepContext.Provider value={effectiveContextValue}>\n {typeof children === 'function' ? children(effectiveContextValue) : children}\n </FunnelStepContext.Provider>\n );\n};\ninterface AnalyticsFunnelSubStepProps {\n subStepIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n subStepErrorContext?: AnalyticsMetadata['errorContext'];\n children?: React.ReactNode | ((props: FunnelSubStepContextValue) => React.ReactNode);\n}\n\nexport const AnalyticsFunnelSubStep = ({\n children,\n subStepIdentifier,\n subStepErrorContext,\n}: AnalyticsFunnelSubStepProps) => {\n const subStepId = useUniqueId('substep');\n const subStepSelector = getSubStepSelector(subStepId);\n const subStepNameSelector = getSubStepNameSelector(subStepId);\n const subStepRef = useRef<HTMLDivElement | null>(null);\n const { subStepCount, onStepChange } = useFunnelStep();\n const mousePressed = useRef<boolean>(false);\n const isFocusedSubStep = useRef<boolean>(false);\n const focusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n const { funnelState, funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const newContext: FunnelSubStepContextValue = {\n subStepIdentifier,\n subStepErrorContext,\n subStepSelector,\n subStepNameSelector,\n subStepId,\n subStepRef,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n isNestedSubStep: false,\n };\n\n const inheritedContext = { ...useContext(FunnelSubStepContext), isNestedSubStep: true };\n\n const isNested = Boolean(inheritedContext.subStepId);\n\n useEffect(() => {\n if (!isNested) {\n subStepCount.current++;\n onStepChange();\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n subStepCount.current--;\n onStepChange();\n };\n }\n }, [isNested, subStepCount, onStepChange]);\n\n const context = isNested ? inheritedContext : newContext;\n\n useEffect(() => {\n if (isNested || !subStepRef.current) {\n return;\n }\n\n const onMouseDown = () => (mousePressed.current = true);\n\n const onMouseUp = async () => {\n mousePressed.current = false;\n\n if (!isFocusedSubStep.current) {\n return;\n }\n\n /*\n Some mouse events result in an element being focused. However,\n this happens only _after_ the onMouseUp event. We yield the\n event loop here, so that `document.activeElement` has the\n correct new value.\n */\n await new Promise(r => setTimeout(r, 1));\n\n if (!subStepRef.current || !document.activeElement || !nodeBelongs(subStepRef.current, document.activeElement)) {\n isFocusedSubStep.current = false;\n\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n };\n window.addEventListener('mousedown', onMouseDown);\n window.addEventListener('mouseup', onMouseUp);\n return () => {\n window.removeEventListener('mousedown', onMouseDown);\n window.removeEventListener('mouseup', onMouseUp);\n };\n }, [\n funnelInteractionId,\n funnelState,\n stepNameSelector,\n stepNumber,\n subStepNameSelector,\n subStepSelector,\n focusCleanupFunction,\n isNested,\n subStepRef,\n ]);\n\n return (\n <FunnelSubStepContext.Provider value={context}>\n {typeof children === 'function' ? children(context) : children}\n </FunnelSubStepContext.Provider>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"analytics-funnel.js","sourceRoot":"","sources":["../../../../../src/internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EACL,aAAa,EAGb,iBAAiB,EAEjB,oBAAoB,GAErB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAS7D,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,MAAM,cAAc,GAAG,KAAK,CAAC;AAgB7B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC7D,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,EAAE,CAAC;IACnC;;;;;MAKE;IACF,IAAI,UAAU,IAAI,KAAK,CAAC,UAAU,KAAK,aAAa,EAAE;QACpD,OAAO,0CAAG,KAAK,C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CAAC;YAEzC,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE;gBAC9G,gBAAgB,CAAC,OAAO,GAAG,KAAK,CAAC;gBAEjC;;;mBAGG;gBACH,MAAA,oBAAoB,CAAC,OAAO,oEAAI,CAAC;aAClC;QACH,CAAC,CAAA,CAAC;QACF,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QACjF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7E,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,mBAAmB;QACnB,WAAW;QACX,gBAAgB;QAChB,UAAU;QACV,mBAAmB;QACnB,eAAe;QACf,oBAAoB;QACpB,QAAQ;QACR,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAC1C,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAChC,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef, useState } from 'react';\n\nimport { PACKAGE_VERSION } from '../../environment';\nimport { useDebounceCallback } from '../../hooks/use-debounce-callback';\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport {\n FunnelContext,\n FunnelContextValue,\n FunnelState,\n FunnelStepContext,\n FunnelStepContextValue,\n FunnelSubStepContext,\n FunnelSubStepContextValue,\n} from '../context/analytics-context';\nimport { useFunnel, useFunnelStep } from '../hooks/use-funnel';\nimport { FunnelMetrics, PerformanceMetrics } from '../index';\nimport {\n AnalyticsMetadata,\n FunnelStartProps,\n FunnelStepProps,\n StepConfiguration,\n SubStepConfiguration,\n TaskCompletionDataProps,\n} from '../interfaces';\nimport {\n DATA_ATTR_FUNNEL_STEP,\n DATA_ATTR_RESOURCE_TYPE,\n getFunnelNameSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n getTextFromSelector,\n} from '../selectors';\n\nconst FUNNEL_VERSION = '1.4';\n\ninterface AnalyticsFunnelProps {\n mounted?: boolean;\n children?: React.ReactNode;\n stepConfiguration?: StepConfiguration[];\n funnelNameSelectors?: () => string[];\n funnelType: FunnelStartProps['funnelType'];\n optionalStepNumbers: FunnelStartProps['optionalStepNumbers'];\n totalFunnelSteps: FunnelStartProps['totalFunnelSteps'];\n funnelIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n funnelFlowType?: AnalyticsMetadata['flowType'];\n funnelErrorContext?: AnalyticsMetadata['errorContext'];\n funnelResourceType?: AnalyticsMetadata['resourceType'];\n}\n\nexport const AnalyticsFunnel = (props: AnalyticsFunnelProps) => {\n const { isInFunnel } = useFunnel();\n /*\n If the current funnel component is a Form (i.e. single-page funnel), it should\n defer its funnel-handling to a parent Form element, if present.\n Wizards (i.e. multi-page funnels) always take highest precedence for handling funnels,\n and do not defer to any other element.\n */\n if (isInFunnel && props.funnelType === 'single-page') {\n return <>{props.children}</>;\n }\n\n return <InnerAnalyticsFunnel {...props} />;\n};\n\nexport const CREATION_EDIT_FLOW_DONE_EVENT_NAME = 'awsui-creation-edit-flow-done';\nconst dispatchCreateEditFlowDoneEvent = () => {\n try {\n window.top?.document.dispatchEvent(new Event(CREATION_EDIT_FLOW_DONE_EVENT_NAME));\n } catch {\n // probably because of cross-origin error, then do not dispatch the event\n }\n};\n\nconst onFunnelCancelled = ({\n funnelInteractionId,\n funnelIdentifier,\n}: {\n funnelInteractionId: string;\n funnelIdentifier?: string;\n}) => {\n FunnelMetrics.funnelCancelled({ funnelInteractionId, funnelIdentifier });\n};\n\nconst onFunnelComplete = (taskCompletionDataProps: TaskCompletionDataProps) => {\n FunnelMetrics.funnelComplete({\n funnelInteractionId: taskCompletionDataProps.taskInteractionId,\n funnelIdentifier: taskCompletionDataProps.taskIdentifier,\n });\n PerformanceMetrics.taskCompletionData(taskCompletionDataProps);\n dispatchCreateEditFlowDoneEvent();\n};\n\nfunction evaluateSelectors(selectors: string[], defaultSelector: string) {\n for (const selector of selectors) {\n const element = document.querySelector(selector);\n if (element) {\n return selector;\n }\n }\n\n return defaultSelector;\n}\n\nconst InnerAnalyticsFunnel = ({ mounted = true, children, stepConfiguration, ...props }: AnalyticsFunnelProps) => {\n const [funnelInteractionId, setFunnelInteractionId] = useState<string>('');\n const [submissionAttempt, setSubmissionAttempt] = useState(0);\n const isVisualRefresh = useVisualRefresh();\n const funnelState = useRef<FunnelState>('default');\n const funnelNameSelector = useRef<string>(getFunnelNameSelector());\n const errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\n const wizardCount = useRef<number>(0);\n const latestFocusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n const formSubmitStartTime = useRef<number>(0);\n // This useEffect hook is run once on component mount to initiate the funnel analytics.\n // It first calls the 'funnelStart' method from FunnelMetrics, providing all necessary details\n // about the funnel, and receives a unique interaction id.\n // This unique interaction id is then stored in the state for further use.\n //\n // On component unmount, it checks whether the funnel was successfully completed.\n // Based on this, it either calls 'funnelComplete' or 'funnelCancelled' method from FunnelMetrics.\n //\n // The eslint-disable is required as we deliberately want this effect to run only once on mount and unmount,\n // hence we do not provide any dependencies.\n useEffect(() => {\n if (!mounted) {\n return;\n }\n\n /*\n We run this effect with a delay, in order to detect whether this funnel contains a Wizard.\n If it does contain a Wizard, that Wizard should take precedence for handling the funnel, and\n this current funnel component should do nothing.\n */\n let funnelInteractionId: string;\n const handle = setTimeout(() => {\n funnelNameSelector.current = evaluateSelectors(props.funnelNameSelectors?.() || [], getFunnelNameSelector());\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n // Reset the state, in case the component was re-mounted.\n funnelState.current = 'default';\n const funnelName = getTextFromSelector(funnelNameSelector.current) ?? '';\n\n const singleStepFlowStepConfiguration = [\n {\n number: 1,\n isOptional: false,\n name: funnelName,\n stepIdentifier: props.funnelIdentifier,\n },\n ];\n\n funnelInteractionId = FunnelMetrics.funnelStart({\n funnelName,\n funnelIdentifier: props.funnelIdentifier,\n flowType: props.funnelFlowType,\n funnelNameSelector: funnelNameSelector.current,\n optionalStepNumbers: props.optionalStepNumbers,\n funnelType: props.funnelType,\n totalFunnelSteps: props.totalFunnelSteps,\n componentVersion: PACKAGE_VERSION,\n componentTheme: isVisualRefresh ? 'vr' : 'classic',\n funnelVersion: FUNNEL_VERSION,\n stepConfiguration: stepConfiguration ?? singleStepFlowStepConfiguration,\n resourceType: props.funnelResourceType || getTextFromSelector(`[${DATA_ATTR_RESOURCE_TYPE}]`),\n });\n\n setFunnelInteractionId(funnelInteractionId);\n }, 1);\n\n /*\n A funnel counts as \"successful\" if it is unmounted after being \"complete\".\n */\n /* eslint-disable react-hooks/exhaustive-deps */\n return () => {\n clearTimeout(handle);\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n if (funnelState.current === 'validating') {\n // Finish the validation phase early.\n const taskCompletionDataProps: TaskCompletionDataProps = {\n taskIdentifier: props.funnelIdentifier,\n taskType: props.funnelType,\n timeToRespondAfterFormSubmit: performance.now() - formSubmitStartTime.current,\n taskInteractionId: funnelInteractionId,\n taskFlowType: props.funnelFlowType,\n };\n onFunnelComplete(taskCompletionDataProps);\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId, funnelIdentifier: props.funnelIdentifier });\n } else {\n funnelState.current = 'cancelled';\n onFunnelCancelled({ funnelInteractionId, funnelIdentifier: props.funnelIdentifier });\n }\n };\n }, [mounted]);\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const funnelSubmit = () => {\n funnelState.current = 'validating';\n formSubmitStartTime.current = performance.now();\n /*\n When the user attempts to submit the form, we wait for 50 milliseconds before checking\n if any form validation errors are present. This value was chosen to give enough time\n for validation and rerendering to occur, but be low enough that the user will not\n be able to take further action in the meantime.\n */\n const VALIDATION_WAIT_DELAY = 50;\n /*\n Loading is expected to take longer than validation, so we can keep the pressure on the CPU low.\n */\n const LOADING_WAIT_DELAY = 100;\n\n const checkForCompleteness = () => {\n if (funnelState.current === 'complete') {\n return;\n }\n\n if (loadingButtonCount.current > 0) {\n setTimeout(checkForCompleteness, LOADING_WAIT_DELAY);\n return;\n }\n\n if (errorCount.current === 0) {\n /*\n If no validation errors are rendered, we treat the funnel as complete.\n */\n const taskCompletionDataProps: TaskCompletionDataProps = {\n taskIdentifier: props.funnelIdentifier,\n taskType: props.funnelType,\n timeToRespondAfterFormSubmit: performance.now() - formSubmitStartTime.current,\n taskInteractionId: funnelInteractionId,\n taskFlowType: props.funnelFlowType,\n };\n onFunnelComplete(taskCompletionDataProps);\n funnelState.current = 'complete';\n } else {\n funnelState.current = 'default';\n }\n };\n setTimeout(checkForCompleteness, VALIDATION_WAIT_DELAY);\n };\n\n const funnelNextOrSubmitAttempt = () => setSubmissionAttempt(i => i + 1);\n\n const funnelCancel = () => {};\n\n const funnelContextValue: FunnelContextValue = {\n funnelInteractionId,\n funnelIdentifier: props.funnelIdentifier,\n funnelFlowType: props.funnelFlowType,\n funnelErrorContext: props.funnelErrorContext,\n setFunnelInteractionId,\n funnelType: props.funnelType,\n optionalStepNumbers: props.optionalStepNumbers,\n totalFunnelSteps: props.totalFunnelSteps,\n funnelNameSelector: funnelNameSelector.current,\n funnelSubmit,\n funnelCancel,\n submissionAttempt,\n funnelNextOrSubmitAttempt,\n funnelState,\n errorCount,\n loadingButtonCount,\n latestFocusCleanupFunction,\n isInFunnel: true,\n wizardCount,\n };\n\n return <FunnelContext.Provider value={funnelContextValue}>{children}</FunnelContext.Provider>;\n};\n\ninterface AnalyticsFunnelStepProps {\n mounted?: boolean;\n stepIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n stepErrorContext?: AnalyticsMetadata['errorContext'];\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n stepNameSelector?: FunnelStepProps['stepNameSelector'];\n stepNumber: FunnelStepProps['stepNumber'];\n}\n\nexport const AnalyticsFunnelStep = (props: AnalyticsFunnelStepProps) => {\n /*\n This wrapper is used to apply a `key` property to the actual (inner) AnalyticsFunnelStep\n element. This allows us to keep the state and effects separate per step.\n */\n return <InnerAnalyticsFunnelStep {...props} key={props.stepNumber} />;\n};\n\nfunction getSubStepConfiguration(): SubStepConfiguration[] {\n const subSteps = Array.from(document.querySelectorAll<HTMLElement>(getSubStepAllSelector()));\n\n const subStepConfiguration = subSteps.map((substep, index) => {\n const subStepIdentifier = (substep as any)?.__awsuiMetadata__?.analytics?.instanceIdentifier;\n const name = substep.querySelector<HTMLElement>(getSubStepNameSelector())?.innerText?.trim() ?? '';\n\n return {\n name,\n number: index + 1,\n subStepIdentifier,\n };\n });\n return subStepConfiguration;\n}\n\nfunction useStepChangeListener(stepNumber: number, handler: (stepConfiguration: SubStepConfiguration[]) => void) {\n const subStepConfiguration = useRef(new Map<number, SubStepConfiguration[] | undefined>());\n /*\n Chosen so that it's hopefully shorter than a user interaction, but gives enough time for the\n amount of containers to stabilise.\n */\n const SUBSTEP_CHANGE_DEBOUNCE = 50;\n\n const listenForSubStepChanges = useRef(false);\n useEffect(() => {\n // We prevent emitting the event on the first render.\n const handle = setTimeout(() => (listenForSubStepChanges.current = true), SUBSTEP_CHANGE_DEBOUNCE);\n\n return () => {\n clearTimeout(handle);\n listenForSubStepChanges.current = false;\n };\n }, []);\n\n useEffect(() => {\n const handle = setTimeout(\n () => subStepConfiguration.current.set(stepNumber, getSubStepConfiguration()),\n SUBSTEP_CHANGE_DEBOUNCE\n );\n return () => {\n clearTimeout(handle);\n };\n }, [stepNumber]);\n\n /* We debounce this handler, so that multiple containers can change at once without causing\n too many events. */\n const stepChangeCallback = useDebounceCallback(() => {\n // We don't want to emit the event after the component has been unmounted.\n if (!listenForSubStepChanges.current) {\n return;\n }\n\n subStepConfiguration.current.set(stepNumber, getSubStepConfiguration());\n handler(subStepConfiguration.current.get(stepNumber)!);\n }, SUBSTEP_CHANGE_DEBOUNCE);\n\n return { onStepChange: stepChangeCallback, subStepConfiguration };\n}\n\nconst InnerAnalyticsFunnelStep = ({\n mounted = true,\n children,\n stepNumber,\n stepIdentifier,\n stepErrorContext,\n ...rest\n}: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, funnelIdentifier, funnelNameSelector, funnelState, funnelType } = useFunnel();\n const parentStep = useFunnelStep();\n const parentStepExists = parentStep.isInStep;\n const parentStepFunnelInteractionId = parentStep.funnelInteractionId;\n\n const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };\n\n const subStepCount = useRef<number>(0);\n\n const stepNameSelector = rest.stepNameSelector || funnelNameSelector;\n const { onStepChange, subStepConfiguration } = useStepChangeListener(stepNumber, subStepConfiguration => {\n if (!funnelInteractionId) {\n return;\n }\n\n FunnelMetrics.funnelStepChange({\n stepIdentifier,\n funnelIdentifier,\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration,\n });\n });\n\n useEffect(() => {\n if (!funnelInteractionId) {\n // This step is not inside an active funnel.\n return;\n }\n\n if (mounted) {\n return;\n }\n\n const stepName = getTextFromSelector(stepNameSelector);\n const handler = setTimeout(() => {\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n funnelIdentifier,\n funnelInteractionId,\n stepIdentifier,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n });\n }\n }, 0);\n\n return () => {\n clearTimeout(handler);\n };\n }, [\n stepIdentifier,\n funnelIdentifier,\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n funnelState,\n parentStepExists,\n funnelType,\n parentStepFunnelInteractionId,\n mounted,\n ]);\n\n // This useEffect hook is used to track the start and completion of interaction with the step.\n // On mount, if there is a valid funnel interaction id, it calls the 'funnelStepStart' method from FunnelMetrics\n // to record the beginning of the interaction with the current step.\n // On unmount, it does a similar thing but this time calling 'funnelStepComplete' to record the completion of the interaction.\n useEffect(() => {\n if (!funnelInteractionId) {\n // This step is not inside an active funnel.\n return;\n }\n\n if (parentStepExists && parentStepFunnelInteractionId) {\n /*\n This step is inside another step, which already reports events as\n part of an active funnel (i.e. that step is not a parent of a Wizard).\n Thus, this current step does not need to report any events.\n */\n return;\n }\n\n const stepName = getTextFromSelector(stepNameSelector);\n\n if (funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n stepIdentifier,\n funnelIdentifier,\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration: getSubStepConfiguration(),\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n funnelIdentifier,\n funnelInteractionId,\n stepIdentifier,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n totalSubSteps: subStepCount.current,\n });\n }\n };\n }, [\n stepIdentifier,\n funnelIdentifier,\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n funnelState,\n parentStepExists,\n funnelType,\n parentStepFunnelInteractionId,\n ]);\n\n const contextValue: FunnelStepContextValue = {\n stepIdentifier,\n stepNumber,\n stepNameSelector,\n funnelStepProps,\n subStepCount,\n isInStep: true,\n funnelInteractionId,\n onStepChange,\n subStepConfiguration,\n stepErrorContext,\n };\n\n /*\n If this step is inside another step which already reports events as part of an active\n funnel (i.e. that step is not a parent of a Wizard), the current step becomes invisible\n in the hierarchy by passing the context of its parent through.\n */\n const effectiveContextValue = parentStepExists && parentStepFunnelInteractionId ? parentStep : contextValue;\n\n return (\n <FunnelStepContext.Provider value={effectiveContextValue}>\n {typeof children === 'function' ? children(effectiveContextValue) : children}\n </FunnelStepContext.Provider>\n );\n};\ninterface AnalyticsFunnelSubStepProps {\n subStepIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n subStepErrorContext?: AnalyticsMetadata['errorContext'];\n children?: React.ReactNode | ((props: FunnelSubStepContextValue) => React.ReactNode);\n}\n\nexport const AnalyticsFunnelSubStep = ({\n children,\n subStepIdentifier,\n subStepErrorContext,\n}: AnalyticsFunnelSubStepProps) => {\n const subStepId = useUniqueId('substep');\n const subStepSelector = getSubStepSelector(subStepId);\n const subStepNameSelector = getSubStepNameSelector(subStepId);\n const subStepRef = useRef<HTMLDivElement | null>(null);\n const { subStepCount, onStepChange } = useFunnelStep();\n const mousePressed = useRef<boolean>(false);\n const isFocusedSubStep = useRef<boolean>(false);\n const focusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n const { funnelState, funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const newContext: FunnelSubStepContextValue = {\n subStepIdentifier,\n subStepErrorContext,\n subStepSelector,\n subStepNameSelector,\n subStepId,\n subStepRef,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n isNestedSubStep: false,\n };\n\n const inheritedContext = { ...useContext(FunnelSubStepContext), isNestedSubStep: true };\n\n const isNested = Boolean(inheritedContext.subStepId);\n\n useEffect(() => {\n if (!isNested) {\n subStepCount.current++;\n onStepChange();\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n subStepCount.current--;\n onStepChange();\n };\n }\n }, [isNested, subStepCount, onStepChange]);\n\n const context = isNested ? inheritedContext : newContext;\n\n useEffect(() => {\n if (isNested || !subStepRef.current) {\n return;\n }\n\n const onMouseDown = () => (mousePressed.current = true);\n\n const onMouseUp = async () => {\n mousePressed.current = false;\n\n if (!isFocusedSubStep.current) {\n return;\n }\n\n /*\n Some mouse events result in an element being focused. However,\n this happens only _after_ the onMouseUp event. We yield the\n event loop here, so that `document.activeElement` has the\n correct new value.\n */\n await new Promise(r => setTimeout(r, 1));\n\n if (!subStepRef.current || !document.activeElement || !nodeBelongs(subStepRef.current, document.activeElement)) {\n isFocusedSubStep.current = false;\n\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n };\n const controller = new AbortController();\n window.addEventListener('mousedown', onMouseDown, { signal: controller.signal });\n window.addEventListener('mouseup', onMouseUp, { signal: controller.signal });\n return () => {\n controller.abort();\n };\n }, [\n funnelInteractionId,\n funnelState,\n stepNameSelector,\n stepNumber,\n subStepNameSelector,\n subStepSelector,\n focusCleanupFunction,\n isNested,\n subStepRef,\n ]);\n\n return (\n <FunnelSubStepContext.Provider value={context}>\n {typeof children === 'function' ? children(context) : children}\n </FunnelSubStepContext.Provider>\n );\n};\n"]}
|
package/internal/animate.js
CHANGED
|
@@ -81,7 +81,7 @@ export function animate({ oldState, elements, onTransitionsEnd, newElementInitia
|
|
|
81
81
|
if (event.target === element) {
|
|
82
82
|
// Clean up remaining inline styles
|
|
83
83
|
element.style.transitionProperty = '';
|
|
84
|
-
element.removeEventListener('
|
|
84
|
+
element.removeEventListener('transitionend', onTransitionEnd);
|
|
85
85
|
if (onTransitionsEnd) {
|
|
86
86
|
ongoingAnimations.delete(id);
|
|
87
87
|
if (ongoingAnimations.size === 0) {
|
package/internal/animate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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C;6BACpB;yBACF;qBACF;gBACH,CAAC,CAAC;gBACF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;gBAC/D,OAAO,CAAC,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;aAC5D;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function getDOMRects(elements: Record<string, HTMLElement | null>) {\n const rects: Record<string, DOMRect> = {};\n for (const id in elements) {\n const element = elements[id];\n if (element) {\n rects[id] = element.getBoundingClientRect();\n }\n }\n return rects;\n}\n\n/*\n Animate DOM elements based on the FLIP technique\n - https://aerotwist.com/blog/flip-your-animations/\n - https://css-tricks.com/animating-layouts-with-the-flip-technique/\n\n This can be useful when the initial dimensions or position of the element is not known,\n so the initial offset or scaling needs to be retrieved via JS.\n\n Caveat: this currently does not support elements having CSS transforms in the end state.\n These would be overridden in the animation instead of combined.\n */\nexport function animate({\n oldState,\n elements,\n onTransitionsEnd,\n newElementInitialState,\n}: {\n elements: Record<string, HTMLElement | null>;\n oldState: Record<string, DOMRect>;\n onTransitionsEnd?: () => void;\n newElementInitialState?: (newRect: DOMRect) => { scale?: number; y?: number };\n}) {\n // First, apply the transform that will make the elements \"look like\" in the start position\n for (const id in elements) {\n const element = elements[id];\n const oldRect = oldState[id];\n if (element) {\n const newRect = element.getBoundingClientRect();\n const noOpTransform = { scale: 1, x: 0, y: 0 };\n // Calculate initial position.\n // If the element didn't exist previously, use the newElementInitialState function if provided.\n // If not, default to no transitions (scale: 1, y: 0)\n const calculatedInverseTransform = oldRect\n ? {\n scale: oldRect.width / newRect.width,\n x: (oldRect.left + oldRect.right) / 2 - (newRect.left + newRect.right) / 2,\n y: (oldRect.top + oldRect.bottom) / 2 - (newRect.top + newRect.bottom) / 2,\n }\n : newElementInitialState\n ? newElementInitialState(newRect)\n : {};\n const inverseTransform = { ...noOpTransform, ...calculatedInverseTransform };\n // Apply this initial change, without animating\n element.style.transitionProperty = 'none';\n element.style.transform = `scale(${inverseTransform.scale}) translate(${inverseTransform.x}px, ${inverseTransform.y}px)`;\n if (!oldRect) {\n // If the element didn't exist, then fade it in\n // (besides any other possibly defined transitions based on `newElementInitialState`)\n element.style.opacity = '0';\n }\n }\n }\n\n // Animate from the initial state to the end state\n requestAnimationFrame(() => {\n const ongoingAnimations = new Set();\n for (const id in elements) {\n const element = elements[id];\n if (element) {\n const oldRect = oldState[id];\n if (oldRect) {\n // Animate from here on\n element.style.transitionProperty = `transform`;\n // Unset inline CSS transforms so that the final state is applied\n element.style.transform = '';\n } else {\n // If the element didn't exist previously, fade in as well\n element.style.transitionProperty = `transform, opacity`;\n element.style.transform = '';\n element.style.opacity = '';\n }\n const onTransitionStart = (event: TransitionEvent) => {\n if (event.target === element) {\n ongoingAnimations.add(id);\n element.removeEventListener('transitionstart', onTransitionStart);\n }\n };\n const onTransitionEnd = (event: TransitionEvent) => {\n if (event.target === element) {\n // Clean up remaining inline styles\n element.style.transitionProperty = '';\n element.removeEventListener('transitionend', onTransitionEnd);\n if (onTransitionsEnd) {\n ongoingAnimations.delete(id);\n if (ongoingAnimations.size === 0) {\n onTransitionsEnd();\n }\n }\n }\n };\n element.addEventListener('transitionstart', onTransitionStart);\n element.addEventListener('transitionend', onTransitionEnd);\n }\n }\n });\n}\n"]}
|
|
@@ -16,11 +16,11 @@ function useFocusVisibleState() {
|
|
|
16
16
|
setFocusVisible(true);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
document.addEventListener('
|
|
19
|
+
const controller = new AbortController();
|
|
20
|
+
document.addEventListener('mousedown', handleMousedown, { signal: controller.signal });
|
|
21
|
+
document.addEventListener('keydown', handleKeydown, { signal: controller.signal });
|
|
21
22
|
return () => {
|
|
22
|
-
|
|
23
|
-
document.removeEventListener('keydown', handleKeydown);
|
|
23
|
+
controller.abort();
|
|
24
24
|
};
|
|
25
25
|
});
|
|
26
26
|
return focusVisible;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-outline.js","sourceRoot":"","sources":["../../../../../src/internal/components/chart-plot/focus-outline.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAI9E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC,SAAS,oBAAoB;IAC3B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,eAAe;YACtB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QAED,SAAS,aAAa,CAAC,KAAoB;YACzC,8CAA8C;YAC9C,gCAAgC;YAChC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;gBACzB,eAAe,CAAC,IAAI,CAAC,CAAC;aACvB;QACH,CAAC;QAED,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"focus-outline.js","sourceRoot":"","sources":["../../../../../src/internal/components/chart-plot/focus-outline.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAI9E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC,SAAS,oBAAoB;IAC3B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,SAAS,CAAC,GAAG,EAAE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AAC,eAAe,CAAC,GAAG,CAAC,CAAC;IACxB,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5B,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { isModifierKey } from '@cloudscape-design/component-toolkit/internal';\n\nimport { Offset } from '../interfaces';\n\nimport styles from './styles.css.js';\n\ninterface FocusOutlineProps {\n elementKey?: null | string | number | boolean;\n elementRef?: React.RefObject<SVGSVGElement | SVGGElement>;\n offset?: Offset;\n}\n\nfunction useFocusVisibleState() {\n const [focusVisible, setFocusVisible] = useState(false);\n useEffect(() => {\n function handleMousedown() {\n return setFocusVisible(false);\n }\n\n function handleKeydown(event: KeyboardEvent) {\n // we do not want to highlight focused element\n // when special keys are pressed\n if (!isModifierKey(event)) {\n setFocusVisible(true);\n }\n }\n\n const controller = new AbortController();\n document.addEventListener('mousedown', handleMousedown, { signal: controller.signal });\n document.addEventListener('keydown', handleKeydown, { signal: controller.signal });\n return () => {\n controller.abort();\n };\n });\n\n return focusVisible;\n}\n\nexport default function FocusOutline({ elementKey, elementRef, offset = 0 }: FocusOutlineProps) {\n const ref = useRef<SVGRectElement>(null);\n const focusVisible = useFocusVisibleState();\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n if (focusVisible && elementKey && elementRef && elementRef.current && elementRef.current.getBBox) {\n const element = elementRef.current.getBBox();\n showOutline(ref.current, element, offset);\n } else {\n hideOutline(ref.current);\n }\n }, [focusVisible, elementKey, elementRef, offset]);\n\n return <rect ref={ref} aria-hidden=\"true\" className={styles['focus-outline']} rx=\"2\" />;\n}\n\nfunction showOutline(\n el: SVGRectElement,\n position: { x: number; y: number; width: number; height: number },\n offset: Offset\n) {\n const offsetX = typeof offset === 'number' ? offset : offset.x;\n const offsetY = typeof offset === 'number' ? offset : offset.y;\n el.setAttribute('x', (position.x - offsetX).toString());\n el.setAttribute('y', (position.y - offsetY).toString());\n el.setAttribute('width', (position.width + 2 * offsetX).toString());\n el.setAttribute('height', (position.height + 2 * offsetY).toString());\n el.style.visibility = 'visible';\n}\n\nfunction hideOutline(el: SVGRectElement) {\n el.style.visibility = 'hidden';\n el.removeAttribute('x');\n el.removeAttribute('y');\n el.removeAttribute('width');\n el.removeAttribute('height');\n}\n"]}
|
|
@@ -244,11 +244,11 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
|
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
246
|
updateDropdownPosition();
|
|
247
|
-
|
|
248
|
-
window.addEventListener('
|
|
247
|
+
const controller = new AbortController();
|
|
248
|
+
window.addEventListener('scroll', updateDropdownPosition, { capture: true, signal: controller.signal });
|
|
249
|
+
window.addEventListener('resize', updateDropdownPosition, { capture: true, signal: controller.signal });
|
|
249
250
|
return () => {
|
|
250
|
-
|
|
251
|
-
window.removeEventListener('resize', updateDropdownPosition, true);
|
|
251
|
+
controller.abort();
|
|
252
252
|
};
|
|
253
253
|
}, [open, expandToViewport]);
|
|
254
254
|
const referrerId = useUniqueId();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,O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,EAAE,GAAG,EAAE,WAAC,OAAA,UAAU,CAAC,OAAO,KAAI,MAAA,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC5F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B;gBAEF,oBAAC,iBAAiB,IAChB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,GAAG,EAClB,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,yBAAyB,EAAE,yBAAyB,EACpD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,mBAAmB,EACzB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,IAE/B,QAAQ,CACS;gBAEpB,oBAAC,OAAO,IACN,iBAAiB,EAAE,GAAG,EAAE,WAAC,OAAA,UAAU,CAAC,OAAO,KAAI,MAAA,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC7F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B,CACE,CACP,CACU,CACK,CAChB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,QAAqD,EACf,EAAE,CAAE,QAAqC,CAAC,aAAa,KAAK,SAAS,CAAC;AAE9G,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\n\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../events';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useUniqueId } from '../../hooks/use-unique-id/index.js';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\nimport TabTrap from '../tab-trap/index.js';\nimport { Transition, TransitionStatus } from '../transition';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport {\n calculatePosition,\n defaultMaxDropdownWidth,\n DropdownPosition,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\n InteriorDropdownPosition,\n} from './dropdown-fit-handler';\nimport { DropdownProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface DropdownContainerProps {\n triggerRef: React.RefObject<HTMLElement>;\n children?: React.ReactNode;\n renderWithPortal: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({\n triggerRef,\n children,\n renderWithPortal,\n id,\n referrerId,\n open,\n}: DropdownContainerProps) => {\n if (!renderWithPortal) {\n return <>{children}</>;\n }\n if (!open) {\n return null;\n }\n const currentDocument = triggerRef.current?.ownerDocument ?? document;\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n currentDocument.body\n );\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: DOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;\n } else {\n verticalContainer.style.maxBlockSize = position.blockSize;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.inlineSize = position.inlineSize;\n }\n\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropBlockStart && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.insetBlockEnd = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.insetInlineStart && position.insetInlineStart !== 'auto') {\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n target.style.position = 'fixed';\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = `calc(100% - ${triggerBox.top}px)`;\n } else {\n target.style.insetBlockStart = `${triggerBox.bottom}px`;\n }\n if (position.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerBox.right}px - ${position.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerBox.left}px`;\n }\n // Keep track of the initial dropdown position and direction.\n // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.\n fixedPosition.current = position;\n return;\n }\n\n // For an interior dropdown (the fly out) we need exact values for positioning\n // and classes are not enough\n // usage of relative position is impossible due to overwrite of overflow-x\n if (interior && isInteriorPosition(position)) {\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = position.insetBlockEnd;\n } else {\n target.style.insetBlockStart = position.insetBlockStart;\n }\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n if (position.dropBlockStart && position.dropInlineStart) {\n setPosition('top-left');\n } else if (position.dropBlockStart) {\n setPosition('top-right');\n } else if (position.dropInlineStart) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n const isOutsideDropdown = (element: Element) =>\n (!wrapperRef.current || !nodeBelongs(wrapperRef.current, element)) &&\n (!dropdownContainerRef.current || !nodeBelongs(dropdownContainerRef.current, element));\n\n const focusHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onFocus, event);\n }\n };\n\n const blurHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onBlur, event);\n }\n };\n\n // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth,\n stretchBeyondTriggerWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (event: MouseEvent) => {\n // Since the listener is registered on the window, `event.target` will incorrectly point at the\n // shadow root if the component is rendered inside shadow DOM.\n const target = event.composedPath ? event.composedPath()[0] : event.target;\n if (!nodeBelongs(dropdownRef.current, target) && !nodeBelongs(triggerRef.current, target)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {\n const triggerRect = getLogicalBoundingClientRect(triggerRef.current);\n const target = dropdownRef.current;\n if (fixedPosition.current) {\n if (fixedPosition.current.dropBlockStart) {\n dropdownRef.current.style.insetBlockEnd = `calc(100% - ${triggerRect.insetBlockStart}px)`;\n } else {\n target.style.insetBlockStart = `${triggerRect.insetBlockEnd}px`;\n }\n if (fixedPosition.current.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerRect.insetInlineEnd}px - ${fixedPosition.current.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerRect.insetInlineStart}px`;\n }\n }\n }\n };\n\n updateDropdownPosition();\n\n window.addEventListener('scroll', updateDropdownPosition, true);\n window.addEventListener('resize', updateDropdownPosition, true);\n return () => {\n window.removeEventListener('scroll', updateDropdownPosition, true);\n window.removeEventListener('resize', updateDropdownPosition, true);\n };\n }, [open, expandToViewport]);\n\n const referrerId = useUniqueId();\n\n return (\n <div\n className={clsx(\n styles.root,\n interior && styles.interior,\n stretchTriggerHeight && styles['stretch-trigger-height']\n )}\n ref={wrapperRef}\n onFocus={focusHandler}\n onBlur={blurHandler}\n >\n <div id={referrerId} className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}>\n {trigger}\n </div>\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <DropdownContainer\n triggerRef={triggerRef}\n renderWithPortal={expandToViewport && !interior}\n id={dropdownId}\n referrerId={referrerId}\n open={open}\n >\n <Transition in={open ?? false} exit={false}>\n {(state, ref) => (\n <div ref={dropdownContainerRef}>\n <TabTrap\n focusNextCallback={() => triggerRef.current && getLastFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <TransitionContent\n state={state}\n transitionRef={ref}\n dropdownClasses={dropdownClasses}\n open={open}\n stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).insetBlockEnd !== undefined;\n\nexport default Dropdown;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,cAAc,MAAM,u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, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\n\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../events';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useUniqueId } from '../../hooks/use-unique-id/index.js';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\nimport TabTrap from '../tab-trap/index.js';\nimport { Transition, TransitionStatus } from '../transition';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport {\n calculatePosition,\n defaultMaxDropdownWidth,\n DropdownPosition,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\n InteriorDropdownPosition,\n} from './dropdown-fit-handler';\nimport { DropdownProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface DropdownContainerProps {\n triggerRef: React.RefObject<HTMLElement>;\n children?: React.ReactNode;\n renderWithPortal: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({\n triggerRef,\n children,\n renderWithPortal,\n id,\n referrerId,\n open,\n}: DropdownContainerProps) => {\n if (!renderWithPortal) {\n return <>{children}</>;\n }\n if (!open) {\n return null;\n }\n const currentDocument = triggerRef.current?.ownerDocument ?? document;\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n currentDocument.body\n );\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: DOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;\n } else {\n verticalContainer.style.maxBlockSize = position.blockSize;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.inlineSize = position.inlineSize;\n }\n\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropBlockStart && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.insetBlockEnd = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.insetInlineStart && position.insetInlineStart !== 'auto') {\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n target.style.position = 'fixed';\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = `calc(100% - ${triggerBox.top}px)`;\n } else {\n target.style.insetBlockStart = `${triggerBox.bottom}px`;\n }\n if (position.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerBox.right}px - ${position.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerBox.left}px`;\n }\n // Keep track of the initial dropdown position and direction.\n // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.\n fixedPosition.current = position;\n return;\n }\n\n // For an interior dropdown (the fly out) we need exact values for positioning\n // and classes are not enough\n // usage of relative position is impossible due to overwrite of overflow-x\n if (interior && isInteriorPosition(position)) {\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = position.insetBlockEnd;\n } else {\n target.style.insetBlockStart = position.insetBlockStart;\n }\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n if (position.dropBlockStart && position.dropInlineStart) {\n setPosition('top-left');\n } else if (position.dropBlockStart) {\n setPosition('top-right');\n } else if (position.dropInlineStart) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n const isOutsideDropdown = (element: Element) =>\n (!wrapperRef.current || !nodeBelongs(wrapperRef.current, element)) &&\n (!dropdownContainerRef.current || !nodeBelongs(dropdownContainerRef.current, element));\n\n const focusHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onFocus, event);\n }\n };\n\n const blurHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onBlur, event);\n }\n };\n\n // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth,\n stretchBeyondTriggerWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (event: MouseEvent) => {\n // Since the listener is registered on the window, `event.target` will incorrectly point at the\n // shadow root if the component is rendered inside shadow DOM.\n const target = event.composedPath ? event.composedPath()[0] : event.target;\n if (!nodeBelongs(dropdownRef.current, target) && !nodeBelongs(triggerRef.current, target)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {\n const triggerRect = getLogicalBoundingClientRect(triggerRef.current);\n const target = dropdownRef.current;\n if (fixedPosition.current) {\n if (fixedPosition.current.dropBlockStart) {\n dropdownRef.current.style.insetBlockEnd = `calc(100% - ${triggerRect.insetBlockStart}px)`;\n } else {\n target.style.insetBlockStart = `${triggerRect.insetBlockEnd}px`;\n }\n if (fixedPosition.current.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerRect.insetInlineEnd}px - ${fixedPosition.current.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerRect.insetInlineStart}px`;\n }\n }\n }\n };\n\n updateDropdownPosition();\n\n const controller = new AbortController();\n window.addEventListener('scroll', updateDropdownPosition, { capture: true, signal: controller.signal });\n window.addEventListener('resize', updateDropdownPosition, { capture: true, signal: controller.signal });\n return () => {\n controller.abort();\n };\n }, [open, expandToViewport]);\n\n const referrerId = useUniqueId();\n\n return (\n <div\n className={clsx(\n styles.root,\n interior && styles.interior,\n stretchTriggerHeight && styles['stretch-trigger-height']\n )}\n ref={wrapperRef}\n onFocus={focusHandler}\n onBlur={blurHandler}\n >\n <div id={referrerId} className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}>\n {trigger}\n </div>\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <DropdownContainer\n triggerRef={triggerRef}\n renderWithPortal={expandToViewport && !interior}\n id={dropdownId}\n referrerId={referrerId}\n open={open}\n >\n <Transition in={open ?? false} exit={false}>\n {(state, ref) => (\n <div ref={dropdownContainerRef}>\n <TabTrap\n focusNextCallback={() => triggerRef.current && getLastFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <TransitionContent\n state={state}\n transitionRef={ref}\n dropdownClasses={dropdownClasses}\n open={open}\n stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).insetBlockEnd !== undefined;\n\nexport default Dropdown;\n"]}
|
|
@@ -24,15 +24,15 @@ export function Transition(_a) {
|
|
|
24
24
|
if (node === null) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
+
const controller = new AbortController();
|
|
27
28
|
const listener = (e) => {
|
|
28
29
|
if (e.target === node) {
|
|
29
|
-
|
|
30
|
-
node.removeEventListener('animationend', listener);
|
|
30
|
+
controller.abort();
|
|
31
31
|
done();
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
node.addEventListener('transitionend', listener);
|
|
35
|
-
node.addEventListener('animationend', listener);
|
|
34
|
+
node.addEventListener('transitionend', listener, { signal: controller.signal });
|
|
35
|
+
node.addEventListener('animationend', listener, { signal: controller.signal });
|
|
36
36
|
}, []);
|
|
37
37
|
return (React.createElement(ReactTransitionGroupTransition, Object.assign({ addEndListener: addTransitionEndListener, timeout: motionDisabled ? 0 : undefined, in: isIn, nodeRef: transitionRootElement, exit: exit, onEnter: isAppearing => {
|
|
38
38
|
if (!isAppearing) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/transition/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAoB,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EACL,UAAU,IAAI,8BAA8B,GAE7C,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAejF;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,EAQT;QARS,EACzB,EAAE,EAAE,IAAI,EACR,QAAQ,EACR,IAAI,GAAG,IAAI,EACX,cAAc,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,EAC7B,QAAQ,GAAG,KAAK,EAChB,qBAAqB,OAEL,EADb,IAAI,cAPkB,iFAQ1B,CADQ;IAEP,MAAM,qBAAqB,GAAG,MAAM,CAAc,IAAI,CAAC,CAAC;IACxD,uFAAuF;IACvF,yFAAyF;IACzF,yHAAyH;IACzH,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAmB,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtG,MAAM,cAAc,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,IAAI,QAAQ,CAAC;IAE3E,MAAM,wBAAwB,GAAG,WAAW,CAAC,CAAC,IAAgB,EAAE,EAAE;QAChE,MAAM,IAAI,GAAG,qBAAqB,CAAC,OAAO,CAAC;QAE3C,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,OAAO;SACR;QACD,MAAM,QAAQ,GAAG,CAAC,CAAmC,EAAE,EAAE;YACvD,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,EAAE;gBACrB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/transition/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAoB,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EACL,UAAU,IAAI,8BAA8B,GAE7C,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAejF;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,EAQT;QARS,EACzB,EAAE,EAAE,IAAI,EACR,QAAQ,EACR,IAAI,GAAG,IAAI,EACX,cAAc,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,EAC7B,QAAQ,GAAG,KAAK,EAChB,qBAAqB,OAEL,EADb,IAAI,cAPkB,iFAQ1B,CADQ;IAEP,MAAM,qBAAqB,GAAG,MAAM,CAAc,IAAI,CAAC,CAAC;IACxD,uFAAuF;IACvF,yFAAyF;IACzF,yHAAyH;IACzH,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAmB,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtG,MAAM,cAAc,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,IAAI,QAAQ,CAAC;IAE3E,MAAM,wBAAwB,GAAG,WAAW,CAAC,CAAC,IAAgB,EAAE,EAAE;QAChE,MAAM,IAAI,GAAG,qBAAqB,CAAC,OAAO,CAAC;QAE3C,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,OAAO;SACR;QACD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CA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Q,CAAC,CAAC;iBACrC;qBAAM;oBACL,kBAAkB,CAAC,UAAU,CAAC,CAAC;oBAC/B,cAAc,CAAC,UAAU,CAAC,CAAC;iBAC5B;aACF;QACH,CAAC,EACD,SAAS,EAAE,WAAW,CAAC,EAAE;YACvB,IAAI,CAAC,WAAW,EAAE;gBAChB,kBAAkB,CAAC,SAAS,CAAC,CAAC;gBAC9B,cAAc,CAAC,SAAS,CAAC,CAAC;aAC3B;QACH,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;YACX,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAC3B,cAAc,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC,EACD,SAAS,EAAE,GAAG,EAAE;YACd,kBAAkB,CAAC,SAAS,CAAC,CAAC;YAC9B,cAAc,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,EACD,QAAQ,EAAE,GAAG,EAAE;YACb,kBAAkB,CAAC,QAAQ,CAAC,CAAC;YAC7B,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC,IACG,IAAI,GAEP,GAAG,EAAE,CAAC,QAAQ,CAAC,eAAe,EAAE,qBAAqB,CAAC,CACxB,CAClC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\nimport { MutableRefObject, useCallback, useRef } from 'react';\nimport {\n Transition as ReactTransitionGroupTransition,\n TransitionStatus as ReactTransitionGroupTransitionStatus,\n} from 'react-transition-group';\n\nimport { useReducedMotion } from '@cloudscape-design/component-toolkit/internal';\n\nexport type TransitionStatus = ReactTransitionGroupTransitionStatus | 'enter' | 'exit';\n\ninterface TransitionProps {\n in: boolean;\n exit?: boolean;\n\n disabled?: boolean;\n\n children: (state: TransitionStatus, transitioningElementRef: MutableRefObject<any>) => React.ReactNode;\n onStatusChange?: (status: TransitionStatus) => void;\n transitionChangeDelay?: { entering?: number };\n}\n\n/**\n * This component is a wrapper around the CSSTransition component.\n *\n * It provides a second parameter in its rendering function that must be\n * attached to the node that is transitioning.\n */\nexport function Transition({\n in: isIn,\n children,\n exit = true,\n onStatusChange = () => void 0,\n disabled = false,\n transitionChangeDelay,\n ...rest\n}: TransitionProps) {\n const transitionRootElement = useRef<HTMLElement>(null);\n // the initial state of the transition should be either 'exited' or 'entered' depending\n // on the `in` property, this mimicks how internally the Transition component works here:\n // https://github.com/reactjs/react-transition-group/blob/6cbd6aaedaf8e9472007640b429ddb48c6c24158/src/Transition.js#L121\n const [transitionState, setTransitionState] = useState<TransitionStatus>(isIn ? 'entered' : 'exited');\n const motionDisabled = useReducedMotion(transitionRootElement) || disabled;\n\n const addTransitionEndListener = useCallback((done: () => void) => {\n const node = transitionRootElement.current;\n\n if (node === null) {\n return;\n }\n const controller = new AbortController();\n const listener = (e: TransitionEvent | AnimationEvent) => {\n if (e.target === node) {\n controller.abort();\n done();\n }\n };\n node.addEventListener('transitionend', listener, { signal: controller.signal });\n node.addEventListener('animationend', listener, { signal: controller.signal });\n }, []);\n\n return (\n <ReactTransitionGroupTransition\n addEndListener={addTransitionEndListener}\n timeout={motionDisabled ? 0 : undefined}\n in={isIn}\n nodeRef={transitionRootElement}\n exit={exit}\n onEnter={isAppearing => {\n if (!isAppearing) {\n setTransitionState('enter');\n onStatusChange('enter');\n }\n }}\n onEntering={isAppearing => {\n if (!isAppearing) {\n // This line forces the browser to recalculate the layout because we want the starting state in the 'enter' style\n // to be applied before the animation starts.\n void transitionRootElement.current?.offsetHeight;\n\n if (transitionChangeDelay?.entering) {\n setTimeout(() => {\n setTransitionState('entering');\n onStatusChange('entering');\n }, transitionChangeDelay?.entering);\n } else {\n setTransitionState('entering');\n onStatusChange('entering');\n }\n }\n }}\n onEntered={isAppearing => {\n if (!isAppearing) {\n setTransitionState('entered');\n onStatusChange('entered');\n }\n }}\n onExit={() => {\n setTransitionState('exit');\n onStatusChange('exit');\n }}\n onExiting={() => {\n setTransitionState('exiting');\n onStatusChange('exiting');\n }}\n onExited={() => {\n setTransitionState('exited');\n onStatusChange('exited');\n }}\n {...rest}\n >\n {() => children(transitionState, transitionRootElement)}\n </ReactTransitionGroupTransition>\n );\n}\n"]}
|
package/internal/environment.js
CHANGED
|
@@ -6,6 +6,7 @@ export default class FocusTracker {
|
|
|
6
6
|
private node;
|
|
7
7
|
private readonly onFocusLeave;
|
|
8
8
|
private readonly onFocusEnter;
|
|
9
|
+
private readonly controller;
|
|
9
10
|
private currentlyFocused;
|
|
10
11
|
constructor(node: HTMLElement, { onFocusEnter, onFocusLeave }: FocusTrackerOptions);
|
|
11
12
|
initialize(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-tracker.d.ts","sourceRoot":"","sources":["../../../src/internal/focus-tracker.ts"],"names":[],"mappings":"AAIA,UAAU,mBAAmB;IAC3B,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"focus-tracker.d.ts","sourceRoot":"","sources":["../../../src/internal/focus-tracker.ts"],"names":[],"mappings":"AAIA,UAAU,mBAAmB;IAC3B,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,OAAO,YAAY;IAQ7B,OAAO,CAAC,IAAI;IAPd,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAE7C,OAAO,CAAC,gBAAgB,CAAS;gBAGvB,IAAI,EAAE,WAAW,EACzB,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,mBAAmB;IAOrD,UAAU;IAMV,OAAO;IAIP,OAAO,CAAC,eAAe,CAKrB;IAEF,OAAO,CAAC,gBAAgB,CAMtB;IAEF,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,YAAY;CAIrB"}
|
|
@@ -20,15 +20,15 @@ export default class FocusTracker {
|
|
|
20
20
|
};
|
|
21
21
|
this.onFocusEnter = onFocusEnter;
|
|
22
22
|
this.onFocusLeave = onFocusLeave;
|
|
23
|
+
this.controller = new AbortController();
|
|
23
24
|
}
|
|
24
25
|
initialize() {
|
|
25
26
|
this.currentlyFocused = nodeBelongs(this.node, document.activeElement);
|
|
26
|
-
document.addEventListener('focusin', this.focusInListener);
|
|
27
|
-
document.addEventListener('focusout', this.focusOutListener);
|
|
27
|
+
document.addEventListener('focusin', this.focusInListener, { signal: this.controller.signal });
|
|
28
|
+
document.addEventListener('focusout', this.focusOutListener, { signal: this.controller.signal });
|
|
28
29
|
}
|
|
29
30
|
destroy() {
|
|
30
|
-
|
|
31
|
-
document.removeEventListener('focusout', this.focusOutListener);
|
|
31
|
+
this.controller.abort();
|
|
32
32
|
}
|
|
33
33
|
triggerBlur() {
|
|
34
34
|
this.currentlyFocused = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-tracker.js","sourceRoot":"","sources":["../../../src/internal/focus-tracker.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAOnD,MAAM,CAAC,OAAO,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"focus-tracker.js","sourceRoot":"","sources":["../../../src/internal/focus-tracker.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAOnD,MAAM,CAAC,OAAO,OAAO,YAAY;IAO/B,YACU,IAAiB,EACzB,EAAE,YAAY,EAAE,YAAY,EAAuB;QAD3C,SAAI,GAAJ,IAAI,CAAa;QAHnB,qBAAgB,GAAG,KAAK,CAAC;QAqBzB,oBAAe,GAAG,CAAC,KAAiB,EAAE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9B,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { nodeBelongs } from './utils/node-belongs';\n\ninterface FocusTrackerOptions {\n onFocusEnter: () => void;\n onFocusLeave: () => void;\n}\n\nexport default class FocusTracker {\n private readonly onFocusLeave: () => void;\n private readonly onFocusEnter: () => void;\n private readonly controller: AbortController;\n\n private currentlyFocused = false;\n\n constructor(\n private node: HTMLElement,\n { onFocusEnter, onFocusLeave }: FocusTrackerOptions\n ) {\n this.onFocusEnter = onFocusEnter;\n this.onFocusLeave = onFocusLeave;\n this.controller = new AbortController();\n }\n\n initialize() {\n this.currentlyFocused = nodeBelongs(this.node, document.activeElement);\n document.addEventListener('focusin', this.focusInListener, { signal: this.controller.signal });\n document.addEventListener('focusout', this.focusOutListener, { signal: this.controller.signal });\n }\n\n destroy() {\n this.controller.abort();\n }\n\n private focusInListener = (event: FocusEvent) => {\n const focusIsInside = nodeBelongs(this.node, event.target);\n if (!this.currentlyFocused && focusIsInside) {\n this.triggerFocus();\n }\n };\n\n private focusOutListener = (event: FocusEvent) => {\n const nextFocused = event.relatedTarget;\n const isNextFocusedInParent = !nodeBelongs(this.node, nextFocused);\n if (this.currentlyFocused && (nextFocused === null || isNextFocusedInParent)) {\n this.triggerBlur();\n }\n };\n\n private triggerBlur() {\n this.currentlyFocused = false;\n this.onFocusLeave();\n }\n\n private triggerFocus() {\n this.currentlyFocused = true;\n this.onFocusEnter();\n }\n}\n"]}
|