@luscii-healthtech/web-ui 57.0.0 → 57.0.2

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.
@@ -6592,6 +6592,23 @@ const calculateSegments = (args) => {
6592
6592
  }
6593
6593
  return segments;
6594
6594
  };
6595
+ const calculateHighlightPosition = (args) => {
6596
+ const { highlightedRange, start, end } = args;
6597
+ const isDescending = start > end;
6598
+ const rangeMin = Math.min(start, end);
6599
+ const rangeMax = Math.max(start, end);
6600
+ const totalRange = Math.abs(end - start);
6601
+ const clampedFrom = Math.max(rangeMin, Math.min(rangeMax, highlightedRange.from));
6602
+ const clampedTo = Math.max(rangeMin, Math.min(rangeMax, highlightedRange.to));
6603
+ const higher = Math.max(clampedFrom, clampedTo);
6604
+ const lower = Math.min(clampedFrom, clampedTo);
6605
+ const widthFraction = (higher - lower) / totalRange;
6606
+ if (widthFraction <= 0) {
6607
+ return null;
6608
+ }
6609
+ const leftFraction = isDescending ? (start - higher) / totalRange : (lower - start) / totalRange;
6610
+ return { leftFraction, widthFraction };
6611
+ };
6595
6612
  const createStripedPattern = (options) => {
6596
6613
  const { colorA, colorB, startOffset = 0 } = options;
6597
6614
  const STRIPE_THICKNESS = 4;
@@ -6645,26 +6662,42 @@ const barStyle = {
6645
6662
  // 3px looks better than 4px
6646
6663
  boxSizing: "border-box"
6647
6664
  };
6665
+ const HIGHLIGHT_RING_COLOR = "var(--ui-color-border-brand-primary-selected)";
6666
+ const HIGHLIGHT_RING_WIDTH = 2;
6667
+ const HIGHLIGHT_RING_INSET = 4;
6668
+ const BAR_HORIZONTAL_PADDING = 3;
6669
+ const getHighlightStyle = (position) => ({
6670
+ position: "absolute",
6671
+ top: -HIGHLIGHT_RING_INSET,
6672
+ bottom: -HIGHLIGHT_RING_INSET,
6673
+ left: `calc(${BAR_HORIZONTAL_PADDING}px + (100% - ${BAR_HORIZONTAL_PADDING * 2}px) * ${position.leftFraction})`,
6674
+ width: `calc((100% - ${BAR_HORIZONTAL_PADDING * 2}px) * ${position.widthFraction})`,
6675
+ border: `${HIGHLIGHT_RING_WIDTH}px solid ${HIGHLIGHT_RING_COLOR}`,
6676
+ borderRadius: `calc(${BORDER_RADIUS} + ${HIGHLIGHT_RING_INSET}px)`,
6677
+ boxSizing: "border-box",
6678
+ pointerEvents: "none"
6679
+ });
6648
6680
  const ticksContainerStyle = {
6649
6681
  position: "relative",
6650
6682
  width: "100%",
6651
6683
  height: "20px"
6652
6684
  };
6653
6685
  const RangeCoverageComponent = (_a) => {
6654
- var { sections, start, end, ticks = [], tickFormatter, title, legendSwatches, onSectionFocus, translations, className, slots } = _a, rest = __rest(_a, ["sections", "start", "end", "ticks", "tickFormatter", "title", "legendSwatches", "onSectionFocus", "translations", "className", "slots"]);
6686
+ 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"]);
6655
6687
  const { tooltipContent } = slots !== null && slots !== void 0 ? slots : {};
6656
6688
  if (hasSectionOverlaps(sections)) {
6657
6689
  return jsxRuntime.jsx(Text, { variant: "strong", children: translations.sectionOverlapsMessage });
6658
6690
  }
6659
6691
  const segments = calculateSegments({ sections, start, end });
6660
- 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", 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) => {
6692
+ const highlightPosition = highlightedRange ? calculateHighlightPosition({ highlightedRange, start, end }) : null;
6693
+ 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) => {
6661
6694
  const background = isColorTuple(swatch.color) ? createStripedPattern({
6662
6695
  colorA: swatch.color[0],
6663
6696
  colorB: swatch.color[1],
6664
6697
  startOffset: -6
6665
6698
  }) : swatch.color;
6666
6699
  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);
6667
- }) }) })] }), jsxRuntime.jsxs(Stack, { _gap: "m", width: "full", align: "stretch", children: [jsxRuntime.jsx("div", { style: barContainerStyle, children: jsxRuntime.jsx("div", { style: barStyle, children: segments.map((segment) => {
6700
+ }) }) })] }), 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) => {
6668
6701
  var _a2, _b;
6669
6702
  const sectionDataWithBackground = Object.assign(Object.assign({}, segment.originalSection), { background: getSegmentStyle(segment.color).background });
6670
6703
  const renderedTooltipContent = (_a2 = tooltipContent === null || tooltipContent === void 0 ? void 0 : tooltipContent.render) === null || _a2 === void 0 ? void 0 : _a2.call(tooltipContent, sectionDataWithBackground);
@@ -6699,7 +6732,7 @@ const RangeCoverageComponent = (_a) => {
6699
6732
  maxWidth: 600
6700
6733
  }, children: jsxRuntime.jsx(Card, { border: true, elevation: "medium", width: "full", children: renderedTooltipContent }) })] }, ariaLabel)
6701
6734
  );
6702
- }) }) }), ticks.length > 0 && jsxRuntime.jsx("div", { style: ticksContainerStyle, children: ticks.map((tick, index) => {
6735
+ }) }) }), highlightPosition && jsxRuntime.jsx("div", { "aria-hidden": "true", style: getHighlightStyle(highlightPosition) })] }), ticks.length > 0 && jsxRuntime.jsx("div", { style: ticksContainerStyle, children: ticks.map((tick, index) => {
6703
6736
  const totalRange = Math.abs(end - start);
6704
6737
  const isDescending = start > end;
6705
6738
  const position = isDescending ? (start - tick) / totalRange * 100 : (tick - start) / totalRange * 100;