@fluentui/react-charts 9.3.21 → 9.3.23

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +25 -2
  2. package/lib/components/DonutChart/Arc/Arc.js +3 -2
  3. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  4. package/lib/components/DonutChart/Pie/Pie.js +3 -1
  5. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  6. package/lib/components/FunnelChart/FunnelChart.js +14 -3
  7. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  8. package/lib/components/GanttChart/GanttChart.js +5 -2
  9. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  10. package/lib/components/GaugeChart/GaugeChart.js +6 -3
  11. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  12. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +9 -3
  13. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  14. package/lib/components/HeatMapChart/HeatMapChart.js +8 -3
  15. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  16. package/lib/components/HorizontalBarChart/HorizontalBarChart.js +8 -5
  17. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  18. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +2 -2
  19. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  20. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +1 -1
  21. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  22. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +17 -5
  23. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  24. package/lib/components/Legends/Legends.js +62 -32
  25. package/lib/components/Legends/Legends.js.map +1 -1
  26. package/lib/components/Legends/OverflowMenu.js +47 -9
  27. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  28. package/lib/components/SankeyChart/SankeyChart.js +13 -7
  29. package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
  30. package/lib/components/ScatterChart/ScatterChart.js +3 -3
  31. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  32. package/lib/components/VerticalBarChart/VerticalBarChart.js +19 -7
  33. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  34. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +16 -10
  35. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  36. package/lib/utilities/utilities.js +2 -2
  37. package/lib/utilities/utilities.js.map +1 -1
  38. package/lib-commonjs/components/DonutChart/Arc/Arc.js +3 -2
  39. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  40. package/lib-commonjs/components/DonutChart/Pie/Pie.js +3 -1
  41. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  42. package/lib-commonjs/components/FunnelChart/FunnelChart.js +14 -3
  43. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  44. package/lib-commonjs/components/GanttChart/GanttChart.js +5 -2
  45. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  46. package/lib-commonjs/components/GaugeChart/GaugeChart.js +6 -3
  47. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  48. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +9 -3
  49. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  50. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +8 -3
  51. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  52. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +8 -5
  53. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  54. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +4 -4
  55. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  56. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +1 -1
  57. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  58. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +17 -5
  59. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  60. package/lib-commonjs/components/Legends/Legends.js +62 -32
  61. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  62. package/lib-commonjs/components/Legends/OverflowMenu.js +46 -8
  63. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  64. package/lib-commonjs/components/SankeyChart/SankeyChart.js +13 -7
  65. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
  66. package/lib-commonjs/components/ScatterChart/ScatterChart.js +3 -3
  67. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  68. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +19 -7
  69. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  70. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +16 -10
  71. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  72. package/lib-commonjs/utilities/utilities.js +2 -2
  73. package/lib-commonjs/utilities/utilities.js.map +1 -1
  74. package/package.json +4 -4
@@ -80,7 +80,7 @@ const Legends = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
80
80
  const itemIds = dataToRender.map((_item, index)=>index.toString());
81
81
  const overflowHoverCardLegends = [];
82
82
  dataToRender.map((legend, index)=>{
83
- const hoverCardElement = _renderButton(legend, index);
83
+ const hoverCardElement = _renderButton(legend, index, true);
84
84
  overflowHoverCardLegends.push(hoverCardElement);
85
85
  });
86
86
  const overflowString = props.overflowText ? props.overflowText : 'more';
@@ -89,11 +89,6 @@ const Legends = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
89
89
  return /*#__PURE__*/ _react.createElement("div", {
90
90
  ...focusAttributes,
91
91
  ...arrowAttributes,
92
- ...allowFocusOnLegends && {
93
- role: 'listbox',
94
- 'aria-label': 'Legends',
95
- 'aria-multiselectable': canSelectMultipleLegends
96
- },
97
92
  className: classes.root,
98
93
  ref: _rootElem
99
94
  }, /*#__PURE__*/ _react.createElement(_reactoverflow.Overflow, null, /*#__PURE__*/ _react.createElement("div", {
@@ -101,10 +96,19 @@ const Legends = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
101
96
  style: {
102
97
  textAlign: props.centerLegends ? 'center' : 'unset'
103
98
  }
99
+ }, /*#__PURE__*/ _react.createElement("div", {
100
+ ...allowFocusOnLegends && {
101
+ role: 'listbox',
102
+ 'aria-label': 'Legends',
103
+ 'aria-multiselectable': canSelectMultipleLegends
104
+ },
105
+ style: {
106
+ display: 'contents'
107
+ }
104
108
  }, dataToRender.map((item, id)=>/*#__PURE__*/ _react.createElement(_reactoverflow.OverflowItem, {
105
109
  key: id,
106
110
  id: id.toString()
107
- }, _renderButton(item))), /*#__PURE__*/ _react.createElement(_OverflowMenu.OverflowMenu, {
111
+ }, _renderButton(item, id)))), /*#__PURE__*/ _react.createElement(_OverflowMenu.OverflowMenu, {
108
112
  itemIds: itemIds,
109
113
  title: `${overflowString}`,
110
114
  items: overflowHoverCardLegends
@@ -133,10 +137,10 @@ const Legends = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
133
137
  flexWrap: 'wrap',
134
138
  overflow: 'auto'
135
139
  }
136
- }, dataToRender.map((item)=>/*#__PURE__*/ _react.createElement("div", {
140
+ }, dataToRender.map((item, id)=>/*#__PURE__*/ _react.createElement("div", {
137
141
  className: (0, _react1.mergeClasses)(classes.legendContainer, item.legendAnnotation && classes.annotation),
138
142
  key: item.key
139
- }, _renderButton(item), item.legendAnnotation && /*#__PURE__*/ _react.createElement("div", null, item.legendAnnotation())))));
143
+ }, _renderButton(item, id), item.legendAnnotation && /*#__PURE__*/ _react.createElement("div", null, item.legendAnnotation())))));
140
144
  }
141
145
  function _generateData() {
142
146
  const { shape } = props;
@@ -227,8 +231,10 @@ const Legends = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
227
231
  }
228
232
  }
