@bpfdev/oly-ui 1.0.15 → 1.0.16

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/dist/index.d.mts CHANGED
@@ -3957,6 +3957,39 @@ type PeakBillingHoursProps = {
3957
3957
  * `0` = horizontal (default), `-90` = vertical.
3958
3958
  */
3959
3959
  barValueLabelAngle?: number;
3960
+ /**
3961
+ * Formats the bar-top value label. Defaults to rounding to the nearest
3962
+ * integer (`Math.round`). Pass e.g. `(v) => v.toFixed(1)` for metrics that
3963
+ * are meaningfully fractional, such as an average queue time in minutes.
3964
+ *
3965
+ * Used as-is when rendering a single series via `data`. When rendering
3966
+ * multiple tabs via `seriesByTabId`, this is the fallback for any tab not
3967
+ * present in `valueFormattersByTabId`.
3968
+ */
3969
+ barValueLabelFormatter?: (value: number) => string;
3970
+ /**
3971
+ * Per-tab bar-top value label formatters, keyed by tab id (mirrors
3972
+ * `seriesByTabId`). Only the active tab's formatter is used at a time. A
3973
+ * tab with no entry here falls back to `barValueLabelFormatter`, then to
3974
+ * rounding to the nearest integer. Use this when some tabs are
3975
+ * whole-number metrics and others are fractional, e.g.:
3976
+ * `{ queue: (v) => v.toFixed(1) }`.
3977
+ */
3978
+ valueFormattersByTabId?: Record<string, (value: number) => string>;
3979
+ /**
3980
+ * Formats the "Total" value in the default tooltip. Defaults to rounding
3981
+ * to the nearest integer with thousands separators. Ignored when
3982
+ * `renderTooltip` is provided. Used as-is for a single series via `data`;
3983
+ * for `seriesByTabId`, this is the fallback for any tab not present in
3984
+ * `tooltipValueFormattersByTabId`.
3985
+ */
3986
+ tooltipValueFormatter?: (value: number) => string;
3987
+ /**
3988
+ * Per-tab default-tooltip value formatters, keyed by tab id (mirrors
3989
+ * `valueFormattersByTabId`, but for the tooltip's "Total" line rather than
3990
+ * the bar-top label). Ignored when `renderTooltip` is provided.
3991
+ */
3992
+ tooltipValueFormattersByTabId?: Record<string, (value: number) => string>;
3960
3993
  yAxisDomain?: [number, number];
3961
3994
  yAxisTicks?: number[];
3962
3995
  infoPopover?: ChartWidgetInfoPopoverContent | null;
@@ -3977,7 +4010,7 @@ declare const peakBillingHoursMockSeriesByTabId: Record<string, PeakBillingHours
3977
4010
  * Peak billing hours card: title + subtitle, info control, violet segmented tabs (intrinsic),
3978
4011
  * vertical bar chart with square tops, value labels, and panel tooltip.
3979
4012
  */
3980
- declare function PeakBillingHours({ title, subtitle, tabs, activeTabId, onTabChange, data, isLoading, seriesByTabId, chartMargin, yAxisTickDx, yAxisTickStyle, xAxisTickDx, xAxisTickStyle, barValueLabelAngle, yAxisDomain, yAxisTicks, infoPopover, renderTooltip, emptyStatePlaceholderProps, customization, }: PeakBillingHoursProps): React$1.ReactElement;
4013
+ declare function PeakBillingHours({ title, subtitle, tabs, activeTabId, onTabChange, data, isLoading, seriesByTabId, chartMargin, yAxisTickDx, yAxisTickStyle, xAxisTickDx, xAxisTickStyle, barValueLabelAngle, barValueLabelFormatter, valueFormattersByTabId, tooltipValueFormatter, tooltipValueFormattersByTabId, yAxisDomain, yAxisTicks, infoPopover, renderTooltip, emptyStatePlaceholderProps, customization, }: PeakBillingHoursProps): React$1.ReactElement;
3981
4014
 
3982
4015
  type PeakBillingHoursCustomizationProviderProps = {
3983
4016
  value: PeakBillingHoursCustomization;
package/dist/index.d.ts CHANGED
@@ -3957,6 +3957,39 @@ type PeakBillingHoursProps = {
3957
3957
  * `0` = horizontal (default), `-90` = vertical.
3958
3958
  */
3959
3959
  barValueLabelAngle?: number;
3960
+ /**
3961
+ * Formats the bar-top value label. Defaults to rounding to the nearest
3962
+ * integer (`Math.round`). Pass e.g. `(v) => v.toFixed(1)` for metrics that
3963
+ * are meaningfully fractional, such as an average queue time in minutes.
3964
+ *
3965
+ * Used as-is when rendering a single series via `data`. When rendering
3966
+ * multiple tabs via `seriesByTabId`, this is the fallback for any tab not
3967
+ * present in `valueFormattersByTabId`.
3968
+ */
3969
+ barValueLabelFormatter?: (value: number) => string;
3970
+ /**
3971
+ * Per-tab bar-top value label formatters, keyed by tab id (mirrors
3972
+ * `seriesByTabId`). Only the active tab's formatter is used at a time. A
3973
+ * tab with no entry here falls back to `barValueLabelFormatter`, then to
3974
+ * rounding to the nearest integer. Use this when some tabs are
3975
+ * whole-number metrics and others are fractional, e.g.:
3976
+ * `{ queue: (v) => v.toFixed(1) }`.
3977
+ */
3978
+ valueFormattersByTabId?: Record<string, (value: number) => string>;
3979
+ /**
3980
+ * Formats the "Total" value in the default tooltip. Defaults to rounding
3981
+ * to the nearest integer with thousands separators. Ignored when
3982
+ * `renderTooltip` is provided. Used as-is for a single series via `data`;
3983
+ * for `seriesByTabId`, this is the fallback for any tab not present in
3984
+ * `tooltipValueFormattersByTabId`.
3985
+ */
3986
+ tooltipValueFormatter?: (value: number) => string;
3987
+ /**
3988
+ * Per-tab default-tooltip value formatters, keyed by tab id (mirrors
3989
+ * `valueFormattersByTabId`, but for the tooltip's "Total" line rather than
3990
+ * the bar-top label). Ignored when `renderTooltip` is provided.
3991
+ */
3992
+ tooltipValueFormattersByTabId?: Record<string, (value: number) => string>;
3960
3993
  yAxisDomain?: [number, number];
3961
3994
  yAxisTicks?: number[];
3962
3995
  infoPopover?: ChartWidgetInfoPopoverContent | null;
@@ -3977,7 +4010,7 @@ declare const peakBillingHoursMockSeriesByTabId: Record<string, PeakBillingHours
3977
4010
  * Peak billing hours card: title + subtitle, info control, violet segmented tabs (intrinsic),
3978
4011
  * vertical bar chart with square tops, value labels, and panel tooltip.
3979
4012
  */
3980
- declare function PeakBillingHours({ title, subtitle, tabs, activeTabId, onTabChange, data, isLoading, seriesByTabId, chartMargin, yAxisTickDx, yAxisTickStyle, xAxisTickDx, xAxisTickStyle, barValueLabelAngle, yAxisDomain, yAxisTicks, infoPopover, renderTooltip, emptyStatePlaceholderProps, customization, }: PeakBillingHoursProps): React$1.ReactElement;
4013
+ declare function PeakBillingHours({ title, subtitle, tabs, activeTabId, onTabChange, data, isLoading, seriesByTabId, chartMargin, yAxisTickDx, yAxisTickStyle, xAxisTickDx, xAxisTickStyle, barValueLabelAngle, barValueLabelFormatter, valueFormattersByTabId, tooltipValueFormatter, tooltipValueFormattersByTabId, yAxisDomain, yAxisTicks, infoPopover, renderTooltip, emptyStatePlaceholderProps, customization, }: PeakBillingHoursProps): React$1.ReactElement;
3981
4014
 
3982
4015
  type PeakBillingHoursCustomizationProviderProps = {
3983
4016
  value: PeakBillingHoursCustomization;
package/dist/index.js CHANGED
@@ -17053,7 +17053,7 @@ function formatTooltipValue2(n) {
17053
17053
  );
17054
17054
  }
17055
17055
  function PeakBillingHoursTooltip(props) {
17056
- const { active, payload, label } = props;
17056
+ const { active, payload, label, formatValue: formatValue3 } = props;
17057
17057
  const { barChart: bc } = usePeakBillingHoursCustomization();
17058
17058
  const tt = bc?.tooltip;
17059
17059
  if (!active || !payload?.length) {
@@ -17130,7 +17130,7 @@ function PeakBillingHoursTooltip(props) {
17130
17130
  ] }),
17131
17131
  /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { style: { ...rowStyle, marginTop: gap }, children: [
17132
17132
  /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { style: { color: prefixCol, fontWeight: prefixFw }, children: totalP }),
17133
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { style: { color: valueCol, fontWeight: valueFw }, children: formatTooltipValue2(num) })
17133
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { style: { color: valueCol, fontWeight: valueFw }, children: formatValue3 ? formatValue3(num) : formatTooltipValue2(num) })
17134
17134
  ] })
