@luscii-healthtech/web-ui 58.0.1 → 58.1.0

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.
@@ -6738,9 +6738,14 @@ const ticksContainerStyle = {
6738
6738
  const RangeCoverageComponent = (_a) => {
6739
6739
  var { sections, start, end, highlightedRange, ticks = [], tickFormatter, title, legendSwatches, onSectionFocus, translations, className, slots } = _a, rest = __rest(_a, ["sections", "start", "end", "highlightedRange", "ticks", "tickFormatter", "title", "legendSwatches", "onSectionFocus", "translations", "className", "slots"]);
6740
6740
  const { tooltipContent } = slots !== null && slots !== void 0 ? slots : {};
6741
+ const idPrefix = React.useId();
6741
6742
  if (hasSectionOverlaps(sections)) {
6742
6743
  return jsxRuntime.jsx(Text, { variant: "strong", children: translations.sectionOverlapsMessage });
6743
6744
  }
6745
+ const legendIdByLabel = new Map((legendSwatches !== null && legendSwatches !== void 0 ? legendSwatches : []).map((swatch, index) => [
6746
+ swatch.label,
6747
+ `${idPrefix}-legend-${index}`
6748
+ ]));
6744
6749
  const segments = calculateSegments({ sections, start, end });
6745
6750
  const highlightPosition = highlightedRange ? calculateHighlightPosition({ highlightedRange, start, end }) : null;
6746
6751
  return jsxRuntime.jsx(Box, Object.assign({ className }, rest, { children: jsxRuntime.jsxs(Stack, { _gap: "m", width: "full", align: "stretch", children: [jsxRuntime.jsxs(Stack, { justify: "between", axis: "x", align: "center", children: [jsxRuntime.jsx(Title, { variant: "xs", level: "3", "aria-hidden": title ? void 0 : true, children: title }), legendSwatches && (legendSwatches === null || legendSwatches === void 0 ? void 0 : legendSwatches.length) > 0 && jsxRuntime.jsx(Stack, { axis: "x", _gap: "l", children: jsxRuntime.jsx(Stack, { axis: "x", _gap: "base", align: "center", children: legendSwatches === null || legendSwatches === void 0 ? void 0 : legendSwatches.map((swatch) => {
@@ -6749,18 +6754,19 @@ const RangeCoverageComponent = (_a) => {
6749
6754
  colorB: swatch.color[1],
6750
6755
  startOffset: -6
6751
6756
  }) : swatch.color;
6752
- return jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx("div", { style: Object.assign(Object.assign({}, legendSwatchStyle), { background }) }), jsxRuntime.jsx(Text, { as: "span", children: swatch.label })] }, swatch.label);
6757
+ return jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx("div", { id: legendIdByLabel.get(swatch.label), role: "img", "aria-label": swatch.label, style: Object.assign(Object.assign({}, legendSwatchStyle), { background }) }), jsxRuntime.jsx(Text, { as: "span", children: swatch.label })] }, swatch.label);
6753
6758
  }) }) })] }), jsxRuntime.jsxs(Stack, { _gap: "m", width: "full", align: "stretch", children: [jsxRuntime.jsxs("div", { style: { position: "relative" }, children: [jsxRuntime.jsx("div", { style: barContainerStyle, children: jsxRuntime.jsx("div", { style: barStyle, children: segments.map((segment) => {
6754
6759
  var _a2, _b;
6755
6760
  const sectionDataWithBackground = Object.assign(Object.assign({}, segment.originalSection), { background: getSegmentStyle(segment.color).background });
6756
6761
  const renderedTooltipContent = (_a2 = tooltipContent === null || tooltipContent === void 0 ? void 0 : tooltipContent.render) === null || _a2 === void 0 ? void 0 : _a2.call(tooltipContent, sectionDataWithBackground);
6757
6762
  const segmentStyle = Object.assign({ flexBasis: `calc(${segment.widthPercent}% - 1px)`, flexGrow: 0, flexShrink: 0, marginRight: "1px" }, getSegmentStyle(segment.color));
6758
6763
  const ariaLabel = `${segment.originalSection.from} - ${segment.originalSection.to}`;
6764
+ const legendId = segment.originalSection.legendLabel ? legendIdByLabel.get(segment.originalSection.legendLabel) : void 0;
6759
6765
  if (!renderedTooltipContent && !onSectionFocus) {
6760
- return jsxRuntime.jsx("div", { style: segmentStyle, "aria-label": ariaLabel }, ariaLabel);
6766
+ return jsxRuntime.jsx("div", { style: segmentStyle, role: "img", "aria-label": ariaLabel, "aria-describedby": legendId }, ariaLabel);
6761
6767
  }
6762
6768
  if (!renderedTooltipContent) {
6763
- return jsxRuntime.jsx("button", { style: segmentStyle, "aria-label": ariaLabel, onFocus: () => {
6769
+ return jsxRuntime.jsx("button", { style: segmentStyle, "aria-label": ariaLabel, "aria-describedby": legendId, onFocus: () => {
6764
6770
  onSectionFocus === null || onSectionFocus === void 0 ? void 0 : onSectionFocus(sectionDataWithBackground);
6765
6771
  }, onBlur: () => {
6766
6772
  onSectionFocus === null || onSectionFocus === void 0 ? void 0 : onSectionFocus(null);
@@ -6772,7 +6778,7 @@ const RangeCoverageComponent = (_a) => {
6772
6778
  }
6773
6779
  return (
6774
6780
  // Sections cannot overlap, so from-to should be unique
6775
- jsxRuntime.jsxs(Tooltip.Root, { delayDuration: (_b = tooltipContent === null || tooltipContent === void 0 ? void 0 : tooltipContent.delayDuration) !== null && _b !== void 0 ? _b : 100, children: [jsxRuntime.jsx(Tooltip.Trigger, { asChild: true, children: jsxRuntime.jsx("button", { "aria-label": ariaLabel, style: segmentStyle, onFocus: () => {
6781
+ jsxRuntime.jsxs(Tooltip.Root, { delayDuration: (_b = tooltipContent === null || tooltipContent === void 0 ? void 0 : tooltipContent.delayDuration) !== null && _b !== void 0 ? _b : 100, children: [jsxRuntime.jsx(Tooltip.Trigger, { asChild: true, children: jsxRuntime.jsx("button", { "aria-label": ariaLabel, "aria-describedby": legendId, style: segmentStyle, onFocus: () => {
6776
6782
  onSectionFocus === null || onSectionFocus === void 0 ? void 0 : onSectionFocus(sectionDataWithBackground);
6777
6783
  }, onBlur: () => {
6778
6784
  onSectionFocus === null || onSectionFocus === void 0 ? void 0 : onSectionFocus(null);
@@ -6785,7 +6791,7 @@ const RangeCoverageComponent = (_a) => {
6785
6791
  maxWidth: 600
6786
6792
  }, children: jsxRuntime.jsx(Card, { border: true, elevation: "medium", width: "full", children: renderedTooltipContent }) })] }, ariaLabel)
6787
6793
  );
6788
- }) }) }), highlightPosition && jsxRuntime.jsx("div", { "aria-hidden": "true", style: getHighlightStyle(highlightPosition) })] }), ticks.length > 0 && jsxRuntime.jsx("div", { style: ticksContainerStyle, children: ticks.map((tick, index) => {
6794
+ }) }) }), highlightPosition && highlightedRange && jsxRuntime.jsx("div", { role: "img", "aria-label": highlightedRange.label ? `${highlightedRange.label} (${highlightedRange.from} - ${highlightedRange.to})` : `${highlightedRange.from} - ${highlightedRange.to}`, style: getHighlightStyle(highlightPosition) })] }), ticks.length > 0 && jsxRuntime.jsx("div", { style: ticksContainerStyle, children: ticks.map((tick, index) => {
6789
6795
  const totalRange = Math.abs(end - start);
6790
6796
  const isDescending = start > end;
6791
6797
  const position = isDescending ? (start - tick) / totalRange * 100 : (tick - start) / totalRange * 100;