@cloudscape-design/components 3.0.422 → 3.0.424
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/chart-container.d.ts.map +1 -1
- package/area-chart/chart-container.js +1 -1
- package/area-chart/chart-container.js.map +1 -1
- package/area-chart/elements/chart-popover.d.ts +2 -1
- package/area-chart/elements/chart-popover.d.ts.map +1 -1
- package/area-chart/elements/chart-popover.js +2 -2
- package/area-chart/elements/chart-popover.js.map +1 -1
- package/area-chart/model/use-chart-model.d.ts.map +1 -1
- package/area-chart/model/use-chart-model.js +3 -2
- package/area-chart/model/use-chart-model.js.map +1 -1
- package/autosuggest/autosuggest-option.js +1 -1
- package/autosuggest/autosuggest-option.js.map +1 -1
- package/autosuggest/plain-list.js +1 -1
- package/autosuggest/plain-list.js.map +1 -1
- package/autosuggest/virtual-list.js +1 -1
- package/autosuggest/virtual-list.js.map +1 -1
- package/internal/components/chart-popover/index.d.ts +1 -0
- package/internal/components/chart-popover/index.d.ts.map +1 -1
- package/internal/components/chart-popover/index.js +2 -2
- package/internal/components/chart-popover/index.js.map +1 -1
- package/internal/components/options-list/utils/use-highlight-option.d.ts +6 -2
- package/internal/components/options-list/utils/use-highlight-option.d.ts.map +1 -1
- package/internal/components/options-list/utils/use-highlight-option.js +13 -7
- package/internal/components/options-list/utils/use-highlight-option.js.map +1 -1
- package/internal/components/options-list/utils/use-open-state.d.ts +2 -1
- package/internal/components/options-list/utils/use-open-state.d.ts.map +1 -1
- package/internal/components/options-list/utils/use-open-state.js +5 -3
- package/internal/components/options-list/utils/use-open-state.js.map +1 -1
- package/internal/components/selectable-item/index.d.ts +1 -1
- package/internal/components/selectable-item/index.d.ts.map +1 -1
- package/internal/components/selectable-item/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/mixed-line-bar-chart/chart-container.d.ts.map +1 -1
- package/mixed-line-bar-chart/chart-container.js +1 -1
- package/mixed-line-bar-chart/chart-container.js.map +1 -1
- package/mixed-line-bar-chart/chart-popover.d.ts +1 -0
- package/mixed-line-bar-chart/chart-popover.d.ts.map +1 -1
- package/mixed-line-bar-chart/chart-popover.js +2 -2
- package/mixed-line-bar-chart/chart-popover.js.map +1 -1
- package/package.json +1 -1
- package/pie-chart/pie-chart.d.ts.map +1 -1
- package/pie-chart/pie-chart.js +1 -1
- package/pie-chart/pie-chart.js.map +1 -1
- package/select/parts/item.d.ts +1 -1
- package/select/parts/item.d.ts.map +1 -1
- package/select/parts/item.js.map +1 -1
- package/select/parts/multiselect-item.js +1 -1
- package/select/parts/multiselect-item.js.map +1 -1
- package/select/parts/plain-list.js +1 -1
- package/select/parts/plain-list.js.map +1 -1
- package/select/parts/virtual-list.js +1 -1
- package/select/parts/virtual-list.js.map +1 -1
- package/select/utils/render-options.js +1 -1
- package/select/utils/render-options.js.map +1 -1
- package/select/utils/use-select.d.ts.map +1 -1
- package/select/utils/use-select.js +22 -4
- package/select/utils/use-select.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-container.d.ts","sourceRoot":"lib/default/","sources":["area-chart/chart-container.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAiBrC,UAAU,mBAAmB,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,CAC9D,SAAQ,IAAI,CACV,cAAc,CAAC,CAAC,CAAC,EACf,QAAQ,GACR,QAAQ,GACR,gBAAgB,GAChB,gBAAgB,GAChB,sBAAsB,GACtB,mBAAmB,GACnB,qBAAqB,GACrB,WAAW,GACX,gBAAgB,GAChB,iBAAiB,GACjB,aAAa,CAChB;IACD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;;AAED,wBAA6D;AAE7D,iBAAS,cAAc,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,EAAE,EAC1D,KAAK,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAW,EAAE,EACX,cAAc,EAAE,wBAAwB,EACxC,cAAc,EAAE,wBAAwB,EACxC,oBAAoB,EAAE,8BAA8B,EACpD,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,GACzB,EACN,SAAS,EACT,SAAS,EACT,cAAyC,EACzC,cAAyC,EACzC,oBAAqD,GACtD,EAAE,mBAAmB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"chart-container.d.ts","sourceRoot":"lib/default/","sources":["area-chart/chart-container.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAiBrC,UAAU,mBAAmB,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,CAC9D,SAAQ,IAAI,CACV,cAAc,CAAC,CAAC,CAAC,EACf,QAAQ,GACR,QAAQ,GACR,gBAAgB,GAChB,gBAAgB,GAChB,sBAAsB,GACtB,mBAAmB,GACnB,qBAAqB,GACrB,WAAW,GACX,gBAAgB,GAChB,iBAAiB,GACjB,aAAa,CAChB;IACD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;;AAED,wBAA6D;AAE7D,iBAAS,cAAc,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,EAAE,EAC1D,KAAK,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAW,EAAE,EACX,cAAc,EAAE,wBAAwB,EACxC,cAAc,EAAE,wBAAwB,EACxC,oBAAoB,EAAE,8BAA8B,EACpD,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,GACzB,EACN,SAAS,EACT,SAAS,EACT,cAAyC,EACzC,cAAyC,EACzC,oBAAqD,GACtD,EAAE,mBAAmB,CAAC,CAAC,CAAC,eAiIxB"}
|
|
@@ -53,6 +53,6 @@ function ChartContainer({ model, autoWidth, xTitle, yTitle, detailPopoverSize, d
|
|
|
53
53
|
React.createElement(BottomLabels, Object.assign({}, bottomLabelsProps, { width: model.width, height: model.height, scale: model.computed.xScale, title: xTitle, ariaRoleDescription: xAxisAriaRoleDescription, offsetLeft: leftLabelsWidth + BOTTOM_LABELS_OFFSET, offsetRight: BOTTOM_LABELS_OFFSET })),
|
|
54
54
|
React.createElement(EmphasizedBaseline, { width: model.width, height: model.height, scale: model.computed.yScale }),
|
|
55
55
|
React.createElement(AreaVerticalMarker, { model: model }),
|
|
56
|
-
React.createElement(AreaHighlightedPoint, { ref: highlightedPointRef, model: model, ariaLabel: highlightDetails === null || highlightDetails === void 0 ? void 0 : highlightDetails.activeLabel })), popover: React.createElement(AreaChartPopover, { model: model, highlightDetails: highlightDetails, dismissAriaLabel: detailPopoverDismissAriaLabel, size: detailPopoverSize, footer: detailPopoverFooterContent }) }));
|
|
56
|
+
React.createElement(AreaHighlightedPoint, { ref: highlightedPointRef, model: model, ariaLabel: highlightDetails === null || highlightDetails === void 0 ? void 0 : highlightDetails.activeLabel })), popover: React.createElement(AreaChartPopover, { model: model, highlightDetails: highlightDetails, dismissAriaLabel: detailPopoverDismissAriaLabel, size: detailPopoverSize, footer: detailPopoverFooterContent, onBlur: model.handlers.onSVGBlur }) }));
|
|
57
57
|
}
|
|
58
58
|
//# sourceMappingURL=chart-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-container.js","sourceRoot":"lib/default/","sources":["area-chart/chart-container.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,SAAS,MAAM,mDAAmD,CAAC;AAC1E,OAAO,aAAa,MAAM,uDAAuD,CAAC;AAClF,OAAO,UAAU,MAAM,oDAAoD,CAAC;AAC5E,OAAO,YAAY,EAAE,EAAE,eAAe,EAAE,MAAM,sDAAsD,CAAC;AACrG,OAAO,kBAAkB,MAAM,4DAA4D,CAAC;AAG5F,OAAO,cAAc,MAAM,wBAAwB,CAAC;AACpD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAChE,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AAEjG,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAyBhC,eAAe,IAAI,CAAC,cAAc,CAA0B,CAAC;AAE7D,SAAS,cAAc,CAAqC,EAC1D,KAAK,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,cA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PDX-License-Identifier: Apache-2.0\nimport React, { useState, useEffect, memo, useRef, useMemo } from 'react';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport ChartPlot from '../internal/components/chart-plot';\nimport AxisLabel from '../internal/components/cartesian-chart/axis-label';\nimport LabelsMeasure from '../internal/components/cartesian-chart/labels-measure';\nimport LeftLabels from '../internal/components/cartesian-chart/left-labels';\nimport BottomLabels, { useBottomLabels } from '../internal/components/cartesian-chart/bottom-labels';\nimport EmphasizedBaseline from '../internal/components/cartesian-chart/emphasized-baseline';\nimport { AreaChartProps } from './interfaces';\nimport { ChartModel } from './model';\nimport AreaDataSeries from './elements/data-series';\nimport AreaChartPopover from './elements/chart-popover';\nimport AreaHighlightedPoint from './elements/highlighted-point';\nimport AreaVerticalMarker from './elements/vertical-marker';\n\nimport useHighlightDetails from './elements/use-highlight-details';\nimport useContainerWidth from '../internal/utils/use-container-width';\nimport { useSelector } from './async-store';\nimport { CartesianChartContainer } from '../internal/components/cartesian-chart/chart-container';\n\nconst DEFAULT_CHART_WIDTH = 500;\nconst LEFT_LABELS_MARGIN = 16;\nconst BOTTOM_LABELS_OFFSET = 12;\n\ntype TickFormatter = undefined | ((value: AreaChartProps.DataTypes) => string);\n\ninterface ChartContainerProps<T extends AreaChartProps.DataTypes>\n extends Pick<\n AreaChartProps<T>,\n | 'xTitle'\n | 'yTitle'\n | 'xTickFormatter'\n | 'yTickFormatter'\n | 'detailTotalFormatter'\n | 'detailPopoverSize'\n | 'detailPopoverFooter'\n | 'ariaLabel'\n | 'ariaLabelledby'\n | 'ariaDescription'\n | 'i18nStrings'\n > {\n model: ChartModel<T>;\n autoWidth: (value: number) => void;\n fitHeight?: boolean;\n minHeight: number;\n}\n\nexport default memo(ChartContainer) as typeof ChartContainer;\n\nfunction ChartContainer<T extends AreaChartProps.DataTypes>({\n model,\n autoWidth,\n xTitle,\n yTitle,\n detailPopoverSize,\n detailPopoverFooter,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n i18nStrings: {\n xTickFormatter: deprecatedXTickFormatter,\n yTickFormatter: deprecatedYTickFormatter,\n detailTotalFormatter: deprecatedDetailTotalFormatter,\n detailTotalLabel,\n chartAriaRoleDescription,\n xAxisAriaRoleDescription,\n yAxisAriaRoleDescription,\n detailPopoverDismissAriaLabel,\n } = {},\n fitHeight,\n minHeight,\n xTickFormatter = deprecatedXTickFormatter,\n yTickFormatter = deprecatedYTickFormatter,\n detailTotalFormatter = deprecatedDetailTotalFormatter,\n}: ChartContainerProps<T>) {\n const [leftLabelsWidth, setLeftLabelsWidth] = useState(0);\n const [containerWidth, containerWidthRef] = useContainerWidth(DEFAULT_CHART_WIDTH);\n const maxLeftLabelsWidth = Math.round(containerWidth / 2);\n\n const bottomLabelsProps = useBottomLabels({\n ticks: model.computed.xTicks,\n scale: model.computed.xScale,\n tickFormatter: xTickFormatter as TickFormatter,\n });\n\n // Calculate the width of the plot area and tell it to the parent.\n const plotWidth = Math.max(0, containerWidth - leftLabelsWidth - LEFT_LABELS_MARGIN);\n useEffect(() => {\n autoWidth(plotWidth);\n }, [autoWidth, plotWidth]);\n\n const highlightDetails = useHighlightDetails({\n model,\n xTickFormatter,\n yTickFormatter,\n detailTotalFormatter,\n detailTotalLabel,\n });\n\n const highlightedPointRef = useRef<SVGGElement>(null);\n\n const mergedRef = useMergeRefs(containerWidthRef, model.refs.container);\n\n const isPointHighlighted = model.interactions.get().highlightedPoint !== null;\n\n const highlightedX = useSelector(model.interactions, state => state.highlightedX);\n\n const detailPopoverFooterContent = useMemo(\n () => (detailPopoverFooter && highlightedX ? detailPopoverFooter(highlightedX[0].x) : null),\n [detailPopoverFooter, highlightedX]\n );\n\n return (\n <CartesianChartContainer\n ref={mergedRef}\n minHeight={minHeight + bottomLabelsProps.height}\n fitHeight={!!fitHeight}\n leftAxisLabel={<AxisLabel axis=\"y\" position=\"left\" title={yTitle} />}\n leftAxisLabelMeasure={\n <LabelsMeasure\n scale={model.computed.yScale}\n ticks={model.computed.yTicks}\n tickFormatter={yTickFormatter as TickFormatter}\n autoWidth={setLeftLabelsWidth}\n maxLabelsWidth={maxLeftLabelsWidth}\n />\n }\n bottomAxisLabel={<AxisLabel axis=\"x\" position=\"bottom\" title={xTitle} />}\n chartPlot={\n <ChartPlot\n ref={model.refs.plot}\n width=\"100%\"\n height={fitHeight ? `calc(100% - ${bottomLabelsProps.height}px)` : model.height}\n offsetBottom={bottomLabelsProps.height}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaRoleDescription={chartAriaRoleDescription}\n activeElementKey={!highlightDetails?.isPopoverPinned && highlightDetails?.activeLabel}\n activeElementRef={isPointHighlighted ? highlightedPointRef : model.refs.verticalMarker}\n activeElementFocusOffset={isPointHighlighted ? 3 : { x: 8, y: 0 }}\n isClickable={!highlightDetails?.isPopoverPinned}\n onMouseMove={model.handlers.onSVGMouseMove}\n onMouseOut={model.handlers.onSVGMouseOut}\n onMouseDown={model.handlers.onSVGMouseDown}\n onKeyDown={model.handlers.onSVGKeyDown}\n onFocus={model.handlers.onSVGFocus}\n onBlur={model.handlers.onSVGBlur}\n >\n <line\n ref={model.refs.plotMeasure}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n stroke=\"transparent\"\n strokeWidth={1}\n style={{ pointerEvents: 'none' }}\n />\n\n <LeftLabels\n plotWidth={model.width}\n plotHeight={model.height}\n scale={model.computed.yScale}\n ticks={model.computed.yTicks}\n tickFormatter={yTickFormatter}\n title={yTitle}\n ariaRoleDescription={yAxisAriaRoleDescription}\n maxLabelsWidth={maxLeftLabelsWidth}\n />\n\n <AreaDataSeries model={model} />\n\n <BottomLabels\n {...bottomLabelsProps}\n width={model.width}\n height={model.height}\n scale={model.computed.xScale}\n title={xTitle}\n ariaRoleDescription={xAxisAriaRoleDescription}\n offsetLeft={leftLabelsWidth + BOTTOM_LABELS_OFFSET}\n offsetRight={BOTTOM_LABELS_OFFSET}\n />\n\n <EmphasizedBaseline width={model.width} height={model.height} scale={model.computed.yScale} />\n\n <AreaVerticalMarker model={model} />\n\n <AreaHighlightedPoint ref={highlightedPointRef} model={model} ariaLabel={highlightDetails?.activeLabel} />\n </ChartPlot>\n }\n popover={\n <AreaChartPopover\n model={model}\n highlightDetails={highlightDetails}\n dismissAriaLabel={detailPopoverDismissAriaLabel}\n size={detailPopoverSize}\n footer={detailPopoverFooterContent}\n />\n }\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chart-container.js","sourceRoot":"lib/default/","sources":["area-chart/chart-container.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,SAAS,MAAM,mDAAmD,CAAC;AAC1E,OAAO,aAAa,MAAM,uDAAuD,CAAC;AAClF,OAAO,UAAU,MAAM,oDAAoD,CAAC;AAC5E,OAAO,YAAY,EAAE,EAAE,eAAe,EAAE,MAAM,sDAAsD,CAAC;AACrG,OAAO,kBAAkB,MAAM,4DAA4D,CAAC;AAG5F,OAAO,cAAc,MAAM,wBAAwB,CAAC;AACpD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAChE,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AAEjG,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,kBAAkB,G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f,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,6BAA6B,EAC/C,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,0BAA0B,EAClC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,SAAS,GAChC,GAEJ,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState, useEffect, memo, useRef, useMemo } from 'react';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport ChartPlot from '../internal/components/chart-plot';\nimport AxisLabel from '../internal/components/cartesian-chart/axis-label';\nimport LabelsMeasure from '../internal/components/cartesian-chart/labels-measure';\nimport LeftLabels from '../internal/components/cartesian-chart/left-labels';\nimport BottomLabels, { useBottomLabels } from '../internal/components/cartesian-chart/bottom-labels';\nimport EmphasizedBaseline from '../internal/components/cartesian-chart/emphasized-baseline';\nimport { AreaChartProps } from './interfaces';\nimport { ChartModel } from './model';\nimport AreaDataSeries from './elements/data-series';\nimport AreaChartPopover from './elements/chart-popover';\nimport AreaHighlightedPoint from './elements/highlighted-point';\nimport AreaVerticalMarker from './elements/vertical-marker';\n\nimport useHighlightDetails from './elements/use-highlight-details';\nimport useContainerWidth from '../internal/utils/use-container-width';\nimport { useSelector } from './async-store';\nimport { CartesianChartContainer } from '../internal/components/cartesian-chart/chart-container';\n\nconst DEFAULT_CHART_WIDTH = 500;\nconst LEFT_LABELS_MARGIN = 16;\nconst BOTTOM_LABELS_OFFSET = 12;\n\ntype TickFormatter = undefined | ((value: AreaChartProps.DataTypes) => string);\n\ninterface ChartContainerProps<T extends AreaChartProps.DataTypes>\n extends Pick<\n AreaChartProps<T>,\n | 'xTitle'\n | 'yTitle'\n | 'xTickFormatter'\n | 'yTickFormatter'\n | 'detailTotalFormatter'\n | 'detailPopoverSize'\n | 'detailPopoverFooter'\n | 'ariaLabel'\n | 'ariaLabelledby'\n | 'ariaDescription'\n | 'i18nStrings'\n > {\n model: ChartModel<T>;\n autoWidth: (value: number) => void;\n fitHeight?: boolean;\n minHeight: number;\n}\n\nexport default memo(ChartContainer) as typeof ChartContainer;\n\nfunction ChartContainer<T extends AreaChartProps.DataTypes>({\n model,\n autoWidth,\n xTitle,\n yTitle,\n detailPopoverSize,\n detailPopoverFooter,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n i18nStrings: {\n xTickFormatter: deprecatedXTickFormatter,\n yTickFormatter: deprecatedYTickFormatter,\n detailTotalFormatter: deprecatedDetailTotalFormatter,\n detailTotalLabel,\n chartAriaRoleDescription,\n xAxisAriaRoleDescription,\n yAxisAriaRoleDescription,\n detailPopoverDismissAriaLabel,\n } = {},\n fitHeight,\n minHeight,\n xTickFormatter = deprecatedXTickFormatter,\n yTickFormatter = deprecatedYTickFormatter,\n detailTotalFormatter = deprecatedDetailTotalFormatter,\n}: ChartContainerProps<T>) {\n const [leftLabelsWidth, setLeftLabelsWidth] = useState(0);\n const [containerWidth, containerWidthRef] = useContainerWidth(DEFAULT_CHART_WIDTH);\n const maxLeftLabelsWidth = Math.round(containerWidth / 2);\n\n const bottomLabelsProps = useBottomLabels({\n ticks: model.computed.xTicks,\n scale: model.computed.xScale,\n tickFormatter: xTickFormatter as TickFormatter,\n });\n\n // Calculate the width of the plot area and tell it to the parent.\n const plotWidth = Math.max(0, containerWidth - leftLabelsWidth - LEFT_LABELS_MARGIN);\n useEffect(() => {\n autoWidth(plotWidth);\n }, [autoWidth, plotWidth]);\n\n const highlightDetails = useHighlightDetails({\n model,\n xTickFormatter,\n yTickFormatter,\n detailTotalFormatter,\n detailTotalLabel,\n });\n\n const highlightedPointRef = useRef<SVGGElement>(null);\n\n const mergedRef = useMergeRefs(containerWidthRef, model.refs.container);\n\n const isPointHighlighted = model.interactions.get().highlightedPoint !== null;\n\n const highlightedX = useSelector(model.interactions, state => state.highlightedX);\n\n const detailPopoverFooterContent = useMemo(\n () => (detailPopoverFooter && highlightedX ? detailPopoverFooter(highlightedX[0].x) : null),\n [detailPopoverFooter, highlightedX]\n );\n\n return (\n <CartesianChartContainer\n ref={mergedRef}\n minHeight={minHeight + bottomLabelsProps.height}\n fitHeight={!!fitHeight}\n leftAxisLabel={<AxisLabel axis=\"y\" position=\"left\" title={yTitle} />}\n leftAxisLabelMeasure={\n <LabelsMeasure\n scale={model.computed.yScale}\n ticks={model.computed.yTicks}\n tickFormatter={yTickFormatter as TickFormatter}\n autoWidth={setLeftLabelsWidth}\n maxLabelsWidth={maxLeftLabelsWidth}\n />\n }\n bottomAxisLabel={<AxisLabel axis=\"x\" position=\"bottom\" title={xTitle} />}\n chartPlot={\n <ChartPlot\n ref={model.refs.plot}\n width=\"100%\"\n height={fitHeight ? `calc(100% - ${bottomLabelsProps.height}px)` : model.height}\n offsetBottom={bottomLabelsProps.height}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaRoleDescription={chartAriaRoleDescription}\n activeElementKey={!highlightDetails?.isPopoverPinned && highlightDetails?.activeLabel}\n activeElementRef={isPointHighlighted ? highlightedPointRef : model.refs.verticalMarker}\n activeElementFocusOffset={isPointHighlighted ? 3 : { x: 8, y: 0 }}\n isClickable={!highlightDetails?.isPopoverPinned}\n onMouseMove={model.handlers.onSVGMouseMove}\n onMouseOut={model.handlers.onSVGMouseOut}\n onMouseDown={model.handlers.onSVGMouseDown}\n onKeyDown={model.handlers.onSVGKeyDown}\n onFocus={model.handlers.onSVGFocus}\n onBlur={model.handlers.onSVGBlur}\n >\n <line\n ref={model.refs.plotMeasure}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n stroke=\"transparent\"\n strokeWidth={1}\n style={{ pointerEvents: 'none' }}\n />\n\n <LeftLabels\n plotWidth={model.width}\n plotHeight={model.height}\n scale={model.computed.yScale}\n ticks={model.computed.yTicks}\n tickFormatter={yTickFormatter}\n title={yTitle}\n ariaRoleDescription={yAxisAriaRoleDescription}\n maxLabelsWidth={maxLeftLabelsWidth}\n />\n\n <AreaDataSeries model={model} />\n\n <BottomLabels\n {...bottomLabelsProps}\n width={model.width}\n height={model.height}\n scale={model.computed.xScale}\n title={xTitle}\n ariaRoleDescription={xAxisAriaRoleDescription}\n offsetLeft={leftLabelsWidth + BOTTOM_LABELS_OFFSET}\n offsetRight={BOTTOM_LABELS_OFFSET}\n />\n\n <EmphasizedBaseline width={model.width} height={model.height} scale={model.computed.yScale} />\n\n <AreaVerticalMarker model={model} />\n\n <AreaHighlightedPoint ref={highlightedPointRef} model={model} ariaLabel={highlightDetails?.activeLabel} />\n </ChartPlot>\n }\n popover={\n <AreaChartPopover\n model={model}\n highlightDetails={highlightDetails}\n dismissAriaLabel={detailPopoverDismissAriaLabel}\n size={detailPopoverSize}\n footer={detailPopoverFooterContent}\n onBlur={model.handlers.onSVGBlur}\n />\n }\n />\n );\n}\n"]}
|
|
@@ -2,11 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { AreaChartProps } from '../interfaces';
|
|
3
3
|
import { ChartModel } from '../model';
|
|
4
4
|
import { HighlightDetails } from './use-highlight-details';
|
|
5
|
-
export default function AreaChartPopover<T extends AreaChartProps.DataTypes>({ model, highlightDetails, dismissAriaLabel, footer, size, }: {
|
|
5
|
+
export default function AreaChartPopover<T extends AreaChartProps.DataTypes>({ model, highlightDetails, dismissAriaLabel, footer, size, onBlur, }: {
|
|
6
6
|
model: ChartModel<T>;
|
|
7
7
|
highlightDetails: null | HighlightDetails;
|
|
8
8
|
dismissAriaLabel?: string;
|
|
9
9
|
footer?: React.ReactNode;
|
|
10
10
|
size?: 'small' | 'medium' | 'large';
|
|
11
|
+
onBlur?: (event: React.FocusEvent) => void;
|
|
11
12
|
}): JSX.Element | null;
|
|
12
13
|
//# sourceMappingURL=chart-popover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-popover.d.ts","sourceRoot":"lib/default/","sources":["area-chart/elements/chart-popover.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,EAAE,EAC3E,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,IAAI,
|
|
1
|
+
{"version":3,"file":"chart-popover.d.ts","sourceRoot":"lib/default/","sources":["area-chart/elements/chart-popover.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,EAAE,EAC3E,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,IAAI,EACJ,MAAM,GACP,EAAE;IACD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,gBAAgB,EAAE,IAAI,GAAG,gBAAgB,CAAC;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CAC5C,sBA6BA"}
|
|
@@ -5,7 +5,7 @@ import ChartPopover from '../../internal/components/chart-popover';
|
|
|
5
5
|
import ChartSeriesDetails from '../../internal/components/chart-series-details';
|
|
6
6
|
import InternalBox from '../../box/internal';
|
|
7
7
|
import styles from '../styles.css.js';
|
|
8
|
-
export default function AreaChartPopover({ model, highlightDetails, dismissAriaLabel, footer, size, }) {
|
|
8
|
+
export default function AreaChartPopover({ model, highlightDetails, dismissAriaLabel, footer, size, onBlur, }) {
|
|
9
9
|
if (!highlightDetails) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
@@ -18,7 +18,7 @@ export default function AreaChartPopover({ model, highlightDetails, dismissAriaL
|
|
|
18
18
|
onMouseLeave: model.handlers.onPopoverLeave,
|
|
19
19
|
ref: model.refs.popoverRef,
|
|
20
20
|
};
|
|
21
|
-
return (React.createElement(ChartPopover, Object.assign({}, popoverProps, { container: model.refs.container.current, dismissAriaLabel: dismissAriaLabel, size: size }),
|
|
21
|
+
return (React.createElement(ChartPopover, Object.assign({}, popoverProps, { container: model.refs.container.current, dismissAriaLabel: dismissAriaLabel, size: size, onBlur: onBlur }),
|
|
22
22
|
React.createElement(ChartSeriesDetails, { details: highlightDetails.seriesDetails }),
|
|
23
23
|
React.createElement("div", { className: styles['popover-divider'] }),
|
|
24
24
|
React.createElement(ChartSeriesDetails, { details: highlightDetails.totalDetails }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-popover.js","sourceRoot":"lib/default/","sources":["area-chart/elements/chart-popover.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,YAAY,MAAM,yCAAyC,CAAC;AACnE,OAAO,kBAAkB,MAAM,gDAAgD,CAAC;AAChF,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAI7C,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAGtC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAqC,EAC3E,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,IAAI,
|
|
1
|
+
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AAI,oBAAC,WAAW,IAAC,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAG,MAAM,CAAe,CACvD,CAChB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport ChartPopover from '../../internal/components/chart-popover';\nimport ChartSeriesDetails from '../../internal/components/chart-series-details';\nimport InternalBox from '../../box/internal';\n\nimport { AreaChartProps } from '../interfaces';\nimport { ChartModel } from '../model';\nimport styles from '../styles.css.js';\nimport { HighlightDetails } from './use-highlight-details';\n\nexport default function AreaChartPopover<T extends AreaChartProps.DataTypes>({\n model,\n highlightDetails,\n dismissAriaLabel,\n footer,\n size,\n onBlur,\n}: {\n model: ChartModel<T>;\n highlightDetails: null | HighlightDetails;\n dismissAriaLabel?: string;\n footer?: React.ReactNode;\n size?: 'small' | 'medium' | 'large';\n onBlur?: (event: React.FocusEvent) => void;\n}) {\n if (!highlightDetails) {\n return null;\n }\n\n const popoverProps = {\n title: highlightDetails.formattedX,\n trackRef: model.refs.verticalMarker,\n trackKey: highlightDetails.highlightIndex,\n dismissButton: highlightDetails.isPopoverPinned,\n onDismiss: model.handlers.onPopoverDismiss,\n onMouseLeave: model.handlers.onPopoverLeave,\n ref: model.refs.popoverRef,\n };\n\n return (\n <ChartPopover\n {...popoverProps}\n container={model.refs.container.current}\n dismissAriaLabel={dismissAriaLabel}\n size={size}\n onBlur={onBlur}\n >\n <ChartSeriesDetails details={highlightDetails.seriesDetails} />\n <div className={styles['popover-divider']} />\n <ChartSeriesDetails details={highlightDetails.totalDetails} />\n {footer && <InternalBox margin={{ top: 's' }}>{footer}</InternalBox>}\n </ChartPopover>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chart-model.d.ts","sourceRoot":"lib/default/","sources":["area-chart/model/use-chart-model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,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M,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;CACpC;AAGD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,EAAE,EACxE,SAAS,EACT,cAAc,EAAE,SAAS,EACzB,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,OAAO,EACP,OAAO,EACP,UAAU,EACV,UAAU,EACV,MAAM,EAAE,cAAc,EACtB,KAAK,EACL,UAAU,GACX,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CA2TvC"}
|
|
@@ -9,6 +9,7 @@ import { throttle } from '../../internal/utils/throttle';
|
|
|
9
9
|
import { useReaction } from '../async-store';
|
|
10
10
|
import { useHeightMeasure } from '../../internal/hooks/container-queries/use-height-measure';
|
|
11
11
|
import { useStableCallback } from '@cloudscape-design/component-toolkit/internal';
|
|
12
|
+
import { nodeBelongs } from '../../internal/utils/node-belongs';
|
|
12
13
|
const MAX_HOVER_MARGIN = 6;
|
|
13
14
|
const SVG_HOVER_THROTTLE = 25;
|
|
14
15
|
const POPOVER_DEADZONE = 12;
|
|
@@ -200,10 +201,10 @@ export default function useChartModel({ fitHeight, externalSeries: allSeries, vi
|
|
|
200
201
|
}
|
|
201
202
|
};
|
|
202
203
|
// A callback for svg blur to clear all highlights unless the popover is pinned.
|
|
203
|
-
const onSVGBlur = () => {
|
|
204
|
+
const onSVGBlur = (event) => {
|
|
204
205
|
// Pinned popover stays pinned even if the focus is lost.
|
|
205
206
|
// If blur is not caused by the popover, forget the previously highlighted point.
|
|
206
|
-
if (!interactions.get().isPopoverPinned) {
|
|
207
|
+
if (!nodeBelongs(containerRef.current, event.relatedTarget) && !interactions.get().isPopoverPinned) {
|
|
207
208
|
interactions.clearHighlight();
|
|
208
209
|
}
|
|
209
210
|
};
|
|
@@ -1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;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';\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 svg focus to highlight series.\n const onSVGFocus = (_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 svg blur to clear all highlights unless the popover is pinned.\n const onSVGBlur = () => {\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 (!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 onSVGFocus,\n onSVGBlur,\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":"lib/default/","sources":["area-chart/model/use-chart-model.ts"],"names":[],"mappings":"AAGA,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAyB,MAAM,OAAO,CAAC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,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';\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 svg focus to highlight series.\n const onSVGFocus = (_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 svg blur to clear all highlights unless the popover is pinned.\n const onSVGBlur = (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 onSVGFocus,\n onSVGBlur,\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"]}
|
|
@@ -34,7 +34,7 @@ const AutosuggestOption = (_a, ref) => {
|
|
|
34
34
|
optionContent = (React.createElement("div", Object.assign({}, a11yProperties),
|
|
35
35
|
React.createElement(OptionComponent, { option: option, highlightedOption: highlighted, highlightText: highlightText })));
|
|
36
36
|
}
|
|
37
|
-
return (React.createElement(SelectableItem, Object.assign({}, baseProps, { className: styles.option, ariaSelected: current, highlighted: highlighted, disabled: option.disabled, hasBackground: useEntered, isParent: isParent, isChild: isChild, virtualPosition: virtualPosition, "data-test-index": throughIndex, "data-in-group-index": inGroupIndex, "data-group-index": groupIndex, ref: ref, padBottom: padBottom, screenReaderContent: screenReaderContent, ariaSetsize: ariaSetsize, ariaPosinset: ariaPosinset, highlightType: highlightType }), optionContent));
|
|
37
|
+
return (React.createElement(SelectableItem, Object.assign({}, baseProps, { className: styles.option, ariaSelected: current, highlighted: highlighted, disabled: option.disabled, hasBackground: useEntered, isParent: isParent, isChild: isChild, virtualPosition: virtualPosition, "data-test-index": throughIndex, "data-in-group-index": inGroupIndex, "data-group-index": groupIndex, ref: ref, padBottom: padBottom, screenReaderContent: screenReaderContent, ariaSetsize: ariaSetsize, ariaPosinset: ariaPosinset, highlightType: highlightType.type }), optionContent));
|
|
38
38
|
};
|
|
39
39
|
export default React.memo(React.forwardRef(AutosuggestOption));
|
|
40
40
|
//# sourceMappingURL=autosuggest-option.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autosuggest-option.js","sourceRoot":"lib/default/","sources":["autosuggest/autosuggest-option.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAC5D,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAsB,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAE9F,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAiBlD,MAAM,iBAAiB,GAAG,CACxB,EAcy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,YAAY,CAAC,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;SAC/D;QAED,aAAa,GAAG,CACd,6CAAS,cAAc;YACrB,oBAAC,eAAe,IAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,GAAI,CAC7F,CACP,CAAC;KACH;IAED,OAAO,CACL,oBAAC,cAAc,oBACT,SAAS,IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EACxB,YAAY,EAAE,OAAO,EACrB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,eAAe,qBACf,YAAY,yBACR,YAAY,sBACf,UAAU,EAC5B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"autosuggest-option.js","sourceRoot":"lib/default/","sources":["autosuggest/autosuggest-option.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAC5D,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAsB,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAE9F,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAiBlD,MAAM,iBAAiB,GAAG,CACxB,EAcyB,EACzB,GAA8B,EAC9B,EAAE;QAhBF,EACE,gBAAgB,GAAG,EAAE,EACrB,aAAa,EACb,MAAM,EACN,WA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c;YACrB,oBAAC,eAAe,IAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,GAAI,CAC7F,CACP,CAAC;KACH;IAED,OAAO,CACL,oBAAC,cAAc,oBACT,SAAS,IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EACxB,YAAY,EAAE,OAAO,EACrB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,eAAe,qBACf,YAAY,yBACR,YAAY,sBACf,UAAU,EAC5B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,CAAC,IAAI,KAEhC,aAAa,CACC,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport OptionComponent from '../internal/components/option';\nimport SelectableItem from '../internal/components/selectable-item';\nimport { BaseComponentProps, getBaseProps } from '../internal/base-component';\nimport { getTestOptionIndexes } from '../internal/components/options-list/utils/test-indexes';\n\nimport styles from './styles.css.js';\nimport { AutosuggestItem } from './interfaces';\nimport { HighlightType } from '../internal/components/options-list/utils/use-highlight-option';\nimport { useInternalI18n } from '../i18n/context';\n\nexport interface AutosuggestOptionProps extends BaseComponentProps {\n nativeAttributes?: Record<string, any>;\n highlightText: string;\n option: AutosuggestItem;\n highlighted: boolean;\n highlightType: HighlightType;\n current: boolean;\n enteredTextLabel?: (value: string) => string;\n virtualPosition?: number;\n padBottom?: boolean;\n screenReaderContent?: string;\n ariaSetsize?: number;\n ariaPosinset?: number;\n}\n\nconst AutosuggestOption = (\n {\n nativeAttributes = {},\n highlightText,\n option,\n highlighted,\n highlightType,\n current,\n enteredTextLabel,\n virtualPosition,\n padBottom,\n screenReaderContent,\n ariaSetsize,\n ariaPosinset,\n ...rest\n }: AutosuggestOptionProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n const baseProps = getBaseProps(rest);\n const i18n = useInternalI18n('autosuggest');\n const useEntered = 'type' in option && option.type === 'use-entered';\n const isParent = 'type' in option && option.type === 'parent';\n const isChild = 'type' in option && option.type === 'child';\n const { throughIndex, inGroupIndex, groupIndex } = getTestOptionIndexes(option) || {};\n\n let optionContent;\n if (useEntered) {\n optionContent = i18n('enteredTextLabel', enteredTextLabel?.(option.value || ''), format =>\n format({ value: option.value || '' })\n );\n // we don't want fancy generated content for screenreader for the \"Use...\" option,\n // just the visible text is fine\n screenReaderContent = undefined;\n } else if (isParent) {\n optionContent = option.label;\n } else {\n const a11yProperties: AutosuggestOptionProps['nativeAttributes'] = {};\n if (nativeAttributes['aria-label']) {\n a11yProperties['aria-label'] = nativeAttributes['aria-label'];\n }\n\n optionContent = (\n <div {...a11yProperties}>\n <OptionComponent option={option} highlightedOption={highlighted} highlightText={highlightText} />\n </div>\n );\n }\n\n return (\n <SelectableItem\n {...baseProps}\n className={styles.option}\n ariaSelected={current}\n highlighted={highlighted}\n disabled={option.disabled}\n hasBackground={useEntered}\n isParent={isParent}\n isChild={isChild}\n virtualPosition={virtualPosition}\n data-test-index={throughIndex}\n data-in-group-index={inGroupIndex}\n data-group-index={groupIndex}\n ref={ref}\n padBottom={padBottom}\n screenReaderContent={screenReaderContent}\n ariaSetsize={ariaSetsize}\n ariaPosinset={ariaPosinset}\n highlightType={highlightType.type}\n >\n {optionContent}\n </SelectableItem>\n );\n};\n\nexport default React.memo(React.forwardRef(AutosuggestOption));\n"]}
|
|
@@ -19,7 +19,7 @@ const PlainList = ({ autosuggestItemsState, handleLoadMore, menuProps, enteredTe
|
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
var _a;
|
|
21
21
|
const item = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-mouse-target="${autosuggestItemsState.highlightedIndex}"]`);
|
|
22
|
-
if (autosuggestItemsState.highlightType
|
|
22
|
+
if (autosuggestItemsState.highlightType.moveFocus && item) {
|
|
23
23
|
scrollElementIntoView(item);
|
|
24
24
|
}
|
|
25
25
|
}, [autosuggestItemsState.highlightType, autosuggestItemsState.highlightedIndex]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plain-list.js","sourceRoot":"lib/default/","sources":["autosuggest/plain-list.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,WAAiC,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAErD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAerC,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAa,EACb,IAAqB,EACrB,aAAyC,EACzC,oBAAuD,EACvD,iBAAmC,EACnC,iBAA2B,EAC3B,EAAE;IACF,MAAM,gBAAgB,GAAG,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChF,MAAM,eAAe,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,KAAK,KAAK,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACtD,MAAM,oBAAoB,GAAG,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,CAAC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;YAEF,OAAO,CACL,oBAAC,iBAAiB,kBAChB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,IAAI,EACZ,WAAW,EAAE,IAAI,KAAK,qBAAqB,CAAC,iBAAiB,EAC7D,OAAO,EAAE,IAAI,CAAC,KAAK,KAAK,aAAa,EACrC,GAAG,EAAE,KAAK,uBACS,KAAK,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,qBAAqB,CAAC,aAAa,IAC9C,WAAW,EACf,CACH,CAAC;QACJ,CAAC,CAAC;QACD,UAAU,CAAC,CAAC,CAAC,CACZ,4BAAI,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,IAC/C,UAAU,CACR,CACN,CAAC,CAAC,CAAC,IAAI,CACI,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,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';\n\nimport OptionsList, { OptionsListProps } from '../internal/components/options-list';\nimport { scrollElementIntoView } from '../internal/utils/scrollable-containers';\nimport { getBaseProps } from '../internal/base-component';\n\nimport AutosuggestOption from './autosuggest-option';\nimport { AutosuggestProps, AutosuggestItem } from './interfaces';\nimport styles from './styles.css.js';\nimport { AutosuggestItemsState } from './options-controller';\n\nexport interface ListProps {\n autosuggestItemsState: AutosuggestItemsState;\n menuProps: Omit<OptionsListProps, 'children'>;\n handleLoadMore: () => void;\n enteredTextLabel?: AutosuggestProps.EnteredTextLabel;\n highlightedA11yProps: Record<string, string | number | boolean>;\n hasDropdownStatus?: boolean;\n highlightText: string;\n listBottom?: React.ReactNode;\n screenReaderContent?: string;\n}\n\nexport const getOptionProps = (\n index: number,\n item: AutosuggestItem,\n filteredItems: readonly AutosuggestItem[],\n highlightedA11yProps: ListProps['highlightedA11yProps'],\n highlightedOption?: AutosuggestItem,\n hasDropdownStatus?: boolean\n) => {\n const nativeAttributes = item === highlightedOption ? highlightedA11yProps : {};\n const baseOptionProps = getBaseProps(nativeAttributes);\n const isLastItem = index === filteredItems.length - 1;\n const isNotEnteredTextItem = filteredItems.length > 1;\n const padBottom = !hasDropdownStatus && isNotEnteredTextItem && isLastItem;\n\n return { nativeAttributes, padBottom, ...baseOptionProps };\n};\n\nconst PlainList = ({\n autosuggestItemsState,\n handleLoadMore,\n menuProps,\n enteredTextLabel,\n highlightedA11yProps,\n hasDropdownStatus,\n highlightText,\n listBottom,\n screenReaderContent,\n}: ListProps) => {\n const listRef = useRef<HTMLUListElement>(null);\n useEffect(() => {\n const item = listRef.current?.querySelector<HTMLElement>(\n `[data-mouse-target=\"${autosuggestItemsState.highlightedIndex}\"]`\n );\n if (autosuggestItemsState.highlightType.moveFocus && item) {\n scrollElementIntoView(item);\n }\n }, [autosuggestItemsState.highlightType, autosuggestItemsState.highlightedIndex]);\n\n return (\n <OptionsList\n {...menuProps}\n onLoadMore={handleLoadMore}\n open={true}\n ref={listRef}\n // to prevent closing the list when clicking the scrollbar on IE11\n nativeAttributes={{ unselectable: 'on' }}\n >\n {autosuggestItemsState.items.map((item, index) => {\n const optionProps = getOptionProps(\n index,\n item,\n autosuggestItemsState.items,\n highlightedA11yProps,\n autosuggestItemsState.highlightedOption,\n hasDropdownStatus\n );\n\n return (\n <AutosuggestOption\n highlightText={highlightText}\n option={item}\n highlighted={item === autosuggestItemsState.highlightedOption}\n current={item.value === highlightText}\n key={index}\n data-mouse-target={index}\n enteredTextLabel={enteredTextLabel}\n screenReaderContent={screenReaderContent}\n highlightType={autosuggestItemsState.highlightType}\n {...optionProps}\n />\n );\n })}\n {listBottom ? (\n <li role=\"option\" className={styles['list-bottom']}>\n {listBottom}\n </li>\n ) : null}\n </OptionsList>\n );\n};\n\nexport default PlainList;\n"]}
|
|
@@ -23,7 +23,7 @@ const VirtualList = ({ autosuggestItemsState, handleLoadMore, menuProps, entered
|
|
|
23
23
|
estimateSize: useCallback(() => 31, [width, highlightText]),
|
|
24
24
|
});
|
|
25
25
|
useEffect(() => {
|
|
26
|
-
if (autosuggestItemsState.highlightType
|
|
26
|
+
if (autosuggestItemsState.highlightType.moveFocus) {
|
|
27
27
|
rowVirtualizer.scrollToIndex(autosuggestItemsState.highlightedIndex);
|
|
28
28
|
}
|
|
29
29
|
}, [autosuggestItemsState.highlightType, autosuggestItemsState.highlightedIndex, rowVirtualizer]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-list.js","sourceRoot":"lib/default/","sources":["autosuggest/virtual-list.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEnF,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAE9D,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAa,MAAM,cAAc,CAAC;AACzD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,MAAM,WAAW,GAAG,CAAC,EACnB,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,mBAAmB,GACT,EAAE,EAAE;IACd,MAAM,SAAS,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IACjD,uEAAuE;IACvE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC9E,mBAAmB,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC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CAAC,KAAK,CAAC,CAAC;YAChD,MAAM,WAAW,GAAG,cAAc,CAChC,KAAK,EACL,IAAI,EACJ,qBAAqB,CAAC,KAAK,EAC3B,oBAAoB,EACpB,qBAAqB,CAAC,iBAAiB,EACvC,iBAAiB,CAClB,CAAC;YAEF,OAAO,CACL,oBAAC,iBAAiB,kBAChB,GAAG,EAAE,KAAK,EACV,GAAG,EAAE,UAAU,EACf,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,IAAI,EACZ,WAAW,EAAE,IAAI,KAAK,qBAAqB,CAAC,iBAAiB,EAC7D,OAAO,EAAE,IAAI,CAAC,KAAK,KAAK,aAAa,uBAClB,KAAK,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC9C,mBAAmB,EAAE,mBAAmB,EACxC,WAAW,EAAE,qBAAqB,CAAC,KAAK,CAAC,MAAM,EAC/C,YAAY,EAAE,KAAK,GAAG,CAAC,EACvB,aAAa,EAAE,qBAAqB,CAAC,aAAa,IAC9C,WAAW,EACf,CACH,CAAC;QACJ,CAAC,CAAC;QACD,UAAU,CAAC,CAAC,CAAC,CACZ,4BAAI,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,IAC/C,UAAU,CACR,CACN,CAAC,CAAC,CAAC,IAAI,CACI,CACf,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, { useCallback, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport OptionsList from '../internal/components/options-list';\n\nimport AutosuggestOption from './autosuggest-option';\nimport { getOptionProps, ListProps } from './plain-list';\nimport styles from './styles.css.js';\nimport { useVirtual } from '../internal/hooks/use-virtual';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\n\nconst VirtualList = ({\n autosuggestItemsState,\n handleLoadMore,\n menuProps,\n enteredTextLabel,\n highlightedA11yProps,\n hasDropdownStatus,\n highlightText,\n listBottom,\n screenReaderContent,\n}: ListProps) => {\n const scrollRef = useRef<HTMLUListElement>(null);\n // update component, when it gets wider or narrower to reposition items\n const [width, strutRef] = useContainerQuery(rect => rect.contentBoxWidth, []);\n useImperativeHandle(strutRef, () => scrollRef.current);\n\n const rowVirtualizer = useVirtual({\n items: autosuggestItemsState.items,\n parentRef: scrollRef,\n // estimateSize is a dependency of measurements memo. We update it to force full recalculation\n // when the height of any option could have changed:\n // 1: because the component got resized (width property got updated)\n // 2: because the option changed its content (highlightText property controls the highlight and the visibility of hidden tags)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n estimateSize: useCallback(() => 31, [width, highlightText]),\n });\n\n useEffect(() => {\n if (autosuggestItemsState.highlightType.moveFocus) {\n rowVirtualizer.scrollToIndex(autosuggestItemsState.highlightedIndex);\n }\n }, [autosuggestItemsState.highlightType, autosuggestItemsState.highlightedIndex, rowVirtualizer]);\n\n return (\n <OptionsList\n {...menuProps}\n onLoadMore={handleLoadMore}\n ref={scrollRef}\n open={true}\n // to prevent closing the list when clicking the scrollbar on IE11\n nativeAttributes={{ unselectable: 'on' }}\n >\n <div\n aria-hidden=\"true\"\n key=\"total-size\"\n className={styles['layout-strut']}\n style={{ height: rowVirtualizer.totalSize + (autosuggestItemsState.items.length === 1 ? 1 : 0) }}\n />\n {rowVirtualizer.virtualItems.map(virtualRow => {\n const { index, start, measureRef } = virtualRow;\n const item = autosuggestItemsState.items[index];\n const optionProps = getOptionProps(\n index,\n item,\n autosuggestItemsState.items,\n highlightedA11yProps,\n autosuggestItemsState.highlightedOption,\n hasDropdownStatus\n );\n\n return (\n <AutosuggestOption\n key={index}\n ref={measureRef}\n highlightText={highlightText}\n option={item}\n highlighted={item === autosuggestItemsState.highlightedOption}\n current={item.value === highlightText}\n data-mouse-target={index}\n enteredTextLabel={enteredTextLabel}\n virtualPosition={start + (index === 0 ? 1 : 0)}\n screenReaderContent={screenReaderContent}\n ariaSetsize={autosuggestItemsState.items.length}\n ariaPosinset={index + 1}\n highlightType={autosuggestItemsState.highlightType}\n {...optionProps}\n />\n );\n })}\n {listBottom ? (\n <li role=\"option\" className={styles['list-bottom']}>\n {listBottom}\n </li>\n ) : null}\n </OptionsList>\n );\n};\n\nexport default VirtualList;\n"]}
|
|
@@ -23,6 +23,7 @@ export interface ChartPopoverProps extends PopoverProps {
|
|
|
23
23
|
onMouseEnter?: (event: React.MouseEvent) => void;
|
|
24
24
|
/** Fired when the pointer leaves the hoverable area around the popover */
|
|
25
25
|
onMouseLeave?: (event: React.MouseEvent) => void;
|
|
26
|
+
onBlur?: (event: React.FocusEvent) => void;
|
|
26
27
|
/** Popover content */
|
|
27
28
|
children?: React.ReactNode;
|
|
28
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/chart-popover/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAMjD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAS3D,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,2BAA2B;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAExB,kEAAkE;IAClE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACnC;;;;;;;;MAQE;IACF,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3B,+FAA+F;IAC/F,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAE1B,wDAAwD;IACxD,SAAS,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAE5C,0EAA0E;IAC1E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAEjD,0EAA0E;IAC1E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAEjD,sBAAsB;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;;AAED,wBAA8C"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/chart-popover/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAMjD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAS3D,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,2BAA2B;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAExB,kEAAkE;IAClE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACnC;;;;;;;;MAQE;IACF,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3B,+FAA+F;IAC/F,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAE1B,wDAAwD;IACxD,SAAS,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAE5C,0EAA0E;IAC1E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAEjD,0EAA0E;IAC1E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAEjD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAE3C,sBAAsB;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;;AAED,wBAA8C"}
|
|
@@ -13,7 +13,7 @@ import styles from './styles.css.js';
|
|
|
13
13
|
import { nodeBelongs } from '../../utils/node-belongs';
|
|
14
14
|
export default React.forwardRef(ChartPopover);
|
|
15
15
|
function ChartPopover(_a, ref) {
|
|
16
|
-
var { position = 'right', size = 'medium', fixedWidth = false, dismissButton = false, dismissAriaLabel, children, title, trackRef, trackKey, onDismiss, container, onMouseEnter, onMouseLeave } = _a, restProps = __rest(_a, ["position", "size", "fixedWidth", "dismissButton", "dismissAriaLabel", "children", "title", "trackRef", "trackKey", "onDismiss", "container", "onMouseEnter", "onMouseLeave"]);
|
|
16
|
+
var { position = 'right', size = 'medium', fixedWidth = false, dismissButton = false, dismissAriaLabel, children, title, trackRef, trackKey, onDismiss, container, onMouseEnter, onMouseLeave, onBlur } = _a, restProps = __rest(_a, ["position", "size", "fixedWidth", "dismissButton", "dismissAriaLabel", "children", "title", "trackRef", "trackKey", "onDismiss", "container", "onMouseEnter", "onMouseLeave", "onBlur"]);
|
|
17
17
|
const baseProps = getBaseProps(restProps);
|
|
18
18
|
const popoverObjectRef = useRef(null);
|
|
19
19
|
const popoverRef = useMergeRefs(popoverObjectRef, ref);
|
|
@@ -31,7 +31,7 @@ function ChartPopover(_a, ref) {
|
|
|
31
31
|
document.removeEventListener('mousedown', onDocumentClick, { capture: true });
|
|
32
32
|
};
|
|
33
33
|
}, [container, onDismiss]);
|
|
34
|
-
return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(popoverStyles.root, styles.root, baseProps.className), ref: popoverRef, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }),
|
|
34
|
+
return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(popoverStyles.root, styles.root, baseProps.className), ref: popoverRef, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onBlur: onBlur }),
|
|
35
35
|
React.createElement(PopoverContainer, { size: size, fixedWidth: fixedWidth, position: position, trackRef: trackRef, trackKey: trackKey, arrow: position => (React.createElement("div", { className: clsx(popoverStyles.arrow, popoverStyles[`arrow-position-${position}`]) },
|
|
36
36
|
React.createElement("div", { className: popoverStyles['arrow-outer'] }),
|
|
37
37
|
React.createElement("div", { className: popoverStyles['arrow-inner'] }))) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/chart-popover/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;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/chart-popover/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;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAqCvD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IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,EACrE,GAAG,EAAE,UAAU,EACf,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM;QAEd,oBAAC,gBAAgB,IACf,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CACjB,6BAAK,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC;gBACpF,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI;gBAChD,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI,CAC5C,CACP;YAED,6BAAK,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC;gBAClC,oBAAC,WAAW,IACV,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,SAAS,EACpB,eAAe,EAAC,SAAS,EACzB,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IAEhC,QAAQ,CACG,CACV,CACW,CACf,CACP,CAAC;AACJ,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 { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport { getBaseProps } from '../../base-component';\n\nimport { PopoverProps } from '../../../popover/interfaces';\nimport PopoverContainer from '../../../popover/container';\nimport PopoverBody from '../../../popover/body';\nimport popoverStyles from '../../../popover/styles.css.js';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\n\nimport styles from './styles.css.js';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\nexport interface ChartPopoverProps extends PopoverProps {\n /** Title of the popover */\n title?: React.ReactNode;\n\n /** References the element the container is positioned against. */\n trackRef: React.RefObject<Element>;\n /**\n Used to update the container position in case track or track position changes:\n \n const trackRef = useRef<Element>(null)\n return (<>\n <Track style={getPosition(selectedItemId)} ref={trackRef} />\n <PopoverContainer trackRef={trackRef} trackKey={selectedItemId} .../>\n </>)\n */\n trackKey?: string | number;\n\n /** Optional container element that prevents any clicks in there from dismissing the popover */\n container: Element | null;\n\n /** Event that is fired when the popover is dismissed */\n onDismiss: (outsideClick?: boolean) => void;\n\n /** Fired when the pointer enters the hoverable area around the popover */\n onMouseEnter?: (event: React.MouseEvent) => void;\n\n /** Fired when the pointer leaves the hoverable area around the popover */\n onMouseLeave?: (event: React.MouseEvent) => void;\n\n onBlur?: (event: React.FocusEvent) => void;\n\n /** Popover content */\n children?: React.ReactNode;\n}\n\nexport default React.forwardRef(ChartPopover);\n\nfunction ChartPopover(\n {\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n dismissButton = false,\n dismissAriaLabel,\n\n children,\n\n title,\n trackRef,\n trackKey,\n onDismiss,\n container,\n\n onMouseEnter,\n onMouseLeave,\n onBlur,\n\n ...restProps\n }: ChartPopoverProps,\n ref: React.Ref<HTMLElement>\n) {\n const baseProps = getBaseProps(restProps);\n const popoverObjectRef = useRef<HTMLDivElement | null>(null);\n\n const popoverRef = useMergeRefs(popoverObjectRef, ref);\n\n useEffect(() => {\n const onDocumentClick = (event: MouseEvent) => {\n if (\n event.target &&\n !nodeBelongs(popoverObjectRef.current, event.target as Element) && // click not in popover\n !nodeContains(container, event.target as Element) // click not in segment\n ) {\n onDismiss(true);\n }\n };\n\n document.addEventListener('mousedown', onDocumentClick, { capture: true });\n return () => {\n document.removeEventListener('mousedown', onDocumentClick, { capture: true });\n };\n }, [container, onDismiss]);\n\n return (\n <div\n {...baseProps}\n className={clsx(popoverStyles.root, styles.root, baseProps.className)}\n ref={popoverRef}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onBlur={onBlur}\n >\n <PopoverContainer\n size={size}\n fixedWidth={fixedWidth}\n position={position}\n trackRef={trackRef}\n trackKey={trackKey}\n arrow={position => (\n <div className={clsx(popoverStyles.arrow, popoverStyles[`arrow-position-${position}`])}>\n <div className={popoverStyles['arrow-outer']} />\n <div className={popoverStyles['arrow-inner']} />\n </div>\n )}\n >\n <div className={styles['hover-area']}>\n <PopoverBody\n dismissButton={dismissButton}\n dismissAriaLabel={dismissAriaLabel}\n header={title}\n onDismiss={onDismiss}\n overflowVisible=\"content\"\n className={styles['popover-body']}\n >\n {children}\n </PopoverBody>\n </div>\n </PopoverContainer>\n </div>\n );\n}\n"]}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare class HighlightType {
|
|
2
|
+
type: 'keyboard' | 'mouse';
|
|
3
|
+
moveFocus: boolean;
|
|
4
|
+
constructor(type: 'keyboard' | 'mouse', moveFocus?: boolean);
|
|
5
|
+
}
|
|
2
6
|
export interface HighlightedOptionProps<OptionType> {
|
|
3
7
|
options: readonly OptionType[];
|
|
4
8
|
isHighlightable: (option: OptionType) => boolean;
|
|
@@ -9,7 +13,7 @@ export interface HighlightedOptionState<OptionType> {
|
|
|
9
13
|
highlightedOption?: OptionType;
|
|
10
14
|
}
|
|
11
15
|
export interface HighlightedOptionHandlers<OptionType> {
|
|
12
|
-
setHighlightedIndexWithMouse(index: number): void;
|
|
16
|
+
setHighlightedIndexWithMouse(index: number, moveFocus?: boolean): void;
|
|
13
17
|
moveHighlightWithKeyboard(direction: -1 | 1): void;
|
|
14
18
|
highlightOptionWithKeyboard(option: OptionType): void;
|
|
15
19
|
resetHighlightWithKeyboard(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-highlight-option.d.ts","sourceRoot":"lib/default/","sources":["internal/components/options-list/utils/use-highlight-option.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"use-highlight-option.d.ts","sourceRoot":"lib/default/","sources":["internal/components/options-list/utils/use-highlight-option.ts"],"names":[],"mappings":"AAIA,qBAAa,aAAa;IACL,IAAI,EAAE,UAAU,GAAG,OAAO;IAAS,SAAS,EAAE,OAAO;gBAArD,IAAI,EAAE,UAAU,GAAG,OAAO,EAAS,SAAS,GAAE,OAA6B;CAC/F;AAED,MAAM,WAAW,sBAAsB,CAAC,UAAU;IAChD,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,eAAe,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;CAClD;AAED,MAAM,WAAW,sBAAsB,CAAC,UAAU;IAChD,aAAa,EAAE,aAAa,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,yBAAyB,CAAC,UAAU;IAEnD,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvE,yBAAyB,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACnD,2BAA2B,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACtD,0BAA0B,IAAI,IAAI,CAAC;IACnC,kBAAkB,IAAI,IAAI,CAAC;IAC3B,iBAAiB,IAAI,IAAI,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,EAC/C,OAAO,EACP,eAAe,GAChB,EAAE,sBAAsB,CAAC,UAAU,CAAC,GAAG,CAAC,sBAAsB,CAAC,UAAU,CAAC,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC,CA6ClH"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useCallback, useState } from 'react';
|
|
4
|
+
export class HighlightType {
|
|
5
|
+
constructor(type, moveFocus = type === 'keyboard') {
|
|
6
|
+
this.type = type;
|
|
7
|
+
this.moveFocus = moveFocus;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
4
10
|
export function useHighlightedOption({ options, isHighlightable, }) {
|
|
5
11
|
const [highlightedIndex, setHighlightedIndexState] = useState(-1);
|
|
6
|
-
const [highlightType, setHighlightType] = useState('keyboard');
|
|
12
|
+
const [highlightType, setHighlightType] = useState(new HighlightType('keyboard'));
|
|
7
13
|
const setHighlightedIndex = useCallback((index, highlightType) => {
|
|
8
14
|
setHighlightedIndexState(index);
|
|
9
15
|
setHighlightType(highlightType);
|
|
@@ -26,12 +32,12 @@ export function useHighlightedOption({ options, isHighlightable, }) {
|
|
|
26
32
|
return [
|
|
27
33
|
{ highlightType, highlightedIndex, highlightedOption },
|
|
28
34
|
{
|
|
29
|
-
setHighlightedIndexWithMouse: (index) => setHighlightedIndex(index, 'mouse'),
|
|
30
|
-
moveHighlightWithKeyboard: (direction) => moveHighlight(direction, 'keyboard'),
|
|
31
|
-
highlightOptionWithKeyboard: (option) => highlightOption(option, 'keyboard'),
|
|
32
|
-
resetHighlightWithKeyboard: () => setHighlightedIndex(-1, 'keyboard'),
|
|
33
|
-
goHomeWithKeyboard: () => moveHighlightFrom(1, -1, 'keyboard'),
|
|
34
|
-
goEndWithKeyboard: () => moveHighlightFrom(-1, options.length, 'keyboard'),
|
|
35
|
+
setHighlightedIndexWithMouse: (index, moveFocus = false) => setHighlightedIndex(index, new HighlightType('mouse', moveFocus)),
|
|
36
|
+
moveHighlightWithKeyboard: (direction) => moveHighlight(direction, new HighlightType('keyboard')),
|
|
37
|
+
highlightOptionWithKeyboard: (option) => highlightOption(option, new HighlightType('keyboard')),
|
|
38
|
+
resetHighlightWithKeyboard: () => setHighlightedIndex(-1, new HighlightType('keyboard')),
|
|
39
|
+
goHomeWithKeyboard: () => moveHighlightFrom(1, -1, new HighlightType('keyboard')),
|
|
40
|
+
goEndWithKeyboard: () => moveHighlightFrom(-1, options.length, new HighlightType('keyboard')),
|
|
35
41
|
},
|
|
36
42
|
];
|
|
37
43
|
}
|