@luscii-healthtech/web-ui 42.8.7 → 42.10.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.
@@ -238,10 +238,12 @@ var css_248z$h = "/* https://stackoverflow.com/a/13924997 */\n.ui\\:text-two-lin
238
238
  styleInject(css_248z$h);
239
239
 
240
240
  const responsiveTextSizeVariants = {
241
+ xs: "ui:text-[12px]",
241
242
  sm: "ui:text-sm ui:sm:text-xs",
242
243
  base: "ui:text-base ui:sm:text-sm"
243
244
  };
244
245
  const allowedTextStyles = {
246
+ xs: `${responsiveTextSizeVariants.xs} ui:font-[400] ui:leading-[16px]`,
245
247
  sm: `${responsiveTextSizeVariants.sm} ui:font-medium`,
246
248
  "sm-strong": `${responsiveTextSizeVariants.sm} ui:font-semibold ui:antialiased`,
247
249
  base: `${responsiveTextSizeVariants.base} ui:font-normal`,
@@ -281,7 +283,8 @@ const allowedColors = {
281
283
  "negative-solid": "ui:text-negative-solid",
282
284
  "neutral-interactive": "ui:text-neutral-interactive",
283
285
  primary: "ui:text-primary",
284
- "primary-dark": "ui:text-primary-dark"
286
+ "primary-dark": "ui:text-primary-dark",
287
+ active: "ui:text-text-body-active"
285
288
  };
286
289
  const allowedHoverColors = {
287
290
  "blue-900": "ui:hover:text-primary-dark",
@@ -5938,6 +5941,159 @@ const Collapse = (props) => {
5938
5941
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("button", { className: buttonClassName, onClick, "aria-expanded": !isCollapsed, children: [jsxRuntime.jsx("div", { className: contentClassName, children }), isCollapsed && showMoreIndicator && moreIndicator] }) });
5939
5942
  };
5940
5943
 
