@cloudscape-design/components 3.0.363 → 3.0.364
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/alert/internal.d.ts.map +1 -1
- package/alert/internal.js +13 -14
- package/alert/internal.js.map +1 -1
- package/alert/styles.css.js +25 -25
- package/alert/styles.scoped.css +52 -66
- package/alert/styles.selectors.js +25 -25
- package/breadcrumb-group/internal.d.ts.map +1 -1
- package/breadcrumb-group/internal.js +5 -5
- package/breadcrumb-group/internal.js.map +1 -1
- package/button-dropdown/interfaces.d.ts +9 -1
- package/button-dropdown/interfaces.d.ts.map +1 -1
- package/button-dropdown/interfaces.js.map +1 -1
- package/button-dropdown/internal.d.ts.map +1 -1
- package/button-dropdown/internal.js +9 -2
- package/button-dropdown/internal.js.map +1 -1
- package/button-dropdown/styles.css.js +15 -14
- package/button-dropdown/styles.scoped.css +25 -21
- package/button-dropdown/styles.selectors.js +15 -14
- package/form/index.d.ts.map +1 -1
- package/form/index.js +2 -1
- package/form/index.js.map +1 -1
- package/internal/analytics/components/analytics-funnel.d.ts +1 -1
- package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
- package/internal/analytics/components/analytics-funnel.js +92 -26
- package/internal/analytics/components/analytics-funnel.js.map +1 -1
- package/internal/analytics/context/analytics-context.d.ts +4 -0
- package/internal/analytics/context/analytics-context.d.ts.map +1 -1
- package/internal/analytics/context/analytics-context.js +4 -0
- package/internal/analytics/context/analytics-context.js.map +1 -1
- package/internal/analytics/hooks/use-funnel.d.ts +2 -0
- package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
- package/internal/components/menu-dropdown/index.d.ts +1 -1
- package/internal/components/menu-dropdown/index.d.ts.map +1 -1
- package/internal/components/menu-dropdown/index.js +7 -5
- package/internal/components/menu-dropdown/index.js.map +1 -1
- package/internal/components/menu-dropdown/interfaces.d.ts +1 -0
- package/internal/components/menu-dropdown/interfaces.d.ts.map +1 -1
- package/internal/components/menu-dropdown/interfaces.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/mixed-line-bar-chart/bar-series.d.ts.map +1 -1
- package/mixed-line-bar-chart/bar-series.js +14 -3
- package/mixed-line-bar-chart/bar-series.js.map +1 -1
- package/mixed-line-bar-chart/styles.css.js +11 -11
- package/mixed-line-bar-chart/styles.scoped.css +17 -22
- package/mixed-line-bar-chart/styles.selectors.js +11 -11
- package/modal/internal.d.ts.map +1 -1
- package/modal/internal.js +14 -12
- package/modal/internal.js.map +1 -1
- package/package.json +1 -1
- package/progress-bar/index.d.ts.map +1 -1
- package/progress-bar/index.js +7 -4
- package/progress-bar/index.js.map +1 -1
- package/table/body-cell/td-element.d.ts +2 -1
- package/table/body-cell/td-element.d.ts.map +1 -1
- package/table/body-cell/td-element.js +3 -3
- package/table/body-cell/td-element.js.map +1 -1
- package/table/header-cell/index.d.ts +1 -1
- package/table/header-cell/index.d.ts.map +1 -1
- package/table/header-cell/index.js +2 -2
- package/table/header-cell/index.js.map +1 -1
- package/table/internal.d.ts.map +1 -1
- package/table/internal.js +12 -14
- package/table/internal.js.map +1 -1
- package/table/table-role/index.d.ts +3 -1
- package/table/table-role/index.d.ts.map +1 -1
- package/table/table-role/index.js +2 -1
- package/table/table-role/index.js.map +1 -1
- package/table/table-role/interfaces.d.ts +18 -0
- package/table/table-role/interfaces.d.ts.map +1 -0
- package/table/table-role/interfaces.js +4 -0
- package/table/table-role/interfaces.js.map +1 -0
- package/table/table-role/table-role-helper.d.ts +16 -4
- package/table/table-role/table-role-helper.d.ts.map +1 -1
- package/table/table-role/table-role-helper.js +39 -4
- package/table/table-role/table-role-helper.js.map +1 -1
- package/table/table-role/use-grid-navigation.d.ts +7 -0
- package/table/table-role/use-grid-navigation.d.ts.map +1 -0
- package/table/table-role/use-grid-navigation.js +185 -0
- package/table/table-role/use-grid-navigation.js.map +1 -0
- package/table/table-role/utils.d.ts +23 -0
- package/table/table-role/utils.d.ts.map +1 -0
- package/table/table-role/utils.js +141 -0
- package/table/table-role/utils.js.map +1 -0
- package/table/thead.d.ts.map +1 -1
- package/table/thead.js +4 -4
- package/table/thead.js.map +1 -1
- package/test-utils/dom/button-dropdown/index.js +1 -3
- package/test-utils/dom/button-dropdown/index.js.map +1 -1
- package/test-utils/selectors/button-dropdown/index.js +1 -3
- package/test-utils/selectors/button-dropdown/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/wizard/index.d.ts.map +1 -1
- package/wizard/index.js +8 -1
- package/wizard/index.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-funnel.js","sourceRoot":"lib/default/","sources":["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,EACL,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,GAKd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAOpC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAA4C,EAAE,EAAE;QAAhD,EAAE,QAAQ,OAAkC,EAA7B,KAAK,cAApB,YAAsB,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AC,CAAC,CAAC;YAEzC,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;gBAC/E,gBAAgB,CAAC,OAAO,GAAG,KAAK,CAAC;gBAEjC;;;mBAGG;gBACH,MAAA,oBAAoB,CAAC,OAAO,oEAAI,CAAC;aAClC;QACH,CAAC,CAAA,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YACrD,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,mBAAmB;QACnB,WAAW;QACX,gBAAgB;QAChB,UAAU;QACV,mBAAmB;QACnB,eAAe;QACf,oBAAoB;KACrB,CAAC,CAAC;IAEH,OAAO,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAAG,QAAQ,CAAiC,CAAC;AACnG,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 {\n FunnelStepContext,\n FunnelSubStepContext,\n FunnelContext,\n FunnelContextValue,\n FunnelStepContextValue,\n FunnelState,\n FunnelSubStepContextValue,\n} from '../context/analytics-context';\nimport { useFunnel, useFunnelStep } from '../hooks/use-funnel';\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\n\nimport { PACKAGE_VERSION } from '../../environment';\n\nimport { FunnelMetrics } from '../';\nimport { FunnelProps, FunnelStepProps } from '../interfaces';\n\nimport {\n DATA_ATTR_FUNNEL_STEP,\n getFunnelNameSelector,\n getNameFromSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n} from '../selectors';\n\nexport const FUNNEL_VERSION = '1.0';\n\ntype AnalyticsFunnelProps = { children?: React.ReactNode } & Pick<\n FunnelProps,\n 'funnelType' | 'optionalStepNumbers' | 'totalFunnelSteps'\n>;\n\nexport const AnalyticsFunnel = ({ children, ...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 errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\n const latestFocusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n\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 // Reset the state, in case the component was re-mounted.\n funnelState.current = 'default';\n\n const funnelInteractionId = FunnelMetrics.funnelStart({\n funnelNameSelector: getFunnelNameSelector(),\n optionalStepNumbers: props.optionalStepNumbers,\n funnelType: props.funnelType,\n totalFunnelSteps: props.totalFunnelSteps,\n componentVersion: PACKAGE_VERSION,\n theme: isVisualRefresh ? 'vr' : 'classic',\n funnelVersion: FUNNEL_VERSION,\n });\n\n setFunnelInteractionId(funnelInteractionId);\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 if (funnelState.current === 'validating') {\n // Finish the validation phase early.\n FunnelMetrics.funnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId });\n } else {\n FunnelMetrics.funnelCancelled({ funnelInteractionId });\n funnelState.current = 'cancelled';\n }\n };\n }, []);\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const funnelSubmit = () => {\n funnelState.current = 'validating';\n\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 FunnelMetrics.funnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n } else {\n funnelState.current = 'default';\n }\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 setFunnelInteractionId,\n funnelType: props.funnelType,\n optionalStepNumbers: props.optionalStepNumbers,\n totalFunnelSteps: props.totalFunnelSteps,\n funnelSubmit,\n funnelCancel,\n submissionAttempt,\n funnelNextOrSubmitAttempt,\n funnelState,\n errorCount,\n loadingButtonCount,\n latestFocusCleanupFunction,\n };\n\n return <FunnelContext.Provider value={funnelContextValue}>{children}</FunnelContext.Provider>;\n};\n\ntype AnalyticsFunnelStepProps = {\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n} & Pick<FunnelStepProps, 'stepNumber' | 'stepNameSelector'>;\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 <InnerAnalyticsFunnelStep {...props} key={props.stepNumber} />\n);\n\nconst InnerAnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector }: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, funnelState } = useFunnel();\n\n const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };\n\n const subStepCount = useRef<number>(0);\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 const stepName = getNameFromSelector(stepNameSelector);\n\n if (funnelInteractionId && funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelInteractionId && funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n funnelInteractionId,\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 //eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, stepNumber, stepNameSelector]);\n\n const contextValue: FunnelStepContextValue = { stepNumber, stepNameSelector, funnelStepProps, subStepCount };\n return (\n <FunnelStepContext.Provider value={contextValue}>\n {typeof children === 'function' ? children(contextValue) : children}\n </FunnelStepContext.Provider>\n );\n};\ninterface AnalyticsFunnelSubStepProps {\n children?: React.ReactNode;\n}\n\nexport const AnalyticsFunnelSubStep = ({ children }: 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 } = 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 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\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return () => void subStepCount.current--;\n }\n }, [isNested, subStepCount]);\n\n const context = isNested ? inheritedContext : newContext;\n\n useEffect(() => {\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 || !subStepRef.current.contains(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 ]);\n\n return <FunnelSubStepContext.Provider value={context}>{children}</FunnelSubStepContext.Provider>;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"analytics-funnel.js","sourceRoot":"lib/default/","sources":["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,EACL,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,GAKd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAOpC,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,CAAC,QAAQ,CAAI,CAAC;KAC9B;IAED,OAAO,oBAAC,oBAAoB,oBAAK,KAAK,EAAI,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,EAA4C,EAAE,EAAE;QAAhD,EAAE,QAAQ,OAAkC,EAA7B,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W,EAAE,WAAW,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YACrD,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,mBAAmB;QACnB,WAAW;QACX,gBAAgB;QAChB,UAAU;QACV,mBAAmB;QACnB,eAAe;QACf,oBAAoB;KACrB,CAAC,CAAC;IAEH,OAAO,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAAG,QAAQ,CAAiC,CAAC;AACnG,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 {\n FunnelStepContext,\n FunnelSubStepContext,\n FunnelContext,\n FunnelContextValue,\n FunnelStepContextValue,\n FunnelState,\n FunnelSubStepContextValue,\n} from '../context/analytics-context';\nimport { useFunnel, useFunnelStep } from '../hooks/use-funnel';\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\n\nimport { PACKAGE_VERSION } from '../../environment';\n\nimport { FunnelMetrics } from '../';\nimport { FunnelProps, FunnelStepProps } from '../interfaces';\n\nimport {\n DATA_ATTR_FUNNEL_STEP,\n getFunnelNameSelector,\n getNameFromSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n} from '../selectors';\n\nexport const FUNNEL_VERSION = '1.0';\n\ntype AnalyticsFunnelProps = { children?: React.ReactNode } & Pick<\n FunnelProps,\n 'funnelType' | 'optionalStepNumbers' | 'totalFunnelSteps'\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\nconst InnerAnalyticsFunnel = ({ children, ...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 errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\n const wizardCount = useRef<number>(0);\n const latestFocusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n\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 /*\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 const handle = setTimeout(() => {\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\n const funnelInteractionId = FunnelMetrics.funnelStart({\n funnelNameSelector: getFunnelNameSelector(),\n optionalStepNumbers: props.optionalStepNumbers,\n funnelType: props.funnelType,\n totalFunnelSteps: props.totalFunnelSteps,\n componentVersion: PACKAGE_VERSION,\n theme: isVisualRefresh ? 'vr' : 'classic',\n funnelVersion: FUNNEL_VERSION,\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 FunnelMetrics.funnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId });\n } else {\n FunnelMetrics.funnelCancelled({ funnelInteractionId });\n funnelState.current = 'cancelled';\n }\n };\n }, []);\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const funnelSubmit = () => {\n funnelState.current = 'validating';\n\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 FunnelMetrics.funnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n } else {\n funnelState.current = 'default';\n }\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 setFunnelInteractionId,\n funnelType: props.funnelType,\n optionalStepNumbers: props.optionalStepNumbers,\n totalFunnelSteps: props.totalFunnelSteps,\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\ntype AnalyticsFunnelStepProps = {\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n} & Pick<FunnelStepProps, 'stepNumber' | 'stepNameSelector'>;\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\nconst InnerAnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector }: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, 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 // 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 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 = getNameFromSelector(stepNameSelector);\n\n if (funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n funnelInteractionId,\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 funnelInteractionId,\n stepNumber,\n stepNameSelector,\n funnelState,\n parentStepExists,\n funnelType,\n parentStepFunnelInteractionId,\n ]);\n\n const contextValue: FunnelStepContextValue = {\n stepNumber,\n stepNameSelector,\n funnelStepProps,\n subStepCount,\n isInStep: true,\n funnelInteractionId,\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 children?: React.ReactNode;\n}\n\nexport const AnalyticsFunnelSubStep = ({ children }: 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 } = 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 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\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return () => void subStepCount.current--;\n }\n }, [isNested, subStepCount]);\n\n const context = isNested ? inheritedContext : newContext;\n\n useEffect(() => {\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 || !subStepRef.current.contains(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 ]);\n\n return <FunnelSubStepContext.Provider value={context}>{children}</FunnelSubStepContext.Provider>;\n};\n"]}
|
|
@@ -15,12 +15,16 @@ export interface FunnelContextValue {
|
|
|
15
15
|
errorCount: MutableRefObject<number>;
|
|
16
16
|
loadingButtonCount: MutableRefObject<number>;
|
|
17
17
|
latestFocusCleanupFunction: MutableRefObject<undefined | (() => void)>;
|
|
18
|
+
isInFunnel: boolean;
|
|
19
|
+
wizardCount: MutableRefObject<number>;
|
|
18
20
|
}
|
|
19
21
|
export interface FunnelStepContextValue {
|
|
20
22
|
stepNameSelector: string;
|
|
21
23
|
stepNumber: number;
|
|
22
24
|
funnelStepProps?: Record<string, string | number | boolean | undefined>;
|
|
23
25
|
subStepCount: MutableRefObject<number>;
|
|
26
|
+
isInStep: boolean;
|
|
27
|
+
funnelInteractionId: string | undefined;
|
|
24
28
|
}
|
|
25
29
|
export interface FunnelSubStepContextValue {
|
|
26
30
|
subStepId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-context.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,UAAU,EAAE,UAAU,CAAC;IACvB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,sBAAsB,EAAE,CAAC,mBAAmB,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yBAAyB,EAAE,MAAM,IAAI,CAAC;IACtC,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IACpC,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACrC,kBAAkB,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC7C,0BAA0B,EAAE,gBAAgB,CAAC,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"analytics-context.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,MAAM,W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B,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACpD,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC;;;;;OAKG;IACH,gBAAgB,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,oBAAoB,EAAE,gBAAgB,CAAC,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACjE,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC5E;AAGD,eAAO,MAAM,aAAa,6CAgBxB,CAAC;AAEH,eAAO,MAAM,iBAAiB,iDAM5B,CAAC;AAEH,eAAO,MAAM,oBAAoB,oDAS/B,CAAC"}
|
|
@@ -16,11 +16,15 @@ export const FunnelContext = createContext({
|
|
|
16
16
|
errorCount: { current: 0 },
|
|
17
17
|
loadingButtonCount: { current: 0 },
|
|
18
18
|
latestFocusCleanupFunction: { current: undefined },
|
|
19
|
+
isInFunnel: false,
|
|
20
|
+
wizardCount: { current: 0 },
|
|
19
21
|
});
|
|
20
22
|
export const FunnelStepContext = createContext({
|
|
21
23
|
stepNameSelector: '',
|
|
22
24
|
stepNumber: 0,
|
|
23
25
|
subStepCount: { current: 0 },
|
|
26
|
+
isInStep: false,
|
|
27
|
+
funnelInteractionId: undefined,
|
|
24
28
|
});
|
|
25
29
|
export const FunnelSubStepContext = createContext({
|
|
26
30
|
subStepId: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-context.js","sourceRoot":"lib/default/","sources":["internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAA+B,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"analytics-context.js","sourceRoot":"lib/default/","sources":["internal/analytics/context/analytics-context.ts"],"names":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,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;IACpC,oBAAoB,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;CAC7C,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { MutableRefObject, RefObject, createContext } from 'react';\nimport { FunnelType } from '../interfaces';\n\nexport type FunnelState = 'default' | 'validating' | 'complete' | 'cancelled';\n\nexport interface FunnelContextValue {\n funnelInteractionId: string | undefined;\n funnelType: FunnelType;\n optionalStepNumbers: number[];\n totalFunnelSteps: number;\n funnelSubmit: () => void;\n funnelCancel: () => void;\n setFunnelInteractionId: (funnelInteractionId: string) => void;\n submissionAttempt: number;\n funnelNextOrSubmitAttempt: () => void;\n funnelState: RefObject<FunnelState>;\n errorCount: MutableRefObject<number>;\n loadingButtonCount: MutableRefObject<number>;\n latestFocusCleanupFunction: MutableRefObject<undefined | (() => void)>;\n isInFunnel: boolean;\n wizardCount: MutableRefObject<number>;\n}\n\nexport interface FunnelStepContextValue {\n stepNameSelector: string;\n stepNumber: number;\n funnelStepProps?: Record<string, string | number | boolean | undefined>;\n subStepCount: MutableRefObject<number>;\n isInStep: boolean;\n funnelInteractionId: string | undefined;\n}\n\nexport interface FunnelSubStepContextValue {\n subStepId: string;\n subStepSelector: string;\n subStepNameSelector: string;\n subStepRef: MutableRefObject<HTMLDivElement | null>;\n mousePressed: MutableRefObject<boolean>;\n /**\n * `isFocusedSubStep` is almost the same as checking if document.activeElement\n * is a child of the curren substep. However, `isFocusedSubStep` stays true\n * while the mouse button is pressed down, even though some browsers move the focus\n * to the body element during that time.\n */\n isFocusedSubStep: MutableRefObject<boolean>;\n\n /**\n * The focus cleanup function should be run when the user leaves the substep.\n */\n focusCleanupFunction: MutableRefObject<undefined | (() => void)>;\n isNestedSubStep: boolean;\n funnelSubStepProps?: Record<string, string | number | boolean | undefined>;\n}\n\n/* istanbul ignore next */\nexport const FunnelContext = createContext<FunnelContextValue>({\n funnelInteractionId: undefined,\n setFunnelInteractionId: () => {},\n funnelType: 'single-page',\n optionalStepNumbers: [],\n totalFunnelSteps: 0,\n funnelSubmit: () => {},\n funnelCancel: () => {},\n submissionAttempt: 0,\n funnelNextOrSubmitAttempt: () => {},\n funnelState: { current: 'default' },\n errorCount: { current: 0 },\n loadingButtonCount: { current: 0 },\n latestFocusCleanupFunction: { current: undefined },\n isInFunnel: false,\n wizardCount: { current: 0 },\n});\n\nexport const FunnelStepContext = createContext<FunnelStepContextValue>({\n stepNameSelector: '',\n stepNumber: 0,\n subStepCount: { current: 0 },\n isInStep: false,\n funnelInteractionId: undefined,\n});\n\nexport const FunnelSubStepContext = createContext<FunnelSubStepContextValue>({\n subStepId: '',\n subStepSelector: '',\n subStepNameSelector: '',\n subStepRef: { current: null },\n isNestedSubStep: false,\n mousePressed: { current: false },\n isFocusedSubStep: { current: false },\n focusCleanupFunction: { current: undefined },\n});\n"]}
|
|
@@ -50,6 +50,8 @@ export declare const useFunnel: () => {
|
|
|
50
50
|
errorCount: import("react").MutableRefObject<number>;
|
|
51
51
|
loadingButtonCount: import("react").MutableRefObject<number>;
|
|
52
52
|
latestFocusCleanupFunction: import("react").MutableRefObject<(() => void) | undefined>;
|
|
53
|
+
isInFunnel: boolean;
|
|
54
|
+
wizardCount: import("react").MutableRefObject<number>;
|
|
53
55
|
funnelProps: Record<string, string | number | boolean | undefined>;
|
|
54
56
|
};
|
|
55
57
|
//# sourceMappingURL=use-funnel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":";AAaA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;CAqH5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,qEAGzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"use-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":";AAaA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;CAqH5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,qEAGzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;CASrB,CAAC"}
|
|
@@ -2,6 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { MenuDropdownProps, ButtonTriggerProps } from './interfaces';
|
|
3
3
|
export { MenuDropdownProps };
|
|
4
4
|
export declare const ButtonTrigger: React.ForwardRefExoticComponent<ButtonTriggerProps & React.RefAttributes<any>>;
|
|
5
|
-
declare const MenuDropdown: ({ iconName, iconUrl, iconAlt, iconSvg, badge,
|
|
5
|
+
declare const MenuDropdown: ({ iconName, iconUrl, iconAlt, iconSvg, badge, offsetRight, children, ...props }: MenuDropdownProps) => JSX.Element;
|
|
6
6
|
export default MenuDropdown;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/menu-dropdown/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/menu-dropdown/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AASrE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,eAAO,MAAM,aAAa,gFAwDzB,CAAC;AAEF,QAAA,MAAM,YAAY,oFASf,iBAAiB,gBAwCnB,CAAC;AAGF,eAAe,YAAY,CAAC"}
|
|
@@ -9,9 +9,11 @@ import InternalButtonDropdown from '../../../button-dropdown/internal';
|
|
|
9
9
|
import InternalIcon from '../../../icon/internal';
|
|
10
10
|
import buttonDropdownStyles from '../../../button-dropdown/styles.css.js';
|
|
11
11
|
import styles from './styles.css.js';
|
|
12
|
-
export const ButtonTrigger = React.forwardRef(({ iconName, iconUrl, iconAlt, iconSvg, badge, ariaLabel, offsetRight, disabled, expanded, children, onClick, }, ref) => {
|
|
12
|
+
export const ButtonTrigger = React.forwardRef(({ testUtilsClass, iconName, iconUrl, iconAlt, iconSvg, badge, ariaLabel, offsetRight, disabled, expanded, children, onClick, }, ref) => {
|
|
13
13
|
const hasIcon = iconName || iconUrl || iconSvg;
|
|
14
|
-
return (React.createElement("button", { ref: ref, type: "button", className: clsx(styles.button, styles[`offset-right-${offsetRight}`],
|
|
14
|
+
return (React.createElement("button", { ref: ref, type: "button", className: clsx(styles.button, styles[`offset-right-${offsetRight}`], testUtilsClass, {
|
|
15
|
+
[styles.expanded]: expanded,
|
|
16
|
+
}), "aria-label": ariaLabel, "aria-expanded": !!expanded, "aria-haspopup": true, disabled: disabled, onClick: event => {
|
|
15
17
|
event.preventDefault();
|
|
16
18
|
onClick && onClick();
|
|
17
19
|
} },
|
|
@@ -20,10 +22,10 @@ export const ButtonTrigger = React.forwardRef(({ iconName, iconUrl, iconAlt, ico
|
|
|
20
22
|
children && (React.createElement(InternalIcon, { name: "caret-down-filled", className: expanded ? buttonDropdownStyles['rotate-up'] : buttonDropdownStyles['rotate-down'] }))));
|
|
21
23
|
});
|
|
22
24
|
const MenuDropdown = (_a) => {
|
|
23
|
-
var { iconName, iconUrl, iconAlt, iconSvg, badge,
|
|
25
|
+
var { iconName, iconUrl, iconAlt, iconSvg, badge, offsetRight, children } = _a, props = __rest(_a, ["iconName", "iconUrl", "iconAlt", "iconSvg", "badge", "offsetRight", "children"]);
|
|
24
26
|
const baseProps = getBaseProps(props);
|
|
25
|
-
const dropdownTrigger = (
|
|
26
|
-
return (React.createElement(ButtonTrigger, { ref:
|
|
27
|
+
const dropdownTrigger = ({ triggerRef, ariaLabel, isOpen, testUtilsClass, disabled, onClick, }) => {
|
|
28
|
+
return (React.createElement(ButtonTrigger, { testUtilsClass: testUtilsClass, ref: triggerRef, disabled: disabled, expanded: isOpen, iconName: iconName, iconUrl: iconUrl, iconAlt: iconAlt, iconSvg: iconSvg, badge: badge, ariaLabel: ariaLabel, offsetRight: offsetRight, onClick: onClick }, children));
|
|
27
29
|
};
|
|
28
30
|
return (React.createElement(InternalButtonDropdown, Object.assign({}, baseProps, props, { variant: "navigation", customTriggerBuilder: dropdownTrigger, preferCenter: true })));
|
|
29
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/menu-dropdown/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,sBAAsB,MAAM,mCAAmC,CAAC;AACvE,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,oBAAoB,MAAM,wCAAwC,CAAC;AAC1E,OAAO,MAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/menu-dropdown/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO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AE,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,aAAa,CAAC,GAC7F,CACH,CACM,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,EASF,EAAE,EAAE;QATF,EACpB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,KAAK,EACL,WAAW,EACX,QAAQ,OAEU,EADf,KAAK,cARY,iFASrB,CADS;IAER,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAEtC,MAAM,eAAe,GAAG,CAAC,EACvB,UAAU,EACV,SAAS,EACT,MAAM,EACN,cAAc,EACd,QAAQ,EACR,OAAO,GACY,EAAE,EAAE;QACvB,OAAO,CACL,oBAAC,aAAa,IACZ,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,UAAU,EACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,IAEf,QAAQ,CACK,CACjB,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,sBAAsB,oBACjB,SAAS,EACT,KAAK,IACT,OAAO,EAAC,YAAY,EACpB,oBAAoB,EAAE,eAAe,EACrC,YAAY,EAAE,IAAI,IAClB,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,gBAAgB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AAC/C,eAAe,YAAY,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React from 'react';\n\nimport { MenuDropdownProps, ButtonTriggerProps } from './interfaces';\nimport { getBaseProps } from '../../base-component';\nimport { applyDisplayName } from '../../utils/apply-display-name';\nimport InternalButtonDropdown from '../../../button-dropdown/internal';\nimport InternalIcon from '../../../icon/internal';\nimport buttonDropdownStyles from '../../../button-dropdown/styles.css.js';\nimport styles from './styles.css.js';\nimport { CustomTriggerProps } from '../../../button-dropdown/interfaces';\n\nexport { MenuDropdownProps };\n\nexport const ButtonTrigger = React.forwardRef(\n (\n {\n testUtilsClass,\n iconName,\n iconUrl,\n iconAlt,\n iconSvg,\n badge,\n ariaLabel,\n offsetRight,\n disabled,\n expanded,\n children,\n onClick,\n }: ButtonTriggerProps,\n ref: React.Ref<any>\n ) => {\n const hasIcon = iconName || iconUrl || iconSvg;\n\n return (\n <button\n ref={ref}\n type=\"button\"\n className={clsx(styles.button, styles[`offset-right-${offsetRight}`], testUtilsClass, {\n [styles.expanded]: expanded,\n })}\n aria-label={ariaLabel}\n aria-expanded={!!expanded}\n aria-haspopup={true}\n disabled={disabled}\n onClick={event => {\n event.preventDefault();\n onClick && onClick();\n }}\n >\n {hasIcon && (\n <InternalIcon\n className={styles.icon}\n name={iconName}\n url={iconUrl}\n alt={iconAlt}\n svg={iconSvg}\n badge={badge}\n />\n )}\n {children && <span className={styles.text}>{children}</span>}\n {children && (\n <InternalIcon\n name=\"caret-down-filled\"\n className={expanded ? buttonDropdownStyles['rotate-up'] : buttonDropdownStyles['rotate-down']}\n />\n )}\n </button>\n );\n }\n);\n\nconst MenuDropdown = ({\n iconName,\n iconUrl,\n iconAlt,\n iconSvg,\n badge,\n offsetRight,\n children,\n ...props\n}: MenuDropdownProps) => {\n const baseProps = getBaseProps(props);\n\n const dropdownTrigger = ({\n triggerRef,\n ariaLabel,\n isOpen,\n testUtilsClass,\n disabled,\n onClick,\n }: CustomTriggerProps) => {\n return (\n <ButtonTrigger\n testUtilsClass={testUtilsClass}\n ref={triggerRef}\n disabled={disabled}\n expanded={isOpen}\n iconName={iconName}\n iconUrl={iconUrl}\n iconAlt={iconAlt}\n iconSvg={iconSvg}\n badge={badge}\n ariaLabel={ariaLabel}\n offsetRight={offsetRight}\n onClick={onClick}\n >\n {children}\n </ButtonTrigger>\n );\n };\n\n return (\n <InternalButtonDropdown\n {...baseProps}\n {...props}\n variant=\"navigation\"\n customTriggerBuilder={dropdownTrigger}\n preferCenter={true}\n />\n );\n};\n\napplyDisplayName(MenuDropdown, 'MenuDropdown');\nexport default MenuDropdown;\n"]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { InternalButtonDropdownProps } from '../../../button-dropdown/interfaces';
|
|
3
3
|
import { IconProps } from '../../../icon/interfaces';
|
|
4
4
|
export interface ButtonTriggerProps {
|
|
5
|
+
testUtilsClass?: string;
|
|
5
6
|
iconName?: IconProps.Name;
|
|
6
7
|
iconUrl?: string;
|
|
7
8
|
iconAlt?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["internal/components/menu-dropdown/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC;IACnC,QAAQ,CAAC,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AC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["internal/components/menu-dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { InternalButtonDropdownProps } from '../../../button-dropdown/interfaces';\nimport { IconProps } from '../../../icon/interfaces';\n\nexport interface ButtonTriggerProps {\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconAlt?: string;\n iconSvg?: React.ReactNode;\n ariaLabel?: string;\n disabled?: boolean;\n children?: React.ReactNode;\n onClick?: () => void;\n\n badge?: boolean;\n offsetRight?: 'none' | 'l' | 'xxl';\n expanded?: boolean;\n}\n\nexport interface MenuDropdownProps extends InternalButtonDropdownProps {\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconAlt?: string;\n iconSvg?: React.ReactNode;\n badge?: boolean;\n description?: string;\n offsetRight?: 'l' | 'xxl';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["internal/components/menu-dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { InternalButtonDropdownProps } from '../../../button-dropdown/interfaces';\nimport { IconProps } from '../../../icon/interfaces';\n\nexport interface ButtonTriggerProps {\n testUtilsClass?: string;\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconAlt?: string;\n iconSvg?: React.ReactNode;\n ariaLabel?: string;\n disabled?: boolean;\n children?: React.ReactNode;\n onClick?: () => void;\n\n badge?: boolean;\n offsetRight?: 'none' | 'l' | 'xxl';\n expanded?: boolean;\n}\n\nexport interface MenuDropdownProps extends InternalButtonDropdownProps {\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconAlt?: string;\n iconSvg?: React.ReactNode;\n badge?: boolean;\n description?: string;\n offsetRight?: 'l' | 'xxl';\n}\n"]}
|
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-series.d.ts","sourceRoot":"lib/default/","sources":["mixed-line-bar-chart/bar-series.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAyB,cAAc,EAAE,MAAM,SAAS,CAAC;AAGhE,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;IAEhB,MAAM,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAEhD,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAEpB,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAE1B,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAE1B,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrC,iBAAiB,CAAC,EAAE,cAAc,CAAC;CACpC;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,EAC1D,IAAI,EACJ,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,WAAW,EACX,MAAM,EACN,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,iBAAiB,GAClB,EAAE,cAAc,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"bar-series.d.ts","sourceRoot":"lib/default/","sources":["mixed-line-bar-chart/bar-series.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAyB,cAAc,EAAE,MAAM,SAAS,CAAC;AAGhE,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;IAEhB,MAAM,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAEhD,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAEpB,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAE1B,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAE1B,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrC,iBAAiB,CAAC,EAAE,cAAc,CAAC;CACpC;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,EAC1D,IAAI,EACJ,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,WAAW,EACX,MAAM,EACN,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,iBAAiB,GAClB,EAAE,cAAc,CAAC,CAAC,CAAC,eA0GnB"}
|
|
@@ -52,9 +52,20 @@ export default function BarSeries({ axis, series, color, xScale, yScale, highlig
|
|
|
52
52
|
return (React.createElement("g", { "aria-label": series.title, clipPath: `url(#${chartAreaClipPath})`, className: clsx(styles.series, styles['series--bar'], {
|
|
53
53
|
[styles['series--highlighted']]: highlighted,
|
|
54
54
|
[styles['series--dimmed']]: dimmed,
|
|
55
|
-
}) }, xCoordinates.map(({ x, y, width, height }, i) =>
|
|
56
|
-
isFinite(
|
|
55
|
+
}) }, xCoordinates.map(({ x, y, width, height }, i) => {
|
|
56
|
+
if (!isFinite(x) || !isFinite(height)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Create margins between stacked series but only when series data is not too small.
|
|
60
|
+
const baseHeightOffset = stackedBarOffsets ? 3 : 0;
|
|
61
|
+
const isSmallBar = height < 4;
|
|
62
|
+
const heightOffset = isSmallBar ? 0 : baseHeightOffset;
|
|
63
|
+
const widthOffset = 2;
|
|
64
|
+
const rx = isRefresh ? (isSmallBar ? '2px' : '4px') : '0px';
|
|
65
|
+
const className = clsx(styles.series__rect, {
|
|
57
66
|
[styles['series--dimmed']]: highlightedXValue !== null && !matchesX(highlightedXValue, series.data[i].x),
|
|
58
|
-
})
|
|
67
|
+
});
|
|
68
|
+
return axis === 'x' ? (React.createElement("rect", { key: `bar-${i}`, fill: color, x: x + widthOffset / 2, y: y + heightOffset / 2, width: width - widthOffset, height: height - heightOffset, rx: rx, className: className })) : (React.createElement("rect", { key: `bar-${i}`, fill: color, x: y - height + heightOffset / 2, y: x + widthOffset / 2, width: height - heightOffset, height: width - widthOffset, rx: rx, className: className }));
|
|
69
|
+
})));
|
|
59
70
|
}
|
|
60
71
|
//# sourceMappingURL=bar-series.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-series.js","sourceRoot":"lib/default/","sources":["mixed-line-bar-chart/bar-series.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO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KAAK,EACX,CAAC,EAAE,CAAC,GAAG,WAAW,GAAG,CAAC,EACtB,CAAC,EAAE,CAAC,GAAG,YAAY,GAAG,CAAC,EACvB,KAAK,EAAE,KAAK,GAAG,WAAW,EAC1B,MAAM,EAAE,MAAM,GAAG,YAAY,EAC7B,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,SAAS,GACpB,CACH,CAAC,CAAC,CAAC,CACF,8BACE,GAAG,EAAE,OAAO,CAAC,EAAE,EACf,IAAI,EAAE,KAAK,EACX,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,YAAY,GAAG,CAAC,EAChC,CAAC,EAAE,CAAC,GAAG,WAAW,GAAG,CAAC,EACtB,KAAK,EAAE,MAAM,GAAG,YAAY,EAC5B,MAAM,EAAE,KAAK,GAAG,WAAW,EAC3B,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;IACJ,CAAC,CAAC,CACA,CACL,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo } from 'react';\nimport clsx from 'clsx';\nimport { ScaleContinuousNumeric, ScaleTime } from '../internal/vendor/d3-scale';\n\nimport { ChartScale, NumericChartScale } from '../internal/components/cartesian-chart/scales';\nimport { ChartDataTypes, MixedLineBarChartProps } from './interfaces';\nimport { matchesX, getKeyValue, StackedOffsets } from './utils';\nimport styles from './styles.css.js';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nexport interface BarSeriesProps<T> {\n axis: 'x' | 'y';\n\n series: MixedLineBarChartProps.BarDataSeries<T>;\n\n color: string;\n totalSeriesCount: number;\n seriesIndex: number;\n\n xScale: ChartScale;\n yScale: NumericChartScale;\n\n plotSize: number;\n chartAreaClipPath: string;\n\n highlighted: boolean;\n dimmed: boolean;\n highlightedGroupIndex: number | null;\n\n // Contains the cumulative offset for each x value in a stacked bar chart\n stackedBarOffsets?: StackedOffsets;\n}\n\nexport default function BarSeries<T extends ChartDataTypes>({\n axis,\n series,\n color,\n xScale,\n yScale,\n highlighted,\n dimmed,\n highlightedGroupIndex,\n stackedBarOffsets,\n totalSeriesCount,\n seriesIndex,\n plotSize,\n chartAreaClipPath,\n}: BarSeriesProps<T>) {\n const isRefresh = useVisualRefresh();\n\n const xCoordinates = useMemo(() => {\n if (series.type !== 'bar' || !xScale.isCategorical()) {\n return [];\n }\n\n const yContinuosScale: ScaleContinuousNumeric<number, number> | ScaleTime<number, number> = yScale.d3Scale;\n const xPoints = (series.data as ReadonlyArray<MixedLineBarChartProps.Datum<ChartDataTypes>>).map(\n ({ x }) => xScale.d3Scale(x) || NaN\n );\n\n const zeroY = yScale.d3Scale(0) ?? NaN;\n const baseY = isFinite(zeroY) ? Math.min(plotSize, zeroY) : plotSize;\n\n let barWidth = xScale.d3Scale.bandwidth();\n\n const PADDING = 4;\n const MINWIDTH = 4;\n\n if (!stackedBarOffsets && totalSeriesCount > 1) {\n // Regular grouped bars\n barWidth = (barWidth - (totalSeriesCount - 1) * PADDING) / totalSeriesCount;\n barWidth = Math.max(barWidth, MINWIDTH);\n }\n\n return xPoints.map((x, i) => {\n const d = series.data[i];\n let barX = x;\n let yValue = d.y;\n\n if (stackedBarOffsets) {\n // Stacked bars\n const offsetMap = d.y < 0 ? stackedBarOffsets.negativeOffsets : stackedBarOffsets.positiveOffsets;\n yValue = d.y + (offsetMap[getKeyValue(d.x)] || 0);\n } else if (totalSeriesCount > 1) {\n // Regular grouped bars\n barX += seriesIndex * (barWidth + PADDING);\n }\n\n // Account for negative values growing \"down\" instead of \"up\"\n yValue = yValue < 0 ? yValue - d.y : yValue;\n\n return {\n x: barX,\n y: yContinuosScale(yValue) ?? NaN,\n width: barWidth,\n height: Math.abs((yContinuosScale(d.y) ?? NaN) - baseY),\n };\n });\n }, [series, xScale, yScale, plotSize, stackedBarOffsets, totalSeriesCount, seriesIndex]);\n\n const highlightedXValue = highlightedGroupIndex !== null ? xScale.domain[highlightedGroupIndex] : null;\n\n return (\n <g\n aria-label={series.title}\n clipPath={`url(#${chartAreaClipPath})`}\n className={clsx(styles.series, styles['series--bar'], {\n [styles['series--highlighted']]: highlighted,\n [styles['series--dimmed']]: dimmed,\n })}\n >\n {xCoordinates.map(({ x, y, width, height }, i) => {\n if (!isFinite(x) || !isFinite(height)) {\n return;\n }\n\n // Create margins between stacked series but only when series data is not too small.\n const baseHeightOffset = stackedBarOffsets ? 3 : 0;\n const isSmallBar = height < 4;\n const heightOffset = isSmallBar ? 0 : baseHeightOffset;\n const widthOffset = 2;\n\n const rx = isRefresh ? (isSmallBar ? '2px' : '4px') : '0px';\n const className = clsx(styles.series__rect, {\n [styles['series--dimmed']]: highlightedXValue !== null && !matchesX(highlightedXValue, series.data[i].x),\n });\n\n return axis === 'x' ? (\n <rect\n key={`bar-${i}`}\n fill={color}\n x={x + widthOffset / 2}\n y={y + heightOffset / 2}\n width={width - widthOffset}\n height={height - heightOffset}\n rx={rx}\n className={className}\n />\n ) : (\n <rect\n key={`bar-${i}`}\n fill={color}\n x={y - height + heightOffset / 2}\n y={x + widthOffset / 2}\n width={height - heightOffset}\n height={width - widthOffset}\n rx={rx}\n className={className}\n />\n );\n })}\n </g>\n );\n}\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"series": "
|
|
5
|
-
"series--bar": "awsui_series--
|
|
6
|
-
"series__rect": "
|
|
7
|
-
"exiting": "
|
|
8
|
-
"awsui-motion-fade-out-0": "awsui_awsui-motion-fade-out-
|
|
9
|
-
"root": "
|
|
10
|
-
"series--highlighted": "awsui_series--
|
|
11
|
-
"series__bar--highlighted": "awsui_series__bar--
|
|
12
|
-
"series--dimmed": "awsui_series--
|
|
13
|
-
"series--threshold": "awsui_series--
|
|
14
|
-
"bar-group": "awsui_bar-
|
|
4
|
+
"series": "awsui_series_1yz9c_174ze_93",
|
|
5
|
+
"series--bar": "awsui_series--bar_1yz9c_174ze_94",
|
|
6
|
+
"series__rect": "awsui_series__rect_1yz9c_174ze_94",
|
|
7
|
+
"exiting": "awsui_exiting_1yz9c_174ze_111",
|
|
8
|
+
"awsui-motion-fade-out-0": "awsui_awsui-motion-fade-out-0_1yz9c_174ze_1",
|
|
9
|
+
"root": "awsui_root_1yz9c_174ze_137",
|
|
10
|
+
"series--highlighted": "awsui_series--highlighted_1yz9c_174ze_150",
|
|
11
|
+
"series__bar--highlighted": "awsui_series__bar--highlighted_1yz9c_174ze_151",
|
|
12
|
+
"series--dimmed": "awsui_series--dimmed_1yz9c_174ze_155",
|
|
13
|
+
"series--threshold": "awsui_series--threshold_1yz9c_174ze_159",
|
|
14
|
+
"bar-group": "awsui_bar-group_1yz9c_174ze_164"
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -90,26 +90,26 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
90
90
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
91
91
|
SPDX-License-Identifier: Apache-2.0
|
|
92
92
|
*/
|
|
93
|
-
.
|
|
94
|
-
.awsui_series--
|
|
93
|
+
.awsui_series_1yz9c_174ze_93:not(#\9),
|
|
94
|
+
.awsui_series--bar_1yz9c_174ze_94 > .awsui_series__rect_1yz9c_174ze_94:not(#\9) {
|
|
95
95
|
transition: opacity var(--motion-duration-transition-quick-6npj01, 90ms) var(--motion-easing-transition-quick-l9jfsx, linear);
|
|
96
96
|
}
|
|
97
97
|
@media (prefers-reduced-motion: reduce) {
|
|
98
|
-
.
|
|
99
|
-
.awsui_series--
|
|
98
|
+
.awsui_series_1yz9c_174ze_93:not(#\9),
|
|
99
|
+
.awsui_series--bar_1yz9c_174ze_94 > .awsui_series__rect_1yz9c_174ze_94:not(#\9) {
|
|
100
100
|
animation: none;
|
|
101
101
|
transition: none;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
.awsui-motion-disabled .
|
|
104
|
+
.awsui-motion-disabled .awsui_series_1yz9c_174ze_93:not(#\9), .awsui-mode-entering .awsui_series_1yz9c_174ze_93:not(#\9), .awsui-motion-disabled .awsui_series--bar_1yz9c_174ze_94 > .awsui_series__rect_1yz9c_174ze_94:not(#\9), .awsui-mode-entering .awsui_series--bar_1yz9c_174ze_94 > .awsui_series__rect_1yz9c_174ze_94:not(#\9) {
|
|
105
105
|
animation: none;
|
|
106
106
|
transition: none;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
.
|
|
110
|
-
animation: awsui_awsui-motion-fade-out-
|
|
109
|
+
.awsui_exiting_1yz9c_174ze_111:not(#\9) {
|
|
110
|
+
animation: awsui_awsui-motion-fade-out-0_1yz9c_174ze_1 var(--motion-duration-refresh-only-fast-4jn2d7, 115ms) var(--motion-easing-refresh-only-b-ufhmjm, cubic-bezier(1, 0, 0.83, 1));
|
|
111
111
|
}
|
|
112
|
-
@keyframes awsui_awsui-motion-fade-out-
|
|
112
|
+
@keyframes awsui_awsui-motion-fade-out-0_1yz9c_174ze_1 {
|
|
113
113
|
from {
|
|
114
114
|
opacity: 1;
|
|
115
115
|
}
|
|
@@ -118,12 +118,12 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
@media (prefers-reduced-motion: reduce) {
|
|
121
|
-
.
|
|
121
|
+
.awsui_exiting_1yz9c_174ze_111:not(#\9) {
|
|
122
122
|
animation: none;
|
|
123
123
|
transition: none;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
.awsui-motion-disabled .
|
|
126
|
+
.awsui-motion-disabled .awsui_exiting_1yz9c_174ze_111:not(#\9), .awsui-mode-entering .awsui_exiting_1yz9c_174ze_111:not(#\9) {
|
|
127
127
|
animation: none;
|
|
128
128
|
transition: none;
|
|
129
129
|
}
|
|
@@ -132,11 +132,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
132
132
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
133
133
|
SPDX-License-Identifier: Apache-2.0
|
|
134
134
|
*/
|
|
135
|
-
.
|
|
135
|
+
.awsui_root_1yz9c_174ze_137:not(#\9) {
|
|
136
136
|
/* used in test-utils */
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
.
|
|
139
|
+
.awsui_series_1yz9c_174ze_93:not(#\9) {
|
|
140
140
|
display: block;
|
|
141
141
|
stroke-width: var(--border-line-chart-width-9mzos2, 2px);
|
|
142
142
|
fill: none;
|
|
@@ -145,25 +145,20 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
145
145
|
pointer-events: none;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
.awsui_series--
|
|
149
|
-
.awsui_series__bar--
|
|
148
|
+
.awsui_series--highlighted_1yz9c_174ze_150:not(#\9),
|
|
149
|
+
.awsui_series__bar--highlighted_1yz9c_174ze_151:not(#\9) {
|
|
150
150
|
/* used in dom query */
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
.awsui_series--
|
|
153
|
+
.awsui_series--dimmed_1yz9c_174ze_155:not(#\9) {
|
|
154
154
|
opacity: 0.3;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
.awsui_series--
|
|
158
|
-
stroke: var(--color-background-container-content-4un1ap, #ffffff);
|
|
159
|
-
stroke-width: 2px;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.awsui_series--threshold_1yz9c_1534m_164:not(#\9) {
|
|
157
|
+
.awsui_series--threshold_1yz9c_174ze_159:not(#\9) {
|
|
163
158
|
stroke-dasharray: var(--border-line-chart-dash-array-k49cgz, 3 5);
|
|
164
159
|
stroke-width: var(--border-line-chart-width-9mzos2, 2px);
|
|
165
160
|
}
|
|
166
161
|
|
|
167
|
-
.awsui_bar-
|
|
162
|
+
.awsui_bar-group_1yz9c_174ze_164:not(#\9) {
|
|
168
163
|
/* used in dom query */
|
|
169
164
|
}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"series": "
|
|
6
|
-
"series--bar": "awsui_series--
|
|
7
|
-
"series__rect": "
|
|
8
|
-
"exiting": "
|
|
9
|
-
"awsui-motion-fade-out-0": "awsui_awsui-motion-fade-out-
|
|
10
|
-
"root": "
|
|
11
|
-
"series--highlighted": "awsui_series--
|
|
12
|
-
"series__bar--highlighted": "awsui_series__bar--
|
|
13
|
-
"series--dimmed": "awsui_series--
|
|
14
|
-
"series--threshold": "awsui_series--
|
|
15
|
-
"bar-group": "awsui_bar-
|
|
5
|
+
"series": "awsui_series_1yz9c_174ze_93",
|
|
6
|
+
"series--bar": "awsui_series--bar_1yz9c_174ze_94",
|
|
7
|
+
"series__rect": "awsui_series__rect_1yz9c_174ze_94",
|
|
8
|
+
"exiting": "awsui_exiting_1yz9c_174ze_111",
|
|
9
|
+
"awsui-motion-fade-out-0": "awsui_awsui-motion-fade-out-0_1yz9c_174ze_1",
|
|
10
|
+
"root": "awsui_root_1yz9c_174ze_137",
|
|
11
|
+
"series--highlighted": "awsui_series--highlighted_1yz9c_174ze_150",
|
|
12
|
+
"series__bar--highlighted": "awsui_series__bar--highlighted_1yz9c_174ze_151",
|
|
13
|
+
"series--dimmed": "awsui_series--dimmed_1yz9c_174ze_155",
|
|
14
|
+
"series--threshold": "awsui_series--threshold_1yz9c_174ze_159",
|
|
15
|
+
"bar-group": "awsui_bar-group_1yz9c_174ze_164"
|
|
16
16
|
};
|
|
17
17
|
|
package/modal/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["modal/internal.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAYlF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["modal/internal.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAYlF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOjD,KAAK,kBAAkB,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,0BAA0B,CAAC;AAExF,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,kBAAkB,eAM/E"}
|