@cloudscape-design/components 3.0.575 → 3.0.576
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/area-chart/model/use-chart-model.js +1 -1
- package/area-chart/model/use-chart-model.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/hooks/use-virtual/index.d.ts +1 -1
- package/internal/hooks/use-virtual/index.d.ts.map +1 -1
- package/internal/hooks/use-virtual/index.js +1 -1
- package/internal/hooks/use-virtual/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/internal/vendor/react-virtual.js +529 -0
- package/mixed-line-bar-chart/hooks/use-mouse-hover.js +1 -1
- package/mixed-line-bar-chart/hooks/use-mouse-hover.js.map +1 -1
- package/package.json +1 -2
- package/select/utils/render-options.d.ts +1 -1
- package/select/utils/render-options.d.ts.map +1 -1
- package/select/utils/render-options.js.map +1 -1
|
@@ -240,7 +240,7 @@ export default function useChartModel({ fitHeight, externalSeries: allSeries, vi
|
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
242
|
const onPopoverLeave = (event) => {
|
|
243
|
-
if (plotRef.current.svg
|
|
243
|
+
if (nodeContains(plotRef.current.svg, event.relatedTarget) || interactions.get().isPopoverPinned) {
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
interactions.clearHighlight();
|
|
@@ -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,CA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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';\n\nconst MAX_HOVER_MARGIN = 6;\nconst SVG_HOVER_THROTTLE = 25;\nconst POPOVER_DEADZONE = 12;\n\nexport interface UseChartModelProps<T extends AreaChartProps.DataTypes> {\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 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 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) => {\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 // Move up/down.\n if (keyCode === KeyCode.down || keyCode === KeyCode.up) {\n moveBetweenSeries(keyCode === KeyCode.down ? -1 : 1);\n }\n // Move left/right.\n else if (keyCode === KeyCode.left || keyCode === KeyCode.right) {\n moveWithinXAxis(keyCode === KeyCode.right ? 1 : -1);\n }\n // Pin popover.\n else if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n 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 (plotRef.current!.svg.contains(event.relatedTarget as Node) || 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 }, [allSeries, series, xDomain, yDomain, xScaleType, yScaleType, height, width, stableSetVisibleSeries, popoverRef]);\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,WAAW,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,OAAO,EA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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';\n\nconst MAX_HOVER_MARGIN = 6;\nconst SVG_HOVER_THROTTLE = 25;\nconst POPOVER_DEADZONE = 12;\n\nexport interface UseChartModelProps<T extends AreaChartProps.DataTypes> {\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 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 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) => {\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 // Move up/down.\n if (keyCode === KeyCode.down || keyCode === KeyCode.up) {\n moveBetweenSeries(keyCode === KeyCode.down ? -1 : 1);\n }\n // Move left/right.\n else if (keyCode === KeyCode.left || keyCode === KeyCode.right) {\n moveWithinXAxis(keyCode === KeyCode.right ? 1 : -1);\n }\n // Pin popover.\n else if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n 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 }, [allSeries, series, xDomain, yDomain, xScaleType, yScaleType, height, width, stableSetVisibleSeries, popoverRef]);\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"]}
|
package/internal/environment.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-virtual/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAmC,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-virtual/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAmC,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAI1F,UAAU,eAAe,CAAC,IAAI;IAC5B,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IACvB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,YAAY,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED,UAAU,cAAc;IACtB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,MAAM,EAAE,EAC9C,KAAK,EACL,SAAS,EACT,YAAY,GACb,EAAE,eAAe,CAAC,IAAI,CAAC,GAAG,cAAc,CAgCxC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useEffect, useMemo, useRef } from 'react';
|
|
4
|
-
import { useVirtual as useVirtualDefault } from 'react-virtual';
|
|
4
|
+
import { useVirtual as useVirtualDefault } from '../../vendor/react-virtual';
|
|
5
5
|
const MAX_ITEM_MOUNTS = 100;
|
|
6
6
|
/**
|
|
7
7
|
* The useVirtual from react-virtual@2 might produce an infinite update loop caused by setting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-virtual/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,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CAAC,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC;YAC9E,IAAI,YAAY,GAAG,eAAe,EAAE;gBAClC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBAC7B,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;aACvE;QACH,CAAC,IACD,CAAC,EACL,CAAC,KAAK,EAAE,cAAc,CAAC,YAAY,CAAC,CACrC,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,SAAS,EAAE,cAAc,CAAC,SAAS;QACnC,aAAa,EAAE,cAAc,CAAC,aAAa;KAC5C,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useRef } from 'react';\nimport { useVirtual as useVirtualDefault, VirtualItem } from '../../vendor/react-virtual';\n\nconst MAX_ITEM_MOUNTS = 100;\n\ninterface UseVirtualProps<Item> {\n items: readonly Item[];\n parentRef: React.RefObject<HTMLElement>;\n estimateSize: () => number;\n}\n\ninterface RowVirtualizer {\n virtualItems: VirtualItem[];\n totalSize: number;\n scrollToIndex: (index: number) => void;\n}\n\n/**\n * The useVirtual from react-virtual@2 might produce an infinite update loop caused by setting\n * measured item sizes in the render cycle (as part of the measureRef assignment):\n * The sum of all measured item sizes is returned as totalSize which is then set on the list container.\n * Enforcing new container height might result in an items size change e.g. when the content wraps.\n *\n * The infinite update cycle causes React \"Maximum update depth exceeded\" error and can be additionally confirmed\n * by logging the totalSize which should then bounce between two values.\n *\n * The number of item refs assignments is limited to MAX_ITEM_MOUNTS unless items or indices change.\n * That is based on the assumption the item height stays constant after its first render.\n */\nexport function useVirtual<Item extends object>({\n items,\n parentRef,\n estimateSize,\n}: UseVirtualProps<Item>): RowVirtualizer {\n const rowVirtualizer = useVirtualDefault({ size: items.length, parentRef, estimateSize, overscan: 5 });\n\n // Cache virtual item mounts to limit the amount of mounts per item.\n const measuresCache = useRef(new WeakMap<Item, number>());\n\n // Clear mounts cache every time indices, items, or size estimate change.\n const indicesKey = rowVirtualizer.virtualItems.map(item => `${item.index}`).join(':');\n useEffect(() => {\n measuresCache.current = new WeakMap();\n }, [indicesKey, items, estimateSize]);\n\n const virtualItems = useMemo(\n () =>\n rowVirtualizer.virtualItems.map(virtualItem => ({\n ...virtualItem,\n measureRef: (node: null | HTMLElement) => {\n const mountedCount = measuresCache.current.get(items[virtualItem.index]) ?? 0;\n if (mountedCount < MAX_ITEM_MOUNTS) {\n virtualItem.measureRef(node);\n measuresCache.current.set(items[virtualItem.index], mountedCount + 1);\n }\n },\n })),\n [items, rowVirtualizer.virtualItems]\n );\n\n return {\n virtualItems,\n totalSize: rowVirtualizer.totalSize,\n scrollToIndex: rowVirtualizer.scrollToIndex,\n };\n}\n"]}
|
package/internal/manifest.json
CHANGED
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name: react-virtual
|
|
3
|
+
* Version: 2.10.4
|
|
4
|
+
* License: MIT
|
|
5
|
+
* Private: false
|
|
6
|
+
* Description: Hooks for virtualizing scrollable elements in React
|
|
7
|
+
* Repository: undefined
|
|
8
|
+
* Homepage: https://github.com/tannerlinsley/react-virtual#readme
|
|
9
|
+
* Author: tannerlinsley
|
|
10
|
+
* License Copyright:
|
|
11
|
+
* ===
|
|
12
|
+
*
|
|
13
|
+
* MIT License
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2019 Tanner Linsley
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
* in the Software without restriction, including without limitation the rights
|
|
20
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
* furnished to do so, subject to the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
* copies or substantial portions of the Software.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
* SOFTWARE.
|
|
34
|
+
*/
|
|
35
|
+
import React from 'react';
|
|
36
|
+
|
|
37
|
+
function _extends() {
|
|
38
|
+
_extends = Object.assign || function (target) {
|
|
39
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
40
|
+
var source = arguments[i];
|
|
41
|
+
|
|
42
|
+
for (var key in source) {
|
|
43
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
44
|
+
target[key] = source[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return target;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return _extends.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
56
|
+
if (source == null) return {};
|
|
57
|
+
var target = {};
|
|
58
|
+
var sourceKeys = Object.keys(source);
|
|
59
|
+
var key, i;
|
|
60
|
+
|
|
61
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
62
|
+
key = sourceKeys[i];
|
|
63
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
64
|
+
target[key] = source[key];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return target;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var props = ['bottom', 'height', 'left', 'right', 'top', 'width'];
|
|
71
|
+
|
|
72
|
+
var rectChanged = function rectChanged(a, b) {
|
|
73
|
+
if (a === void 0) {
|
|
74
|
+
a = {};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (b === void 0) {
|
|
78
|
+
b = {};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return props.some(function (prop) {
|
|
82
|
+
return a[prop] !== b[prop];
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
var observedNodes = /*#__PURE__*/new Map();
|
|
87
|
+
var rafId;
|
|
88
|
+
|
|
89
|
+
var run = function run() {
|
|
90
|
+
var changedStates = [];
|
|
91
|
+
observedNodes.forEach(function (state, node) {
|
|
92
|
+
var newRect = node.getBoundingClientRect();
|
|
93
|
+
|
|
94
|
+
if (rectChanged(newRect, state.rect)) {
|
|
95
|
+
state.rect = newRect;
|
|
96
|
+
changedStates.push(state);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
changedStates.forEach(function (state) {
|
|
100
|
+
state.callbacks.forEach(function (cb) {
|
|
101
|
+
return cb(state.rect);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
rafId = window.requestAnimationFrame(run);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
function observeRect(node, cb) {
|
|
108
|
+
return {
|
|
109
|
+
observe: function observe() {
|
|
110
|
+
var wasEmpty = observedNodes.size === 0;
|
|
111
|
+
|
|
112
|
+
if (observedNodes.has(node)) {
|
|
113
|
+
observedNodes.get(node).callbacks.push(cb);
|
|
114
|
+
} else {
|
|
115
|
+
observedNodes.set(node, {
|
|
116
|
+
rect: undefined,
|
|
117
|
+
hasRectChanged: false,
|
|
118
|
+
callbacks: [cb]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (wasEmpty) run();
|
|
123
|
+
},
|
|
124
|
+
unobserve: function unobserve() {
|
|
125
|
+
var state = observedNodes.get(node);
|
|
126
|
+
|
|
127
|
+
if (state) {
|
|
128
|
+
// Remove the callback
|
|
129
|
+
var index = state.callbacks.indexOf(cb);
|
|
130
|
+
if (index >= 0) state.callbacks.splice(index, 1); // Remove the node reference
|
|
131
|
+
|
|
132
|
+
if (!state.callbacks.length) observedNodes["delete"](node); // Stop the loop
|
|
133
|
+
|
|
134
|
+
if (!observedNodes.size) cancelAnimationFrame(rafId);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
141
|
+
|
|
142
|
+
function useRect(nodeRef, initialRect) {
|
|
143
|
+
if (initialRect === void 0) {
|
|
144
|
+
initialRect = {
|
|
145
|
+
width: 0,
|
|
146
|
+
height: 0
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var _React$useState = React.useState(nodeRef.current),
|
|
151
|
+
element = _React$useState[0],
|
|
152
|
+
setElement = _React$useState[1];
|
|
153
|
+
|
|
154
|
+
var _React$useReducer = React.useReducer(rectReducer, initialRect),
|
|
155
|
+
rect = _React$useReducer[0],
|
|
156
|
+
dispatch = _React$useReducer[1];
|
|
157
|
+
|
|
158
|
+
var initialRectSet = React.useRef(false);
|
|
159
|
+
useIsomorphicLayoutEffect(function () {
|
|
160
|
+
if (nodeRef.current !== element) {
|
|
161
|
+
setElement(nodeRef.current);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
useIsomorphicLayoutEffect(function () {
|
|
165
|
+
if (element && !initialRectSet.current) {
|
|
166
|
+
initialRectSet.current = true;
|
|
167
|
+
|
|
168
|
+
var _rect = element.getBoundingClientRect();
|
|
169
|
+
|
|
170
|
+
dispatch({
|
|
171
|
+
rect: _rect
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}, [element]);
|
|
175
|
+
React.useEffect(function () {
|
|
176
|
+
if (!element) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
var observer = observeRect(element, function (rect) {
|
|
181
|
+
dispatch({
|
|
182
|
+
rect: rect
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
observer.observe();
|
|
186
|
+
return function () {
|
|
187
|
+
observer.unobserve();
|
|
188
|
+
};
|
|
189
|
+
}, [element]);
|
|
190
|
+
return rect;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function rectReducer(state, action) {
|
|
194
|
+
var rect = action.rect;
|
|
195
|
+
|
|
196
|
+
if (state.height !== rect.height || state.width !== rect.width) {
|
|
197
|
+
return rect;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return state;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
var defaultEstimateSize = function defaultEstimateSize() {
|
|
204
|
+
return 50;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
var defaultKeyExtractor = function defaultKeyExtractor(index) {
|
|
208
|
+
return index;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
var defaultMeasureSize = function defaultMeasureSize(el, horizontal) {
|
|
212
|
+
var key = horizontal ? 'offsetWidth' : 'offsetHeight';
|
|
213
|
+
return el[key];
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
var defaultRangeExtractor = function defaultRangeExtractor(range) {
|
|
217
|
+
var start = Math.max(range.start - range.overscan, 0);
|
|
218
|
+
var end = Math.min(range.end + range.overscan, range.size - 1);
|
|
219
|
+
var arr = [];
|
|
220
|
+
|
|
221
|
+
for (var i = start; i <= end; i++) {
|
|
222
|
+
arr.push(i);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return arr;
|
|
226
|
+
};
|
|
227
|
+
function useVirtual(_ref) {
|
|
228
|
+
var _measurements;
|
|
229
|
+
|
|
230
|
+
var _ref$size = _ref.size,
|
|
231
|
+
size = _ref$size === void 0 ? 0 : _ref$size,
|
|
232
|
+
_ref$estimateSize = _ref.estimateSize,
|
|
233
|
+
estimateSize = _ref$estimateSize === void 0 ? defaultEstimateSize : _ref$estimateSize,
|
|
234
|
+
_ref$overscan = _ref.overscan,
|
|
235
|
+
overscan = _ref$overscan === void 0 ? 1 : _ref$overscan,
|
|
236
|
+
_ref$paddingStart = _ref.paddingStart,
|
|
237
|
+
paddingStart = _ref$paddingStart === void 0 ? 0 : _ref$paddingStart,
|
|
238
|
+
_ref$paddingEnd = _ref.paddingEnd,
|
|
239
|
+
paddingEnd = _ref$paddingEnd === void 0 ? 0 : _ref$paddingEnd,
|
|
240
|
+
parentRef = _ref.parentRef,
|
|
241
|
+
horizontal = _ref.horizontal,
|
|
242
|
+
scrollToFn = _ref.scrollToFn,
|
|
243
|
+
useObserver = _ref.useObserver,
|
|
244
|
+
initialRect = _ref.initialRect,
|
|
245
|
+
onScrollElement = _ref.onScrollElement,
|
|
246
|
+
scrollOffsetFn = _ref.scrollOffsetFn,
|
|
247
|
+
_ref$keyExtractor = _ref.keyExtractor,
|
|
248
|
+
keyExtractor = _ref$keyExtractor === void 0 ? defaultKeyExtractor : _ref$keyExtractor,
|
|
249
|
+
_ref$measureSize = _ref.measureSize,
|
|
250
|
+
measureSize = _ref$measureSize === void 0 ? defaultMeasureSize : _ref$measureSize,
|
|
251
|
+
_ref$rangeExtractor = _ref.rangeExtractor,
|
|
252
|
+
rangeExtractor = _ref$rangeExtractor === void 0 ? defaultRangeExtractor : _ref$rangeExtractor;
|
|
253
|
+
var sizeKey = horizontal ? 'width' : 'height';
|
|
254
|
+
var scrollKey = horizontal ? 'scrollLeft' : 'scrollTop';
|
|
255
|
+
var latestRef = React.useRef({
|
|
256
|
+
scrollOffset: 0,
|
|
257
|
+
measurements: []
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
var _React$useState = React.useState(0),
|
|
261
|
+
scrollOffset = _React$useState[0],
|
|
262
|
+
setScrollOffset = _React$useState[1];
|
|
263
|
+
|
|
264
|
+
latestRef.current.scrollOffset = scrollOffset;
|
|
265
|
+
var useMeasureParent = useObserver || useRect;
|
|
266
|
+
|
|
267
|
+
var _useMeasureParent = useMeasureParent(parentRef, initialRect),
|
|
268
|
+
outerSize = _useMeasureParent[sizeKey];
|
|
269
|
+
|
|
270
|
+
latestRef.current.outerSize = outerSize;
|
|
271
|
+
var defaultScrollToFn = React.useCallback(function (offset) {
|
|
272
|
+
if (parentRef.current) {
|
|
273
|
+
parentRef.current[scrollKey] = offset;
|
|
274
|
+
}
|
|
275
|
+
}, [parentRef, scrollKey]);
|
|
276
|
+
var resolvedScrollToFn = scrollToFn || defaultScrollToFn;
|
|
277
|
+
scrollToFn = React.useCallback(function (offset) {
|
|
278
|
+
resolvedScrollToFn(offset, defaultScrollToFn);
|
|
279
|
+
}, [defaultScrollToFn, resolvedScrollToFn]);
|
|
280
|
+
|
|
281
|
+
var _React$useState2 = React.useState({}),
|
|
282
|
+
measuredCache = _React$useState2[0],
|
|
283
|
+
setMeasuredCache = _React$useState2[1];
|
|
284
|
+
|
|
285
|
+
var measure = React.useCallback(function () {
|
|
286
|
+
return setMeasuredCache({});
|
|
287
|
+
}, []);
|
|
288
|
+
var pendingMeasuredCacheIndexesRef = React.useRef([]);
|
|
289
|
+
var measurements = React.useMemo(function () {
|
|
290
|
+
var min = pendingMeasuredCacheIndexesRef.current.length > 0 ? Math.min.apply(Math, pendingMeasuredCacheIndexesRef.current) : 0;
|
|
291
|
+
pendingMeasuredCacheIndexesRef.current = [];
|
|
292
|
+
var measurements = latestRef.current.measurements.slice(0, min);
|
|
293
|
+
|
|
294
|
+
for (var i = min; i < size; i++) {
|
|
295
|
+
var key = keyExtractor(i);
|
|
296
|
+
var measuredSize = measuredCache[key];
|
|
297
|
+
|
|
298
|
+
var _start = measurements[i - 1] ? measurements[i - 1].end : paddingStart;
|
|
299
|
+
|
|
300
|
+
var _size = typeof measuredSize === 'number' ? measuredSize : estimateSize(i);
|
|
301
|
+
|
|
302
|
+
var _end = _start + _size;
|
|
303
|
+
|
|
304
|
+
measurements[i] = {
|
|
305
|
+
index: i,
|
|
306
|
+
start: _start,
|
|
307
|
+
size: _size,
|
|
308
|
+
end: _end,
|
|
309
|
+
key: key
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return measurements;
|
|
314
|
+
}, [estimateSize, measuredCache, paddingStart, size, keyExtractor]);
|
|
315
|
+
var totalSize = (((_measurements = measurements[size - 1]) == null ? void 0 : _measurements.end) || paddingStart) + paddingEnd;
|
|
316
|
+
latestRef.current.measurements = measurements;
|
|
317
|
+
latestRef.current.totalSize = totalSize;
|
|
318
|
+
var element = onScrollElement ? onScrollElement.current : parentRef.current;
|
|
319
|
+
var scrollOffsetFnRef = React.useRef(scrollOffsetFn);
|
|
320
|
+
scrollOffsetFnRef.current = scrollOffsetFn;
|
|
321
|
+
useIsomorphicLayoutEffect(function () {
|
|
322
|
+
if (!element) {
|
|
323
|
+
setScrollOffset(0);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
var onScroll = function onScroll(event) {
|
|
328
|
+
var offset = scrollOffsetFnRef.current ? scrollOffsetFnRef.current(event) : element[scrollKey];
|
|
329
|
+
setScrollOffset(offset);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
onScroll();
|
|
333
|
+
element.addEventListener('scroll', onScroll, {
|
|
334
|
+
capture: false,
|
|
335
|
+
passive: true
|
|
336
|
+
});
|
|
337
|
+
return function () {
|
|
338
|
+
element.removeEventListener('scroll', onScroll);
|
|
339
|
+
};
|
|
340
|
+
}, [element, scrollKey]);
|
|
341
|
+
|
|
342
|
+
var _calculateRange = calculateRange(latestRef.current),
|
|
343
|
+
start = _calculateRange.start,
|
|
344
|
+
end = _calculateRange.end;
|
|
345
|
+
|
|
346
|
+
var indexes = React.useMemo(function () {
|
|
347
|
+
return rangeExtractor({
|
|
348
|
+
start: start,
|
|
349
|
+
end: end,
|
|
350
|
+
overscan: overscan,
|
|
351
|
+
size: measurements.length
|
|
352
|
+
});
|
|
353
|
+
}, [start, end, overscan, measurements.length, rangeExtractor]);
|
|
354
|
+
var measureSizeRef = React.useRef(measureSize);
|
|
355
|
+
measureSizeRef.current = measureSize;
|
|
356
|
+
var virtualItems = React.useMemo(function () {
|
|
357
|
+
var virtualItems = [];
|
|
358
|
+
|
|
359
|
+
var _loop = function _loop(k, len) {
|
|
360
|
+
var i = indexes[k];
|
|
361
|
+
var measurement = measurements[i];
|
|
362
|
+
|
|
363
|
+
var item = _extends(_extends({}, measurement), {}, {
|
|
364
|
+
measureRef: function measureRef(el) {
|
|
365
|
+
if (el) {
|
|
366
|
+
var measuredSize = measureSizeRef.current(el, horizontal);
|
|
367
|
+
|
|
368
|
+
if (measuredSize !== item.size) {
|
|
369
|
+
var _scrollOffset = latestRef.current.scrollOffset;
|
|
370
|
+
|
|
371
|
+
if (item.start < _scrollOffset) {
|
|
372
|
+
defaultScrollToFn(_scrollOffset + (measuredSize - item.size));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
pendingMeasuredCacheIndexesRef.current.push(i);
|
|
376
|
+
setMeasuredCache(function (old) {
|
|
377
|
+
var _extends2;
|
|
378
|
+
|
|
379
|
+
return _extends(_extends({}, old), {}, (_extends2 = {}, _extends2[item.key] = measuredSize, _extends2));
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
virtualItems.push(item);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
for (var k = 0, len = indexes.length; k < len; k++) {
|
|
390
|
+
_loop(k);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return virtualItems;
|
|
394
|
+
}, [indexes, defaultScrollToFn, horizontal, measurements]);
|
|
395
|
+
var mountedRef = React.useRef(false);
|
|
396
|
+
useIsomorphicLayoutEffect(function () {
|
|
397
|
+
if (mountedRef.current) {
|
|
398
|
+
setMeasuredCache({});
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
mountedRef.current = true;
|
|
402
|
+
}, [estimateSize]);
|
|
403
|
+
var scrollToOffset = React.useCallback(function (toOffset, _temp) {
|
|
404
|
+
var _ref2 = _temp === void 0 ? {} : _temp,
|
|
405
|
+
_ref2$align = _ref2.align,
|
|
406
|
+
align = _ref2$align === void 0 ? 'start' : _ref2$align;
|
|
407
|
+
|
|
408
|
+
var _latestRef$current = latestRef.current,
|
|
409
|
+
scrollOffset = _latestRef$current.scrollOffset,
|
|
410
|
+
outerSize = _latestRef$current.outerSize;
|
|
411
|
+
|
|
412
|
+
if (align === 'auto') {
|
|
413
|
+
if (toOffset <= scrollOffset) {
|
|
414
|
+
align = 'start';
|
|
415
|
+
} else if (toOffset >= scrollOffset + outerSize) {
|
|
416
|
+
align = 'end';
|
|
417
|
+
} else {
|
|
418
|
+
align = 'start';
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (align === 'start') {
|
|
423
|
+
scrollToFn(toOffset);
|
|
424
|
+
} else if (align === 'end') {
|
|
425
|
+
scrollToFn(toOffset - outerSize);
|
|
426
|
+
} else if (align === 'center') {
|
|
427
|
+
scrollToFn(toOffset - outerSize / 2);
|
|
428
|
+
}
|
|
429
|
+
}, [scrollToFn]);
|
|
430
|
+
var tryScrollToIndex = React.useCallback(function (index, _temp2) {
|
|
431
|
+
var _ref3 = _temp2 === void 0 ? {} : _temp2,
|
|
432
|
+
_ref3$align = _ref3.align,
|
|
433
|
+
align = _ref3$align === void 0 ? 'auto' : _ref3$align,
|
|
434
|
+
rest = _objectWithoutPropertiesLoose(_ref3, ["align"]);
|
|
435
|
+
|
|
436
|
+
var _latestRef$current2 = latestRef.current,
|
|
437
|
+
measurements = _latestRef$current2.measurements,
|
|
438
|
+
scrollOffset = _latestRef$current2.scrollOffset,
|
|
439
|
+
outerSize = _latestRef$current2.outerSize;
|
|
440
|
+
var measurement = measurements[Math.max(0, Math.min(index, size - 1))];
|
|
441
|
+
|
|
442
|
+
if (!measurement) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (align === 'auto') {
|
|
447
|
+
if (measurement.end >= scrollOffset + outerSize) {
|
|
448
|
+
align = 'end';
|
|
449
|
+
} else if (measurement.start <= scrollOffset) {
|
|
450
|
+
align = 'start';
|
|
451
|
+
} else {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
var toOffset = align === 'center' ? measurement.start + measurement.size / 2 : align === 'end' ? measurement.end : measurement.start;
|
|
457
|
+
scrollToOffset(toOffset, _extends({
|
|
458
|
+
align: align
|
|
459
|
+
}, rest));
|
|
460
|
+
}, [scrollToOffset, size]);
|
|
461
|
+
var scrollToIndex = React.useCallback(function () {
|
|
462
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
463
|
+
args[_key] = arguments[_key];
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// We do a double request here because of
|
|
467
|
+
// dynamic sizes which can cause offset shift
|
|
468
|
+
// and end up in the wrong spot. Unfortunately,
|
|
469
|
+
// we can't know about those dynamic sizes until
|
|
470
|
+
// we try and render them. So double down!
|
|
471
|
+
tryScrollToIndex.apply(void 0, args);
|
|
472
|
+
requestAnimationFrame(function () {
|
|
473
|
+
tryScrollToIndex.apply(void 0, args);
|
|
474
|
+
});
|
|
475
|
+
}, [tryScrollToIndex]);
|
|
476
|
+
return {
|
|
477
|
+
virtualItems: virtualItems,
|
|
478
|
+
totalSize: totalSize,
|
|
479
|
+
scrollToOffset: scrollToOffset,
|
|
480
|
+
scrollToIndex: scrollToIndex,
|
|
481
|
+
measure: measure
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCurrentValue, value) {
|
|
486
|
+
while (low <= high) {
|
|
487
|
+
var middle = (low + high) / 2 | 0;
|
|
488
|
+
var currentValue = getCurrentValue(middle);
|
|
489
|
+
|
|
490
|
+
if (currentValue < value) {
|
|
491
|
+
low = middle + 1;
|
|
492
|
+
} else if (currentValue > value) {
|
|
493
|
+
high = middle - 1;
|
|
494
|
+
} else {
|
|
495
|
+
return middle;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (low > 0) {
|
|
500
|
+
return low - 1;
|
|
501
|
+
} else {
|
|
502
|
+
return 0;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
function calculateRange(_ref4) {
|
|
507
|
+
var measurements = _ref4.measurements,
|
|
508
|
+
outerSize = _ref4.outerSize,
|
|
509
|
+
scrollOffset = _ref4.scrollOffset;
|
|
510
|
+
var size = measurements.length - 1;
|
|
511
|
+
|
|
512
|
+
var getOffset = function getOffset(index) {
|
|
513
|
+
return measurements[index].start;
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
var start = findNearestBinarySearch(0, size, getOffset, scrollOffset);
|
|
517
|
+
var end = start;
|
|
518
|
+
|
|
519
|
+
while (end < size && measurements[end].end < scrollOffset + outerSize) {
|
|
520
|
+
end++;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return {
|
|
524
|
+
start: start,
|
|
525
|
+
end: end
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export { useVirtual };
|
|
@@ -86,7 +86,7 @@ export function useMouseHover({ plotRef, popoverRef, scaledSeries, barGroups, hi
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
const onPopoverLeave = (event) => {
|
|
89
|
-
if (!isHandlersDisabled &&
|
|
89
|
+
if (!isHandlersDisabled && nodeContains(plotRef.current.svg, event.relatedTarget)) {
|
|
90
90
|
highlightX(null);
|
|
91
91
|
clearHighlightedSeries();
|
|
92
92
|
}
|
|
@@ -1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C,EAAE;YAC9F,IAAI,iBAAiB,EAAE;gBACrB,gBAAgB,CAAC,KAAK,CAAC,CAAC;aACzB;iBAAM,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAClC,iBAAiB,CAAC,KAAK,CAAC,CAAC;aAC1B;SACF;IACH,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,KAA+C,EAAE,EAAE;QACxE,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE;YACnD,OAAO;SACR;QACD,IACE,CAAC,YAAY,CAAC,OAAO,CAAC,OAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC;YACxD,CAAC,KAAK,CAAC,aAAa,IAAK,KAAK,CAAC,aAAyB,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAC3F;YACA,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,sBAAsB,EAAE,CAAC;SAC1B;IACH,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,CAAC,KAAuB,EAAE,EAAE;QACjD,IAAI,CAAC,kBAAkB,IAAI,YAAY,CAAC,OAAO,CAAC,OAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC,EAAE;YAClF,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,sBAAsB,EAAE,CAAC;SAC1B;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport { ScaledBarGroup } from '../make-scaled-bar-groups';\nimport { ScaledPoint } from '../make-scaled-series';\n\nimport styles from '../styles.css.js';\nimport { ChartPlotRef } from '../../internal/components/chart-plot';\nimport { VerticalMarkerX } from '../interfaces';\nimport { isYThreshold } from '../utils';\n\nconst MAX_HOVER_MARGIN = 6;\nconst POPOVER_DEADZONE = 12;\n\nexport interface UseMouseHoverProps<T> {\n plotRef: React.RefObject<ChartPlotRef>;\n popoverRef: React.RefObject<HTMLElement>;\n scaledSeries: ReadonlyArray<ScaledPoint<T>>;\n barGroups: ScaledBarGroup<T>[];\n highlightPoint: (point: ScaledPoint<T> | null) => void;\n highlightGroup: (groupIndex: number) => void;\n clearHighlightedSeries: () => void;\n isGroupNavigation: boolean;\n isHandlersDisabled: boolean;\n highlightX: (verticalMarker: VerticalMarkerX<T> | null) => void;\n}\n\nexport function useMouseHover<T>({\n plotRef,\n popoverRef,\n scaledSeries,\n barGroups,\n highlightPoint,\n highlightGroup,\n clearHighlightedSeries,\n isGroupNavigation,\n isHandlersDisabled,\n highlightX,\n}: UseMouseHoverProps<T>) {\n const isMouseOverPopover = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (popoverRef.current?.firstChild) {\n const popoverPosition = (popoverRef.current.firstChild as HTMLElement).getBoundingClientRect();\n if (\n event.clientX > popoverPosition.x - POPOVER_DEADZONE &&\n event.clientX < popoverPosition.x + popoverPosition.width + POPOVER_DEADZONE &&\n event.clientY > popoverPosition.y - POPOVER_DEADZONE &&\n event.clientY < popoverPosition.y + popoverPosition.height + POPOVER_DEADZONE\n ) {\n return true;\n }\n }\n return false;\n };\n\n const onSeriesMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n\n const closestX = scaledSeries\n .map(v => v.x)\n .reduce((prev, curr) => (Math.abs(curr - offsetX) < Math.abs(prev - offsetX) ? curr : prev), -Infinity);\n\n if (isFinite(closestX)) {\n const offsetY = event.clientY - svgRect.top;\n const closestY = scaledSeries\n .filter(v => v.x === closestX || isYThreshold(v.series))\n .map(v => v.y)\n .reduce((prev, curr) => (Math.abs(curr - offsetY) < Math.abs(prev - offsetY) ? curr : prev), -Infinity);\n\n if (\n isFinite(closestY) &&\n Math.abs(offsetX - closestX) < MAX_HOVER_MARGIN &&\n Math.abs(offsetY - closestY) < MAX_HOVER_MARGIN\n ) {\n const [{ color, datum, series }] = scaledSeries.filter(\n s => (s.x === closestX || isYThreshold(s.series)) && s.y === closestY\n );\n highlightPoint({ x: closestX, y: closestY, color, datum, series });\n } else {\n let datumX = null;\n for (const point of scaledSeries) {\n if (point.x === closestX) {\n datumX = point.datum?.x ?? null;\n break;\n }\n }\n highlightX({ scaledX: closestX, label: datumX });\n }\n }\n };\n\n const onGroupMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n const offsetY = event.clientY - svgRect.top;\n\n // If hovering over some group - highlight it.\n for (let groupIndex = 0; groupIndex < barGroups.length; groupIndex++) {\n const {\n position: { x, y, width, height },\n } = barGroups[groupIndex];\n\n if (x <= offsetX && offsetX <= x + width && y <= offsetY && offsetY <= y + height) {\n highlightGroup(groupIndex);\n return;\n }\n }\n // Otherwise - clear the highlight.\n clearHighlightedSeries();\n };\n\n const onSVGMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (event.target === plotRef.current!.svg && !isHandlersDisabled && !isMouseOverPopover(event)) {\n if (isGroupNavigation) {\n onGroupMouseMove(event);\n } else if (scaledSeries.length > 0) {\n onSeriesMouseMove(event);\n }\n }\n };\n\n const onSVGMouseOut = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (isHandlersDisabled || isMouseOverPopover(event)) {\n return;\n }\n if (\n !nodeContains(plotRef.current!.svg, event.relatedTarget) ||\n (event.relatedTarget && (event.relatedTarget as Element).classList.contains(styles.series))\n ) {\n highlightX(null);\n clearHighlightedSeries();\n }\n };\n\n const onPopoverLeave = (event: React.MouseEvent) => {\n if (!isHandlersDisabled && nodeContains(plotRef.current!.svg, event.relatedTarget)) {\n highlightX(null);\n clearHighlightedSeries();\n }\n };\n\n return { onSVGMouseMove, onSVGMouseOut, onPopoverLeave };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"./internal/base-component/index.js",
|
|
117
117
|
"./internal/base-component/styles.css.js"
|
|
118
118
|
],
|
|
119
|
-
"version": "3.0.
|
|
119
|
+
"version": "3.0.576",
|
|
120
120
|
"repository": {
|
|
121
121
|
"type": "git",
|
|
122
122
|
"url": "https://github.com/cloudscape-design/components.git"
|
|
@@ -140,7 +140,6 @@
|
|
|
140
140
|
"mnth": "^2.0.0",
|
|
141
141
|
"react-keyed-flatten-children": "^1.3.0",
|
|
142
142
|
"react-transition-group": "^4.4.2",
|
|
143
|
-
"react-virtual": "^2.8.2",
|
|
144
143
|
"tslib": "^2.4.0",
|
|
145
144
|
"weekstart": "^1.1.0"
|
|
146
145
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { VirtualItem } from 'react-virtual';
|
|
2
|
+
import { VirtualItem } from '../../internal/vendor/react-virtual';
|
|
3
3
|
import { DropdownOption } from '../../internal/components/option/interfaces';
|
|
4
4
|
import { HighlightType } from '../../internal/components/options-list/utils/use-highlight-option';
|
|
5
5
|
export interface RenderOptionProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-options.d.ts","sourceRoot":"","sources":["../../../../src/select/utils/render-options.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"render-options.d.ts","sourceRoot":"","sources":["../../../../src/select/utils/render-options.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAGlE,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,mEAAmE,CAAC;AAElG,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACvC,cAAc,EAAE,GAAG,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,qKAWvB,iBAAiB,kBA8BnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-options.js","sourceRoot":"","sources":["../../../../src/select/utils/render-options.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,IAAI,MAAM,eAAe,CAAC;AACjC,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgBhD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,EACP,cAAc,EACd,cAAc,EACd,aAAa,EACb,UAAU,GAAG,KAAK,EAClB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACO,EAAE,EAAE;IACtB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,YAAY,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;QACxD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5D,MAAM,KAAK,GAAG,YAAY,CAAC;YACzB,MAAM;YACN,KAAK,EAAE,WAAW;YAClB,cAAc;YACd,cAAc;YACd,UAAU;SACX,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,KAAK,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,CAAC,iBAAiB,IAAI,UAAU,CAAC;QACnD,MAAM,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC;QAE/D,OAAO,CACL,oBAAC,QAAQ,kBACP,GAAG,EAAE,WAAW,IACZ,KAAK,IACT,eAAe,EAAE,WAAW,IAAI,WAAW,CAAC,KAAK,EACjD,GAAG,EAAE,WAAW,IAAI,WAAW,CAAC,UAAU,EAC1C,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,YAAY,EAAE,WAAW,GAAG,CAAC,EAC7B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,CAAC,IAAI,IACjC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { VirtualItem } from 'react-virtual';\nimport Item from '../parts/item';\nimport MutliselectItem from '../parts/multiselect-item';\nimport { DropdownOption } from '../../internal/components/option/interfaces';\nimport { getItemProps } from './get-item-props';\nimport { HighlightType } from '../../internal/components/options-list/utils/use-highlight-option';\n\nexport interface RenderOptionProps {\n options: ReadonlyArray<DropdownOption>;\n getOptionProps: any;\n filteringValue: string;\n highlightType: HighlightType;\n checkboxes?: boolean;\n hasDropdownStatus?: boolean;\n virtualItems?: VirtualItem[];\n useInteractiveGroups?: boolean;\n screenReaderContent?: string;\n ariaSetsize?: number;\n}\n\nexport const renderOptions = ({\n options,\n getOptionProps,\n filteringValue,\n highlightType,\n checkboxes = false,\n hasDropdownStatus,\n virtualItems,\n useInteractiveGroups,\n screenReaderContent,\n ariaSetsize,\n}: RenderOptionProps) => {\n return options.map((option, index) => {\n const virtualItem = virtualItems && virtualItems[index];\n const globalIndex = virtualItem ? virtualItem.index : index;\n const props = getItemProps({\n option,\n index: globalIndex,\n getOptionProps,\n filteringValue,\n checkboxes,\n });\n\n const isLastItem = index === options.length - 1;\n const padBottom = !hasDropdownStatus && isLastItem;\n const ListItem = useInteractiveGroups ? MutliselectItem : Item;\n\n return (\n <ListItem\n key={globalIndex}\n {...props}\n virtualPosition={virtualItem && virtualItem.start}\n ref={virtualItem && virtualItem.measureRef}\n padBottom={padBottom}\n screenReaderContent={screenReaderContent}\n ariaPosinset={globalIndex + 1}\n ariaSetsize={ariaSetsize}\n highlightType={highlightType.type}\n />\n );\n });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"render-options.js","sourceRoot":"","sources":["../../../../src/select/utils/render-options.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,IAAI,MAAM,eAAe,CAAC;AACjC,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgBhD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,EACP,cAAc,EACd,cAAc,EACd,aAAa,EACb,UAAU,GAAG,KAAK,EAClB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACO,EAAE,EAAE;IACtB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,YAAY,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;QACxD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5D,MAAM,KAAK,GAAG,YAAY,CAAC;YACzB,MAAM;YACN,KAAK,EAAE,WAAW;YAClB,cAAc;YACd,cAAc;YACd,UAAU;SACX,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,KAAK,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,CAAC,iBAAiB,IAAI,UAAU,CAAC;QACnD,MAAM,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC;QAE/D,OAAO,CACL,oBAAC,QAAQ,kBACP,GAAG,EAAE,WAAW,IACZ,KAAK,IACT,eAAe,EAAE,WAAW,IAAI,WAAW,CAAC,KAAK,EACjD,GAAG,EAAE,WAAW,IAAI,WAAW,CAAC,UAAU,EAC1C,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,YAAY,EAAE,WAAW,GAAG,CAAC,EAC7B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,CAAC,IAAI,IACjC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { VirtualItem } from '../../internal/vendor/react-virtual';\nimport Item from '../parts/item';\nimport MutliselectItem from '../parts/multiselect-item';\nimport { DropdownOption } from '../../internal/components/option/interfaces';\nimport { getItemProps } from './get-item-props';\nimport { HighlightType } from '../../internal/components/options-list/utils/use-highlight-option';\n\nexport interface RenderOptionProps {\n options: ReadonlyArray<DropdownOption>;\n getOptionProps: any;\n filteringValue: string;\n highlightType: HighlightType;\n checkboxes?: boolean;\n hasDropdownStatus?: boolean;\n virtualItems?: VirtualItem[];\n useInteractiveGroups?: boolean;\n screenReaderContent?: string;\n ariaSetsize?: number;\n}\n\nexport const renderOptions = ({\n options,\n getOptionProps,\n filteringValue,\n highlightType,\n checkboxes = false,\n hasDropdownStatus,\n virtualItems,\n useInteractiveGroups,\n screenReaderContent,\n ariaSetsize,\n}: RenderOptionProps) => {\n return options.map((option, index) => {\n const virtualItem = virtualItems && virtualItems[index];\n const globalIndex = virtualItem ? virtualItem.index : index;\n const props = getItemProps({\n option,\n index: globalIndex,\n getOptionProps,\n filteringValue,\n checkboxes,\n });\n\n const isLastItem = index === options.length - 1;\n const padBottom = !hasDropdownStatus && isLastItem;\n const ListItem = useInteractiveGroups ? MutliselectItem : Item;\n\n return (\n <ListItem\n key={globalIndex}\n {...props}\n virtualPosition={virtualItem && virtualItem.start}\n ref={virtualItem && virtualItem.measureRef}\n padBottom={padBottom}\n screenReaderContent={screenReaderContent}\n ariaPosinset={globalIndex + 1}\n ariaSetsize={ariaSetsize}\n highlightType={highlightType.type}\n />\n );\n });\n};\n"]}
|