17135
17135
  ] })
17136
17136
  ]
@@ -17153,7 +17153,17 @@ function toNum5(n) {
17153
17153
  return typeof n === "number" ? n : Number(n);
17154
17154
  }
17155
17155
  function PeakBarTopLabel(props) {
17156
- const { x, y, width, value, fill, fontSize, fontWeight, angle = 0 } = props;
17156
+ const {
17157
+ x,
17158
+ y,
17159
+ width,
17160
+ value,
17161
+ fill,
17162
+ fontSize,
17163
+ fontWeight,
17164
+ angle = 0,
17165
+ formatValue: formatValue3
17166
+ } = props;
17157
17167
  const nx = toNum5(x);
17158
17168
  const ny = toNum5(y);
17159
17169
  const nw = toNum5(width);
@@ -17177,7 +17187,7 @@ function PeakBarTopLabel(props) {
17177
17187
  fontWeight,
17178
17188
  textAnchor: isHorizontal ? "middle" : "start",
17179
17189
  transform: isHorizontal ? void 0 : `rotate(${angle} ${cx} ${cy})`,
17180
- children: String(Math.round(n))
17190
+ children: formatValue3 ? formatValue3(n) : String(Math.round(n))
17181
17191
  }
17182
17192
  );
17183
17193
  }