229
233
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
230
- function _renderButton(data, index) {
234
+ function _renderButton(data, index, isOverflowItem) {
231
235
  const { allowFocusOnLegends = true } = props;
236
+ // Overflow legends are rendered inside a menu, not the listbox, so they must not carry `option` semantics.
237
+ const showListboxOption = allowFocusOnLegends && !isOverflowItem;
232
238
  const legend = {
233
239
  title: data.title,
234
240
  color: data.color,
@@ -251,38 +257,62 @@ const Legends = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
251
257
  _onLeave(legend);
252
258
  };
253
259
  const shape = _getShape(legend, color);
260
+ const legendStyle = {
261
+ '--rect-height': legend.isLineLegendInBarChart ? '4px' : '12px',
262
+ '--rect-backgroundColor': legend.stripePattern ? '' : color,
263
+ '--rect-borderColor': legend.color ? legend.color : _reacttheme.tokens.colorNeutralStroke1,
264
+ '--rect-content': legend.stripePattern ? `repeating-linear-gradient(135deg, transparent, transparent 3px, ${color} 1px, ${color} 4px)` : ''
265
+ };
266
+ const legendContent = /*#__PURE__*/ _react.createElement(_react.Fragment, null, shape, /*#__PURE__*/ _react.createElement("div", {
267
+ className: classes.text,
268
+ style: {
269
+ opacity: color === _reacttheme.tokens.colorNeutralBackground1 ? '0.67' : ''
270
+ }
271
+ }, legend.title));
272
+ // Shared by the listbox Button and the overflow div. Hover/focus handlers are included so the overflow
273
+ // menu can forward them to its item (the div itself never receives focus).
274
+ const commonProps = {
275
+ className: classes.legend,
276
+ onClick: onClickHandler,
277
+ onMouseOver: onHoverHandler,
278
+ onMouseOut: onMouseOut,
279
+ onFocus: onHoverHandler,
280
+ onBlur: onMouseOut,
281
+ style: legendStyle
282
+ };
283
+ if (isOverflowItem) {
284
+ // In the overflow menu the item itself is interactive, so keep this content a non-interactive div to
285
+ // avoid nested clickable elements. display:flex lays the swatch and label out inline (a bare div would
286
+ // stack them). data-selected / data-title are read by the overflow menu to drive its checked state.
287
+ return /*#__PURE__*/ _react.createElement("div", {
288
+ key: index,
289
+ ...commonProps,
290
+ "data-selected": !!selectedLegends[legend.title],
291
+ "data-title": legend.title,
292
+ style: {
293
+ ...legendStyle,
294
+ display: 'flex',
295
+ alignItems: 'center'
296
+ }
297
+ }, legendContent);
298
+ }
254
299
  return /*#__PURE__*/ _react.createElement(_reactbutton.Button, {
255
- ...allowFocusOnLegends && {
300
+ ...showListboxOption && {
256
301
  'aria-selected': !!selectedLegends[legend.title],
257
302
  role: 'option',
258
303
  'aria-label': `${legend.title}`,
259
- 'aria-setsize': data['aria-setsize'],
260
- 'aria-posinset': data['aria-posinset']
304
+ // Full-list position so counts match the overflow menu.
305
+ 'aria-setsize': props.legends.length,
306
+ 'aria-posinset': (index !== null && index !== void 0 ? index : 0) + 1
261
307
  },
262
308
  ...data.nativeButtonProps && {
263
309
  ...data.nativeButtonProps
264
310
  },
265
311
  key: index,
266
- className: classes.legend,
267
- onClick: onClickHandler,
268
- onMouseOver: onHoverHandler,
269
- onMouseOut: onMouseOut,
270
- onFocus: onHoverHandler,
271
- onBlur: onMouseOut,
312
+ ...commonProps,
272
313
  appearance: 'outline',
273
- size: "small",
274
- style: {
275
- '--rect-height': legend.isLineLegendInBarChart ? '4px' : '12px',
276
- '--rect-backgroundColor': legend.stripePattern ? '' : color,
277
- '--rect-borderColor': legend.color ? legend.color : _reacttheme.tokens.colorNeutralStroke1,
278
- '--rect-content': legend.stripePattern ? `repeating-linear-gradient(135deg, transparent, transparent 3px, ${color} 1px, ${color} 4px)` : ''
279
- }
280
- }, shape, /*#__PURE__*/ _react.createElement("div", {
281
- className: classes.text,
282
- style: {
283
- opacity: color === _reacttheme.tokens.colorNeutralBackground1 ? '0.67' : ''
284
- }
285
- }, legend.title));
314
+ size: "small"
315
+ }, legendContent);
286
316
  }
