@cloudscape-design/components 3.0.684 → 3.0.686
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/annotation-context/annotation/styles.css.js +24 -24
- package/annotation-context/annotation/styles.scoped.css +31 -31
- package/annotation-context/annotation/styles.selectors.js +24 -24
- package/app-layout/notifications/styles.css.js +3 -3
- package/app-layout/notifications/styles.scoped.css +7 -7
- package/app-layout/notifications/styles.selectors.js +3 -3
- package/app-layout/visual-refresh/styles.css.js +82 -82
- package/app-layout/visual-refresh/styles.scoped.css +255 -255
- package/app-layout/visual-refresh/styles.selectors.js +82 -82
- package/app-layout/visual-refresh-toolbar/navigation/styles.css.js +6 -6
- package/app-layout/visual-refresh-toolbar/navigation/styles.scoped.css +13 -13
- package/app-layout/visual-refresh-toolbar/navigation/styles.selectors.js +6 -6
- package/app-layout/visual-refresh-toolbar/skeleton/styles.css.js +16 -16
- package/app-layout/visual-refresh-toolbar/skeleton/styles.scoped.css +37 -37
- package/app-layout/visual-refresh-toolbar/skeleton/styles.selectors.js +16 -16
- package/area-chart/model/use-chart-model.d.ts.map +1 -1
- package/area-chart/model/use-chart-model.js +2 -1
- package/area-chart/model/use-chart-model.js.map +1 -1
- package/area-chart/model/utils.d.ts +0 -1
- package/area-chart/model/utils.d.ts.map +1 -1
- package/area-chart/model/utils.js +0 -10
- package/area-chart/model/utils.js.map +1 -1
- package/button/interfaces.d.ts +1 -1
- package/button/interfaces.js.map +1 -1
- package/button-dropdown/item-element/index.js +1 -1
- package/button-dropdown/item-element/index.js.map +1 -1
- package/button-dropdown/item-element/styles.css.js +12 -11
- package/button-dropdown/item-element/styles.scoped.css +14 -14
- package/button-dropdown/item-element/styles.selectors.js +12 -11
- package/button-dropdown/tooltip.d.ts +2 -1
- package/button-dropdown/tooltip.d.ts.map +1 -1
- package/button-dropdown/tooltip.js +2 -2
- package/button-dropdown/tooltip.js.map +1 -1
- package/content-layout/styles.css.js +14 -14
- package/content-layout/styles.scoped.css +27 -27
- package/content-layout/styles.selectors.js +14 -14
- package/copy-to-clipboard/index.d.ts +1 -1
- package/copy-to-clipboard/index.d.ts.map +1 -1
- package/copy-to-clipboard/index.js +2 -2
- package/copy-to-clipboard/index.js.map +1 -1
- package/copy-to-clipboard/interfaces.d.ts +8 -0
- package/copy-to-clipboard/interfaces.d.ts.map +1 -1
- package/copy-to-clipboard/interfaces.js.map +1 -1
- package/copy-to-clipboard/internal.d.ts +1 -1
- package/copy-to-clipboard/internal.d.ts.map +1 -1
- package/copy-to-clipboard/internal.js +2 -2
- package/copy-to-clipboard/internal.js.map +1 -1
- package/flashbar/styles.css.js +47 -47
- package/flashbar/styles.scoped.css +171 -171
- package/flashbar/styles.selectors.js +47 -47
- package/i18n/dynamic.js +2 -0
- package/i18n/messages/all.all.js +1 -1
- package/i18n/messages/all.all.json +1 -1
- package/i18n/messages/all.ar.d.ts +3 -0
- package/i18n/messages/all.ar.js +1 -0
- package/i18n/messages/all.ar.json +1 -0
- package/i18n/messages/all.de.js +1 -1
- package/i18n/messages/all.de.json +1 -1
- package/i18n/messages/all.en-GB.js +1 -1
- package/i18n/messages/all.en-GB.json +1 -1
- package/i18n/messages/all.en.js +1 -1
- package/i18n/messages/all.en.json +1 -1
- package/i18n/messages/all.es.js +1 -1
- package/i18n/messages/all.es.json +1 -1
- package/i18n/messages/all.fr.js +1 -1
- package/i18n/messages/all.fr.json +1 -1
- package/i18n/messages/all.id.js +1 -1
- package/i18n/messages/all.id.json +1 -1
- package/i18n/messages/all.it.js +1 -1
- package/i18n/messages/all.it.json +1 -1
- package/i18n/messages/all.ja.js +1 -1
- package/i18n/messages/all.ja.json +1 -1
- package/i18n/messages/all.ko.js +1 -1
- package/i18n/messages/all.ko.json +1 -1
- package/i18n/messages/all.pt-BR.js +1 -1
- package/i18n/messages/all.pt-BR.json +1 -1
- package/i18n/messages/all.tr.js +1 -1
- package/i18n/messages/all.tr.json +1 -1
- package/i18n/messages/all.zh-CN.js +1 -1
- package/i18n/messages/all.zh-CN.json +1 -1
- package/i18n/messages/all.zh-TW.js +1 -1
- package/i18n/messages/all.zh-TW.json +1 -1
- package/i18n/messages-types.d.ts +12 -0
- package/i18n/messages-types.d.ts.map +1 -1
- package/i18n/messages-types.js.map +1 -1
- package/icon/styles.css.js +38 -37
- package/icon/styles.scoped.css +82 -80
- package/icon/styles.selectors.js +38 -37
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/internal/components/chart-plot/focus-outline.js +1 -1
- package/internal/components/chart-plot/focus-outline.js.map +1 -1
- package/internal/components/dropdown/styles.css.js +20 -20
- package/internal/components/dropdown/styles.scoped.css +40 -40
- package/internal/components/dropdown/styles.selectors.js +20 -20
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/generated/custom-css-properties/index.d.ts +2 -0
- package/internal/generated/custom-css-properties/index.d.ts.map +1 -1
- package/internal/generated/custom-css-properties/index.js +57 -55
- package/internal/generated/custom-css-properties/index.js.map +1 -1
- package/internal/hooks/use-base-component/index.d.ts.map +1 -1
- package/internal/hooks/use-base-component/index.js +1 -2
- package/internal/hooks/use-base-component/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/internal/utils/circle-index.d.ts +2 -0
- package/internal/utils/circle-index.d.ts.map +1 -0
- package/internal/utils/circle-index.js +13 -0
- package/internal/utils/circle-index.js.map +1 -0
- package/key-value-pairs/index.d.ts +1 -1
- package/key-value-pairs/index.d.ts.map +1 -1
- package/key-value-pairs/index.js +2 -2
- package/key-value-pairs/index.js.map +1 -1
- package/key-value-pairs/interfaces.d.ts +11 -0
- package/key-value-pairs/interfaces.d.ts.map +1 -1
- package/key-value-pairs/interfaces.js.map +1 -1
- package/key-value-pairs/internal.d.ts.map +1 -1
- package/key-value-pairs/internal.js +2 -2
- package/key-value-pairs/internal.js.map +1 -1
- package/mixed-line-bar-chart/hooks/use-navigation.d.ts.map +1 -1
- package/mixed-line-bar-chart/hooks/use-navigation.js +1 -10
- package/mixed-line-bar-chart/hooks/use-navigation.js.map +1 -1
- package/package.json +4 -1
- package/prompt-input/index.d.ts +6 -0
- package/prompt-input/index.d.ts.map +1 -0
- package/prompt-input/index.js +27 -0
- package/prompt-input/index.js.map +1 -0
- package/prompt-input/interfaces.d.ts +82 -0
- package/prompt-input/interfaces.d.ts.map +1 -0
- package/prompt-input/interfaces.js +2 -0
- package/prompt-input/interfaces.js.map +1 -0
- package/prompt-input/internal.d.ts +8 -0
- package/prompt-input/internal.d.ts.map +1 -0
- package/prompt-input/internal.js +109 -0
- package/prompt-input/internal.js.map +1 -0
- package/prompt-input/styles.css.js +13 -0
- package/prompt-input/styles.scoped.css +248 -0
- package/prompt-input/styles.selectors.js +14 -0
- package/prompt-input/test-classes/styles.css.js +8 -0
- package/prompt-input/test-classes/styles.scoped.css +15 -0
- package/prompt-input/test-classes/styles.selectors.js +9 -0
- package/property-filter/filtering-token/index.d.ts.map +1 -0
- package/{internal/components → property-filter}/filtering-token/index.js +7 -6
- package/property-filter/filtering-token/index.js.map +1 -0
- package/property-filter/filtering-token/styles.css.js +12 -0
- package/{internal/components → property-filter}/filtering-token/styles.scoped.css +15 -15
- package/property-filter/filtering-token/styles.selectors.js +13 -0
- package/property-filter/test-classes/styles.css.js +14 -0
- package/property-filter/test-classes/styles.scoped.css +39 -0
- package/property-filter/test-classes/styles.selectors.js +15 -0
- package/property-filter/token-editor.d.ts.map +1 -1
- package/property-filter/token-editor.js +7 -5
- package/property-filter/token-editor.js.map +1 -1
- package/property-filter/token.js +1 -1
- package/property-filter/token.js.map +1 -1
- package/select/parts/filter.d.ts +1 -1
- package/slider/styles.css.js +26 -27
- package/slider/styles.scoped.css +90 -90
- package/slider/styles.selectors.js +26 -27
- package/spinner/styles.css.js +13 -13
- package/spinner/styles.scoped.css +39 -39
- package/spinner/styles.selectors.js +13 -13
- package/table/body-cell/styles.css.js +46 -46
- package/table/body-cell/styles.scoped.css +525 -274
- package/table/body-cell/styles.selectors.js +46 -46
- package/table/body-cell/td-element.d.ts.map +1 -1
- package/table/body-cell/td-element.js +3 -4
- package/table/body-cell/td-element.js.map +1 -1
- package/tabs/styles.css.js +28 -28
- package/tabs/styles.scoped.css +53 -53
- package/tabs/styles.selectors.js +28 -28
- package/tabs/tab-header-bar.d.ts.map +1 -1
- package/tabs/tab-header-bar.js +1 -9
- package/tabs/tab-header-bar.js.map +1 -1
- package/test-utils/dom/copy-to-clipboard/index.d.ts +3 -1
- package/test-utils/dom/copy-to-clipboard/index.js +2 -2
- package/test-utils/dom/copy-to-clipboard/index.js.map +1 -1
- package/test-utils/dom/index.d.ts +3 -0
- package/test-utils/dom/index.js +10 -2
- package/test-utils/dom/index.js.map +1 -1
- package/test-utils/dom/prompt-input/index.d.ts +18 -0
- package/test-utils/dom/prompt-input/index.js +49 -0
- package/test-utils/dom/prompt-input/index.js.map +1 -0
- package/test-utils/dom/property-filter/index.d.ts +25 -2
- package/test-utils/dom/property-filter/index.js +59 -6
- package/test-utils/dom/property-filter/index.js.map +1 -1
- package/test-utils/selectors/copy-to-clipboard/index.d.ts +3 -1
- package/test-utils/selectors/copy-to-clipboard/index.js +4 -2
- package/test-utils/selectors/copy-to-clipboard/index.js.map +1 -1
- package/test-utils/selectors/index.d.ts +3 -0
- package/test-utils/selectors/index.js +10 -2
- package/test-utils/selectors/index.js.map +1 -1
- package/test-utils/selectors/prompt-input/index.d.ts +6 -0
- package/test-utils/selectors/prompt-input/index.js +15 -0
- package/test-utils/selectors/prompt-input/index.js.map +1 -0
- package/test-utils/selectors/property-filter/index.d.ts +25 -2
- package/test-utils/selectors/property-filter/index.js +61 -6
- package/test-utils/selectors/property-filter/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/internal/components/filtering-token/index.d.ts.map +0 -1
- package/internal/components/filtering-token/index.js.map +0 -1
- package/internal/components/filtering-token/styles.css.js +0 -12
- package/internal/components/filtering-token/styles.selectors.js +0 -13
- package/internal/hooks/focus-visible/index.d.ts +0 -3
- package/internal/hooks/focus-visible/index.d.ts.map +0 -1
- package/internal/hooks/focus-visible/index.js +0 -49
- package/internal/hooks/focus-visible/index.js.map +0 -1
- package/test-utils/dom/internal/filtering-token.d.ts +0 -8
- package/test-utils/dom/internal/filtering-token.js +0 -21
- package/test-utils/dom/internal/filtering-token.js.map +0 -1
- package/test-utils/selectors/internal/filtering-token.d.ts +0 -8
- package/test-utils/selectors/internal/filtering-token.js +0 -21
- package/test-utils/selectors/internal/filtering-token.js.map +0 -1
- /package/{internal/components → property-filter}/filtering-token/index.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chart-model.js","sourceRoot":"","sources":["../../../../src/area-chart/model/use-chart-model.ts"],"names":[],"mappings":"AAGA,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAyB,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,qBAAqB,MAAM,2BAA2B,CAAC;AAC9D,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,SAAS,MAAM,iCAAiC,CAAC;AAExD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM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gBAAgB;gBAChB,eAAe;gBACf,iBAAiB;gBACjB,cAAc;aACf;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,cAAc;gBAC3B,SAAS,EAAE,YAAY;gBACvB,cAAc,EAAE,iBAAiB;gBACjC,UAAU;aACX;SACF,CAAC;IACJ,CAAC,EAAE;QACD,SAAS;QACT,MAAM;QACN,OAAO;QACP,OAAO;QACP,UAAU;QACV,UAAU;QACV,MAAM;QACN,KAAK;QACL,sBAAsB;QACtB,UAAU;QACV,KAAK;KACN,CAAC,CAAC;IAEH,8CAA8C;IAC9C,WAAW,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;IAExF,uEAAuE;IACvE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,iBAAiB,KAAK,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,iBAAiB,EAAE;YACpE,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;SACvD;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAE/B,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AreaChartProps } from '../interfaces';\nimport React, { useEffect, useMemo, useRef, RefObject, MouseEvent } from 'react';\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { findClosest, circleIndex } from './utils';\n\nimport { KeyCode } from '../../internal/keycode';\nimport { XDomain, XScaleType, YDomain, YScaleType } from '../../internal/components/cartesian-chart/interfaces';\nimport computeChartProps from './compute-chart-props';\nimport createSeriesDecorator from './create-series-decorator';\nimport InteractionsStore from './interactions-store';\nimport { ChartModel } from './index';\nimport { ChartPlotRef } from '../../internal/components/chart-plot';\nimport { throttle } from '../../internal/utils/throttle';\nimport { useReaction } from '../async-store';\nimport { useHeightMeasure } from '../../internal/hooks/container-queries/use-height-measure';\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\nimport { nodeBelongs } from '../../internal/utils/node-belongs';\nimport handleKey from '../../internal/utils/handle-key';\n\nconst MAX_HOVER_MARGIN = 6;\nconst SVG_HOVER_THROTTLE = 25;\nconst POPOVER_DEADZONE = 12;\n\nexport interface UseChartModelProps<T extends AreaChartProps.DataTypes> {\n isRtl?: boolean;\n fitHeight?: boolean;\n externalSeries: readonly AreaChartProps.Series<T>[];\n visibleSeries: readonly AreaChartProps.Series<T>[];\n setVisibleSeries: (series: readonly AreaChartProps.Series<T>[]) => void;\n highlightedSeries: null | AreaChartProps.Series<T>;\n setHighlightedSeries: (series: null | AreaChartProps.Series<T>) => void;\n xDomain?: XDomain<T>;\n yDomain?: YDomain;\n xScaleType: XScaleType;\n yScaleType: YScaleType;\n height: number;\n width: number;\n popoverRef: RefObject<HTMLElement>;\n}\n\n// Represents the core the chart logic, including the model of all allowed user interactions.\nexport default function useChartModel<T extends AreaChartProps.DataTypes>({\n isRtl,\n fitHeight,\n externalSeries: allSeries,\n visibleSeries: series,\n setVisibleSeries,\n highlightedSeries,\n setHighlightedSeries,\n xDomain,\n yDomain,\n xScaleType,\n yScaleType,\n height: explicitHeight,\n width,\n popoverRef,\n}: UseChartModelProps<T>): ChartModel<T> {\n // Chart elements refs used in handlers.\n const plotRef = useRef<ChartPlotRef>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const verticalMarkerRef = useRef<SVGLineElement>(null);\n\n const plotMeasureRef = useRef<SVGLineElement>(null);\n const hasVisibleSeries = series.length > 0;\n const height = useHeightMeasure(() => plotMeasureRef.current, !fitHeight, [hasVisibleSeries]) ?? explicitHeight;\n\n const stableSetVisibleSeries = useStableCallback(setVisibleSeries);\n\n const model = useMemo(() => {\n // Compute scales, ticks and two-dimensional plots.\n const computed = computeChartProps({\n isRtl,\n series,\n xDomain,\n yDomain,\n xScaleType,\n yScaleType,\n height,\n width,\n });\n\n // A store for chart interactions that don't require plot recomputation.\n const interactions = new InteractionsStore(series, computed.plot);\n\n const containsMultipleSeries = interactions.series.length > 1;\n\n // A series decorator to provide extra props such as color and marker type.\n const getInternalSeries = createSeriesDecorator(allSeries);\n\n const isMouseOverPopover = (clientX: number, clientY: number) => {\n if (popoverRef.current?.firstChild) {\n const popoverPosition = (popoverRef.current.firstChild as HTMLElement).getBoundingClientRect();\n if (\n clientX > popoverPosition.x - POPOVER_DEADZONE &&\n clientX < popoverPosition.x + popoverPosition.width + POPOVER_DEADZONE &&\n clientY > popoverPosition.y - POPOVER_DEADZONE &&\n clientY < popoverPosition.y + popoverPosition.height + POPOVER_DEADZONE\n ) {\n return true;\n }\n }\n return false;\n };\n\n // A Callback for svg mouseover to hover the plot points.\n // Throttling is necessary for a substantially smoother customer experience.\n const onSVGMouseMoveThrottled = throttle((clientX: number, clientY: number) => {\n // No hover logic when the popover is pinned or no data available.\n if (\n interactions.get().isPopoverPinned ||\n !plotRef.current ||\n interactions.plot.xy.length === 0 ||\n isMouseOverPopover(clientX, clientY)\n ) {\n return;\n }\n\n const svgRect = plotRef.current.svg.getBoundingClientRect();\n const offsetX = clientX - svgRect.left;\n const offsetY = clientY - svgRect.top;\n\n const closestX = findClosest(interactions.plot.xy, offsetX, xPoints => xPoints[0].scaled.x);\n const closestPoint = findClosest(closestX, offsetY, point => point.scaled.y1);\n\n // If close enough to the point - highlight the point and its column.\n // If not - only highlight the closest column.\n if (\n Math.abs(offsetX - closestPoint.scaled.x) < MAX_HOVER_MARGIN &&\n Math.abs(offsetY - closestPoint.scaled.y1) < MAX_HOVER_MARGIN\n ) {\n interactions.highlightPoint(closestPoint);\n } else {\n interactions.highlightX(closestX);\n }\n }, SVG_HOVER_THROTTLE);\n\n const onSVGMouseMove = ({ clientX, clientY }: React.MouseEvent<SVGElement>) =>\n onSVGMouseMoveThrottled(clientX, clientY);\n\n // A callback for svg mouseout to clear all highlights.\n const onSVGMouseOut = (event: React.MouseEvent<SVGElement>) => {\n // Because the mouseover is throttled, in can occur slightly after the mouseout,\n // neglecting its effect; cancelling the throttled function prevents that.\n onSVGMouseMoveThrottled.cancel();\n\n // No hover logic when the popover is pinned or mouse is over popover\n if (interactions.get().isPopoverPinned || isMouseOverPopover(event.clientX, event.clientY)) {\n return;\n }\n\n // Check if the target is contained within svg to allow hovering on the popover body.\n if (!nodeContains(plotRef.current!.svg, event.relatedTarget as Element)) {\n interactions.clearHighlightedLegend();\n interactions.clearHighlight();\n }\n };\n\n // A callback for svg click to pin/unpin the popover.\n const onSVGMouseDown = (event: React.MouseEvent<SVGSVGElement>) => {\n interactions.togglePopoverPin();\n event.preventDefault();\n };\n\n const moveWithinXAxis = (direction: -1 | 1) => {\n if (interactions.get().highlightedPoint) {\n return moveWithinSeries(direction);\n } else if (containsMultipleSeries) {\n const { highlightedX } = interactions.get();\n if (highlightedX) {\n const currentXIndex = highlightedX[0].index.x;\n const nextXIndex = circleIndex(currentXIndex + direction, [0, interactions.plot.xy.length - 1]);\n interactions.highlightX(interactions.plot.xy[nextXIndex]);\n }\n }\n };\n\n // A helper function to highlight the next or previous point within selected series.\n const moveWithinSeries = (direction: -1 | 1) => {\n // Can only use motion when a particular point is highlighted.\n const point = interactions.get().highlightedPoint;\n if (!point) {\n return;\n }\n\n // Take the index of the currently highlighted series.\n const sIndex = point.index.s;\n // Take the incremented(circularly) x-index of the currently highlighted point.\n const xIndex = circleIndex(point.index.x + direction, [0, interactions.plot.xs.length - 1]);\n // Highlight the next point using x:s grouped data.\n interactions.highlightPoint(interactions.plot.xs[xIndex][sIndex]);\n };\n\n // A helper function to highlight the next or previous point within the selected column.\n const moveBetweenSeries = (direction: -1 | 1) => {\n const point = interactions.get().highlightedPoint;\n if (!point) {\n const { highlightedX } = interactions.get();\n if (highlightedX) {\n const xIndex = highlightedX[0].index.x;\n const points = interactions.plot.xy[xIndex];\n const yIndex = direction === 1 ? 0 : points.length - 1;\n interactions.highlightPoint(points[yIndex]);\n }\n return;\n }\n\n // Take the index of the currently highlighted column.\n const xIndex = point.index.x;\n const currentYIndex = point.index.y;\n\n if (\n containsMultipleSeries &&\n ((currentYIndex === 0 && direction === -1) ||\n (currentYIndex === interactions.plot.xy[xIndex].length - 1 && direction === 1))\n ) {\n interactions.highlightX(interactions.plot.xy[xIndex]);\n } else {\n // Take the incremented(circularly) y-index of the currently highlighted point.\n const nextYIndex = circleIndex(currentYIndex + direction, [0, interactions.plot.xy[xIndex].length - 1]);\n // Highlight the next point using x:y grouped data.\n interactions.highlightPoint(interactions.plot.xy[xIndex][nextYIndex]);\n }\n };\n\n // A callback for svg keydown to enable motions and popover pin with the keyboard.\n const onSVGKeyDown = (event: React.KeyboardEvent<HTMLElement | SVGElement>) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.up &&\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.down &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.space &&\n keyCode !== KeyCode.enter\n ) {\n return;\n }\n\n // Preventing default fixes an issue in Safari+VO when VO additionally interprets arrow keys as its commands.\n event.preventDefault();\n\n // No keydown logic when the popover is pinned.\n if (interactions.get().isPopoverPinned) {\n return;\n }\n\n handleKey(event, {\n onBlockEnd: () => moveBetweenSeries(-1),\n onBlockStart: () => moveBetweenSeries(1),\n onInlineStart: () => moveWithinXAxis(-1),\n onInlineEnd: () => moveWithinXAxis(1),\n onActivate: () => interactions.pinPopover(),\n });\n };\n\n const highlightFirstX = () => {\n interactions.highlightX(interactions.plot.xy[0]);\n };\n\n // A callback for application focus to highlight series.\n const onApplicationFocus = (_event: React.FocusEvent, trigger: 'mouse' | 'keyboard') => {\n // When focus is caused by a click event nothing is expected as clicks are handled separately.\n if (trigger === 'keyboard') {\n const { highlightedX, highlightedPoint, highlightedSeries, legendSeries } = interactions.get();\n if (containsMultipleSeries && !highlightedX && !highlightedPoint && !highlightedSeries && !legendSeries) {\n highlightFirstX();\n } else if (!highlightedX) {\n interactions.highlightFirstPoint();\n }\n }\n };\n\n // A callback for application blur to clear all highlights unless the popover is pinned.\n const onApplicationBlur = (event: React.FocusEvent<Element>) => {\n // Pinned popover stays pinned even if the focus is lost.\n // If blur is not caused by the popover, forget the previously highlighted point.\n if (!nodeBelongs(containerRef.current, event.relatedTarget) && !interactions.get().isPopoverPinned) {\n interactions.clearHighlight();\n }\n };\n\n const onFilterSeries = (series: readonly AreaChartProps.Series<T>[]) => {\n stableSetVisibleSeries(series);\n };\n\n const onLegendHighlight = (series: null | AreaChartProps.Series<T>) => {\n interactions.highlightSeries(series);\n };\n\n const onPopoverDismiss = (outsideClick?: boolean) => {\n interactions.unpinPopover();\n\n // Return focus back to the application or plot (when no point is highlighted).\n if (!outsideClick) {\n // The delay is needed to bypass focus events caused by click or keypress needed to unpin the popover.\n setTimeout(() => {\n if (interactions.get().highlightedPoint || interactions.get().highlightedX) {\n plotRef.current!.focusApplication();\n } else {\n interactions.clearHighlight();\n plotRef.current!.focusPlot();\n }\n }, 0);\n }\n };\n\n const onContainerBlur = () => {\n interactions.clearState();\n };\n\n const onDocumentKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n interactions.clearHighlight();\n interactions.clearHighlightedLegend();\n }\n };\n\n const onPopoverLeave = (event: MouseEvent) => {\n if (nodeContains(plotRef.current!.svg, event.relatedTarget as Element) || interactions.get().isPopoverPinned) {\n return;\n }\n interactions.clearHighlight();\n interactions.clearHighlightedLegend();\n };\n return {\n width,\n height,\n series,\n allSeries,\n getInternalSeries,\n computed,\n interactions,\n handlers: {\n onSVGMouseMove,\n onSVGMouseOut,\n onSVGMouseDown,\n onSVGKeyDown,\n onApplicationFocus,\n onApplicationBlur,\n onFilterSeries,\n onLegendHighlight,\n onPopoverDismiss,\n onContainerBlur,\n onDocumentKeyDown,\n onPopoverLeave,\n },\n refs: {\n plot: plotRef,\n plotMeasure: plotMeasureRef,\n container: containerRef,\n verticalMarker: verticalMarkerRef,\n popoverRef,\n },\n };\n }, [\n allSeries,\n series,\n xDomain,\n yDomain,\n xScaleType,\n yScaleType,\n height,\n width,\n stableSetVisibleSeries,\n popoverRef,\n isRtl,\n ]);\n\n // Notify client when series highlight change.\n useReaction(model.interactions, state => state.highlightedSeries, setHighlightedSeries);\n\n // Update interactions store when series highlight in a controlled way.\n useEffect(() => {\n if (highlightedSeries !== model.interactions.get().highlightedSeries) {\n model.interactions.highlightSeries(highlightedSeries);\n }\n }, [model, highlightedSeries]);\n\n return model;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-chart-model.js","sourceRoot":"","sources":["../../../../src/area-chart/model/use-chart-model.ts"],"names":[],"mappings":"AAGA,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAyB,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,qBAAqB,MAAM,2BAA2B,CAAC;AAC9D,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,SAAS,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAm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AiB;gBACjB,cAAc;aACf;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,cAAc;gBAC3B,SAAS,EAAE,YAAY;gBACvB,cAAc,EAAE,iBAAiB;gBACjC,UAAU;aACX;SACF,CAAC;IACJ,CAAC,EAAE;QACD,SAAS;QACT,MAAM;QACN,OAAO;QACP,OAAO;QACP,UAAU;QACV,UAAU;QACV,MAAM;QACN,KAAK;QACL,sBAAsB;QACtB,UAAU;QACV,KAAK;KACN,CAAC,CAAC;IAEH,8CAA8C;IAC9C,WAAW,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;IAExF,uEAAuE;IACvE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,iBAAiB,KAAK,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,iBAAiB,EAAE;YACpE,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;SACvD;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAE/B,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AreaChartProps } from '../interfaces';\nimport React, { useEffect, useMemo, useRef, RefObject, MouseEvent } from 'react';\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { findClosest } from './utils';\n\nimport { KeyCode } from '../../internal/keycode';\nimport { XDomain, XScaleType, YDomain, YScaleType } from '../../internal/components/cartesian-chart/interfaces';\nimport computeChartProps from './compute-chart-props';\nimport createSeriesDecorator from './create-series-decorator';\nimport InteractionsStore from './interactions-store';\nimport { ChartModel } from './index';\nimport { ChartPlotRef } from '../../internal/components/chart-plot';\nimport { throttle } from '../../internal/utils/throttle';\nimport { useReaction } from '../async-store';\nimport { useHeightMeasure } from '../../internal/hooks/container-queries/use-height-measure';\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\nimport { nodeBelongs } from '../../internal/utils/node-belongs';\nimport handleKey from '../../internal/utils/handle-key';\nimport { circleIndex } from '../../internal/utils/circle-index';\n\nconst MAX_HOVER_MARGIN = 6;\nconst SVG_HOVER_THROTTLE = 25;\nconst POPOVER_DEADZONE = 12;\n\nexport interface UseChartModelProps<T extends AreaChartProps.DataTypes> {\n isRtl?: boolean;\n fitHeight?: boolean;\n externalSeries: readonly AreaChartProps.Series<T>[];\n visibleSeries: readonly AreaChartProps.Series<T>[];\n setVisibleSeries: (series: readonly AreaChartProps.Series<T>[]) => void;\n highlightedSeries: null | AreaChartProps.Series<T>;\n setHighlightedSeries: (series: null | AreaChartProps.Series<T>) => void;\n xDomain?: XDomain<T>;\n yDomain?: YDomain;\n xScaleType: XScaleType;\n yScaleType: YScaleType;\n height: number;\n width: number;\n popoverRef: RefObject<HTMLElement>;\n}\n\n// Represents the core the chart logic, including the model of all allowed user interactions.\nexport default function useChartModel<T extends AreaChartProps.DataTypes>({\n isRtl,\n fitHeight,\n externalSeries: allSeries,\n visibleSeries: series,\n setVisibleSeries,\n highlightedSeries,\n setHighlightedSeries,\n xDomain,\n yDomain,\n xScaleType,\n yScaleType,\n height: explicitHeight,\n width,\n popoverRef,\n}: UseChartModelProps<T>): ChartModel<T> {\n // Chart elements refs used in handlers.\n const plotRef = useRef<ChartPlotRef>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const verticalMarkerRef = useRef<SVGLineElement>(null);\n\n const plotMeasureRef = useRef<SVGLineElement>(null);\n const hasVisibleSeries = series.length > 0;\n const height = useHeightMeasure(() => plotMeasureRef.current, !fitHeight, [hasVisibleSeries]) ?? explicitHeight;\n\n const stableSetVisibleSeries = useStableCallback(setVisibleSeries);\n\n const model = useMemo(() => {\n // Compute scales, ticks and two-dimensional plots.\n const computed = computeChartProps({\n isRtl,\n series,\n xDomain,\n yDomain,\n xScaleType,\n yScaleType,\n height,\n width,\n });\n\n // A store for chart interactions that don't require plot recomputation.\n const interactions = new InteractionsStore(series, computed.plot);\n\n const containsMultipleSeries = interactions.series.length > 1;\n\n // A series decorator to provide extra props such as color and marker type.\n const getInternalSeries = createSeriesDecorator(allSeries);\n\n const isMouseOverPopover = (clientX: number, clientY: number) => {\n if (popoverRef.current?.firstChild) {\n const popoverPosition = (popoverRef.current.firstChild as HTMLElement).getBoundingClientRect();\n if (\n clientX > popoverPosition.x - POPOVER_DEADZONE &&\n clientX < popoverPosition.x + popoverPosition.width + POPOVER_DEADZONE &&\n clientY > popoverPosition.y - POPOVER_DEADZONE &&\n clientY < popoverPosition.y + popoverPosition.height + POPOVER_DEADZONE\n ) {\n return true;\n }\n }\n return false;\n };\n\n // A Callback for svg mouseover to hover the plot points.\n // Throttling is necessary for a substantially smoother customer experience.\n const onSVGMouseMoveThrottled = throttle((clientX: number, clientY: number) => {\n // No hover logic when the popover is pinned or no data available.\n if (\n interactions.get().isPopoverPinned ||\n !plotRef.current ||\n interactions.plot.xy.length === 0 ||\n isMouseOverPopover(clientX, clientY)\n ) {\n return;\n }\n\n const svgRect = plotRef.current.svg.getBoundingClientRect();\n const offsetX = clientX - svgRect.left;\n const offsetY = clientY - svgRect.top;\n\n const closestX = findClosest(interactions.plot.xy, offsetX, xPoints => xPoints[0].scaled.x);\n const closestPoint = findClosest(closestX, offsetY, point => point.scaled.y1);\n\n // If close enough to the point - highlight the point and its column.\n // If not - only highlight the closest column.\n if (\n Math.abs(offsetX - closestPoint.scaled.x) < MAX_HOVER_MARGIN &&\n Math.abs(offsetY - closestPoint.scaled.y1) < MAX_HOVER_MARGIN\n ) {\n interactions.highlightPoint(closestPoint);\n } else {\n interactions.highlightX(closestX);\n }\n }, SVG_HOVER_THROTTLE);\n\n const onSVGMouseMove = ({ clientX, clientY }: React.MouseEvent<SVGElement>) =>\n onSVGMouseMoveThrottled(clientX, clientY);\n\n // A callback for svg mouseout to clear all highlights.\n const onSVGMouseOut = (event: React.MouseEvent<SVGElement>) => {\n // Because the mouseover is throttled, in can occur slightly after the mouseout,\n // neglecting its effect; cancelling the throttled function prevents that.\n onSVGMouseMoveThrottled.cancel();\n\n // No hover logic when the popover is pinned or mouse is over popover\n if (interactions.get().isPopoverPinned || isMouseOverPopover(event.clientX, event.clientY)) {\n return;\n }\n\n // Check if the target is contained within svg to allow hovering on the popover body.\n if (!nodeContains(plotRef.current!.svg, event.relatedTarget as Element)) {\n interactions.clearHighlightedLegend();\n interactions.clearHighlight();\n }\n };\n\n // A callback for svg click to pin/unpin the popover.\n const onSVGMouseDown = (event: React.MouseEvent<SVGSVGElement>) => {\n interactions.togglePopoverPin();\n event.preventDefault();\n };\n\n const moveWithinXAxis = (direction: -1 | 1) => {\n if (interactions.get().highlightedPoint) {\n return moveWithinSeries(direction);\n } else if (containsMultipleSeries) {\n const { highlightedX } = interactions.get();\n if (highlightedX) {\n const currentXIndex = highlightedX[0].index.x;\n const nextXIndex = circleIndex(currentXIndex + direction, [0, interactions.plot.xy.length - 1]);\n interactions.highlightX(interactions.plot.xy[nextXIndex]);\n }\n }\n };\n\n // A helper function to highlight the next or previous point within selected series.\n const moveWithinSeries = (direction: -1 | 1) => {\n // Can only use motion when a particular point is highlighted.\n const point = interactions.get().highlightedPoint;\n if (!point) {\n return;\n }\n\n // Take the index of the currently highlighted series.\n const sIndex = point.index.s;\n // Take the incremented(circularly) x-index of the currently highlighted point.\n const xIndex = circleIndex(point.index.x + direction, [0, interactions.plot.xs.length - 1]);\n // Highlight the next point using x:s grouped data.\n interactions.highlightPoint(interactions.plot.xs[xIndex][sIndex]);\n };\n\n // A helper function to highlight the next or previous point within the selected column.\n const moveBetweenSeries = (direction: -1 | 1) => {\n const point = interactions.get().highlightedPoint;\n if (!point) {\n const { highlightedX } = interactions.get();\n if (highlightedX) {\n const xIndex = highlightedX[0].index.x;\n const points = interactions.plot.xy[xIndex];\n const yIndex = direction === 1 ? 0 : points.length - 1;\n interactions.highlightPoint(points[yIndex]);\n }\n return;\n }\n\n // Take the index of the currently highlighted column.\n const xIndex = point.index.x;\n const currentYIndex = point.index.y;\n\n if (\n containsMultipleSeries &&\n ((currentYIndex === 0 && direction === -1) ||\n (currentYIndex === interactions.plot.xy[xIndex].length - 1 && direction === 1))\n ) {\n interactions.highlightX(interactions.plot.xy[xIndex]);\n } else {\n // Take the incremented(circularly) y-index of the currently highlighted point.\n const nextYIndex = circleIndex(currentYIndex + direction, [0, interactions.plot.xy[xIndex].length - 1]);\n // Highlight the next point using x:y grouped data.\n interactions.highlightPoint(interactions.plot.xy[xIndex][nextYIndex]);\n }\n };\n\n // A callback for svg keydown to enable motions and popover pin with the keyboard.\n const onSVGKeyDown = (event: React.KeyboardEvent<HTMLElement | SVGElement>) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.up &&\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.down &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.space &&\n keyCode !== KeyCode.enter\n ) {\n return;\n }\n\n // Preventing default fixes an issue in Safari+VO when VO additionally interprets arrow keys as its commands.\n event.preventDefault();\n\n // No keydown logic when the popover is pinned.\n if (interactions.get().isPopoverPinned) {\n return;\n }\n\n handleKey(event, {\n onBlockEnd: () => moveBetweenSeries(-1),\n onBlockStart: () => moveBetweenSeries(1),\n onInlineStart: () => moveWithinXAxis(-1),\n onInlineEnd: () => moveWithinXAxis(1),\n onActivate: () => interactions.pinPopover(),\n });\n };\n\n const highlightFirstX = () => {\n interactions.highlightX(interactions.plot.xy[0]);\n };\n\n // A callback for application focus to highlight series.\n const onApplicationFocus = (_event: React.FocusEvent, trigger: 'mouse' | 'keyboard') => {\n // When focus is caused by a click event nothing is expected as clicks are handled separately.\n if (trigger === 'keyboard') {\n const { highlightedX, highlightedPoint, highlightedSeries, legendSeries } = interactions.get();\n if (containsMultipleSeries && !highlightedX && !highlightedPoint && !highlightedSeries && !legendSeries) {\n highlightFirstX();\n } else if (!highlightedX) {\n interactions.highlightFirstPoint();\n }\n }\n };\n\n // A callback for application blur to clear all highlights unless the popover is pinned.\n const onApplicationBlur = (event: React.FocusEvent<Element>) => {\n // Pinned popover stays pinned even if the focus is lost.\n // If blur is not caused by the popover, forget the previously highlighted point.\n if (!nodeBelongs(containerRef.current, event.relatedTarget) && !interactions.get().isPopoverPinned) {\n interactions.clearHighlight();\n }\n };\n\n const onFilterSeries = (series: readonly AreaChartProps.Series<T>[]) => {\n stableSetVisibleSeries(series);\n };\n\n const onLegendHighlight = (series: null | AreaChartProps.Series<T>) => {\n interactions.highlightSeries(series);\n };\n\n const onPopoverDismiss = (outsideClick?: boolean) => {\n interactions.unpinPopover();\n\n // Return focus back to the application or plot (when no point is highlighted).\n if (!outsideClick) {\n // The delay is needed to bypass focus events caused by click or keypress needed to unpin the popover.\n setTimeout(() => {\n if (interactions.get().highlightedPoint || interactions.get().highlightedX) {\n plotRef.current!.focusApplication();\n } else {\n interactions.clearHighlight();\n plotRef.current!.focusPlot();\n }\n }, 0);\n }\n };\n\n const onContainerBlur = () => {\n interactions.clearState();\n };\n\n const onDocumentKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n interactions.clearHighlight();\n interactions.clearHighlightedLegend();\n }\n };\n\n const onPopoverLeave = (event: MouseEvent) => {\n if (nodeContains(plotRef.current!.svg, event.relatedTarget as Element) || interactions.get().isPopoverPinned) {\n return;\n }\n interactions.clearHighlight();\n interactions.clearHighlightedLegend();\n };\n return {\n width,\n height,\n series,\n allSeries,\n getInternalSeries,\n computed,\n interactions,\n handlers: {\n onSVGMouseMove,\n onSVGMouseOut,\n onSVGMouseDown,\n onSVGKeyDown,\n onApplicationFocus,\n onApplicationBlur,\n onFilterSeries,\n onLegendHighlight,\n onPopoverDismiss,\n onContainerBlur,\n onDocumentKeyDown,\n onPopoverLeave,\n },\n refs: {\n plot: plotRef,\n plotMeasure: plotMeasureRef,\n container: containerRef,\n verticalMarker: verticalMarkerRef,\n popoverRef,\n },\n };\n }, [\n allSeries,\n series,\n xDomain,\n yDomain,\n xScaleType,\n yScaleType,\n height,\n width,\n stableSetVisibleSeries,\n popoverRef,\n isRtl,\n ]);\n\n // Notify client when series highlight change.\n useReaction(model.interactions, state => state.highlightedSeries, setHighlightedSeries);\n\n // Update interactions store when series highlight in a controlled way.\n useEffect(() => {\n if (highlightedSeries !== model.interactions.get().highlightedSeries) {\n model.interactions.highlightSeries(highlightedSeries);\n }\n }, [model, highlightedSeries]);\n\n return model;\n}\n"]}
|
|
@@ -10,6 +10,5 @@ export declare function computePlotPoints<T>(series: readonly AreaChartProps.Ser
|
|
|
10
10
|
sx: ChartModel.PlotPoint<T>[][];
|
|
11
11
|
};
|
|
12
12
|
export declare function findClosest<T>(sortedArray: readonly T[], target: number, getter: (item: T) => number): T;
|
|
13
|
-
export declare function circleIndex(index: number, [from, to]: [number, number]): number;
|
|
14
13
|
export declare function isSeriesValid<T>(series: readonly AreaChartProps.Series<T>[]): boolean;
|
|
15
14
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/area-chart/model/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sDAAsD,CAAC;AACpH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAQrC,wBAAgB,cAAc,CAAC,CAAC,SAAS,cAAc,EAAE,MAAM,EAAE,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAkBhH;AAGD,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,CA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GAAG,OAAO,CAqC7G;AAID,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,MAAM,EAAE,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAC3C,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,iBAAiB,GACxB;IACD,EAAE,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAChC,EAAE,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAChC,EAAE,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;CACjC,CA6DA;AAGD,wBAAgB,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,CAsBxG;AAGD,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAc3E"}
|
|
@@ -131,16 +131,6 @@ export function findClosest(sortedArray, target, getter) {
|
|
|
131
131
|
}
|
|
132
132
|
return delta(sortedArray[lo]) < delta(sortedArray[hi]) ? sortedArray[lo] : sortedArray[hi];
|
|
133
133
|
}
|
|
134
|
-
// Returns given index if it is in range or the opposite range boundary otherwise.
|
|
135
|
-
export function circleIndex(index, [from, to]) {
|
|
136
|
-
if (index < from) {
|
|
137
|
-
return to;
|
|
138
|
-
}
|
|
139
|
-
if (index > to) {
|
|
140
|
-
return from;
|
|
141
|
-
}
|
|
142
|
-
return index;
|
|
143
|
-
}
|
|
144
134
|
// Compares all x-values between series to ensure they are consistent.
|
|
145
135
|
export function isSeriesValid(series) {
|
|
146
136
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/area-chart/model/utils.ts"],"names":[],"m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AAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnG,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE;QACpB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAQ,CAAC,CAAC;QAEzC,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,EAAE,CAAC,CAAC;SAC3D;KACF;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,oDAAoD;AACpD,SAAS,gBAAgB,CAAI,MAAa,EAAE,GAAW,EAAE,GAAW,EAAE,KAAQ;IAC5E,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QAChB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;IACD,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC3B,CAAC;AAED,kEAAkE;AAClE,SAAS,IAAI,CAAI,GAAiB;IAChC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACtB,MAAM,SAAS,GAAQ,EAAE,CAAC;IAE1B,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE;QACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACnB,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACf,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACvB;KACF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AreaChartProps } from '../interfaces';\nimport { ChartScale, NumericChartScale } from '../../internal/components/cartesian-chart/scales';\nimport { ChartDataTypes, XDomain, YDomain, YScaleType } from '../../internal/components/cartesian-chart/interfaces';\nimport { ChartModel } from './index';\n\n// A sufficiently small value.\n// The Number.EPSILON is not available in the target ECMA version.\n// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON\nconst EPSILON = 0.0000000000001;\n\n// When x-domain is not set explicitly - guess it based on the available data.\nexport function computeDomainX<T extends ChartDataTypes>(series: readonly AreaChartProps.Series<T>[]): XDomain<T> {\n const xValues = getXValues(series);\n\n if (xValues.length === 0) {\n return [] as unknown as XDomain<T>;\n }\n\n // Assuming categorical domain.\n // In that case, all values are to be included.\n if (typeof xValues[0] === 'string') {\n return uniq(xValues) as unknown as XDomain<T>;\n }\n\n // For non-categorical domain find min and max bounds.\n return xValues.reduce(\n ([min, max], x) => [x < min ? x : min, max < x ? x : max],\n [xValues[0], xValues[0]]\n ) as unknown as XDomain<T>;\n}\n\n// When y-domain is not set explicitly - guess it based on the available data and series.\nexport function computeDomainY<T>(series: readonly AreaChartProps.Series<T>[], scaleType: YScaleType): YDomain {\n let min = Number.POSITIVE_INFINITY;\n let max = Number.NEGATIVE_INFINITY;\n\n // Find the min and max for threshold series.\n series.forEach(s => {\n if (s.type === 'threshold') {\n min = Math.min(min, s.y);\n max = Math.max(max, s.y);\n }\n });\n\n // Find the min and max for area series considering their stacking.\n getXValues(series).forEach((_, xIndex) => {\n // Maintains the prev stack level.\n let stackY = scaleType === 'linear' ? 0 : EPSILON;\n\n for (const s of series) {\n if (s.type === 'area') {\n stackY = stackY + (s.data[xIndex]?.y || 0);\n min = Math.min(min, stackY);\n max = Math.max(max, stackY);\n }\n }\n });\n\n // If min/max is not overridden than either series or series data is empty.\n if (min === Number.POSITIVE_INFINITY) {\n return [];\n }\n\n // Log scales can't start from 0, so, if possible, start from 1.\n if (scaleType === 'log' && min === 0 && max > 1) {\n return [1, max];\n }\n\n return [min, max];\n}\n\n// For given data, series and scales, compute all points and group them as\n// x:y, x:series and series:x to allow constant time access to the required point or subset.\nexport function computePlotPoints<T>(\n series: readonly AreaChartProps.Series<T>[],\n xScale: ChartScale,\n yScale: NumericChartScale\n): {\n xy: ChartModel.PlotPoint<T>[][];\n xs: ChartModel.PlotPoint<T>[][];\n sx: ChartModel.PlotPoint<T>[][];\n} {\n const xValues = getXValues(series);\n\n // Lookup for xy[xIndex][yIndex]\n const xy: ChartModel.PlotPoint<T>[][] = [];\n // Lookup for xs[xIndex][seriesIndex]\n const xs: ChartModel.PlotPoint<T>[][] = [];\n // Lookup for sx[seriesIndex][xIndex]\n const sx: ChartModel.PlotPoint<T>[][] = [];\n\n // Filter out the data which is beyond the plot for whatever reason.\n getVisibleData(xValues, xScale).forEach(({ x, scaledX }, xIndex) => {\n // Maintains the prev stack level. Starting from epsilon to not break log scales.\n let stackY = yScale.scaleType === 'linear' ? 0 : EPSILON;\n\n // A column of series points related to the same x.\n const points: ChartModel.PlotPoint<T>[] = [];\n\n // Collect the points, leaving y-index as 0 for now.\n series.forEach((s, sIndex) => {\n if (s.type === 'threshold') {\n const scaledY = yScale.d3Scale(s.y) || 0;\n points.push({\n x: x,\n y0: s.y,\n y1: s.y,\n scaled: { x: scaledX, y0: scaledY, y1: scaledY },\n index: { x: xIndex, s: sIndex, y: 0 },\n value: 0,\n });\n } else {\n const value = s.data[xIndex]?.y || 0;\n const y0 = stackY;\n const y1 = stackY + value;\n points.push({\n x: x,\n y0: y0,\n y1: y1,\n scaled: { x: scaledX, y0: yScale.d3Scale(y0) || 0, y1: yScale.d3Scale(y1) || 0 },\n index: { x: xIndex, s: sIndex, y: 0 },\n value: value,\n });\n\n stackY = y1;\n }\n });\n\n // Sort points by y and insert the missing y-index.\n points\n .sort((p1, p2) => p1.y1 - p2.y1)\n .forEach((point, index) => {\n point.index.y = index;\n\n // Insert the points to the respective two-dimensional lookup arrays.\n insertIntoMatrix(xy, point.index.x, point.index.y, point);\n insertIntoMatrix(xs, point.index.x, point.index.s, point);\n insertIntoMatrix(sx, point.index.s, point.index.x, point);\n });\n });\n\n return { xy, xs, sx };\n}\n\n// Finds the closest point in the sorted array.\nexport function findClosest<T>(sortedArray: readonly T[], target: number, getter: (item: T) => number): T {\n // The method guarantees to return a point hence empty arrays are not allowed.\n if (sortedArray.length === 0) {\n throw new Error('Invariant violation: array is empty.');\n }\n\n const isAscending = getter(sortedArray[0]) < getter(sortedArray[sortedArray.length - 1]);\n const compare = (x: T) => (isAscending ? getter(x) < target : getter(x) > target);\n const delta = (x: T) => Math.abs(getter(x) - target);\n\n // Use binary search to find the closest value in a sorted array.\n let lo = 0;\n let hi = sortedArray.length - 1;\n while (hi - lo > 1) {\n const mid = Math.floor((lo + hi) / 2);\n if (compare(sortedArray[mid])) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n return delta(sortedArray[lo]) < delta(sortedArray[hi]) ? sortedArray[lo] : sortedArray[hi];\n}\n\n// Returns given index if it is in range or the opposite range boundary otherwise.\nexport function circleIndex(index: number, [from, to]: [number, number]): number {\n if (index < from) {\n return to;\n }\n if (index > to) {\n return from;\n }\n return index;\n}\n\n// Compares all x-values between series to ensure they are consistent.\nexport function isSeriesValid<T>(series: readonly AreaChartProps.Series<T>[]) {\n const sampleXValues = getXValues(series);\n\n for (const s of series) {\n if (s.type === 'area') {\n for (let i = 0; i < Math.max(s.data.length, sampleXValues.length); i++) {\n if (s.data[i]?.x !== sampleXValues[i]) {\n return false;\n }\n }\n }\n }\n\n return true;\n}\n\n// Takes first area series x-values as all data x-values are to match across series.\nfunction getXValues<T>(series: readonly AreaChartProps.Series<T>[]) {\n for (const s of series) {\n if (s.type === 'area') {\n return s.data.map(({ x }) => x);\n }\n }\n\n return [];\n}\n\n// Returns data that is visible in the given scale.\nfunction getVisibleData<T>(data: readonly T[], xScale: ChartScale) {\n const scaledOffsetX = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;\n\n const visibleData = [];\n for (const x of data) {\n const scaledX = xScale.d3Scale(x as any);\n\n if (scaledX !== undefined) {\n visibleData.push({ x, scaledX: scaledX + scaledOffsetX });\n }\n }\n return visibleData;\n}\n\n// Inserts given value into a two-dimensional array.\nfunction insertIntoMatrix<T>(matrix: T[][], row: number, col: number, value: T) {\n if (!matrix[row]) {\n matrix[row] = [];\n }\n matrix[row][col] = value;\n}\n\n// Creates new array with only unique elements of the given array.\nfunction uniq<T>(arr: readonly T[]): readonly T[] {\n const set = new Set();\n const uniqArray: T[] = [];\n\n for (const value of arr) {\n if (!set.has(value)) {\n set.add(value);\n uniqArray.push(value);\n }\n }\n\n return uniqArray;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/area-chart/model/utils.ts"],"names":[],"mappings":"AAOA,8BAA8B;AAC9B,kEAAkE;AAClE,sGAAsG;AACtG,MAAM,OAAO,GAAG,eAAe,CAAC;AAEhC,8EAA8E;AAC9E,MAAM,UAAU,cAAc,CAA2B,MAA2C;IAClG,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAEnC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,EAA2B,CAAC;KACpC;IAED,+BAA+B;IAC/B,+CAA+C;IAC/C,IAAI,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QAClC,OAAO,IAAI,CAAC,OAAO,CAA0B,CAAC;KAC/C;IAED,sDAAsD;IACtD,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EACzD,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CACA,CAAC;AAC7B,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,cAAc,CAAI,MAA2C,EAAE,SAAqB;IAClG,IAAI,GAAG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C,aAAa,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnG,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE;QACpB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAQ,CAAC,CAAC;QAEzC,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,EAAE,CAAC,CAAC;SAC3D;KACF;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,oDAAoD;AACpD,SAAS,gBAAgB,CAAI,MAAa,EAAE,GAAW,EAAE,GAAW,EAAE,KAAQ;IAC5E,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QAChB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;IACD,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC3B,CAAC;AAED,kEAAkE;AAClE,SAAS,IAAI,CAAI,GAAiB;IAChC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACtB,MAAM,SAAS,GAAQ,EAAE,CAAC;IAE1B,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE;QACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACnB,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACf,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACvB;KACF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AreaChartProps } from '../interfaces';\nimport { ChartScale, NumericChartScale } from '../../internal/components/cartesian-chart/scales';\nimport { ChartDataTypes, XDomain, YDomain, YScaleType } from '../../internal/components/cartesian-chart/interfaces';\nimport { ChartModel } from './index';\n\n// A sufficiently small value.\n// The Number.EPSILON is not available in the target ECMA version.\n// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON\nconst EPSILON = 0.0000000000001;\n\n// When x-domain is not set explicitly - guess it based on the available data.\nexport function computeDomainX<T extends ChartDataTypes>(series: readonly AreaChartProps.Series<T>[]): XDomain<T> {\n const xValues = getXValues(series);\n\n if (xValues.length === 0) {\n return [] as unknown as XDomain<T>;\n }\n\n // Assuming categorical domain.\n // In that case, all values are to be included.\n if (typeof xValues[0] === 'string') {\n return uniq(xValues) as unknown as XDomain<T>;\n }\n\n // For non-categorical domain find min and max bounds.\n return xValues.reduce(\n ([min, max], x) => [x < min ? x : min, max < x ? x : max],\n [xValues[0], xValues[0]]\n ) as unknown as XDomain<T>;\n}\n\n// When y-domain is not set explicitly - guess it based on the available data and series.\nexport function computeDomainY<T>(series: readonly AreaChartProps.Series<T>[], scaleType: YScaleType): YDomain {\n let min = Number.POSITIVE_INFINITY;\n let max = Number.NEGATIVE_INFINITY;\n\n // Find the min and max for threshold series.\n series.forEach(s => {\n if (s.type === 'threshold') {\n min = Math.min(min, s.y);\n max = Math.max(max, s.y);\n }\n });\n\n // Find the min and max for area series considering their stacking.\n getXValues(series).forEach((_, xIndex) => {\n // Maintains the prev stack level.\n let stackY = scaleType === 'linear' ? 0 : EPSILON;\n\n for (const s of series) {\n if (s.type === 'area') {\n stackY = stackY + (s.data[xIndex]?.y || 0);\n min = Math.min(min, stackY);\n max = Math.max(max, stackY);\n }\n }\n });\n\n // If min/max is not overridden than either series or series data is empty.\n if (min === Number.POSITIVE_INFINITY) {\n return [];\n }\n\n // Log scales can't start from 0, so, if possible, start from 1.\n if (scaleType === 'log' && min === 0 && max > 1) {\n return [1, max];\n }\n\n return [min, max];\n}\n\n// For given data, series and scales, compute all points and group them as\n// x:y, x:series and series:x to allow constant time access to the required point or subset.\nexport function computePlotPoints<T>(\n series: readonly AreaChartProps.Series<T>[],\n xScale: ChartScale,\n yScale: NumericChartScale\n): {\n xy: ChartModel.PlotPoint<T>[][];\n xs: ChartModel.PlotPoint<T>[][];\n sx: ChartModel.PlotPoint<T>[][];\n} {\n const xValues = getXValues(series);\n\n // Lookup for xy[xIndex][yIndex]\n const xy: ChartModel.PlotPoint<T>[][] = [];\n // Lookup for xs[xIndex][seriesIndex]\n const xs: ChartModel.PlotPoint<T>[][] = [];\n // Lookup for sx[seriesIndex][xIndex]\n const sx: ChartModel.PlotPoint<T>[][] = [];\n\n // Filter out the data which is beyond the plot for whatever reason.\n getVisibleData(xValues, xScale).forEach(({ x, scaledX }, xIndex) => {\n // Maintains the prev stack level. Starting from epsilon to not break log scales.\n let stackY = yScale.scaleType === 'linear' ? 0 : EPSILON;\n\n // A column of series points related to the same x.\n const points: ChartModel.PlotPoint<T>[] = [];\n\n // Collect the points, leaving y-index as 0 for now.\n series.forEach((s, sIndex) => {\n if (s.type === 'threshold') {\n const scaledY = yScale.d3Scale(s.y) || 0;\n points.push({\n x: x,\n y0: s.y,\n y1: s.y,\n scaled: { x: scaledX, y0: scaledY, y1: scaledY },\n index: { x: xIndex, s: sIndex, y: 0 },\n value: 0,\n });\n } else {\n const value = s.data[xIndex]?.y || 0;\n const y0 = stackY;\n const y1 = stackY + value;\n points.push({\n x: x,\n y0: y0,\n y1: y1,\n scaled: { x: scaledX, y0: yScale.d3Scale(y0) || 0, y1: yScale.d3Scale(y1) || 0 },\n index: { x: xIndex, s: sIndex, y: 0 },\n value: value,\n });\n\n stackY = y1;\n }\n });\n\n // Sort points by y and insert the missing y-index.\n points\n .sort((p1, p2) => p1.y1 - p2.y1)\n .forEach((point, index) => {\n point.index.y = index;\n\n // Insert the points to the respective two-dimensional lookup arrays.\n insertIntoMatrix(xy, point.index.x, point.index.y, point);\n insertIntoMatrix(xs, point.index.x, point.index.s, point);\n insertIntoMatrix(sx, point.index.s, point.index.x, point);\n });\n });\n\n return { xy, xs, sx };\n}\n\n// Finds the closest point in the sorted array.\nexport function findClosest<T>(sortedArray: readonly T[], target: number, getter: (item: T) => number): T {\n // The method guarantees to return a point hence empty arrays are not allowed.\n if (sortedArray.length === 0) {\n throw new Error('Invariant violation: array is empty.');\n }\n\n const isAscending = getter(sortedArray[0]) < getter(sortedArray[sortedArray.length - 1]);\n const compare = (x: T) => (isAscending ? getter(x) < target : getter(x) > target);\n const delta = (x: T) => Math.abs(getter(x) - target);\n\n // Use binary search to find the closest value in a sorted array.\n let lo = 0;\n let hi = sortedArray.length - 1;\n while (hi - lo > 1) {\n const mid = Math.floor((lo + hi) / 2);\n if (compare(sortedArray[mid])) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n return delta(sortedArray[lo]) < delta(sortedArray[hi]) ? sortedArray[lo] : sortedArray[hi];\n}\n\n// Compares all x-values between series to ensure they are consistent.\nexport function isSeriesValid<T>(series: readonly AreaChartProps.Series<T>[]) {\n const sampleXValues = getXValues(series);\n\n for (const s of series) {\n if (s.type === 'area') {\n for (let i = 0; i < Math.max(s.data.length, sampleXValues.length); i++) {\n if (s.data[i]?.x !== sampleXValues[i]) {\n return false;\n }\n }\n }\n }\n\n return true;\n}\n\n// Takes first area series x-values as all data x-values are to match across series.\nfunction getXValues<T>(series: readonly AreaChartProps.Series<T>[]) {\n for (const s of series) {\n if (s.type === 'area') {\n return s.data.map(({ x }) => x);\n }\n }\n\n return [];\n}\n\n// Returns data that is visible in the given scale.\nfunction getVisibleData<T>(data: readonly T[], xScale: ChartScale) {\n const scaledOffsetX = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;\n\n const visibleData = [];\n for (const x of data) {\n const scaledX = xScale.d3Scale(x as any);\n\n if (scaledX !== undefined) {\n visibleData.push({ x, scaledX: scaledX + scaledOffsetX });\n }\n }\n return visibleData;\n}\n\n// Inserts given value into a two-dimensional array.\nfunction insertIntoMatrix<T>(matrix: T[][], row: number, col: number, value: T) {\n if (!matrix[row]) {\n matrix[row] = [];\n }\n matrix[row][col] = value;\n}\n\n// Creates new array with only unique elements of the given array.\nfunction uniq<T>(arr: readonly T[]): readonly T[] {\n const set = new Set();\n const uniqArray: T[] = [];\n\n for (const value of arr) {\n if (!set.has(value)) {\n set.add(value);\n uniqArray.push(value);\n }\n }\n\n return uniqArray;\n}\n"]}
|
package/button/interfaces.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface ButtonProps extends BaseComponentProps {
|
|
|
10
10
|
/**
|
|
11
11
|
* Provides a reason why the button is disabled (only when `disabled` is `true`).
|
|
12
12
|
* If provided, the button becomes focusable.
|
|
13
|
-
* Applicable for all button variants, except link.
|
|
13
|
+
* Applicable for all button variants, except link and icon.
|
|
14
14
|
*/
|
|
15
15
|
disabledReason?: string;
|
|
16
16
|
/**
|
package/button/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/button/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { IconProps } from '../icon/interfaces';\nimport React from 'react';\nimport { BaseNavigationDetail, CancelableEventHandler, ClickDetail as _ClickDetail } from '../internal/events';\n\nexport interface ButtonProps extends BaseComponentProps {\n /**\n * Renders the button as disabled and prevents clicks.\n */\n disabled?: boolean;\n /**\n * Provides a reason why the button is disabled (only when `disabled` is `true`).\n * If provided, the button becomes focusable.\n * Applicable for all button variants, except link.\n */\n disabledReason?: string;\n /**\n * Renders the button as being in a loading state. It takes precedence over the `disabled` if both are set to `true`.\n * It prevents users from clicking the button, but it can still be focused.\n */\n loading?: boolean;\n /**\n * Specifies the text that screen reader announces when the button is in a loading state.\n */\n loadingText?: string;\n /**\n * Displays an icon next to the text. You can use the `iconAlign` property to position the icon.\n */\n iconName?: IconProps.Name;\n /**\n * Specifies the alignment of the icon.\n */\n iconAlign?: ButtonProps.IconAlign;\n /**\n * Specifies the URL of a custom icon. Use this property if the icon you want isn't available.\n *\n * If you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n */\n iconUrl?: string;\n /**\n * Specifies the SVG of a custom icon.\n *\n * Use this property if you want your custom icon to inherit colors dictated by variant or hover states.\n * When this property is set, the component will be decorated with `aria-hidden=\"true\"`. Ensure that the `svg` element:\n * - has attribute `focusable=\"false\"`.\n * - has `viewBox=\"0 0 16 16\"`.\n *\n * If you set the `svg` element as the root node of the slot, the component will automatically\n * - set `stroke=\"currentColor\"`, `fill=\"none\"`, and `vertical-align=\"top\"`.\n * - set the stroke width based on the size of the icon.\n * - set the width and height of the SVG element based on the size of the icon.\n *\n * If you don't want these styles to be automatically set, wrap the `svg` element into a `span`.\n * You can still set the stroke to `currentColor` to inherit the color of the surrounding elements.\n *\n * If you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n *\n * *Note:* Remember to remove any additional elements (for example: `defs`) and related CSS classes from SVG files exported from design software.\n * In most cases, they aren't needed, as the `svg` element inherits styles from the icon component.\n */\n iconSvg?: React.ReactNode;\n /**\n * Specifies alternate text for a custom icon. We recommend that you provide this for accessibility.\n * This property is ignored if you use a predefined icon or if you set your custom icon using the `iconSvg` slot.\n */\n iconAlt?: string;\n /**\n * The form action that is performed by a button click.\n */\n formAction?: ButtonProps.FormAction;\n\n /**\n * Adds `aria-label` to the button element. Use this to provide an accessible name for buttons\n * that don't have visible text, and to distinguish between multiple buttons with identical visible text.\n * The text will also be added to the `title` attribute of the button.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-describedby` to the button.\n */\n ariaDescribedby?: string;\n\n /**\n * Applies button styling to a link. Use this property if you need a link styled as a button (`variant=link`).\n * For example, if you have a 'help' button that links to a documentation page.\n */\n href?: string;\n\n /**\n * Specifies where to open the linked URL (for example, to open in a new browser window or tab use `_blank`).\n * This property only applies when an `href` is provided.\n */\n target?: string;\n\n /**\n * Adds a `rel` attribute to the link. By default, the component sets the `rel` attribute to \"noopener noreferrer\" when `target` is `\"_blank\"`.\n * If the `rel` property is provided, it overrides the default behavior.\n */\n rel?: string;\n\n /**\n * Specifies whether the linked URL, when selected, will prompt the user to download instead of navigate.\n * You can specify a string value that will be suggested as the name of the downloaded file.\n * This property only applies when an `href` is provided.\n **/\n download?: boolean | string;\n\n /**\n * Specifies if the `text` content wraps. If you set it to `false`, it prevents the text from wrapping.\n */\n wrapText?: boolean;\n\n /** Determines the general styling of the button as follows:\n * * `primary` for primary buttons.\n * * `normal` for secondary buttons.\n * * `link` for tertiary buttons.\n * * `icon` to display an icon only (no text).\n * * `inline-icon` to display an icon-only (no text) button within a text context.\n * * `inline-link` to display a tertiary button with no outer padding.\n */\n variant?: ButtonProps.Variant;\n\n /** The id of the <form> element to associate with the button. The value of this attribute must be the id of a <form> in the same document.\n * Use when a button is not the ancestor of a form element, such as when used in a modal.\n */\n form?: string;\n\n /**\n * Text displayed in the button element.\n * @displayname text\n */\n children?: React.ReactNode;\n\n /**\n * Called when the user clicks on the button and the button is not disabled or in loading state.\n */\n onClick?: CancelableEventHandler<ButtonProps.ClickDetail>;\n\n /**\n * Called when the user clicks on the button with the left mouse button without pressing\n * modifier keys (that is, CTRL, ALT, SHIFT, META), and the button has an `href` set.\n */\n onFollow?: CancelableEventHandler<ButtonProps.FollowDetail>;\n\n /**\n * Adds aria-expanded to the button element. Use when the button controls an expandable element.\n */\n ariaExpanded?: boolean;\n\n /**\n * Adds `aria-controls` to the button. Use when the button controls the contents or presence of an element.\n */\n ariaControls?: string;\n\n /**\n * Sets the button width to be 100% of the parent container width. Button content is centered.\n */\n fullWidth?: boolean;\n}\n\nexport namespace ButtonProps {\n export type Variant = 'normal' | 'primary' | 'link' | 'icon' | 'inline-icon' | 'inline-link';\n export type ClickDetail = _ClickDetail;\n export type FollowDetail = BaseNavigationDetail;\n\n export type FormAction = 'submit' | 'none';\n\n export type IconAlign = 'left' | 'right';\n\n export interface Ref {\n /**\n * Focuses the underlying native button.\n */\n focus(options?: FocusOptions): void;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/button/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { IconProps } from '../icon/interfaces';\nimport React from 'react';\nimport { BaseNavigationDetail, CancelableEventHandler, ClickDetail as _ClickDetail } from '../internal/events';\n\nexport interface ButtonProps extends BaseComponentProps {\n /**\n * Renders the button as disabled and prevents clicks.\n */\n disabled?: boolean;\n /**\n * Provides a reason why the button is disabled (only when `disabled` is `true`).\n * If provided, the button becomes focusable.\n * Applicable for all button variants, except link and icon.\n */\n disabledReason?: string;\n /**\n * Renders the button as being in a loading state. It takes precedence over the `disabled` if both are set to `true`.\n * It prevents users from clicking the button, but it can still be focused.\n */\n loading?: boolean;\n /**\n * Specifies the text that screen reader announces when the button is in a loading state.\n */\n loadingText?: string;\n /**\n * Displays an icon next to the text. You can use the `iconAlign` property to position the icon.\n */\n iconName?: IconProps.Name;\n /**\n * Specifies the alignment of the icon.\n */\n iconAlign?: ButtonProps.IconAlign;\n /**\n * Specifies the URL of a custom icon. Use this property if the icon you want isn't available.\n *\n * If you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n */\n iconUrl?: string;\n /**\n * Specifies the SVG of a custom icon.\n *\n * Use this property if you want your custom icon to inherit colors dictated by variant or hover states.\n * When this property is set, the component will be decorated with `aria-hidden=\"true\"`. Ensure that the `svg` element:\n * - has attribute `focusable=\"false\"`.\n * - has `viewBox=\"0 0 16 16\"`.\n *\n * If you set the `svg` element as the root node of the slot, the component will automatically\n * - set `stroke=\"currentColor\"`, `fill=\"none\"`, and `vertical-align=\"top\"`.\n * - set the stroke width based on the size of the icon.\n * - set the width and height of the SVG element based on the size of the icon.\n *\n * If you don't want these styles to be automatically set, wrap the `svg` element into a `span`.\n * You can still set the stroke to `currentColor` to inherit the color of the surrounding elements.\n *\n * If you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n *\n * *Note:* Remember to remove any additional elements (for example: `defs`) and related CSS classes from SVG files exported from design software.\n * In most cases, they aren't needed, as the `svg` element inherits styles from the icon component.\n */\n iconSvg?: React.ReactNode;\n /**\n * Specifies alternate text for a custom icon. We recommend that you provide this for accessibility.\n * This property is ignored if you use a predefined icon or if you set your custom icon using the `iconSvg` slot.\n */\n iconAlt?: string;\n /**\n * The form action that is performed by a button click.\n */\n formAction?: ButtonProps.FormAction;\n\n /**\n * Adds `aria-label` to the button element. Use this to provide an accessible name for buttons\n * that don't have visible text, and to distinguish between multiple buttons with identical visible text.\n * The text will also be added to the `title` attribute of the button.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-describedby` to the button.\n */\n ariaDescribedby?: string;\n\n /**\n * Applies button styling to a link. Use this property if you need a link styled as a button (`variant=link`).\n * For example, if you have a 'help' button that links to a documentation page.\n */\n href?: string;\n\n /**\n * Specifies where to open the linked URL (for example, to open in a new browser window or tab use `_blank`).\n * This property only applies when an `href` is provided.\n */\n target?: string;\n\n /**\n * Adds a `rel` attribute to the link. By default, the component sets the `rel` attribute to \"noopener noreferrer\" when `target` is `\"_blank\"`.\n * If the `rel` property is provided, it overrides the default behavior.\n */\n rel?: string;\n\n /**\n * Specifies whether the linked URL, when selected, will prompt the user to download instead of navigate.\n * You can specify a string value that will be suggested as the name of the downloaded file.\n * This property only applies when an `href` is provided.\n **/\n download?: boolean | string;\n\n /**\n * Specifies if the `text` content wraps. If you set it to `false`, it prevents the text from wrapping.\n */\n wrapText?: boolean;\n\n /** Determines the general styling of the button as follows:\n * * `primary` for primary buttons.\n * * `normal` for secondary buttons.\n * * `link` for tertiary buttons.\n * * `icon` to display an icon only (no text).\n * * `inline-icon` to display an icon-only (no text) button within a text context.\n * * `inline-link` to display a tertiary button with no outer padding.\n */\n variant?: ButtonProps.Variant;\n\n /** The id of the <form> element to associate with the button. The value of this attribute must be the id of a <form> in the same document.\n * Use when a button is not the ancestor of a form element, such as when used in a modal.\n */\n form?: string;\n\n /**\n * Text displayed in the button element.\n * @displayname text\n */\n children?: React.ReactNode;\n\n /**\n * Called when the user clicks on the button and the button is not disabled or in loading state.\n */\n onClick?: CancelableEventHandler<ButtonProps.ClickDetail>;\n\n /**\n * Called when the user clicks on the button with the left mouse button without pressing\n * modifier keys (that is, CTRL, ALT, SHIFT, META), and the button has an `href` set.\n */\n onFollow?: CancelableEventHandler<ButtonProps.FollowDetail>;\n\n /**\n * Adds aria-expanded to the button element. Use when the button controls an expandable element.\n */\n ariaExpanded?: boolean;\n\n /**\n * Adds `aria-controls` to the button. Use when the button controls the contents or presence of an element.\n */\n ariaControls?: string;\n\n /**\n * Sets the button width to be 100% of the parent container width. Button content is centered.\n */\n fullWidth?: boolean;\n}\n\nexport namespace ButtonProps {\n export type Variant = 'normal' | 'primary' | 'link' | 'icon' | 'inline-icon' | 'inline-link';\n export type ClickDetail = _ClickDetail;\n export type FollowDetail = BaseNavigationDetail;\n\n export type FormAction = 'submit' | 'none';\n\n export type IconAlign = 'left' | 'right';\n\n export interface Ref {\n /**\n * Focuses the underlying native button.\n */\n focus(options?: FocusOptions): void;\n }\n}\n"]}
|
|
@@ -57,7 +57,7 @@ function MenuItem({ item, disabled, highlighted }) {
|
|
|
57
57
|
React.createElement(MenuItemContent, { item: item, disabled: disabled })));
|
|
58
58
|
const { position } = useDropdownContext();
|
|
59
59
|
const tooltipPosition = position === 'bottom-left' || position === 'top-left' ? 'left' : 'right';
|
|
60
|
-
return isDisabledWithReason ? (React.createElement(Tooltip, { content: item.disabledReason, position: tooltipPosition },
|
|
60
|
+
return isDisabledWithReason ? (React.createElement(Tooltip, { content: item.disabledReason, position: tooltipPosition, className: styles['item-tooltip-wrapper'] },
|
|
61
61
|
menuItem,
|
|
62
62
|
descriptionEl)) : (menuItem);
|
|
63
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/button-dropdown/item-element/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,oBAAoB,MAAM,6CAA6C,CAAC;AAC/E,OAAO,YAAmC,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,MAAM,WAAW,GAAG,CAAC,EACnB,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,WAAW,EACX,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,qBAAqB,GAAG,KAAK,EAC7B,OAAO,GAAG,QAAQ,GACR,EAAE,EAAE;IACd,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,CAAC,KAAuB,EAAE,EAAE;QAC1C,qFAAqF;QACrF,kEAAkE;QAClE,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE;YACX,KAAK,CAAC,cAAc,EAAE,CAAC;SACxB;QACD,IAAI,CAAC,QAAQ,EAAE;YACb,cAAc,CAAC,I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ffect, useRef } from 'react';\nimport clsx from 'clsx';\nimport { ItemProps } from '../interfaces';\nimport { isCheckboxItem, isLinkItem } from '../utils/utils';\nimport styles from './styles.css.js';\nimport Tooltip from '../tooltip';\n\nimport { ButtonDropdownProps } from '../interfaces';\nimport { getItemTarget } from '../utils/utils';\nimport useHiddenDescription from '../../internal/hooks/use-hidden-description';\nimport InternalIcon, { InternalIconProps } from '../../icon/internal';\nimport { useDropdownContext } from '../../internal/components/dropdown/context';\nimport { getMenuItemProps, getMenuItemCheckboxProps } from '../utils/menu-item';\n\nconst ItemElement = ({\n item,\n disabled,\n onItemActivate,\n highlighted,\n highlightItem,\n showDivider,\n hasCategoryHeader,\n isKeyboardHighlighted = false,\n variant = 'normal',\n}: ItemProps) => {\n const isLink = isLinkItem(item);\n const isCheckbox = isCheckboxItem(item);\n const onClick = (event: React.MouseEvent) => {\n // Stop propagation to parent node and handle event exclusively in here. This ensures\n // that no group will interfere with the default behavior of links\n event.stopPropagation();\n if (!isLink) {\n event.preventDefault();\n }\n if (!disabled) {\n onItemActivate(item, event);\n }\n };\n\n const onHover = () => {\n highlightItem(item);\n };\n\n return (\n <li\n className={clsx(styles['item-element'], styles[`variant-${variant}`], {\n [styles.highlighted]: highlighted,\n [styles.disabled]: disabled,\n [styles['has-category-header']]: hasCategoryHeader,\n [styles['has-checkmark']]: isCheckbox,\n [styles['show-divider']]: showDivider,\n [styles['is-focused']]: isKeyboardHighlighted,\n })}\n role=\"presentation\"\n data-testid={item.id}\n data-description={item.description}\n onClick={onClick}\n onMouseEnter={onHover}\n onTouchStart={onHover}\n >\n <MenuItem item={item} disabled={disabled} highlighted={highlighted} />\n </li>\n );\n};\n\nexport type InternalItemProps = ButtonDropdownProps.Item & {\n badge?: boolean;\n};\n\nexport type InternalCheckboxItemProps = ButtonDropdownProps.CheckboxItem & {\n badge?: boolean;\n};\n\ninterface MenuItemProps {\n item: InternalItemProps | InternalCheckboxItemProps;\n disabled: boolean;\n highlighted: boolean;\n}\n\nfunction MenuItem({ item, disabled, highlighted }: MenuItemProps) {\n const menuItemRef = useRef<(HTMLSpanElement & HTMLAnchorElement) | null>(null);\n const isCheckbox = isCheckboxItem(item);\n\n useEffect(() => {\n if (highlighted && menuItemRef.current) {\n menuItemRef.current.focus();\n }\n }, [highlighted]);\n\n const isDisabledWithReason = disabled && item.disabledReason;\n const { targetProps, descriptionEl } = useHiddenDescription(item.disabledReason);\n const menuItemProps: React.HTMLAttributes<HTMLSpanElement & HTMLAnchorElement> = {\n className: styles['menu-item'],\n lang: item.lang,\n ref: menuItemRef,\n // We are using the roving tabindex technique to manage the focus state of the dropdown.\n // The current element will always have tabindex=0 which means that it can be tabbed to,\n // while all other items have tabindex=-1 so we can focus them when necessary.\n tabIndex: highlighted ? 0 : -1,\n ...(isCheckbox ? getMenuItemCheckboxProps({ disabled, checked: item.checked }) : getMenuItemProps({ disabled })),\n ...(isDisabledWithReason ? targetProps : {}),\n };\n\n const menuItem = isLinkItem(item) ? (\n <a\n {...menuItemProps}\n href={!disabled ? item.href : undefined}\n target={getItemTarget(item)}\n rel={item.external ? 'noopener noreferrer' : undefined}\n >\n <MenuItemContent item={item} disabled={disabled} />\n </a>\n ) : (\n <span {...menuItemProps}>\n <MenuItemContent item={item} disabled={disabled} />\n </span>\n );\n\n const { position } = useDropdownContext();\n const tooltipPosition = position === 'bottom-left' || position === 'top-left' ? 'left' : 'right';\n return isDisabledWithReason ? (\n <Tooltip content={item.disabledReason} position={tooltipPosition}>\n {menuItem}\n {descriptionEl}\n </Tooltip>\n ) : (\n menuItem\n );\n}\n\nconst MenuItemContent = ({\n item,\n disabled,\n}: {\n item: InternalItemProps | InternalCheckboxItemProps;\n disabled: boolean;\n}) => {\n const hasIcon = !!(item.iconName || item.iconUrl || item.iconSvg);\n const hasExternal = isLinkItem(item) && item.external;\n const isCheckbox = isCheckboxItem(item);\n return (\n <>\n {isCheckbox && <MenuItemCheckmark checked={item.checked} disabled={disabled} />}\n {hasIcon && (\n <MenuItemIcon\n name={item.iconName}\n url={item.iconUrl}\n svg={item.iconSvg}\n alt={item.iconAlt}\n badge={item.badge}\n />\n )}\n {item.text}\n {hasExternal && <ExternalIcon disabled={disabled} ariaLabel={item.externalIconAriaLabel} />}\n </>\n );\n};\n\nconst MenuItemIcon = (props: InternalIconProps) => (\n <span className={styles.icon}>\n <InternalIcon {...props} />\n </span>\n);\n\n// Toggle has aria-hidden set because it's just used as a graphical element,\n// a11y attributes for the checkmark are communicated through the role and aria-checked state\n// of the menu element item.\nconst MenuItemCheckmark = ({ disabled, checked }: { disabled: boolean; checked: boolean }) => {\n const checkmark = <InternalIcon variant={disabled ? 'disabled' : 'normal'} name=\"check\" />;\n return (\n <span\n className={clsx(styles.icon, styles.checkmark, { [styles.disabled]: disabled })}\n aria-hidden=\"true\"\n style={{ visibility: checked ? 'visible' : 'hidden' }}\n >\n {checkmark}\n </span>\n );\n};\n\nconst ExternalIcon = ({ disabled, ariaLabel }: { disabled: boolean; ariaLabel?: string }) => {\n const icon = <InternalIcon variant={disabled ? 'disabled' : 'normal'} name=\"external\" />;\n return (\n <span className={styles['external-icon']} role={ariaLabel ? 'img' : undefined} aria-label={ariaLabel}>\n {icon}\n </span>\n );\n};\n\nexport default ItemElement;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/button-dropdown/item-element/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,oBAAoB,MAAM,6CAA6C,CAAC;AAC/E,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,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,iBACnE,MAAM,EAClB,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,IAEpD,SAAS,CACL,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAA6C,EAAE,EAAE;IAC1F,MAAM,IAAI,GAAG,oBAAC,YAAY,IAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAC,UAAU,GAAG,CAAC;IACzF,OAAO,CACL,8BAAM,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,gBAAc,SAAS,IACjG,IAAI,CACA,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\nimport { ItemProps } from '../interfaces';\nimport { isCheckboxItem, isLinkItem } from '../utils/utils';\nimport styles from './styles.css.js';\nimport Tooltip from '../tooltip';\n\nimport { ButtonDropdownProps } from '../interfaces';\nimport { getItemTarget } from '../utils/utils';\nimport useHiddenDescription from '../../internal/hooks/use-hidden-description';\nimport InternalIcon, { InternalIconProps } from '../../icon/internal';\nimport { useDropdownContext } from '../../internal/components/dropdown/context';\nimport { getMenuItemProps, getMenuItemCheckboxProps } from '../utils/menu-item';\n\nconst ItemElement = ({\n item,\n disabled,\n onItemActivate,\n highlighted,\n highlightItem,\n showDivider,\n hasCategoryHeader,\n isKeyboardHighlighted = false,\n variant = 'normal',\n}: ItemProps) => {\n const isLink = isLinkItem(item);\n const isCheckbox = isCheckboxItem(item);\n const onClick = (event: React.MouseEvent) => {\n // Stop propagation to parent node and handle event exclusively in here. This ensures\n // that no group will interfere with the default behavior of links\n event.stopPropagation();\n if (!isLink) {\n event.preventDefault();\n }\n if (!disabled) {\n onItemActivate(item, event);\n }\n };\n\n const onHover = () => {\n highlightItem(item);\n };\n\n return (\n <li\n className={clsx(styles['item-element'], styles[`variant-${variant}`], {\n [styles.highlighted]: highlighted,\n [styles.disabled]: disabled,\n [styles['has-category-header']]: hasCategoryHeader,\n [styles['has-checkmark']]: isCheckbox,\n [styles['show-divider']]: showDivider,\n [styles['is-focused']]: isKeyboardHighlighted,\n })}\n role=\"presentation\"\n data-testid={item.id}\n data-description={item.description}\n onClick={onClick}\n onMouseEnter={onHover}\n onTouchStart={onHover}\n >\n <MenuItem item={item} disabled={disabled} highlighted={highlighted} />\n </li>\n );\n};\n\nexport type InternalItemProps = ButtonDropdownProps.Item & {\n badge?: boolean;\n};\n\nexport type InternalCheckboxItemProps = ButtonDropdownProps.CheckboxItem & {\n badge?: boolean;\n};\n\ninterface MenuItemProps {\n item: InternalItemProps | InternalCheckboxItemProps;\n disabled: boolean;\n highlighted: boolean;\n}\n\nfunction MenuItem({ item, disabled, highlighted }: MenuItemProps) {\n const menuItemRef = useRef<(HTMLSpanElement & HTMLAnchorElement) | null>(null);\n const isCheckbox = isCheckboxItem(item);\n\n useEffect(() => {\n if (highlighted && menuItemRef.current) {\n menuItemRef.current.focus();\n }\n }, [highlighted]);\n\n const isDisabledWithReason = disabled && item.disabledReason;\n const { targetProps, descriptionEl } = useHiddenDescription(item.disabledReason);\n const menuItemProps: React.HTMLAttributes<HTMLSpanElement & HTMLAnchorElement> = {\n className: styles['menu-item'],\n lang: item.lang,\n ref: menuItemRef,\n // We are using the roving tabindex technique to manage the focus state of the dropdown.\n // The current element will always have tabindex=0 which means that it can be tabbed to,\n // while all other items have tabindex=-1 so we can focus them when necessary.\n tabIndex: highlighted ? 0 : -1,\n ...(isCheckbox ? getMenuItemCheckboxProps({ disabled, checked: item.checked }) : getMenuItemProps({ disabled })),\n ...(isDisabledWithReason ? targetProps : {}),\n };\n\n const menuItem = isLinkItem(item) ? (\n <a\n {...menuItemProps}\n href={!disabled ? item.href : undefined}\n target={getItemTarget(item)}\n rel={item.external ? 'noopener noreferrer' : undefined}\n >\n <MenuItemContent item={item} disabled={disabled} />\n </a>\n ) : (\n <span {...menuItemProps}>\n <MenuItemContent item={item} disabled={disabled} />\n </span>\n );\n\n const { position } = useDropdownContext();\n const tooltipPosition = position === 'bottom-left' || position === 'top-left' ? 'left' : 'right';\n return isDisabledWithReason ? (\n <Tooltip content={item.disabledReason} position={tooltipPosition} className={styles['item-tooltip-wrapper']}>\n {menuItem}\n {descriptionEl}\n </Tooltip>\n ) : (\n menuItem\n );\n}\n\nconst MenuItemContent = ({\n item,\n disabled,\n}: {\n item: InternalItemProps | InternalCheckboxItemProps;\n disabled: boolean;\n}) => {\n const hasIcon = !!(item.iconName || item.iconUrl || item.iconSvg);\n const hasExternal = isLinkItem(item) && item.external;\n const isCheckbox = isCheckboxItem(item);\n return (\n <>\n {isCheckbox && <MenuItemCheckmark checked={item.checked} disabled={disabled} />}\n {hasIcon && (\n <MenuItemIcon\n name={item.iconName}\n url={item.iconUrl}\n svg={item.iconSvg}\n alt={item.iconAlt}\n badge={item.badge}\n />\n )}\n {item.text}\n {hasExternal && <ExternalIcon disabled={disabled} ariaLabel={item.externalIconAriaLabel} />}\n </>\n );\n};\n\nconst MenuItemIcon = (props: InternalIconProps) => (\n <span className={styles.icon}>\n <InternalIcon {...props} />\n </span>\n);\n\n// Toggle has aria-hidden set because it's just used as a graphical element,\n// a11y attributes for the checkmark are communicated through the role and aria-checked state\n// of the menu element item.\nconst MenuItemCheckmark = ({ disabled, checked }: { disabled: boolean; checked: boolean }) => {\n const checkmark = <InternalIcon variant={disabled ? 'disabled' : 'normal'} name=\"check\" />;\n return (\n <span\n className={clsx(styles.icon, styles.checkmark, { [styles.disabled]: disabled })}\n aria-hidden=\"true\"\n style={{ visibility: checked ? 'visible' : 'hidden' }}\n >\n {checkmark}\n </span>\n );\n};\n\nconst ExternalIcon = ({ disabled, ariaLabel }: { disabled: boolean; ariaLabel?: string }) => {\n const icon = <InternalIcon variant={disabled ? 'disabled' : 'normal'} name=\"external\" />;\n return (\n <span className={styles['external-icon']} role={ariaLabel ? 'img' : undefined} aria-label={ariaLabel}>\n {icon}\n </span>\n );\n};\n\nexport default ItemElement;\n"]}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"item-element": "awsui_item-
|
|
5
|
-
"disabled": "
|
|
6
|
-
"show-divider": "awsui_show-
|
|
7
|
-
"highlighted": "
|
|
8
|
-
"is-focused": "awsui_is-
|
|
9
|
-
"menu-item": "awsui_menu-
|
|
10
|
-
"has-category-header": "awsui_has-category-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
4
|
+
"item-element": "awsui_item-element_93a1u_16wwy_97",
|
|
5
|
+
"disabled": "awsui_disabled_93a1u_16wwy_109",
|
|
6
|
+
"show-divider": "awsui_show-divider_93a1u_16wwy_116",
|
|
7
|
+
"highlighted": "awsui_highlighted_93a1u_16wwy_119",
|
|
8
|
+
"is-focused": "awsui_is-focused_93a1u_16wwy_134",
|
|
9
|
+
"menu-item": "awsui_menu-item_93a1u_16wwy_139",
|
|
10
|
+
"has-category-header": "awsui_has-category-header_93a1u_16wwy_154",
|
|
11
|
+
"item-tooltip-wrapper": "awsui_item-tooltip-wrapper_93a1u_16wwy_154",
|
|
12
|
+
"has-checkmark": "awsui_has-checkmark_93a1u_16wwy_154",
|
|
13
|
+
"icon": "awsui_icon_93a1u_16wwy_158",
|
|
14
|
+
"checkmark": "awsui_checkmark_93a1u_16wwy_162",
|
|
15
|
+
"external-icon": "awsui_external-icon_93a1u_16wwy_169"
|
|
15
16
|
};
|
|
16
17
|
|
|
@@ -94,7 +94,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
94
94
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
95
95
|
SPDX-License-Identifier: Apache-2.0
|
|
96
96
|
*/
|
|
97
|
-
.awsui_item-
|
|
97
|
+
.awsui_item-element_93a1u_16wwy_97:not(#\9) {
|
|
98
98
|
position: relative;
|
|
99
99
|
z-index: 1;
|
|
100
100
|
border-block: var(--border-item-width-yel47s, 2px) solid transparent;
|
|
@@ -106,17 +106,17 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
106
106
|
margin-block-start: calc(-1 * var(--border-field-width-09w7vk, 2px));
|
|
107
107
|
cursor: pointer;
|
|
108
108
|
}
|
|
109
|
-
.awsui_item-
|
|
109
|
+
.awsui_item-element_93a1u_16wwy_97.awsui_disabled_93a1u_16wwy_109:not(#\9) {
|
|
110
110
|
cursor: default;
|
|
111
111
|
color: var(--color-text-dropdown-item-disabled-6oq3n6, #9ba7b6);
|
|
112
112
|
}
|
|
113
|
-
.awsui_item-
|
|
113
|
+
.awsui_item-element_93a1u_16wwy_97:not(#\9):first-child {
|
|
114
114
|
margin-block-start: 0;
|
|
115
115
|
}
|
|
116
|
-
.awsui_item-
|
|
116
|
+
.awsui_item-element_93a1u_16wwy_97.awsui_show-divider_93a1u_16wwy_116:not(#\9) {
|
|
117
117
|
border-block-end: var(--border-item-width-yel47s, 2px) solid var(--color-border-dropdown-group-yakmix, #b6bec9);
|
|
118
118
|
}
|
|
119
|
-
.awsui_item-
|
|
119
|
+
.awsui_item-element_93a1u_16wwy_97.awsui_highlighted_93a1u_16wwy_119:not(#\9) {
|
|
120
120
|
color: var(--color-text-dropdown-item-highlighted-a51hdb, #000716);
|
|
121
121
|
z-index: 2;
|
|
122
122
|
background-color: var(--color-background-dropdown-item-hover-swsulg, #f4f4f4);
|
|
@@ -126,17 +126,17 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
126
126
|
border-end-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
127
127
|
border-end-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
128
128
|
}
|
|
129
|
-
.awsui_item-
|
|
129
|
+
.awsui_item-element_93a1u_16wwy_97.awsui_highlighted_93a1u_16wwy_119.awsui_disabled_93a1u_16wwy_109:not(#\9) {
|
|
130
130
|
color: var(--color-text-dropdown-item-dimmed-f2joj8, #9ba7b6);
|
|
131
131
|
border-color: var(--color-border-dropdown-item-dimmed-hover-xdu0hf, #7d8998);
|
|
132
132
|
background-color: var(--color-background-dropdown-item-dimmed-dlm6wk, transparent);
|
|
133
133
|
}
|
|
134
|
-
.awsui_item-
|
|
134
|
+
.awsui_item-element_93a1u_16wwy_97.awsui_highlighted_93a1u_16wwy_119.awsui_is-focused_93a1u_16wwy_134:not(#\9) {
|
|
135
135
|
border-color: var(--color-border-dropdown-item-focused-5hbaf3, #414d5c);
|
|
136
136
|
box-shadow: inset 0 0 0 var(--border-control-focus-ring-shadow-spread-0ctpjf, 0px) var(--color-border-item-focused-b2ntyl, #0972d3);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
.awsui_menu-
|
|
139
|
+
.awsui_menu-item_93a1u_16wwy_139:not(#\9) {
|
|
140
140
|
min-inline-size: 0;
|
|
141
141
|
word-break: break-word;
|
|
142
142
|
display: flex;
|
|
@@ -148,24 +148,24 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
148
148
|
/* stylelint-disable selector-max-type */
|
|
149
149
|
/* stylelint-enable selector-max-type */
|
|
150
150
|
}
|
|
151
|
-
.awsui_menu-
|
|
151
|
+
.awsui_menu-item_93a1u_16wwy_139:not(#\9):focus {
|
|
152
152
|
outline: none;
|
|
153
153
|
}
|
|
154
|
-
.awsui_has-category-
|
|
154
|
+
.awsui_has-category-header_93a1u_16wwy_154 > .awsui_menu-item_93a1u_16wwy_139:not(#\9), .awsui_has-category-header_93a1u_16wwy_154 > .awsui_item-tooltip-wrapper_93a1u_16wwy_154 > .awsui_menu-item_93a1u_16wwy_139:not(#\9), .awsui_has-category-header_93a1u_16wwy_154:not(#\9):not(.awsui_has-checkmark_93a1u_16wwy_154) > span > .awsui_menu-item_93a1u_16wwy_139 {
|
|
155
155
|
padding-inline-start: calc(var(--space-xs-zb16t3, 8px) + var(--space-l-t419sm, 20px));
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
.
|
|
158
|
+
.awsui_icon_93a1u_16wwy_158:not(#\9) {
|
|
159
159
|
padding-inline-end: var(--space-xxs-p8yyaw, 4px);
|
|
160
160
|
flex-shrink: 0;
|
|
161
161
|
}
|
|
162
|
-
.
|
|
162
|
+
.awsui_icon_93a1u_16wwy_158.awsui_checkmark_93a1u_16wwy_162:not(#\9) {
|
|
163
163
|
color: var(--color-text-status-info-ahz8zp, #0972d3);
|
|
164
164
|
}
|
|
165
|
-
.
|
|
165
|
+
.awsui_icon_93a1u_16wwy_158.awsui_disabled_93a1u_16wwy_109:not(#\9) {
|
|
166
166
|
color: var(--color-text-interactive-disabled-z7a3t4, #9ba7b6);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
.awsui_external-
|
|
169
|
+
.awsui_external-icon_93a1u_16wwy_169:not(#\9) {
|
|
170
170
|
margin-inline-start: var(--space-xxs-p8yyaw, 4px);
|
|
171
171
|
}
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"item-element": "awsui_item-
|
|
6
|
-
"disabled": "
|
|
7
|
-
"show-divider": "awsui_show-
|
|
8
|
-
"highlighted": "
|
|
9
|
-
"is-focused": "awsui_is-
|
|
10
|
-
"menu-item": "awsui_menu-
|
|
11
|
-
"has-category-header": "awsui_has-category-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
5
|
+
"item-element": "awsui_item-element_93a1u_16wwy_97",
|
|
6
|
+
"disabled": "awsui_disabled_93a1u_16wwy_109",
|
|
7
|
+
"show-divider": "awsui_show-divider_93a1u_16wwy_116",
|
|
8
|
+
"highlighted": "awsui_highlighted_93a1u_16wwy_119",
|
|
9
|
+
"is-focused": "awsui_is-focused_93a1u_16wwy_134",
|
|
10
|
+
"menu-item": "awsui_menu-item_93a1u_16wwy_139",
|
|
11
|
+
"has-category-header": "awsui_has-category-header_93a1u_16wwy_154",
|
|
12
|
+
"item-tooltip-wrapper": "awsui_item-tooltip-wrapper_93a1u_16wwy_154",
|
|
13
|
+
"has-checkmark": "awsui_has-checkmark_93a1u_16wwy_154",
|
|
14
|
+
"icon": "awsui_icon_93a1u_16wwy_158",
|
|
15
|
+
"checkmark": "awsui_checkmark_93a1u_16wwy_162",
|
|
16
|
+
"external-icon": "awsui_external-icon_93a1u_16wwy_169"
|
|
16
17
|
};
|
|
17
18
|
|
|
@@ -3,6 +3,7 @@ export interface TooltipProps {
|
|
|
3
3
|
children?: React.ReactNode;
|
|
4
4
|
content?: React.ReactNode;
|
|
5
5
|
position?: 'top' | 'right' | 'bottom' | 'left';
|
|
6
|
+
className?: string;
|
|
6
7
|
}
|
|
7
|
-
export default function Tooltip({ children, content, position }: TooltipProps): JSX.Element;
|
|
8
|
+
export default function Tooltip({ children, content, position, className }: TooltipProps): JSX.Element;
|
|
8
9
|
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/button-dropdown/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAStE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/button-dropdown/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAStE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAkB,EAAE,SAAS,EAAE,EAAE,YAAY,eAsCjG"}
|
|
@@ -8,12 +8,12 @@ import Portal from '../internal/components/portal';
|
|
|
8
8
|
import { usePortalModeClasses } from '../internal/hooks/use-portal-mode-classes';
|
|
9
9
|
import { useReducedMotion } from '@cloudscape-design/component-toolkit/internal';
|
|
10
10
|
const DEFAULT_OPEN_TIMEOUT_IN_MS = 120;
|
|
11
|
-
export default function Tooltip({ children, content, position = 'right' }) {
|
|
11
|
+
export default function Tooltip({ children, content, position = 'right', className }) {
|
|
12
12
|
const ref = useRef(null);
|
|
13
13
|
const isReducedMotion = useReducedMotion(ref);
|
|
14
14
|
const { open, triggerProps } = useTooltipOpen(isReducedMotion ? 0 : DEFAULT_OPEN_TIMEOUT_IN_MS);
|
|
15
15
|
const portalClasses = usePortalModeClasses(ref);
|
|
16
|
-
return (React.createElement("span", Object.assign({ ref: ref }, triggerProps),
|
|
16
|
+
return (React.createElement("span", Object.assign({ ref: ref }, triggerProps, { className: className }),
|
|
17
17
|
children,
|
|
18
18
|
open && (React.createElement(Portal, null,
|
|
19
19
|
React.createElement("span", { className: portalClasses },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../src/button-dropdown/tooltip.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAwB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../src/button-dropdown/tooltip.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAwB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AASjF,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAEvC,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,EAAE,SAAS,EAAgB;IAChG,MAAM,GAAG,GAAG,MAAM,CAAyB,IAAI,CAAC,CAAC;IACjD,MAAM,eAAe,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC,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AM,CAAC,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC;IACF,MAAM,SAAS,GAAyB,CAAC,CAAC,EAAE;QAC1C,IAAI,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;YAC7B,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,KAAK,EAAE,CAAC;SACT;IACH,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,WAAW,CAAC;IAC5B,MAAM,MAAM,GAAG,KAAK,CAAC;IAErB,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE;YACZ,MAAM;YACN,OAAO;YACP,SAAS;SACV;KACF,CAAC;AACJ,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { KeyboardEventHandler, useRef, useState } from 'react';\n\nimport Arrow from '../popover/arrow';\nimport PopoverContainer from '../popover/container';\nimport PopoverBody from '../popover/body';\nimport Portal from '../internal/components/portal';\nimport { usePortalModeClasses } from '../internal/hooks/use-portal-mode-classes';\nimport { useReducedMotion } from '@cloudscape-design/component-toolkit/internal';\n\nexport interface TooltipProps {\n children?: React.ReactNode;\n content?: React.ReactNode;\n position?: 'top' | 'right' | 'bottom' | 'left';\n className?: string;\n}\n\nconst DEFAULT_OPEN_TIMEOUT_IN_MS = 120;\n\nexport default function Tooltip({ children, content, position = 'right', className }: TooltipProps) {\n const ref = useRef<HTMLSpanElement | null>(null);\n const isReducedMotion = useReducedMotion(ref);\n const { open, triggerProps } = useTooltipOpen(isReducedMotion ? 0 : DEFAULT_OPEN_TIMEOUT_IN_MS);\n const portalClasses = usePortalModeClasses(ref);\n\n return (\n <span ref={ref} {...triggerProps} className={className}>\n {children}\n {open && (\n <Portal>\n <span className={portalClasses}>\n <PopoverContainer\n size=\"small\"\n fixedWidth={false}\n position={position}\n trackRef={ref}\n arrow={position => <Arrow position={position} />}\n renderWithPortal={true}\n zIndex={7000}\n >\n <PopoverBody\n dismissButton={false}\n dismissAriaLabel={undefined}\n header={null}\n onDismiss={() => {}}\n overflowVisible=\"both\"\n >\n <span data-testid=\"button-dropdown-disabled-reason\" role=\"tooltip\">\n {content}\n </span>\n </PopoverBody>\n </PopoverContainer>\n </span>\n </Portal>\n )}\n </span>\n );\n}\n\nfunction useTooltipOpen(timeout: number) {\n const handle = useRef<number>();\n const [isOpen, setIsOpen] = useState(false);\n\n const close = () => {\n clearTimeout(handle.current);\n setIsOpen(false);\n };\n const open = () => setIsOpen(true);\n const openDelayed = () => {\n handle.current = setTimeout(open, timeout);\n };\n const onKeyDown: KeyboardEventHandler = e => {\n if (isOpen && isEscape(e.key)) {\n e.preventDefault();\n e.stopPropagation();\n close();\n }\n };\n\n const onFocus = openDelayed;\n const onBlur = close;\n\n return {\n open: isOpen,\n triggerProps: {\n onBlur,\n onFocus,\n onKeyDown,\n },\n };\n}\n\nconst isEscape = (key: string) => key === 'Escape' || key === 'Esc';\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"layout": "
|
|
5
|
-
"background": "
|
|
6
|
-
"is-overlap-disabled": "awsui_is-overlap-
|
|
7
|
-
"header-background": "awsui_header-
|
|
8
|
-
"notifications": "
|
|
9
|
-
"breadcrumbs": "
|
|
10
|
-
"default-padding": "awsui_default-
|
|
11
|
-
"header-wrapper": "awsui_header-
|
|
12
|
-
"with-divider": "awsui_with-
|
|
13
|
-
"content": "
|
|
14
|
-
"has-header": "awsui_has-
|
|
15
|
-
"is-visual-refresh": "awsui_is-visual-
|
|
16
|
-
"has-default-background": "awsui_has-default-
|
|
17
|
-
"has-notifications": "awsui_has-
|
|
4
|
+
"layout": "awsui_layout_5gtk3_1hkx1_97",
|
|
5
|
+
"background": "awsui_background_5gtk3_1hkx1_111",
|
|
6
|
+
"is-overlap-disabled": "awsui_is-overlap-disabled_5gtk3_1hkx1_116",
|
|
7
|
+
"header-background": "awsui_header-background_5gtk3_1hkx1_119",
|
|
8
|
+
"notifications": "awsui_notifications_5gtk3_1hkx1_123",
|
|
9
|
+
"breadcrumbs": "awsui_breadcrumbs_5gtk3_1hkx1_128",
|
|
10
|
+
"default-padding": "awsui_default-padding_5gtk3_1hkx1_133",
|
|
11
|
+
"header-wrapper": "awsui_header-wrapper_5gtk3_1hkx1_137",
|
|
12
|
+
"with-divider": "awsui_with-divider_5gtk3_1hkx1_142",
|
|
13
|
+
"content": "awsui_content_5gtk3_1hkx1_145",
|
|
14
|
+
"has-header": "awsui_has-header_5gtk3_1hkx1_149",
|
|
15
|
+
"is-visual-refresh": "awsui_is-visual-refresh_5gtk3_1hkx1_156",
|
|
16
|
+
"has-default-background": "awsui_has-default-background_5gtk3_1hkx1_156",
|
|
17
|
+
"has-notifications": "awsui_has-notifications_5gtk3_1hkx1_160"
|
|
18
18
|
};
|
|
19
19
|
|