@@ -17192,7 +17202,9 @@ function BarPlot2({
17192
17202
  yAxisTickStyle,
17193
17203
  xAxisTickDx = 0,
17194
17204
  xAxisTickStyle,
17195
- barValueLabelAngle = 0
17205
+ barValueLabelAngle = 0,
17206
+ barValueLabelFormatter,
17207
+ tooltipValueFormatter
17196
17208
  }) {
17197
17209
  const { barChart: bc } = usePeakBillingHoursCustomization();
17198
17210
  const height = bc?.heightPx ?? 320;
@@ -17274,7 +17286,13 @@ function BarPlot2({
17274
17286
  });
17275
17287
  return customTooltip == null ? null : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_jsx_runtime55.Fragment, { children: customTooltip });
17276
17288
  }
17277
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PeakBillingHoursTooltip, { ...tooltipProps });
17289
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
17290
+ PeakBillingHoursTooltip,
17291
+ {
17292
+ ...tooltipProps,
17293
+ formatValue: tooltipValueFormatter
17294
+ }
17295
+ );
17278
17296
  },
17279
17297
  cursor: {
17280
17298
  fill: hoverBandFill,
@@ -17304,7 +17322,8 @@ function BarPlot2({
17304
17322
  fill: labelFill,
17305
17323
  fontSize: labelFs,
17306
17324
  fontWeight: 500,
17307
- angle: barValueLabelAngle
17325
+ angle: barValueLabelAngle,
17326
+ formatValue: barValueLabelFormatter
17308
17327
  }
17309
17328
  )
17310
17329
  }
@@ -17330,6 +17349,10 @@ function PeakBillingHours({
17330
17349
  xAxisTickDx = 0,
17331
17350
  xAxisTickStyle,
17332
17351
  barValueLabelAngle = 0,
17352
+ barValueLabelFormatter,
17353
+ valueFormattersByTabId,
17354
+ tooltipValueFormatter,
17355
+ tooltipValueFormattersByTabId,
17333
17356
  yAxisDomain = [0, 50],
17334
17357
  yAxisTicks = [0, 10, 20, 30, 40, 50],
17335
17358
  infoPopover,
@@ -17343,6 +17366,8 @@ function PeakBillingHours({
17343
17366
  }
17344
17367
  return data ?? [];
17345
17368
  }, [seriesByTabId, data, activeTabId]);
17369
+ const resolvedBarValueLabelFormatter = valueFormattersByTabId?.[activeTabId] ?? barValueLabelFormatter;
17370
+ const resolvedTooltipValueFormatter = tooltipValueFormattersByTabId?.[activeTabId] ?? tooltipValueFormatter;
17346
17371
  const resolvedInfo = infoPopover === void 0 ? DEFAULT_PEAK_BILLING_HOURS_INFO_POPOVER : infoPopover;
17347
17372
  const rootSx = mergeSx3(
17348
17373
  {
@@ -17441,7 +17466,9 @@ function PeakBillingHours({
17441
17466
  yAxisTickStyle,
17442
17467
  xAxisTickDx,
17443
17468
  xAxisTickStyle,
17444
- barValueLabelAngle
17469
+ barValueLabelAngle,
17470
+ barValueLabelFormatter: resolvedBarValueLabelFormatter,
17471
+ tooltipValueFormatter: resolvedTooltipValueFormatter
17445
17472
  }
17446
17473
  ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
17447
17474
  ChartEmptyState,