287
317
  function _getShape(legend, color) {
288
318
  const svgParentProps = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Legends/Legends.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\n\nimport { Button } from '@fluentui/react-button';\nimport type { Legend, LegendsProps, LegendShape } from './Legends.types';\nimport { Shape } from './shape';\nimport { useLegendStyles } from './useLegendsStyles.styles';\nimport { Overflow, OverflowItem } from '@fluentui/react-overflow';\nimport { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { OverflowMenu } from './OverflowMenu';\nimport { tokens } from '@fluentui/react-theme';\nimport { cloneLegendsToSVG } from '../../utilities/image-export-utils';\nimport { mergeClasses } from '@griffel/react';\n\n// This is an internal interface used for rendering the legends with unique key\ninterface LegendItem extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n name?: string;\n title: string;\n action: VoidFunction;\n hoverAction: VoidFunction;\n onMouseOutAction: VoidFunction;\n color: string;\n shape?: LegendShape;\n key: number;\n opacity?: number;\n stripePattern?: boolean;\n isLineLegendInBarChart?: boolean;\n legendAnnotation?: () => React.ReactNode;\n}\n\ninterface LegendMap {\n [key: string]: boolean;\n}\n\nexport interface LegendState {\n activeLegend: string;\n /** Set of legends selected, both for multiple selection and single selection */\n selectedLegends: LegendMap;\n}\nexport const Legends: React.FunctionComponent<LegendsProps> = React.forwardRef<HTMLDivElement, LegendsProps>(\n (props, forwardedRef) => {\n /** Boolean variable to check if one or more legends are selected */\n let _isLegendSelected = false;\n const _rootElem = React.useRef<HTMLDivElement | null>(null);\n\n // set states separately for each instance of the component\n const [activeLegend, setActiveLegend] = React.useState('');\n const [selectedLegends, setSelectedLegends] = React.useState<LegendMap>({});\n const focusAttributes = useFocusableGroup();\n const arrowAttributes = useArrowNavigationGroup({ axis: 'horizontal', memorizeCurrent: true });\n const classes = useLegendStyles(props);\n const toSVG = React.useCallback(\n (svgWidth: number, isRTL: boolean = false) => {\n return cloneLegendsToSVG(\n props.legends,\n svgWidth,\n {\n selectedLegends,\n centerLegends: !!props.centerLegends,\n textClassName: classes.text!,\n isRTL,\n },\n _rootElem.current,\n );\n },\n [props.legends, props.centerLegends, selectedLegends, classes.text],\n );\n\n React.useImperativeHandle(props.legendRef, () => ({\n toSVG,\n }));\n\n React.useEffect(() => {\n const initialSelectedLegends = props.selectedLegends ?? props.defaultSelectedLegends;\n const initialSelectedLegend = props.selectedLegend ?? props.defaultSelectedLegend;\n let selectedLegendsState = {};\n if (props.canSelectMultipleLegends) {\n selectedLegendsState =\n (initialSelectedLegends ?? [])?.reduce(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (combineDict: any, key: any) => ({ [key]: true, ...combineDict }),\n {},\n ) || {};\n setSelectedLegends(selectedLegendsState);\n } else if (initialSelectedLegend !== undefined) {\n selectedLegendsState = { [initialSelectedLegend]: true };\n setSelectedLegends(selectedLegendsState);\n }\n }, [\n props.canSelectMultipleLegends,\n props.defaultSelectedLegend,\n props.defaultSelectedLegends,\n props.selectedLegend,\n props.selectedLegends,\n ]);\n\n _isLegendSelected = Object.keys(selectedLegends).length > 0;\n const dataToRender = _generateData();\n const { overflowStyles, allowFocusOnLegends = true, canSelectMultipleLegends = false } = props;\n const itemIds = dataToRender.map((_item, index) => index.toString());\n const overflowHoverCardLegends: JSXElement[] = [];\n dataToRender.map((legend, index) => {\n const hoverCardElement = _renderButton(legend, index);\n overflowHoverCardLegends.push(hoverCardElement);\n });\n const overflowString = props.overflowText ? props.overflowText : 'more';\n return props.enabledWrapLines ? renderWrappedLegends() : renderLegends();\n\n function renderLegends(): JSXElement {\n return (\n <div\n {...focusAttributes}\n {...arrowAttributes}\n {...(allowFocusOnLegends && {\n role: 'listbox',\n 'aria-label': 'Legends',\n 'aria-multiselectable': canSelectMultipleLegends,\n })}\n className={classes.root}\n ref={_rootElem}\n >\n <Overflow>\n <div className={classes.resizableArea} style={{ textAlign: props.centerLegends ? 'center' : 'unset' }}>\n {dataToRender.map((item, id) => (\n <OverflowItem key={id} id={id.toString()}>\n {_renderButton(item)}\n </OverflowItem>\n ))}\n <OverflowMenu itemIds={itemIds} title={`${overflowString}`} items={overflowHoverCardLegends} />\n </div>\n </Overflow>\n </div>\n );\n }\n\n function renderWrappedLegends(): JSXElement {\n return (\n <div\n {...focusAttributes}\n {...arrowAttributes}\n {...(allowFocusOnLegends && {\n role: 'listbox',\n 'aria-label': 'Legends',\n 'aria-multiselectable': canSelectMultipleLegends,\n })}\n style={{ justifyContent: props.centerLegends ? 'center' : 'unset', flexWrap: 'wrap', ...overflowStyles }}\n className={classes.root}\n ref={_rootElem}\n >\n <div className={classes.resizableArea} style={{ display: 'flex', flexWrap: 'wrap', overflow: 'auto' }}>\n {dataToRender.map(item => (\n <div\n className={mergeClasses(classes.legendContainer, item.legendAnnotation && classes.annotation)}\n key={item.key}\n >\n {_renderButton(item)}\n {item.legendAnnotation && <div>{item.legendAnnotation()}</div>}\n </div>\n ))}\n </div>\n </div>\n );\n }\n\n function _generateData(): LegendItem[] {\n const { /*allowFocusOnLegends = true,*/ shape } = props;\n const dataItems: LegendItem[] = props.legends.map((legend: Legend, index: number) => {\n return {\n /* ...(allowFocusOnLegends && {\n nativeButtonProps: getIntrinsicElementProps(\n 'div',\n {\n legend,\n ...buttonProperties,\n },\n ['title'],\n ),\n 'aria-setsize': props.legends.length,\n 'aria-posinset': index + 1,\n }), */\n title: legend.title,\n action: legend.action!,\n hoverAction: legend.hoverAction!,\n onMouseOutAction: legend.onMouseOutAction!,\n color: legend.color,\n shape: shape ? shape : legend.shape,\n stripePattern: legend.stripePattern,\n isLineLegendInBarChart: legend.isLineLegendInBarChart,\n opacity: legend.opacity,\n key: index,\n legendAnnotation: legend.legendAnnotation,\n };\n });\n return dataItems;\n }\n\n /**\n * Determine whether the component is in \"controlled\" mode for selections, where the selected legend(s) are\n * determined entirely by props passed in from the parent component.\n */\n function _isInControlledMode(): boolean {\n return props.canSelectMultipleLegends ? props.selectedLegends !== undefined : props.selectedLegend !== undefined;\n }\n\n /**\n * Get the new selected legends based on the legend that was clicked when multi-select is enabled.\n * @param legend The legend that was clicked\n * @returns An object with the new selected legend(s) state data.\n */\n function _getNewSelectedLegendsForMultiselect(legend: Legend): { [key: string]: boolean } {\n let legendsSelected = { ...selectedLegends };\n if (legendsSelected[legend.title]) {\n // Delete entry for the deselected legend to make\n // the number of keys equal to the number of selected legends\n delete legendsSelected[legend.title];\n } else {\n legendsSelected[legend.title] = true;\n // Clear set if all legends are selected\n if (Object.keys(legendsSelected).length === props.legends.length) {\n legendsSelected = {};\n }\n }\n return legendsSelected;\n }\n\n /**\n * Get the new selected legends based on the legend that was clicked when single-select is enabled.\n * @param legend The legend that was clicked\n * @returns An object with the new selected legend state data.\n */\n function _getNewSelectedLegendsForSingleSelect(legend: Legend): { [key: string]: boolean } {\n return selectedLegends[legend.title] ? {} : { [legend.title]: true };\n }\n\n function _onClick(legend: Legend, event: React.MouseEvent<HTMLButtonElement>): void {\n const { canSelectMultipleLegends = false } = props;\n const nextSelectedLegends = canSelectMultipleLegends\n ? _getNewSelectedLegendsForMultiselect(legend)\n : _getNewSelectedLegendsForSingleSelect(legend);\n\n if (!_isInControlledMode()) {\n setSelectedLegends(nextSelectedLegends);\n }\n props.onChange?.(Object.keys(nextSelectedLegends), event, legend);\n legend.action?.();\n }\n\n function _onHoverOverLegend(legend: Legend) {\n if (legend.hoverAction) {\n setActiveLegend(legend.title);\n legend.hoverAction();\n }\n }\n\n function _onLeave(legend: Legend) {\n if (legend.onMouseOutAction) {\n setActiveLegend('');\n legend.onMouseOutAction();\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function _renderButton(data: any, index?: number) {\n const { allowFocusOnLegends = true } = props;\n const legend: Legend = {\n title: data.title,\n color: data.color,\n shape: data.shape,\n action: data.action,\n hoverAction: data.hoverAction,\n onMouseOutAction: data.onMouseOutAction,\n stripePattern: data.stripePattern,\n isLineLegendInBarChart: data.isLineLegendInBarChart,\n opacity: data.opacity,\n };\n const color = _getColor(legend.title, legend.color);\n const onClickHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n _onClick(legend, event);\n };\n const onHoverHandler = () => {\n _onHoverOverLegend(legend);\n };\n const onMouseOut = () => {\n _onLeave(legend);\n };\n const shape = _getShape(legend, color);\n return (\n <Button\n {...(allowFocusOnLegends && {\n 'aria-selected': !!selectedLegends[legend.title],\n role: 'option',\n 'aria-label': `${legend.title}`,\n 'aria-setsize': data['aria-setsize'],\n 'aria-posinset': data['aria-posinset'],\n })}\n {...(data.nativeButtonProps && { ...data.nativeButtonProps })}\n key={index}\n className={classes.legend}\n onClick={onClickHandler}\n onMouseOver={onHoverHandler}\n onMouseOut={onMouseOut}\n onFocus={onHoverHandler}\n onBlur={onMouseOut}\n appearance={'outline'}\n size=\"small\"\n style={{\n '--rect-height': legend.isLineLegendInBarChart ? '4px' : '12px',\n '--rect-backgroundColor': legend.stripePattern ? '' : color,\n '--rect-borderColor': legend.color ? legend.color : tokens.colorNeutralStroke1,\n '--rect-content': legend.stripePattern\n ? `repeating-linear-gradient(135deg, transparent, transparent 3px, ${color} 1px, ${color} 4px)`\n : '',\n }}\n >\n {shape}\n <div className={classes.text} style={{ opacity: color === tokens.colorNeutralBackground1 ? '0.67' : '' }}>\n {legend.title}\n </div>\n </Button>\n );\n }\n\n function _getShape(legend: Legend, color: string): React.ReactNode | string {\n const svgParentProps: React.SVGAttributes<SVGElement> = {\n className: classes.shape,\n };\n const svgChildProps: React.SVGAttributes<SVGElement> = {\n fill: color,\n strokeWidth: 2,\n stroke: legend.color,\n };\n return (\n <Shape\n svgProps={svgParentProps}\n pathProps={svgChildProps}\n shape={legend.shape as LegendShape}\n classNameForNonSvg={classes.rect}\n style={\n {\n height: legend.isLineLegendInBarChart ? '4px' : '12px',\n backgroundColor: legend.stripePattern ? '' : color,\n borderColor: legend.color ? legend.color : tokens.colorNeutralStroke1,\n content: legend.stripePattern\n ? `repeating-linear-gradient(135deg, transparent, transparent 3px, ${color} 1px, ${color} 4px)`\n : '',\n '--rect-content-high-contrast': `linear-gradient(to right, ${color}, ${color})`,\n '--rect-opacity-high-contrast': color === tokens.colorNeutralBackground1 ? '0.6' : '',\n } as React.CSSProperties\n }\n />\n );\n }\n\n function _getColor(title: string, color: string): string {\n let legendColor = color;\n // if one or more legends are selected\n if (_isLegendSelected) {\n // if the given legend (title) is one of the selected legends\n if (selectedLegends[title]) {\n legendColor = color;\n }\n // if the given legend is unselected\n else {\n legendColor = tokens.colorNeutralBackground1;\n }\n }\n // if no legend is selected\n else {\n // if the given legend is hovered\n // or none of the legends is hovered\n if (activeLegend === title || activeLegend === '') {\n legendColor = color;\n }\n // if there is a hovered legend but the given legend is not the one\n else {\n legendColor = tokens.colorNeutralBackground1;\n }\n }\n return legendColor;\n }\n },\n);\nLegends.displayName = 'Legends';\n"],"names":["React","Button","Shape","useLegendStyles","Overflow","OverflowItem","useFocusableGroup","useArrowNavigationGroup","OverflowMenu","tokens","cloneLegendsToSVG","mergeClasses","Legends","forwardRef","props","forwardedRef","_isLegendSelected","_rootElem","useRef","activeLegend","setActiveLegend","useState","selectedLegends","setSelectedLegends","focusAttributes","arrowAttributes","axis","memorizeCurrent","classes","toSVG","useCallback","svgWidth","isRTL","legends","centerLegends","textClassName","text","current","useImperativeHandle","legendRef","useEffect","initialSelectedLegends","defaultSelectedLegends","initialSelectedLegend","selectedLegend","defaultSelectedLegend","selectedLegendsState","canSelectMultipleLegends","reduce","combineDict","key","undefined","Object","keys","length","dataToRender","_generateData","overflowStyles","allowFocusOnLegends","itemIds","map","_item","index","toString","overflowHoverCardLegends","legend","hoverCardElement","_renderButton","push","overflowString","overflowText","enabledWrapLines","renderWrappedLegends","renderLegends","div","role","className","root","ref","resizableArea","style","textAlign","item","id","title","items","justifyContent","flexWrap","display","overflow","legendContainer","legendAnnotation","annotation","shape","dataItems","action","hoverAction","onMouseOutAction","color","stripePattern","isLineLegendInBarChart","opacity","_isInControlledMode","_getNewSelectedLegendsForMultiselect","legendsSelected","_getNewSelectedLegendsForSingleSelect","_onClick","event","nextSelectedLegends","onChange","_onHoverOverLegend","_onLeave","data","_getColor","onClickHandler","onHoverHandler","onMouseOut","_getShape","nativeButtonProps","onClick","onMouseOver","onFocus","onBlur","appearance","size","colorNeutralStroke1","colorNeutralBackground1","svgParentProps","svgChildProps","fill","strokeWidth","stroke","svgProps","pathProps","classNameForNonSvg","rect","height","backgroundColor","borderColor","content","legendColor","displayName"],"mappings":"AAAA;;;;;+BAyCaY;;;;;;;iEAvCU,QAAQ;6BAGR,yBAAyB;uBAE1B,UAAU;wCACA,4BAA4B;+BACrB,2BAA2B;8BACP,0BAA0B;8BACxD,iBAAiB;4BACvB,wBAAwB;kCACb,qCAAqC;wBAC1C,iBAAiB;AA2BvC,gBAAMA,WAAAA,GAAiDZ,OAAMa,UAAU,CAC5E,CAACC,OAAOC;IACN,kEAAkE,GAClE,IAAIC,oBAAoB;IACxB,MAAMC,YAAYjB,OAAMkB,MAAM,CAAwB;IAEtD,2DAA2D;IAC3D,MAAM,CAACC,cAAcC,gBAAgB,GAAGpB,OAAMqB,QAAQ,CAAC;IACvD,MAAM,CAACC,iBAAiBC,mBAAmB,GAAGvB,OAAMqB,QAAQ,CAAY,CAAC;IACzE,MAAMG,sBAAkBlB,+BAAAA;IACxB,MAAMmB,sBAAkBlB,qCAAAA,EAAwB;QAAEmB,MAAM;QAAcC,iBAAiB;IAAK;IAC5F,MAAMC,UAAUzB,2CAAAA,EAAgBW;IAChC,MAAMe,QAAQ7B,OAAM8B,WAAW,CAC7B,CAACC,UAAkBC,QAAiB,KAAK;QACvC,WAAOtB,mCAAAA,EACLI,MAAMmB,OAAO,EACbF,UACA;YACET;YACAY,eAAe,CAAC,CAACpB,MAAMoB,aAAa;YACpCC,eAAeP,QAAQQ,IAA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AgE,EAAED,MAAM,MAAM,EAAEA,MAAM,KAAK,CAAC,GAC7F;gBACJ,gCAAgC,CAAC,0BAA0B,EAAEA,MAAM,EAAE,EAAEA,MAAM,CAAC,CAAC;gBAC/E,gCAAgCA,UAAUzF,kBAAAA,CAAOqH,uBAAuB,GAAG,QAAQ;YACrF;;IAIR;IAEA,SAASb,UAAU7B,KAAa,EAAEc,KAAa;QAC7C,IAAI0C,cAAc1C;QAClB,sCAAsC;QACtC,IAAIlF,mBAAmB;YACrB,6DAA6D;YAC7D,IAAIM,eAAe,CAAC8D,MAAM,EAAE;gBAC1BwD,cAAc1C;YAChB,OAEK;gBACH0C,cAAcnI,kBAAAA,CAAOqH,uBAAuB;YAC9C;QACF,OAEK;YACH,iCAAiC;YACjC,oCAAoC;YACpC,IAAI3G,iBAAiBiE,SAASjE,iBAAiB,IAAI;gBACjDyH,cAAc1C;YAChB,OAEK;gBACH0C,cAAcnI,kBAAAA,CAAOqH,uBAAuB;YAC9C;QACF;QACA,OAAOc;IACT;AACF,GACA;AACFhI,QAAQiI,WAAW,GAAG"}
1
+ {"version":3,"sources":["../src/components/Legends/Legends.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\n\nimport { Button } from '@fluentui/react-button';\nimport type { Legend, LegendsProps, LegendShape } from './Legends.types';\nimport { Shape } from './shape';\nimport { useLegendStyles } from './useLegendsStyles.styles';\nimport { Overflow, OverflowItem } from '@fluentui/react-overflow';\nimport { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { OverflowMenu } from './OverflowMenu';\nimport { tokens } from '@fluentui/react-theme';\nimport { cloneLegendsToSVG } from '../../utilities/image-export-utils';\nimport { mergeClasses } from '@griffel/react';\n\n// This is an internal interface used for rendering the legends with unique key\ninterface LegendItem extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n name?: string;\n title: string;\n action: VoidFunction;\n hoverAction: VoidFunction;\n onMouseOutAction: VoidFunction;\n color: string;\n shape?: LegendShape;\n key: number;\n opacity?: number;\n stripePattern?: boolean;\n isLineLegendInBarChart?: boolean;\n legendAnnotation?: () => React.ReactNode;\n}\n\ninterface LegendMap {\n [key: string]: boolean;\n}\n\nexport interface LegendState {\n activeLegend: string;\n /** Set of legends selected, both for multiple selection and single selection */\n selectedLegends: LegendMap;\n}\nexport const Legends: React.FunctionComponent<LegendsProps> = React.forwardRef<HTMLDivElement, LegendsProps>(\n (props, forwardedRef) => {\n /** Boolean variable to check if one or more legends are selected */\n let _isLegendSelected = false;\n const _rootElem = React.useRef<HTMLDivElement | null>(null);\n\n // set states separately for each instance of the component\n const [activeLegend, setActiveLegend] = React.useState('');\n const [selectedLegends, setSelectedLegends] = React.useState<LegendMap>({});\n const focusAttributes = useFocusableGroup();\n const arrowAttributes = useArrowNavigationGroup({ axis: 'horizontal', memorizeCurrent: true });\n const classes = useLegendStyles(props);\n const toSVG = React.useCallback(\n (svgWidth: number, isRTL: boolean = false) => {\n return cloneLegendsToSVG(\n props.legends,\n svgWidth,\n {\n selectedLegends,\n centerLegends: !!props.centerLegends,\n textClassName: classes.text!,\n isRTL,\n },\n _rootElem.current,\n );\n },\n [props.legends, props.centerLegends, selectedLegends, classes.text],\n );\n\n React.useImperativeHandle(props.legendRef, () => ({\n toSVG,\n }));\n\n React.useEffect(() => {\n const initialSelectedLegends = props.selectedLegends ?? props.defaultSelectedLegends;\n const initialSelectedLegend = props.selectedLegend ?? props.defaultSelectedLegend;\n let selectedLegendsState = {};\n if (props.canSelectMultipleLegends) {\n selectedLegendsState =\n (initialSelectedLegends ?? [])?.reduce(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (combineDict: any, key: any) => ({ [key]: true, ...combineDict }),\n {},\n ) || {};\n setSelectedLegends(selectedLegendsState);\n } else if (initialSelectedLegend !== undefined) {\n selectedLegendsState = { [initialSelectedLegend]: true };\n setSelectedLegends(selectedLegendsState);\n }\n }, [\n props.canSelectMultipleLegends,\n props.defaultSelectedLegend,\n props.defaultSelectedLegends,\n props.selectedLegend,\n props.selectedLegends,\n ]);\n\n _isLegendSelected = Object.keys(selectedLegends).length > 0;\n const dataToRender = _generateData();\n const { overflowStyles, allowFocusOnLegends = true, canSelectMultipleLegends = false } = props;\n const itemIds = dataToRender.map((_item, index) => index.toString());\n const overflowHoverCardLegends: JSXElement[] = [];\n dataToRender.map((legend, index) => {\n const hoverCardElement = _renderButton(legend, index, true);\n overflowHoverCardLegends.push(hoverCardElement);\n });\n const overflowString = props.overflowText ? props.overflowText : 'more';\n return props.enabledWrapLines ? renderWrappedLegends() : renderLegends();\n\n function renderLegends(): JSXElement {\n return (\n <div {...focusAttributes} {...arrowAttributes} className={classes.root} ref={_rootElem}>\n <Overflow>\n <div className={classes.resizableArea} style={{ textAlign: props.centerLegends ? 'center' : 'unset' }}>\n {/*\n Only the selectable options belong to the listbox; the overflow trigger stays a sibling so a\n menu button is not treated as a listbox child. `display: contents` keeps the options as direct\n flex participants so overflow measurement is unaffected.\n */}\n <div\n {...(allowFocusOnLegends && {\n role: 'listbox',\n 'aria-label': 'Legends',\n 'aria-multiselectable': canSelectMultipleLegends,\n })}\n style={{ display: 'contents' }}\n >\n {dataToRender.map((item, id) => (\n <OverflowItem key={id} id={id.toString()}>\n {_renderButton(item, id)}\n </OverflowItem>\n ))}\n </div>\n <OverflowMenu itemIds={itemIds} title={`${overflowString}`} items={overflowHoverCardLegends} />\n </div>\n </Overflow>\n </div>\n );\n }\n\n function renderWrappedLegends(): JSXElement {\n return (\n <div\n {...focusAttributes}\n {...arrowAttributes}\n {...(allowFocusOnLegends && {\n role: 'listbox',\n 'aria-label': 'Legends',\n 'aria-multiselectable': canSelectMultipleLegends,\n })}\n style={{ justifyContent: props.centerLegends ? 'center' : 'unset', flexWrap: 'wrap', ...overflowStyles }}\n className={classes.root}\n ref={_rootElem}\n >\n <div className={classes.resizableArea} style={{ display: 'flex', flexWrap: 'wrap', overflow: 'auto' }}>\n {dataToRender.map((item, id) => (\n <div\n className={mergeClasses(classes.legendContainer, item.legendAnnotation && classes.annotation)}\n key={item.key}\n >\n {_renderButton(item, id)}\n {item.legendAnnotation && <div>{item.legendAnnotation()}</div>}\n </div>\n ))}\n </div>\n </div>\n );\n }\n\n function _generateData(): LegendItem[] {\n const { /*allowFocusOnLegends = true,*/ shape } = props;\n const dataItems: LegendItem[] = props.legends.map((legend: Legend, index: number) => {\n return {\n /* ...(allowFocusOnLegends && {\n nativeButtonProps: getIntrinsicElementProps(\n 'div',\n {\n legend,\n ...buttonProperties,\n },\n ['title'],\n ),\n 'aria-setsize': props.legends.length,\n 'aria-posinset': index + 1,\n }), */\n title: legend.title,\n action: legend.action!,\n hoverAction: legend.hoverAction!,\n onMouseOutAction: legend.onMouseOutAction!,\n color: legend.color,\n shape: shape ? shape : legend.shape,\n stripePattern: legend.stripePattern,\n isLineLegendInBarChart: legend.isLineLegendInBarChart,\n opacity: legend.opacity,\n key: index,\n legendAnnotation: legend.legendAnnotation,\n };\n });\n return dataItems;\n }\n\n /**\n * Determine whether the component is in \"controlled\" mode for selections, where the selected legend(s) are\n * determined entirely by props passed in from the parent component.\n */\n function _isInControlledMode(): boolean {\n return props.canSelectMultipleLegends ? props.selectedLegends !== undefined : props.selectedLegend !== undefined;\n }\n\n /**\n * Get the new selected legends based on the legend that was clicked when multi-select is enabled.\n * @param legend The legend that was clicked\n * @returns An object with the new selected legend(s) state data.\n */\n function _getNewSelectedLegendsForMultiselect(legend: Legend): { [key: string]: boolean } {\n let legendsSelected = { ...selectedLegends };\n if (legendsSelected[legend.title]) {\n // Delete entry for the deselected legend to make\n // the number of keys equal to the number of selected legends\n delete legendsSelected[legend.title];\n } else {\n legendsSelected[legend.title] = true;\n // Clear set if all legends are selected\n if (Object.keys(legendsSelected).length === props.legends.length) {\n legendsSelected = {};\n }\n }\n return legendsSelected;\n }\n\n /**\n * Get the new selected legends based on the legend that was clicked when single-select is enabled.\n * @param legend The legend that was clicked\n * @returns An object with the new selected legend state data.\n */\n function _getNewSelectedLegendsForSingleSelect(legend: Legend): { [key: string]: boolean } {\n return selectedLegends[legend.title] ? {} : { [legend.title]: true };\n }\n\n function _onClick(legend: Legend, event: React.MouseEvent<HTMLButtonElement>): void {\n const { canSelectMultipleLegends = false } = props;\n const nextSelectedLegends = canSelectMultipleLegends\n ? _getNewSelectedLegendsForMultiselect(legend)\n : _getNewSelectedLegendsForSingleSelect(legend);\n\n if (!_isInControlledMode()) {\n setSelectedLegends(nextSelectedLegends);\n }\n props.onChange?.(Object.keys(nextSelectedLegends), event, legend);\n legend.action?.();\n }\n\n function _onHoverOverLegend(legend: Legend) {\n if (legend.hoverAction) {\n setActiveLegend(legend.title);\n legend.hoverAction();\n }\n }\n\n function _onLeave(legend: Legend) {\n if (legend.onMouseOutAction) {\n setActiveLegend('');\n legend.onMouseOutAction();\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function _renderButton(data: any, index?: number, isOverflowItem?: boolean) {\n const { allowFocusOnLegends = true } = props;\n // Overflow legends are rendered inside a menu, not the listbox, so they must not carry `option` semantics.\n const showListboxOption = allowFocusOnLegends && !isOverflowItem;\n const legend: Legend = {\n title: data.title,\n color: data.color,\n shape: data.shape,\n action: data.action,\n hoverAction: data.hoverAction,\n onMouseOutAction: data.onMouseOutAction,\n stripePattern: data.stripePattern,\n isLineLegendInBarChart: data.isLineLegendInBarChart,\n opacity: data.opacity,\n };\n const color = _getColor(legend.title, legend.color);\n const onClickHandler = (event: React.MouseEvent<HTMLElement>) => {\n _onClick(legend, event as React.MouseEvent<HTMLButtonElement>);\n };\n const onHoverHandler = () => {\n _onHoverOverLegend(legend);\n };\n const onMouseOut = () => {\n _onLeave(legend);\n };\n const shape = _getShape(legend, color);\n const legendStyle = {\n '--rect-height': legend.isLineLegendInBarChart ? '4px' : '12px',\n '--rect-backgroundColor': legend.stripePattern ? '' : color,\n '--rect-borderColor': legend.color ? legend.color : tokens.colorNeutralStroke1,\n '--rect-content': legend.stripePattern\n ? `repeating-linear-gradient(135deg, transparent, transparent 3px, ${color} 1px, ${color} 4px)`\n : '',\n } as React.CSSProperties;\n const legendContent = (\n <>\n {shape}\n <div className={classes.text} style={{ opacity: color === tokens.colorNeutralBackground1 ? '0.67' : '' }}>\n {legend.title}\n </div>\n </>\n );\n // Shared by the listbox Button and the overflow div. Hover/focus handlers are included so the overflow\n // menu can forward them to its item (the div itself never receives focus).\n const commonProps: React.HTMLAttributes<HTMLElement> = {\n className: classes.legend,\n onClick: onClickHandler,\n onMouseOver: onHoverHandler,\n onMouseOut: onMouseOut,\n onFocus: onHoverHandler,\n onBlur: onMouseOut,\n style: legendStyle,\n };\n if (isOverflowItem) {\n // In the overflow menu the item itself is interactive, so keep this content a non-interactive div to\n // avoid nested clickable elements. display:flex lays the swatch and label out inline (a bare div would\n // stack them). data-selected / data-title are read by the overflow menu to drive its checked state.\n return (\n <div\n key={index}\n {...commonProps}\n data-selected={!!selectedLegends[legend.title]}\n data-title={legend.title}\n style={{ ...legendStyle, display: 'flex', alignItems: 'center' }}\n >\n {legendContent}\n </div>\n );\n }\n return (\n <Button\n {...(showListboxOption && {\n 'aria-selected': !!selectedLegends[legend.title],\n role: 'option',\n 'aria-label': `${legend.title}`,\n // Full-list position so counts match the overflow menu.\n 'aria-setsize': props.legends.length,\n 'aria-posinset': (index ?? 0) + 1,\n })}\n {...(data.nativeButtonProps && { ...data.nativeButtonProps })}\n key={index}\n {...commonProps}\n appearance={'outline'}\n size=\"small\"\n >\n {legendContent}\n </Button>\n );\n }\n\n function _getShape(legend: Legend, color: string): React.ReactNode | string {\n const svgParentProps: React.SVGAttributes<SVGElement> = {\n className: classes.shape,\n };\n const svgChildProps: React.SVGAttributes<SVGElement> = {\n fill: color,\n strokeWidth: 2,\n stroke: legend.color,\n };\n return (\n <Shape\n svgProps={svgParentProps}\n pathProps={svgChildProps}\n shape={legend.shape as LegendShape}\n classNameForNonSvg={classes.rect}\n style={\n {\n height: legend.isLineLegendInBarChart ? '4px' : '12px',\n backgroundColor: legend.stripePattern ? '' : color,\n borderColor: legend.color ? legend.color : tokens.colorNeutralStroke1,\n content: legend.stripePattern\n ? `repeating-linear-gradient(135deg, transparent, transparent 3px, ${color} 1px, ${color} 4px)`\n : '',\n '--rect-content-high-contrast': `linear-gradient(to right, ${color}, ${color})`,\n '--rect-opacity-high-contrast': color === tokens.colorNeutralBackground1 ? '0.6' : '',\n } as React.CSSProperties\n }\n />\n );\n }\n\n function _getColor(title: string, color: string): string {\n let legendColor = color;\n // if one or more legends are selected\n if (_isLegendSelected) {\n // if the given legend (title) is one of the selected legends\n if (selectedLegends[title]) {\n legendColor = color;\n }\n // if the given legend is unselected\n else {\n legendColor = tokens.colorNeutralBackground1;\n }\n }\n // if no legend is selected\n else {\n // if the given legend is hovered\n // or none of the legends is hovered\n if (activeLegend === title || activeLegend === '') {\n legendColor = color;\n }\n // if there is a hovered legend but the given legend is not the one\n else {\n legendColor = tokens.colorNeutralBackground1;\n }\n }\n return legendColor;\n }\n },\n);\nLegends.displayName = 'Legends';\n"],"names":["React","Button","Shape","useLegendStyles","Overflow","OverflowItem","useFocusableGroup","useArrowNavigationGroup","OverflowMenu","tokens","cloneLegendsToSVG","mergeClasses","Legends","forwardRef","props","forwardedRef","_isLegendSelected","_rootElem","useRef","activeLegend","setActiveLegend","useState","selectedLegends","setSelectedLegends","focusAttributes","arrowAttributes","axis","memorizeCurrent","classes","toSVG","useCallback","svgWidth","isRTL","legends","centerLegends","textClassName","text","current","useImperativeHandle","legendRef","useEffect","initialSelectedLegends","defaultSelectedLegends","initialSelectedLegend","selectedLegend","defaultSelectedLegend","selectedLegendsState","canSelectMultipleLegends","reduce","combineDict","key","undefined","Object","keys","length","dataToRender","_generateData","overflowStyles","allowFocusOnLegends","itemIds","map","_item","index","toString","overflowHoverCardLegends","legend","hoverCardElement","_renderButton","push","overflowString","overflowText","enabledWrapLines","renderWrappedLegends","renderLegends","div","className","root","ref","resizableArea","style","textAlign","role","display","item","id","title","items","justifyContent","flexWrap","overflow","legendContainer","legendAnnotation","annotation","shape","dataItems","action","hoverAction","onMouseOutAction","color","stripePattern","isLineLegendInBarChart","opacity","_isInControlledMode","_getNewSelectedLegendsForMultiselect","legendsSelected","_getNewSelectedLegendsForSingleSelect","_onClick","event","nextSelectedLegends","onChange","_onHoverOverLegend","_onLeave","data","isOverflowItem","showListboxOption","_getColor","onClickHandler","onHoverHandler","onMouseOut","_getShape","legendStyle","colorNeutralStroke1","legendContent","colorNeutralBackground1","commonProps","onClick","onMouseOver","onFocus","onBlur","data-selected","data-title","alignItems","nativeButtonProps","appearance","size","svgParentProps","svgChildProps","fill","strokeWidth","stroke","svgProps","pathProps","classNameForNonSvg","rect","height","backgroundColor","borderColor","content","legendColor","displayName"],"mappings":"AAAA;;;;;+BAyCaY;;;;;;;iEAvCU,QAAQ;6BAGR,yBAAyB;uBAE1B,UAAU;wCACA,4BAA4B;+BACrB,2BAA2B;8BACP,0BAA0B;8BACxD,iBAAiB;4BACvB,wBAAwB;kCACb,qCAAqC;wBAC1C,iBAAiB;AA2BvC,gBAAMA,WAAAA,GAAiDZ,OAAMa,UAAU,CAC5E,CAACC,OAAOC;IACN,kEAAkE,GAClE,IAAIC,oBAAoB;IACxB,MAAMC,YAAYjB,OAAMkB,MAAM,CAAwB;IAEtD,2DAA2D;IAC3D,MAAM,CAACC,cAAcC,gBAAgB,GAAGpB,OAAMqB,QAAQ,CAAC;IACvD,MAAM,CAACC,iBAAiBC,mBAAmB,GAAGvB,OAAMqB,QAAQ,CAAY,CAAC;IACzE,MAAMG,sBAAkBlB,+BAAAA;IACxB,MAAMmB,sBAAkBlB,qCAAAA,EAAwB;QAAEmB,MAAM;QAAcC,iBAAiB;IAAK;IAC5F,MAAMC,cAAUzB,uCAAAA,EAAgBW;IAChC,MAAMe,QAAQ7B,OAAM8B,WAAW,CAC7B,CAACC,UAAkBC,QAAiB,KAAK;QACvC,WAAOtB,mCAAAA,EACLI,MAAMmB,OAAO,EACbF,UACA;YACET;YACAY,eAAe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c3I,kBAAAA,CAAOkH,uBAAuB;YAC9C;QACF,OAEK;YACH,iCAAiC;YACjC,oCAAoC;YACpC,IAAIxG,iBAAiBkE,SAASlE,iBAAiB,IAAI;gBACjDiI,cAAclD;YAChB,OAEK;gBACHkD,cAAc3I,kBAAAA,CAAOkH,uBAAuB;YAC9C;QACF;QACA,OAAOyB;IACT;AACF,GACA;AACFxI,QAAQyI,WAAW,GAAG"}
@@ -22,23 +22,61 @@ const OverflowMenu = ({ itemIds, title, items })=>{
22
22
  return null;
23
23
  }
24
24
  const remainingItemsCount = itemIds.length - overflowCount;
25
+ const checkedLegends = [];
25
26
  const menuList = [];
26
27
  for(let i = remainingItemsCount; i < itemIds.length; i++){
27
28
  const buttonElement = items[i];
28
- menuList.push(/*#__PURE__*/ _react.createElement(_reactmenu.MenuItem, {
29
- tabIndex: -1,
29
+ var _buttonElement_props_datatitle;
30
+ const value = `${(_buttonElement_props_datatitle = buttonElement.props['data-title']) !== null && _buttonElement_props_datatitle !== void 0 ? _buttonElement_props_datatitle : i}`;
31
+ if (buttonElement.props['data-selected']) {
32
+ checkedLegends.push(value);
33
+ }
34
+ menuList.push(/*#__PURE__*/ _react.createElement(_reactmenu.MenuItemCheckbox, {
30
35
  key: i,
36
+ name: "legends",
37
+ value: value,
38
+ // Full-list position so counts match the listbox.
39
+ "aria-setsize": itemIds.length,
40
+ "aria-posinset": i + 1,
41
+ // Hide the checkmark so the row matches the listbox legend; selection is conveyed via aria-checked.
42
+ checkmark: null,
31
43
  onClick: (e)=>{
32
- const button = buttonElement.props;
33
- if (button.onClick) {
34
- button.onClick(e);
35
- }
44
+ var _buttonElement_props_onClick, _buttonElement_props;
45
+ return (_buttonElement_props_onClick = (_buttonElement_props = buttonElement.props).onClick) === null || _buttonElement_props_onClick === void 0 ? void 0 : _buttonElement_props_onClick.call(_buttonElement_props, e);
46
+ },
47
+ // The content is smaller than the row, so handle hover/focus on the item to cover its full area.
48
+ onMouseEnter: ()=>{
49
+ var _buttonElement_props_onMouseOver, _buttonElement_props;
50
+ return (_buttonElement_props_onMouseOver = (_buttonElement_props = buttonElement.props).onMouseOver) === null || _buttonElement_props_onMouseOver === void 0 ? void 0 : _buttonElement_props_onMouseOver.call(_buttonElement_props);
51
+ },
52
+ onMouseLeave: ()=>{
53
+ var _buttonElement_props_onMouseOut, _buttonElement_props;
54
+ return (_buttonElement_props_onMouseOut = (_buttonElement_props = buttonElement.props).onMouseOut) === null || _buttonElement_props_onMouseOut === void 0 ? void 0 : _buttonElement_props_onMouseOut.call(_buttonElement_props);
55
+ },
56
+ onFocus: ()=>{
57
+ var _buttonElement_props_onFocus, _buttonElement_props;
58
+ return (_buttonElement_props_onFocus = (_buttonElement_props = buttonElement.props).onFocus) === null || _buttonElement_props_onFocus === void 0 ? void 0 : _buttonElement_props_onFocus.call(_buttonElement_props);
59
+ },
60
+ onBlur: ()=>{
61
+ var _buttonElement_props_onBlur, _buttonElement_props;
62
+ return (_buttonElement_props_onBlur = (_buttonElement_props = buttonElement.props).onBlur) === null || _buttonElement_props_onBlur === void 0 ? void 0 : _buttonElement_props_onBlur.call(_buttonElement_props);
36
63
  }
37
- }, buttonElement));
64
+ }, /*#__PURE__*/ _react.cloneElement(buttonElement, {
65
+ onClick: undefined,
66
+ onMouseOver: undefined,
67
+ onMouseOut: undefined,
68
+ onFocus: undefined,
69
+ onBlur: undefined
70
+ })));
38
71
  }
39
72
  return /*#__PURE__*/ _react.createElement(_reactmenu.Menu, null, /*#__PURE__*/ _react.createElement(_reactmenu.MenuTrigger, {
40
73
  disableButtonEnhancement: true
41
74
  }, /*#__PURE__*/ _react.createElement(_reactbutton.MenuButton, {
42
75
  ref: ref
43
- }, displayLabel)), /*#__PURE__*/ _react.createElement(_reactmenu.MenuPopover, null, /*#__PURE__*/ _react.createElement(_reactmenu.MenuList, null, menuList)));
76
+ }, displayLabel)), /*#__PURE__*/ _react.createElement(_reactmenu.MenuPopover, null, /*#__PURE__*/ _react.createElement(_reactmenu.MenuList, {
77
+ "aria-label": "Legends",
78
+ checkedValues: {
79
+ legends: checkedLegends
80
+ }
81
+ }, menuList)));
44
82
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Legends/OverflowMenu.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { Menu, MenuTrigger, MenuPopover, MenuList, MenuItem } from '@fluentui/react-menu';\nimport { MenuButton } from '@fluentui/react-button';\nimport { useOverflowMenu } from '@fluentui/react-overflow';\n\nexport const OverflowMenu: React.FC<{\n itemIds: string[];\n title: string;\n items: JSXElement[];\n}> = ({ itemIds, title, items }) => {\n const { ref, overflowCount, isOverflowing } = useOverflowMenu<HTMLButtonElement>();\n let displayLabel = title;\n displayLabel = title === '' ? `+${overflowCount} items` : `+${overflowCount} ${title}`;\n\n if (!isOverflowing) {\n return null;\n }\n const remainingItemsCount = itemIds.length - overflowCount;\n const menuList = [];\n for (let i = remainingItemsCount; i < itemIds.length; i++) {\n const buttonElement = items[i];\n menuList.push(\n <MenuItem\n tabIndex={-1}\n key={i}\n onClick={e => {\n const button = buttonElement.props;\n if (button.onClick) {\n button.onClick(e);\n }\n }}\n >\n {buttonElement}\n </MenuItem>,\n );\n }\n return (\n <Menu>\n <MenuTrigger disableButtonEnhancement>\n <MenuButton ref={ref}>{displayLabel}</MenuButton>\n </MenuTrigger>\n\n <MenuPopover>\n <MenuList>{menuList}</MenuList>\n </MenuPopover>\n </Menu>\n );\n};\n"],"names":["React","Menu","MenuTrigger","MenuPopover","MenuList","MenuItem","MenuButton","useOverflowMenu","OverflowMenu","itemIds","title","items","ref","overflowCount","isOverflowing","displayLabel","remainingItemsCount","length","menuList","i","buttonElement","push","tabIndex","key","onClick","e","button","props","disableButtonEnhancement"],"mappings":"AAAA;;;;;+BAQaQ;;;;;;;iEANU,QAAQ;2BAEoC,uBAAuB;6BAC/D,yBAAyB;+BACpB,2BAA2B;AAEpD,qBAIF,CAAC,EAAEC,OAAO,EAAEC,KAAK,EAAEC,KAAK,EAAE;IAC7B,MAAM,EAAEC,GAAG,EAAEC,aAAa,EAAEC,aAAa,EAAE,OAAGP,8BAAAA;IAC9C,IAAIQ,eAAeL;IACnBK,eAAeL,UAAU,KAAK,CAAC,CAAC,EAAEG,cAAc,MAAM,CAAC,GAAG,CAAC,CAAC,EAAEA,cAAc,CAAC,EAAEH,OAAO;IAEtF,IAAI,CAACI,eAAe;QAClB,OAAO;IACT;IACA,MAAME,sBAAsBP,QAAQQ,MAAM,GAAGJ;IAC7C,MAAMK,WAAW,EAAE;IACnB,IAAK,IAAIC,IAAIH,qBAAqBG,IAAIV,QAAQQ,MAAM,EAAEE,IAAK;QACzD,MAAMC,gBAAgBT,KAAK,CAACQ,EAAE;QAC9BD,SAASG,IAAI,CAAA,WAAA,GACX,OAAA,aAAA,CAAChB,mBAAAA,EAAAA;YACCiB,UAAU,CAAC;YACXC,KAAKJ;YACLK,SAASC,CAAAA;gBACP,MAAMC,SAASN,cAAcO,KAAK;gBAClC,IAAID,OAAOF,OAAO,EAAE;oBAClBE,OAAOF,OAAO,CAACC;gBACjB;YACF;WAECL;IAGP;IACA,OAAA,WAAA,GACE,OAAA,aAAA,CAACnB,eAAAA,EAAAA,MAAAA,WAAAA,GACC,OAAA,aAAA,CAACC,sBAAAA,EAAAA;QAAY0B,0BAAAA;qBACX,OAAA,aAAA,CAACtB,uBAAAA,EAAAA;QAAWM,KAAKA;OAAMG,gBAAAA,WAAAA,GAGzB,OAAA,aAAA,CAACZ,sBAAAA,EAAAA,MAAAA,WAAAA,GACC,OAAA,aAAA,CAACC,mBAAAA,EAAAA,MAAUc;AAInB,EAAE"}
1
+ {"version":3,"sources":["../src/components/Legends/OverflowMenu.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { Menu, MenuTrigger, MenuPopover, MenuList, MenuItemCheckbox } from '@fluentui/react-menu';\nimport { MenuButton } from '@fluentui/react-button';\nimport { useOverflowMenu } from '@fluentui/react-overflow';\n\nexport const OverflowMenu: React.FC<{\n itemIds: string[];\n title: string;\n items: JSXElement[];\n}> = ({ itemIds, title, items }) => {\n const { ref, overflowCount, isOverflowing } = useOverflowMenu<HTMLButtonElement>();\n let displayLabel = title;\n displayLabel = title === '' ? `+${overflowCount} items` : `+${overflowCount} ${title}`;\n\n if (!isOverflowing) {\n return null;\n }\n const remainingItemsCount = itemIds.length - overflowCount;\n const checkedLegends: string[] = [];\n const menuList = [];\n for (let i = remainingItemsCount; i < itemIds.length; i++) {\n const buttonElement = items[i];\n const value = `${buttonElement.props['data-title'] ?? i}`;\n if (buttonElement.props['data-selected']) {\n checkedLegends.push(value);\n }\n menuList.push(\n <MenuItemCheckbox\n key={i}\n name=\"legends\"\n value={value}\n // Full-list position so counts match the listbox.\n aria-setsize={itemIds.length}\n aria-posinset={i + 1}\n // Hide the checkmark so the row matches the listbox legend; selection is conveyed via aria-checked.\n checkmark={null}\n onClick={e => buttonElement.props.onClick?.(e)}\n // The content is smaller than the row, so handle hover/focus on the item to cover its full area.\n onMouseEnter={() => buttonElement.props.onMouseOver?.()}\n onMouseLeave={() => buttonElement.props.onMouseOut?.()}\n onFocus={() => buttonElement.props.onFocus?.()}\n onBlur={() => buttonElement.props.onBlur?.()}\n >\n {React.cloneElement(buttonElement, {\n onClick: undefined,\n onMouseOver: undefined,\n onMouseOut: undefined,\n onFocus: undefined,\n onBlur: undefined,\n })}\n </MenuItemCheckbox>,\n );\n }\n return (\n <Menu>\n <MenuTrigger disableButtonEnhancement>\n <MenuButton ref={ref}>{displayLabel}</MenuButton>\n </MenuTrigger>\n\n <MenuPopover>\n <MenuList aria-label=\"Legends\" checkedValues={{ legends: checkedLegends }}>\n {menuList}\n </MenuList>\n </MenuPopover>\n </Menu>\n );\n};\n"],"names":["React","Menu","MenuTrigger","MenuPopover","MenuList","MenuItemCheckbox","MenuButton","useOverflowMenu","OverflowMenu","itemIds","title","items","ref","overflowCount","isOverflowing","displayLabel","remainingItemsCount","length","checkedLegends","menuList","i","buttonElement","value","props","push","key","name","aria-setsize","aria-posinset","checkmark","onClick","e","onMouseEnter","onMouseOver","onMouseLeave","onMouseOut","onFocus","onBlur","cloneElement","undefined","disableButtonEnhancement","aria-label","checkedValues","legends"],"mappings":"AAAA;;;;;+BAQaQ;;;;;;;iEANU,QAAQ;2BAE4C,uBAAuB;6BACvE,yBAAyB;+BACpB,2BAA2B;AAEpD,qBAIF,CAAC,EAAEC,OAAO,EAAEC,KAAK,EAAEC,KAAK,EAAE;IAC7B,MAAM,EAAEC,GAAG,EAAEC,aAAa,EAAEC,aAAa,EAAE,OAAGP,8BAAAA;IAC9C,IAAIQ,eAAeL;IACnBK,eAAeL,UAAU,KAAK,CAAC,CAAC,EAAEG,cAAc,MAAM,CAAC,GAAG,CAAC,CAAC,EAAEA,cAAc,CAAC,EAAEH,OAAO;IAEtF,IAAI,CAACI,eAAe;QAClB,OAAO;IACT;IACA,MAAME,sBAAsBP,QAAQQ,MAAM,GAAGJ;IAC7C,MAAMK,iBAA2B,EAAE;IACnC,MAAMC,WAAW,EAAE;IACnB,IAAK,IAAIC,IAAIJ,qBAAqBI,IAAIX,QAAQQ,MAAM,EAAEG,IAAK;QACzD,MAAMC,gBAAgBV,KAAK,CAACS,EAAE;YACbC;QAAjB,MAAMC,QAAQ,GAAGD,CAAAA,iCAAAA,cAAcE,KAAK,CAAC,aAAA,AAAa,MAAA,QAAjCF,mCAAAA,KAAAA,IAAAA,iCAAqCD,GAAG;QACzD,IAAIC,cAAcE,KAAK,CAAC,gBAAgB,EAAE;YACxCL,eAAeM,IAAI,CAACF;QACtB;QACAH,SAASK,IAAI,CAAA,WAAA,GACX,OAAA,aAAA,CAACnB,2BAAAA,EAAAA;YACCoB,KAAKL;YACLM,MAAK;YACLJ,OAAOA;YACP,kDAAkD;YAClDK,gBAAclB,QAAQQ,MAAM;YAC5BW,iBAAeR,IAAI;YACnB,oGAAoG;YACpGS,WAAW;YACXC,SAASC,CA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GAGzB,OAAA,aAAA,CAACZ,sBAAAA,EAAAA,MAAAA,WAAAA,GACC,OAAA,aAAA,CAACC,mBAAAA,EAAAA;QAASqC,cAAW;QAAUC,eAAe;YAAEC,SAASzB;QAAe;OACrEC;AAKX,EAAE"}
@@ -642,7 +642,8 @@ const SankeyChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
642
642
  const target = singleLink.target;