5944
+ function isColorTuple(color) {
5945
+ return Array.isArray(color) && color.length === 2;
5946
+ }
5947
+ const validateNoOverlaps = (sections) => {
5948
+ sections.forEach((sectionA, i) => {
5949
+ sections.slice(i + 1).forEach((sectionB) => {
5950
+ const aMin = Math.min(sectionA.from, sectionA.to);
5951
+ const aMax = Math.max(sectionA.from, sectionA.to);
5952
+ const bMin = Math.min(sectionB.from, sectionB.to);
5953
+ const bMax = Math.max(sectionB.from, sectionB.to);
5954
+ const overlaps = aMin < bMax && bMin < aMax;
5955
+ if (overlaps) {
5956
+ throw new Error(`RangeCoverage: Sections cannot overlap. Section [${sectionA.from}, ${sectionA.to}] overlaps with section [${sectionB.from}, ${sectionB.to}].`);
5957
+ }
5958
+ });
5959
+ });
5960
+ };
5961
+ const generateIntermediateTicks = (args) => {
5962
+ const { step, start, end } = args;
5963
+ const tickSet = /* @__PURE__ */ new Set();
5964
+ const isDescending = start > end;
5965
+ let currentValue = start;
5966
+ const rangeMin = Math.min(start, end);
5967
+ const rangeMax = Math.max(start, end);
5968
+ tickSet.add(start);
5969
+ tickSet.add(end);
5970
+ while (currentValue >= rangeMin && currentValue <= rangeMax) {
5971
+ tickSet.add(currentValue);
5972
+ if (isDescending) {
5973
+ currentValue -= step;
5974
+ } else {
5975
+ currentValue += step;
5976
+ }
5977
+ }
5978
+ return Array.from(tickSet).sort((a, b) => isDescending ? b - a : a - b);
5979
+ };
5980
+ const calculateSegments = (sections, start, end) => {
5981
+ const isDescending = start > end;
5982
+ const rangeMin = Math.min(start, end);
5983
+ const rangeMax = Math.max(start, end);
5984
+ const totalRange = Math.abs(end - start);
5985
+ const segments = [];
5986
+ const normalizedSections = sections.map((section) => {
5987
+ const clampedFrom = Math.max(rangeMin, Math.min(rangeMax, section.from));
5988
+ const clampedTo = Math.max(rangeMin, Math.min(rangeMax, section.to));
5989
+ const higher = Math.max(clampedFrom, clampedTo);
5990
+ const lower = Math.min(clampedFrom, clampedTo);
5991
+ const startPos = isDescending ? (start - higher) / totalRange * 100 : (lower - start) / totalRange * 100;
5992
+ const width = (higher - lower) / totalRange * 100;
5993
+ return {
5994
+ startPos,
5995
+ width,
5996
+ color: section.color
5997
+ };
5998
+ }).filter((s) => s.width > 0).sort((a, b) => a.startPos - b.startPos);
5999
+ let currentPos = 0;
6000
+ for (const section of normalizedSections) {
6001
+ if (section.startPos > currentPos) {
6002
+ segments.push({
6003
+ widthPercent: section.startPos - currentPos,
6004
+ color: "transparent"
6005
+ });
6006
+ }
6007
+ segments.push({
6008
+ widthPercent: section.width,
6009
+ color: section.color
6010
+ });
6011
+ currentPos = section.startPos + section.width;
6012
+ }
6013
+ if (currentPos < 100) {
6014
+ segments.push({
6015
+ widthPercent: 100 - currentPos,
6016
+ color: "transparent"
6017
+ });
6018
+ }
6019
+ return segments;
6020
+ };
6021
+ const createStripedPattern = (colorA, colorB) => `repeating-linear-gradient(-45deg, ${colorA}, ${colorA} 4px, ${colorB} 4px, ${colorB} 8px)`;
6022
+ const getSegmentStyle = (color) => {
6023
+ const baseStyle = {
6024
+ height: "18px",
6025
+ boxSizing: "content-box"
6026
+ };
6027
+ if (isColorTuple(color)) {
6028
+ return Object.assign(Object.assign({}, baseStyle), { background: createStripedPattern(color[0], color[1]) });
6029
+ }
6030
+ return Object.assign(Object.assign({}, baseStyle), { background: color });
6031
+ };
6032
+ const legendSwatchStyle = {
6033
+ width: "18px",
6034
+ height: "18px",
6035
+ borderRadius: "2px",
6036
+ flexShrink: 0
6037
+ };
6038
+ const COLOR_RED = "var(--ui-color-red-800)";
6039
+ const COLOR_AMBER = "var(--ui-color-amber-700)";
6040
+ const COLOR_GREY_DARK = "var(--ui-color-slate-700)";
6041
+ const COLOR_GREY_LIGHT = "var(--ui-color-slate-300)";
6042
+ const COLOR_BLUE = "var(--ui-color-blue-200)";
6043
+ const BORDER_COLOR = COLOR_GREY_LIGHT;
6044
+ const BORDER_RADIUS = "var(--ui-radius-sm, 4px)";
6045
+ const barContainerStyle = {
6046
+ width: "100%",
6047
+ border: `1px solid ${BORDER_COLOR}`,
6048
+ borderRadius: BORDER_RADIUS,
6049
+ overflow: "hidden"
6050
+ };
6051
+ const barStyle = {
6052
+ display: "flex",
6053
+ alignItems: "center",
6054
+ width: "100%",
6055
+ height: "24px",
6056
+ padding: "0 3px",
6057
+ // 3px looks better than 4px
6058
+ boxSizing: "border-box"
6059
+ };
6060
+ const ticksContainerStyle = {
6061
+ position: "relative",
6062
+ width: "100%",
6063
+ height: "20px"
6064
+ };
6065
+ const RangeCoverageComponent = ({ sections, start, end, ticks = [], title, legendSwatches, className }) => {
6066
+ validateNoOverlaps(sections);
6067
+ const segments = calculateSegments(sections, start, end);
6068
+ return jsxRuntime.jsx(Box, { className, children: jsxRuntime.jsxs(Stack, { gap: "xs", 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: "m", children: jsxRuntime.jsx(Stack, { axis: "x", gap: "xxs", align: "center", children: legendSwatches === null || legendSwatches === void 0 ? void 0 : legendSwatches.map((swatch) => {
6069
+ const background = isColorTuple(swatch.color) ? createStripedPattern(swatch.color[0], swatch.color[1]) : swatch.color;
6070
+ 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);
6071
+ }) }) })] }), jsxRuntime.jsxs(Stack, { gap: "xs", width: "full", align: "stretch", children: [jsxRuntime.jsx("div", { style: barContainerStyle, children: jsxRuntime.jsx("div", { style: barStyle, children: segments.map((segment, index) => jsxRuntime.jsx("div", { style: Object.assign({ flexBasis: `${segment.widthPercent}%`, flexGrow: 0, flexShrink: 0 }, getSegmentStyle(segment.color)) }, index)) }) }), ticks.length > 0 && jsxRuntime.jsx("div", { style: ticksContainerStyle, children: ticks.map((tick, index) => {
6072
+ const totalRange = Math.abs(end - start);
6073
+ const isDescending = start > end;
6074
+ const position = isDescending ? (start - tick) / totalRange * 100 : (tick - start) / totalRange * 100;
6075
+ const isFirst = index === 0;
6076
+ const isLast = index === ticks.length - 1;
6077
+ return jsxRuntime.jsx(Text, { style: {
6078
+ position: "absolute",
6079
+ color: COLOR_GREY_DARK,
6080
+ whiteSpace: "nowrap",
6081
+ left: `${position}%`,
6082
+ transform: isFirst ? "translateX(0%)" : isLast ? "translateX(-100%)" : "translateX(-50%)"
6083
+ }, children: tick }, tick);
6084
+ }) })] })] }) });
6085
+ };
6086
+ const RangeCoverage = Object.assign(RangeCoverageComponent, {
6087
+ Colors: {
6088
+ RED: COLOR_RED,
6089
+ AMBER: COLOR_AMBER,
6090
+ GREY_DARK: COLOR_GREY_DARK,
6091
+ GREY_LIGHT: COLOR_GREY_LIGHT,
6092
+ BLUE: COLOR_BLUE
6093
+ },
6094
+ generateIntermediateTicks
6095
+ });
6096
+
5941
6097
  const AsideLayout = (_a) => {
5942
6098
  var { aside, children } = _a, rest = __rest(_a, ["aside", "children"]);
5943
6099
  const containerClasses = classNames__default.default("ui:flex-col ui:md:flex-row");
@@ -6444,6 +6600,7 @@ exports.Radio = Radio;
6444
6600
  exports.RadioGroup = RadioGroup;
6445
6601
  exports.RadioGroupV2 = RadioGroupV2;
6446
6602
  exports.RadioV2 = RadioV2;
6603
+ exports.RangeCoverage = RangeCoverage;
6447
6604
  exports.RedAlertColoredIcon = RedAlertColoredIcon;
6448
6605
  exports.RedAlertIcon = RedAlertIcon;
6449
6606
  exports.RightArrowIcon = ChevronRightIcon;