643
643
  // TODO: localize the aria-label string
644
644
  return /*#__PURE__*/ _react.createElement("g", {
645
- key: key
645
+ key: key,
646
+ role: "presentation"
646
647
  }, /*#__PURE__*/ _react.createElement("defs", null, /*#__PURE__*/ _react.createElement("linearGradient", {
647
648
  id: gradientId,
648
649
  x1: "0%",
@@ -669,7 +670,7 @@ const SankeyChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
669
670
  fillOpacity: _getOpacityStream(singleLink),
670
671
  tabIndex: 0,
671
672
  "aria-label": aria,
672
- role: "img"
673
+ role: "option"
673
674
  }));
674
675
  });
675
676
  }
@@ -692,7 +693,8 @@ const SankeyChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
692
693
  }, singleNode);
693
694
  return /*#__PURE__*/ _react.createElement("g", {
694
695
  key: index,
695
- id: gElementId
696
+ id: gElementId,
697
+ role: "presentation"
696
698
  }, /*#__PURE__*/ _react.createElement("rect", {
697
699
  x: x0,
698
700
  y: y0,
@@ -708,7 +710,7 @@ const SankeyChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
708
710
  opacity: "1",
709
711
  tabIndex: 0,
710
712
  "aria-label": aria,
711
- role: "img"
713
+ role: "option"
712
714
  }), height > MIN_HEIGHT_FOR_TYPE && /*#__PURE__*/ _react.createElement("g", {
713
715
  className: classes.nodeTextContainer
714
716
  }, /*#__PURE__*/ _react.createElement("g", {
@@ -999,7 +1001,9 @@ const SankeyChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
999
1001
  width: width,
1000
1002
  height: height,
1001
1003
  id: _chartId,
1002
- className: classes.chart
1004
+ className: classes.chart,
1005
+ role: "listbox",
1006
+ "aria-label": `Sankey chart with ${nodes.length} nodes and ${links.length} links`
1003
1007
  }, !props.hideLegend && props.data.chartTitle && /*#__PURE__*/ _react.createElement(_index1.ChartTitle, {
1004
1008
  title: props.data.chartTitle,
1005
1009
  x: width / 2,
@@ -1011,14 +1015,16 @@ const SankeyChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
1011
1015
  if (item.type === 'node') {
1012
1016
  return /*#__PURE__*/ _react.createElement("g", {
1013
1017
  key: nodes[item.index].nodeId,
1014
- className: classes.nodes
1018
+ className: classes.nodes,
1019
+ role: "presentation"
1015
1020
  }, nodeData[item.index]);
1016
1021
  } else {
1017
1022
  return /*#__PURE__*/ _react.createElement("g", {
1018
1023
  key: `${links[item.index].source.nodeId}-${links[item.index].target.nodeId}`,
1019
1024
  className: classes.links,
1020
1025
  stroke: props.pathColor ? props.pathColor : _reacttheme.tokens.colorStrokeFocus2,
1021
- strokeOpacity: 1
1026
+ strokeOpacity: 1,
1027
+ role: "presentation"
1022
1028
  }, linkData[item.index]);
1023
1029
  }
1024
1030
  }))), calloutProps.isPopoverOpen && /*#__PURE__*/ _react.createElement(_index.ChartPopover, calloutProps), /*#__PURE__*/ _react.createElement("div", {