@sybilion/uilib 1.3.103 → 1.3.105

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.
@@ -6,18 +6,22 @@ import 'recharts';
6
6
  import '../../../Chart/Chart.context.js';
7
7
  import '../../../Chart/Chart.styl.js';
8
8
  import { useDebounceCallback } from '../../../../../hooks/useDebounceCallback.js';
9
+ import useElemDrag from '../../../../../hooks/useDragElem.js';
9
10
  import { ChevronsLeftRight } from 'lucide-react';
10
11
  import S from '../../ChartAreaInteractive.styl.js';
11
12
  import { useChartYRange } from '../useChartYRange.js';
12
13
  import S$1 from './PinOverlay.styl.js';
13
14
 
14
- function PinOverlay({ baseChartProps, pinMonth, onPinMonthChange, onPreviewMonthChange: _onPreviewMonthChange, className, }) {
15
+ function PinOverlay({ baseChartProps, pinMonth, onPinMonthChange, onPreviewMonthChange, className, }) {
15
16
  const { chartData } = baseChartProps;
16
17
  const chartRef = useRef(null);
17
18
  const pinRef = useRef(null);
18
19
  const pinPlaceholderRef = useRef(null);
19
20
  const pinContainerRef = useRef(null);
21
+ const containerRectRef = useRef(null);
20
22
  const [isPinHovered, setIsPinHovered] = useState(false);
23
+ const [isDraggingPin, setIsDraggingPin] = useState(false);
24
+ const [isPinAnimating, setIsPinAnimating] = useState(true);
21
25
  const pinPosRef = useRef(0);
22
26
  const currPinMonthRef = useRef(pinMonth);
23
27
  const debouncedOnPinMonthChange = useDebounceCallback((...args) => onPinMonthChange?.(args[0]), 500, [onPinMonthChange]);
@@ -97,6 +101,57 @@ function PinOverlay({ baseChartProps, pinMonth, onPinMonthChange, onPreviewMonth
97
101
  currPinMonthRef.current = pinMonth;
98
102
  }
99
103
  }, [pinMonth, chartData]);
104
+ const clearPinTransforms = () => {
105
+ if (pinRef.current) {
106
+ pinRef.current.style.transform = '';
107
+ pinRef.current.style.transition = '';
108
+ }
109
+ if (pinPlaceholderRef.current) {
110
+ pinPlaceholderRef.current.style.transform = '';
111
+ pinPlaceholderRef.current.style.transition = '';
112
+ }
113
+ };
114
+ useElemDrag({
115
+ elem: pinPlaceholderRef,
116
+ isActive: chartData.length > 0,
117
+ onDragStart: e => {
118
+ e.stopPropagation();
119
+ setIsDraggingPin(true);
120
+ setIsPinAnimating(false);
121
+ containerRectRef.current =
122
+ pinContainerRef.current?.getBoundingClientRect() ?? null;
123
+ if (pinRef.current)
124
+ pinRef.current.style.transition = 'none';
125
+ if (pinPlaceholderRef.current) {
126
+ pinPlaceholderRef.current.style.transition = 'none';
127
+ }
128
+ },
129
+ onDrag: (_delta, e) => {
130
+ const containerRect = containerRectRef.current;
131
+ if (!containerRect)
132
+ return;
133
+ const pinCurrentLeft = (pinPosRef.current / 100) * containerRect.width;
134
+ const relativeX = e.clientX - containerRect.left;
135
+ const clampedX = Math.max(0, Math.min(containerRect.width, relativeX));
136
+ const translateX = clampedX - pinCurrentLeft;
137
+ const transform = `translateX(${translateX}px)`;
138
+ if (pinRef.current)
139
+ pinRef.current.style.transform = transform;
140
+ if (pinPlaceholderRef.current) {
141
+ pinPlaceholderRef.current.style.transform = transform;
142
+ }
143
+ const previewPercent = containerRect.width > 0 ? (clampedX / containerRect.width) * 100 : 0;
144
+ onPreviewMonthChange?.(getPinMonthAndYear(previewPercent) ?? undefined);
145
+ },
146
+ onDragEnd: e => {
147
+ e.stopPropagation();
148
+ setIsDraggingPin(false);
149
+ setTimeout(() => setIsPinAnimating(true), 200);
150
+ containerRectRef.current = null;
151
+ clearPinTransforms();
152
+ snapPinToPosition(e.clientX, true, true);
153
+ },
154
+ });
100
155
  const onChartClick = (e) => {
101
156
  if (e.button !== 0)
102
157
  return;
@@ -105,8 +160,8 @@ function PinOverlay({ baseChartProps, pinMonth, onPinMonthChange, onPreviewMonth
105
160
  return;
106
161
  snapPinToPosition(e.clientX, true, false);
107
162
  };
108
- const overlay = (jsxs(Fragment, { children: [jsx("div", { className: cn(S.overlay, S$1.pinContainer), ref: pinContainerRef, children: jsx("div", { className: S$1.pinLineBase, style: { left: `${pinPosRef.current}%` }, ref: pinRef, children: jsx("div", { className: S$1.pinButton, "aria-label": "News pin", title: `Current month: ${getPinMonthAndYear() || 'Loading...'}`, children: jsx(ChevronsLeftRight, { className: S$1.pinIcon, "aria-hidden": "true" }) }) }) }), jsx("div", { className: S$1.pinPlaceholder, style: { left: `${pinPosRef.current}%` }, ref: pinPlaceholderRef, onPointerEnter: () => setIsPinHovered(true), onPointerLeave: () => setIsPinHovered(false) })] }));
109
- return (jsx("div", { className: cn(className, S$1.root, S$1.pinAnimating, isPinHovered && S$1.pinHovered), onClick: onChartClick, ref: chartRef, children: jsx(BaseChartWrapper, { ...baseChartProps, yMin: yMin, yMax: yMax, autoScaleYAxis: false, overlayElements: overlay }) }));
163
+ const overlay = (jsxs(Fragment, { children: [jsx("div", { className: cn(S.overlay, S$1.pinContainer), ref: pinContainerRef, children: jsx("div", { className: S$1.pinLineBase, style: { left: `${pinPosRef.current}%` }, ref: pinRef, children: jsx("div", { className: S$1.pinButton, "aria-label": "News pin", title: `Current month: ${getPinMonthAndYear() || 'Loading...'}`, children: jsx(ChevronsLeftRight, { className: S$1.pinIcon, "aria-hidden": "true" }) }) }) }), jsx("div", { className: cn(S.overlay, S$1.pinPlaceholderHost), children: jsx("div", { className: S$1.pinPlaceholder, style: { left: `${pinPosRef.current}%` }, ref: pinPlaceholderRef, onPointerEnter: () => setIsPinHovered(true), onPointerLeave: () => setIsPinHovered(false) }) })] }));
164
+ return (jsx("div", { className: cn(className, S$1.root, isPinAnimating && S$1.pinAnimating, isPinHovered && S$1.pinHovered, isDraggingPin && S$1.pinDragging), onClick: onChartClick, ref: chartRef, children: jsx(BaseChartWrapper, { ...baseChartProps, yMin: yMin, yMax: yMax, autoScaleYAxis: false, showTooltip: !isDraggingPin, overlayElements: overlay }) }));
110
165
  }
111
166
 
112
167
  export { PinOverlay };
@@ -1,7 +1,7 @@
1
1
  import styleInject from 'style-inject';
2
2
 
3
- var css_248z = ".PinOverlay_root__RUZxO{touch-action:pan-y}.PinOverlay_pinContainer__6sc1J{height:calc(var(--chart-height) - 70px);inset:0;margin:var(--p-5) var(--p-8) var(--p-24) var(--p-12);pointer-events:none;position:absolute;touch-action:pan-y;transition:transform .2s ease-out,z-index 0ms;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:2}.PinOverlay_pinHovered__cGPjN .PinOverlay_pinContainer__6sc1J{z-index:10}.PinOverlay_pinLineBase__0BWsD{height:100%;pointer-events:none;position:absolute;width:3px}.PinOverlay_pinLineBase__0BWsD:before{border-radius:50%;box-shadow:0 4px 6px -1px var(--shadow-color);content:\"\";height:36px;left:-16px;position:absolute;top:-8px;width:36px;z-index:-1}.PinOverlay_pinLineBase__0BWsD:after{background-color:var(--background);border-radius:12px;bottom:0;content:\"\";left:0;position:absolute;top:0;transform:translate3d(.5px,0,0);transition:background-color .3s ease-out;width:100%;z-index:1}.PinOverlay_pinAnimating__5XMJG .PinOverlay_pinLineBase__0BWsD{transition:left .3s ease-out}.PinOverlay_pinButton__cnV1K{position:absolute;--offset:-8px;align-items:center;background-color:var(--background);border-radius:9999px;cursor:pointer;display:flex;justify-content:center;left:-8px;left:var(--offset);margin-left:-8px;margin-left:var(--offset);padding:10px;pointer-events:auto;top:-18px;touch-action:none;transition:transform .2s ease-out;-webkit-user-select:none;-moz-user-select:none;user-select:none}.PinOverlay_pinHovered__cGPjN .PinOverlay_pinButton__cnV1K{transform:scale(1.1)}.PinOverlay_pinButton__cnV1K:active{cursor:grabbing}.PinOverlay_pinIcon__s7Ze0{color:var(--foreground);height:16px;width:16px}.PinOverlay_pinPlaceholder__JhKcQ{cursor:pointer;height:72px;margin-left:-40px;margin-top:-40px;pointer-events:auto;position:absolute;top:var(--p-5);touch-action:none;width:72px;z-index:20}.PinOverlay_pinAnimating__5XMJG .PinOverlay_pinPlaceholder__JhKcQ{transition:left .3s ease-out}.PinOverlay_pinPlaceholder__JhKcQ:active{cursor:grabbing}";
4
- var S = {"root":"PinOverlay_root__RUZxO","pinContainer":"PinOverlay_pinContainer__6sc1J","pinHovered":"PinOverlay_pinHovered__cGPjN","pinLineBase":"PinOverlay_pinLineBase__0BWsD","pinAnimating":"PinOverlay_pinAnimating__5XMJG","pinButton":"PinOverlay_pinButton__cnV1K","pinIcon":"PinOverlay_pinIcon__s7Ze0","pinPlaceholder":"PinOverlay_pinPlaceholder__JhKcQ"};
3
+ var css_248z = ".PinOverlay_root__RUZxO{touch-action:pan-y}.PinOverlay_pinDragging__gu3xp .PinOverlay_pinLineBase__0BWsD{opacity:.8}.PinOverlay_pinDragging__gu3xp .PinOverlay_pinButton__cnV1K,.PinOverlay_pinDragging__gu3xp .PinOverlay_pinPlaceholder__JhKcQ{transition:none}.PinOverlay_pinContainer__6sc1J{height:calc(var(--chart-height) - 70px);inset:0;margin:var(--p-5) var(--p-8) var(--p-24) var(--p-12);pointer-events:none;position:absolute;touch-action:pan-y;transition:transform .2s ease-out,z-index 0ms;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:2}.PinOverlay_pinHovered__cGPjN .PinOverlay_pinContainer__6sc1J{z-index:10}.PinOverlay_pinLineBase__0BWsD{height:100%;pointer-events:none;position:absolute;width:3px}.PinOverlay_pinLineBase__0BWsD:before{border-radius:50%;box-shadow:0 4px 6px -1px var(--shadow-color);content:\"\";height:36px;left:-16px;position:absolute;top:-8px;width:36px;z-index:-1}.PinOverlay_pinLineBase__0BWsD:after{background-color:var(--background);border-radius:12px;bottom:0;content:\"\";left:0;position:absolute;top:0;transform:translate3d(.5px,0,0);transition:background-color .3s ease-out;width:100%;z-index:1}.PinOverlay_pinAnimating__5XMJG .PinOverlay_pinLineBase__0BWsD{transition:left .3s ease-out}.PinOverlay_pinButton__cnV1K{position:absolute;--offset:-8px;align-items:center;background-color:var(--background);border-radius:9999px;cursor:pointer;display:flex;justify-content:center;left:-8px;left:var(--offset);margin-left:-8px;margin-left:var(--offset);padding:10px;pointer-events:none;top:-18px;touch-action:none;transition:transform .2s ease-out;-webkit-user-select:none;-moz-user-select:none;user-select:none}.PinOverlay_pinHovered__cGPjN .PinOverlay_pinButton__cnV1K{transform:scale(1.1)}.PinOverlay_pinButton__cnV1K:active{cursor:grabbing}.PinOverlay_pinIcon__s7Ze0{color:var(--foreground);height:16px;width:16px}.PinOverlay_pinPlaceholderHost__oiZxE{pointer-events:none;z-index:20}.PinOverlay_pinPlaceholder__JhKcQ{cursor:pointer;height:72px;margin-left:-36px;margin-top:-36px;pointer-events:auto;position:absolute;top:0;touch-action:none;width:72px}.PinOverlay_pinAnimating__5XMJG .PinOverlay_pinPlaceholder__JhKcQ{transition:left .3s ease-out}.PinOverlay_pinPlaceholder__JhKcQ:active{cursor:grabbing}";
4
+ var S = {"root":"PinOverlay_root__RUZxO","pinDragging":"PinOverlay_pinDragging__gu3xp","pinLineBase":"PinOverlay_pinLineBase__0BWsD","pinButton":"PinOverlay_pinButton__cnV1K","pinPlaceholder":"PinOverlay_pinPlaceholder__JhKcQ","pinContainer":"PinOverlay_pinContainer__6sc1J","pinHovered":"PinOverlay_pinHovered__cGPjN","pinAnimating":"PinOverlay_pinAnimating__5XMJG","pinIcon":"PinOverlay_pinIcon__s7Ze0","pinPlaceholderHost":"PinOverlay_pinPlaceholderHost__oiZxE"};
5
5
  styleInject(css_248z);
6
6
 
7
7
  export { S as default };
@@ -26,6 +26,34 @@ const injectHTMLTags = (content) => {
26
26
  length: matches[0].length,
27
27
  };
28
28
  };
29
+ const injectHTMLCodeTags = (content) => {
30
+ const regex = /<(code)\s*>([\s\S]*?)<\/\1\s*>/i;
31
+ const matches = content.match(regex);
32
+ if (!matches)
33
+ return null;
34
+ if (isInsideHtmlListOrTable(content, matches.index)) {
35
+ return null;
36
+ }
37
+ return {
38
+ elem: jsx("code", { children: matches[2] }),
39
+ index: matches.index,
40
+ length: matches[0].length,
41
+ };
42
+ };
43
+ const injectBacktickCode = (content) => {
44
+ const regex = /`([^`\n]+?)`/;
45
+ const matches = content.match(regex);
46
+ if (!matches)
47
+ return null;
48
+ if (isInsideHtmlListOrTable(content, matches.index)) {
49
+ return null;
50
+ }
51
+ return {
52
+ elem: jsx("code", { children: matches[1] }),
53
+ index: matches.index,
54
+ length: matches[0].length,
55
+ };
56
+ };
29
57
  const injectBold = (content) => {
30
58
  const regex = /\*\*([^*]+?)\*\*/;
31
59
  const matches = content.match(regex);
@@ -296,6 +324,8 @@ const runFormattingPipeline = (text, injectors) => {
296
324
  };
297
325
  const linkLabelInjectors = [
298
326
  injectHTMLTags,
327
+ injectHTMLCodeTags,
328
+ injectBacktickCode,
299
329
  injectBold,
300
330
  injectItalic,
301
331
  injectNewlines,
@@ -427,6 +457,8 @@ const applyFormatting = (text) => runFormattingPipeline(text, [
427
457
  injectAnchor,
428
458
  injectMarkdownLink,
429
459
  injectHTMLTags,
460
+ injectHTMLCodeTags,
461
+ injectBacktickCode,
430
462
  injectBullet,
431
463
  injectBold,
432
464
  injectItalic,
@@ -437,6 +469,8 @@ const applyFormattingInline = (text) => runFormattingPipeline(text, [
437
469
  injectAnchor,
438
470
  injectMarkdownLink,
439
471
  injectHTMLTags,
472
+ injectHTMLCodeTags,
473
+ injectBacktickCode,
440
474
  injectBold,
441
475
  injectItalic,
442
476
  injectAutolinkUrl,
@@ -1,6 +1,6 @@
1
1
  import styleInject from 'style-inject';
2
2
 
3
- var css_248z = ".InteractiveContent_root__FHnlY{box-sizing:border-box;display:inline-block;max-width:100%;min-width:0;overflow-wrap:anywhere;word-break:break-word}.InteractiveContent_root__FHnlY strong{font-weight:600}.InteractiveContent_root__FHnlY em{font-style:italic}.InteractiveContent_textLink__Ubh4i{color:var(--sb-green-600);text-decoration:underline;text-underline-offset:2px}.InteractiveContent_textLink__Ubh4i:hover{color:var(--sb-green-700)}.dark .InteractiveContent_textLink__Ubh4i{color:var(--sb-green-400)}.dark .InteractiveContent_textLink__Ubh4i:hover{color:var(--sb-green-300)}.InteractiveContent_autolinkUrl__W0tQH{align-items:center;border-radius:var(--p-2);box-sizing:border-box;color:var(--link-color);display:inline-flex;font-size:var(--text-xs);gap:6px;line-height:1.4;margin:0 1px;max-width:100%;padding:2px 8px 2px 6px;position:relative;text-decoration:none;vertical-align:middle}.InteractiveContent_autolinkUrl__W0tQH:before{background-color:var(--link-color);border-radius:inherit;content:\"\";display:inline-block;height:100%;left:0;opacity:.1;position:absolute;top:0;width:100%}.InteractiveContent_autolinkUrl__W0tQH:hover:before{opacity:.2}.InteractiveContent_autolinkUrlIcon__QoqlQ{flex-shrink:0}.InteractiveContent_autolinkUrlLabel__CcJOG{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";
3
+ var css_248z = ".InteractiveContent_root__FHnlY{box-sizing:border-box;display:inline-block;max-width:100%;min-width:0;overflow-wrap:anywhere;word-break:break-word}.InteractiveContent_root__FHnlY strong{font-weight:600}.InteractiveContent_root__FHnlY em{font-style:italic}.InteractiveContent_root__FHnlY code{background-color:var(--background);border-radius:var(--p-1);box-shadow:0 0 1px var(--foreground);color:var(--foreground);font-family:ui-monospace,SF Mono,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.875em;padding:.2em .35em}.InteractiveContent_textLink__Ubh4i{color:var(--sb-green-600);text-decoration:underline;text-underline-offset:2px}.InteractiveContent_textLink__Ubh4i:hover{color:var(--sb-green-700)}.dark .InteractiveContent_textLink__Ubh4i{color:var(--sb-green-400)}.dark .InteractiveContent_textLink__Ubh4i:hover{color:var(--sb-green-300)}.InteractiveContent_autolinkUrl__W0tQH{align-items:center;border-radius:var(--p-2);box-sizing:border-box;color:var(--link-color);display:inline-flex;font-size:var(--text-xs);gap:6px;line-height:1.4;margin:0 1px;max-width:100%;padding:2px 8px 2px 6px;position:relative;text-decoration:none;vertical-align:middle}.InteractiveContent_autolinkUrl__W0tQH:before{background-color:var(--link-color);border-radius:inherit;content:\"\";display:inline-block;height:100%;left:0;opacity:.1;position:absolute;top:0;width:100%}.InteractiveContent_autolinkUrl__W0tQH:hover:before{opacity:.2}.InteractiveContent_autolinkUrlIcon__QoqlQ{flex-shrink:0}.InteractiveContent_autolinkUrlLabel__CcJOG{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";
4
4
  var S = {"root":"InteractiveContent_root__FHnlY","textLink":"InteractiveContent_textLink__Ubh4i","autolinkUrl":"InteractiveContent_autolinkUrl__W0tQH","autolinkUrlIcon":"InteractiveContent_autolinkUrlIcon__QoqlQ","autolinkUrlLabel":"InteractiveContent_autolinkUrlLabel__CcJOG"};
5
5
  styleInject(css_248z);
6
6
 
@@ -6,5 +6,5 @@ interface PinOverlayProps {
6
6
  onPreviewMonthChange?: (month: string | undefined) => void;
7
7
  className?: string;
8
8
  }
9
- export declare function PinOverlay({ baseChartProps, pinMonth, onPinMonthChange, onPreviewMonthChange: _onPreviewMonthChange, className, }: PinOverlayProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function PinOverlay({ baseChartProps, pinMonth, onPinMonthChange, onPreviewMonthChange, className, }: PinOverlayProps): import("react/jsx-runtime").JSX.Element;
10
10
  export {};
@@ -17,6 +17,35 @@ function hasForecastValue(point, id) {
17
17
  const v = point[forecastSeriesKey(id)];
18
18
  return v !== null && v !== undefined && typeof v === 'number';
19
19
  }
20
+ /**
21
+ * First forecast month for bridge logic — skips synthetic connection rows already
22
+ * injected upstream (forecast equals historical on the month before the next forecast).
23
+ */
24
+ function findFirstForecastDateForBridge(rows, id) {
25
+ const dataKey = forecastSeriesKey(id);
26
+ const withForecast = rows
27
+ .filter(row => hasForecastValue(row, id))
28
+ .sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
29
+ for (let i = 0; i < withForecast.length; i++) {
30
+ const row = withForecast[i];
31
+ const next = withForecast[i + 1];
32
+ if (!next) {
33
+ return row.date;
34
+ }
35
+ const expectedBridgeDate = normalizeToMonthStart(getPreviousMonth(next.date));
36
+ const forecastVal = row[dataKey];
37
+ const isSyntheticBridge = normalizeToMonthStart(row.date) === expectedBridgeDate &&
38
+ row.historical != null &&
39
+ typeof forecastVal === 'number' &&
40
+ forecastVal === row.historical;
41
+ if (!isSyntheticBridge) {
42
+ return row.date;
43
+ }
44
+ }
45
+ return withForecast.length > 0
46
+ ? withForecast[withForecast.length - 1].date
47
+ : null;
48
+ }
20
49
  /**
21
50
  * Injects `forecast_{id}` on the row before each series’ first forecast month (historical value)
22
51
  * so dashed forecast lines meet the historical line. Matches sybilion-client bridge behavior.
@@ -36,16 +65,11 @@ function ensureChartForecastBridge(chartData, options) {
36
65
  const rows = sorted.map(p => ({ ...p }));
37
66
  for (const id of seriesIds) {
38
67
  const dataKey = forecastSeriesKey(id);
39
- let firstForecastDate = null;
40
- for (const row of rows) {
41
- if (hasForecastValue(row, id)) {
42
- firstForecastDate = row.date;
43
- break;
44
- }
45
- }
68
+ const firstForecastDate = findFirstForecastDateForBridge(rows, id);
46
69
  if (!firstForecastDate)
47
70
  continue;
48
- const prevMonthNorm = normalizeToMonthStart(getPreviousMonth(firstForecastDate));
71
+ const prevMonthRaw = getPreviousMonth(firstForecastDate);
72
+ const prevMonthNorm = normalizeToMonthStart(prevMonthRaw);
49
73
  const prevMonthIdx = rows.findIndex(row => normalizeToMonthStart(row.date) === prevMonthNorm);
50
74
  if (prevMonthIdx >= 0) {
51
75
  const existing = rows[prevMonthIdx][dataKey];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybilion/uilib",
3
- "version": "1.3.103",
3
+ "version": "1.3.105",
4
4
  "description": "Sybilion Design System — React UI components (Webpack + Stylus)",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -1,6 +1,16 @@
1
1
  .root
2
2
  touch-action pan-y
3
3
 
4
+ .pinDragging
5
+ .pinLineBase
6
+ opacity 0.8
7
+
8
+ .pinButton
9
+ transition none
10
+
11
+ .pinPlaceholder
12
+ transition none
13
+
4
14
  // Chart overlay and pin styles
5
15
  .pinContainer
6
16
  position absolute
@@ -64,7 +74,7 @@
64
74
  background-color var(--background)
65
75
  cursor pointer
66
76
  user-select none
67
- pointer-events auto
77
+ pointer-events none
68
78
  touch-action none
69
79
 
70
80
  .pinHovered &
@@ -80,19 +90,20 @@
80
90
 
81
91
 
82
92
  // Hover placeholder for better pin access - rendered on top of all chart layers
93
+ .pinPlaceholderHost
94
+ pointer-events none
95
+ z-index 20
96
+
83
97
  .pinPlaceholder
84
98
  position absolute
85
- top var(--p-5)
99
+ top 0
86
100
  width 72px
87
101
  height 72px
88
- margin-left -40px
89
- margin-top -40px
90
- z-index 20
102
+ margin-left -36px
103
+ margin-top -36px
91
104
  pointer-events auto
92
105
  cursor pointer
93
106
  touch-action none
94
- // Debug: uncomment to visualize
95
- // background-color rgba(255, 0, 0, 0.1)
96
107
 
97
108
  .pinAnimating &
98
109
  transition left 300ms ease-out
@@ -4,10 +4,12 @@ interface CssExports {
4
4
  'pinAnimating': string;
5
5
  'pinButton': string;
6
6
  'pinContainer': string;
7
+ 'pinDragging': string;
7
8
  'pinHovered': string;
8
9
  'pinIcon': string;
9
10
  'pinLineBase': string;
10
11
  'pinPlaceholder': string;
12
+ 'pinPlaceholderHost': string;
11
13
  'root': string;
12
14
  }
13
15
  export const cssExports: CssExports;
@@ -4,6 +4,7 @@ import { useEffect, useRef, useState } from 'react';
4
4
  import { BaseChartWrapper } from '#uilib/components/ui/Chart/components';
5
5
  import { BaseChartWrapperProps } from '#uilib/components/ui/Chart/components/BaseChartWrapper';
6
6
  import { useDebounceCallback } from '#uilib/hooks/useDebounceCallback';
7
+ import useElemDrag from '#uilib/hooks/useDragElem';
7
8
  import { ChevronsLeftRight } from 'lucide-react';
8
9
 
9
10
  import CAS from '../../ChartAreaInteractive.styl';
@@ -22,7 +23,7 @@ export function PinOverlay({
22
23
  baseChartProps,
23
24
  pinMonth,
24
25
  onPinMonthChange,
25
- onPreviewMonthChange: _onPreviewMonthChange,
26
+ onPreviewMonthChange,
26
27
  className,
27
28
  }: PinOverlayProps) {
28
29
  const { chartData } = baseChartProps;
@@ -30,8 +31,11 @@ export function PinOverlay({
30
31
  const pinRef = useRef<HTMLDivElement>(null);
31
32
  const pinPlaceholderRef = useRef<HTMLDivElement>(null);
32
33
  const pinContainerRef = useRef<HTMLDivElement>(null);
34
+ const containerRectRef = useRef<DOMRect | null>(null);
33
35
 
34
36
  const [isPinHovered, setIsPinHovered] = useState(false);
37
+ const [isDraggingPin, setIsDraggingPin] = useState(false);
38
+ const [isPinAnimating, setIsPinAnimating] = useState(true);
35
39
 
36
40
  const pinPosRef = useRef<number>(0);
37
41
  const currPinMonthRef = useRef<string | undefined>(pinMonth);
@@ -135,6 +139,60 @@ export function PinOverlay({
135
139
  }
136
140
  }, [pinMonth, chartData]);
137
141
 
142
+ const clearPinTransforms = () => {
143
+ if (pinRef.current) {
144
+ pinRef.current.style.transform = '';
145
+ pinRef.current.style.transition = '';
146
+ }
147
+ if (pinPlaceholderRef.current) {
148
+ pinPlaceholderRef.current.style.transform = '';
149
+ pinPlaceholderRef.current.style.transition = '';
150
+ }
151
+ };
152
+
153
+ useElemDrag({
154
+ elem: pinPlaceholderRef,
155
+ isActive: chartData.length > 0,
156
+ onDragStart: e => {
157
+ e.stopPropagation();
158
+ setIsDraggingPin(true);
159
+ setIsPinAnimating(false);
160
+ containerRectRef.current =
161
+ pinContainerRef.current?.getBoundingClientRect() ?? null;
162
+ if (pinRef.current) pinRef.current.style.transition = 'none';
163
+ if (pinPlaceholderRef.current) {
164
+ pinPlaceholderRef.current.style.transition = 'none';
165
+ }
166
+ },
167
+ onDrag: (_delta, e) => {
168
+ const containerRect = containerRectRef.current;
169
+ if (!containerRect) return;
170
+
171
+ const pinCurrentLeft = (pinPosRef.current / 100) * containerRect.width;
172
+ const relativeX = e.clientX - containerRect.left;
173
+ const clampedX = Math.max(0, Math.min(containerRect.width, relativeX));
174
+ const translateX = clampedX - pinCurrentLeft;
175
+ const transform = `translateX(${translateX}px)`;
176
+
177
+ if (pinRef.current) pinRef.current.style.transform = transform;
178
+ if (pinPlaceholderRef.current) {
179
+ pinPlaceholderRef.current.style.transform = transform;
180
+ }
181
+
182
+ const previewPercent =
183
+ containerRect.width > 0 ? (clampedX / containerRect.width) * 100 : 0;
184
+ onPreviewMonthChange?.(getPinMonthAndYear(previewPercent) ?? undefined);
185
+ },
186
+ onDragEnd: e => {
187
+ e.stopPropagation();
188
+ setIsDraggingPin(false);
189
+ setTimeout(() => setIsPinAnimating(true), 200);
190
+ containerRectRef.current = null;
191
+ clearPinTransforms();
192
+ snapPinToPosition(e.clientX, true, true);
193
+ },
194
+ });
195
+
138
196
  const onChartClick = (e: React.MouseEvent<HTMLDivElement>) => {
139
197
  if (e.button !== 0) return;
140
198
  const target = e.target as HTMLElement;
@@ -159,13 +217,15 @@ export function PinOverlay({
159
217
  </div>
160
218
  </div>
161
219
  </div>
162
- <div
163
- className={S.pinPlaceholder}
164
- style={{ left: `${pinPosRef.current}%` }}
165
- ref={pinPlaceholderRef}
166
- onPointerEnter={() => setIsPinHovered(true)}
167
- onPointerLeave={() => setIsPinHovered(false)}
168
- />
220
+ <div className={cn(CAS.overlay, S.pinPlaceholderHost)}>
221
+ <div
222
+ className={S.pinPlaceholder}
223
+ style={{ left: `${pinPosRef.current}%` }}
224
+ ref={pinPlaceholderRef}
225
+ onPointerEnter={() => setIsPinHovered(true)}
226
+ onPointerLeave={() => setIsPinHovered(false)}
227
+ />
228
+ </div>
169
229
  </>
170
230
  );
171
231
 
@@ -174,8 +234,9 @@ export function PinOverlay({
174
234
  className={cn(
175
235
  className,
176
236
  S.root,
177
- S.pinAnimating,
237
+ isPinAnimating && S.pinAnimating,
178
238
  isPinHovered && S.pinHovered,
239
+ isDraggingPin && S.pinDragging,
179
240
  )}
180
241
  onClick={onChartClick}
181
242
  ref={chartRef}
@@ -185,6 +246,7 @@ export function PinOverlay({
185
246
  yMin={yMin}
186
247
  yMax={yMax}
187
248
  autoScaleYAxis={false}
249
+ showTooltip={!isDraggingPin}
188
250
  overlayElements={overlay}
189
251
  />
190
252
  </div>
@@ -1,6 +1,9 @@
1
1
  import { render } from '@testing-library/react';
2
2
 
3
- import { applyFormatting } from './AgentMessageContent.helpers';
3
+ import {
4
+ applyFormatting,
5
+ applyFormattingInline,
6
+ } from './AgentMessageContent.helpers';
4
7
 
5
8
  function renderFormatting(text: string) {
6
9
  const parts = applyFormatting(text);
@@ -24,6 +27,24 @@ describe('applyFormatting emphasis', () => {
24
27
  });
25
28
  });
26
29
 
30
+ describe('applyFormattingInline code', () => {
31
+ it('renders HTML code tags', () => {
32
+ const parts = applyFormattingInline(
33
+ 'Restored <code>?prompt=</code> URLs for deep links.',
34
+ );
35
+ const { container } = render(<>{parts}</>);
36
+
37
+ expect(container.querySelector('code')?.textContent).toBe('?prompt=');
38
+ });
39
+
40
+ it('renders backtick inline code', () => {
41
+ const parts = applyFormattingInline('Use `?prompt=` in the query string.');
42
+ const { container } = render(<>{parts}</>);
43
+
44
+ expect(container.querySelector('code')?.textContent).toBe('?prompt=');
45
+ });
46
+ });
47
+
27
48
  describe('applyFormatting headers', () => {
28
49
  it('renders bold inside markdown headers', () => {
29
50
  const { container } = renderFormatting(
@@ -43,6 +43,40 @@ const injectHTMLTags = (content: string) => {
43
43
  };
44
44
  };
45
45
 
46
+ const injectHTMLCodeTags = (content: string) => {
47
+ const regex = /<(code)\s*>([\s\S]*?)<\/\1\s*>/i;
48
+ const matches = content.match(regex);
49
+
50
+ if (!matches) return null;
51
+
52
+ if (isInsideHtmlListOrTable(content, matches.index!)) {
53
+ return null;
54
+ }
55
+
56
+ return {
57
+ elem: <code>{matches[2]}</code>,
58
+ index: matches.index!,
59
+ length: matches[0].length,
60
+ };
61
+ };
62
+
63
+ const injectBacktickCode = (content: string) => {
64
+ const regex = /`([^`\n]+?)`/;
65
+ const matches = content.match(regex);
66
+
67
+ if (!matches) return null;
68
+
69
+ if (isInsideHtmlListOrTable(content, matches.index!)) {
70
+ return null;
71
+ }
72
+
73
+ return {
74
+ elem: <code>{matches[1]}</code>,
75
+ index: matches.index!,
76
+ length: matches[0].length,
77
+ };
78
+ };
79
+
46
80
  const injectBold = (content: string) => {
47
81
  const regex = /\*\*([^*]+?)\*\*/;
48
82
  const matches = content.match(regex);
@@ -371,6 +405,8 @@ const runFormattingPipeline = (
371
405
 
372
406
  const linkLabelInjectors: Injector[] = [
373
407
  injectHTMLTags,
408
+ injectHTMLCodeTags,
409
+ injectBacktickCode,
374
410
  injectBold,
375
411
  injectItalic,
376
412
  injectNewlines,
@@ -571,6 +607,8 @@ const applyFormatting = (text: string): React.ReactNode[] =>
571
607
  injectAnchor,
572
608
  injectMarkdownLink,
573
609
  injectHTMLTags,
610
+ injectHTMLCodeTags,
611
+ injectBacktickCode,
574
612
  injectBullet,
575
613
  injectBold,
576
614
  injectItalic,
@@ -583,6 +621,8 @@ const applyFormattingInline = (text: string): React.ReactNode[] =>
583
621
  injectAnchor,
584
622
  injectMarkdownLink,
585
623
  injectHTMLTags,
624
+ injectHTMLCodeTags,
625
+ injectBacktickCode,
586
626
  injectBold,
587
627
  injectItalic,
588
628
  injectAutolinkUrl,
@@ -12,6 +12,15 @@
12
12
  em
13
13
  font-style italic
14
14
 
15
+ code
16
+ font-family ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace
17
+ font-size 0.875em
18
+ padding 0.2em 0.35em
19
+ border-radius var(--p-1)
20
+ background-color var(--background)
21
+ color var(--foreground)
22
+ box-shadow 0 0 1px var(--foreground)
23
+
15
24
  .textLink
16
25
  color var(--sb-green-600)
17
26
  text-decoration underline
@@ -5,8 +5,59 @@ import { AppPageHeader } from '../components/AppPageHeader/AppPageHeader';
5
5
  import { DocsGuidance } from '../components/DocsGuidance/DocsGuidance';
6
6
  import { DocsHeaderActions } from '../docsHeaderActions';
7
7
 
8
- const SAMPLE =
9
- 'Use **bold** and *italic* in formatted text. See https://www.theguardian.com/business/ng-interactive/2026/may/14/us-stock-market-war-inflation-tariffs-trump for context.';
8
+ type ShowcaseRow = {
9
+ label: string;
10
+ source: string;
11
+ variant?: 'full' | 'inline';
12
+ };
13
+
14
+ const SHOWCASE_ROWS: ShowcaseRow[] = [
15
+ {
16
+ label: 'Bold (markdown)',
17
+ source: 'Use **bold** for emphasis.',
18
+ },
19
+ {
20
+ label: 'Bold (HTML)',
21
+ source: 'Use <strong>bold</strong> for emphasis.',
22
+ },
23
+ {
24
+ label: 'Italic (markdown)',
25
+ source: 'Use *italic* or _italic_ for emphasis.',
26
+ },
27
+ {
28
+ label: 'Code (HTML)',
29
+ source: 'Restored <code>?prompt=</code> URLs for chat deep links.',
30
+ variant: 'inline',
31
+ },
32
+ {
33
+ label: 'Code (backticks)',
34
+ source: 'Pass `?prompt=` in the query string.',
35
+ variant: 'inline',
36
+ },
37
+ {
38
+ label: 'Markdown link',
39
+ source: 'Read the [release notes](/releases) for details.',
40
+ },
41
+ {
42
+ label: 'HTML link',
43
+ source: 'Read the <a href="/releases">release notes</a> for details.',
44
+ },
45
+ {
46
+ label: 'Autolink URL',
47
+ source: 'See https://example.com/docs for more context.',
48
+ },
49
+ {
50
+ label: 'Combined inline',
51
+ source:
52
+ '<strong>Chat deep links.</strong> Restored <code>?prompt=</code> URLs. See https://example.com/help.',
53
+ variant: 'inline',
54
+ },
55
+ ];
56
+
57
+ const FULL_VARIANT_SAMPLE = `# Section title
58
+
59
+ - **First item.** With *italic* detail.
60
+ - Second item with \`inline code\` and a [link](/settings).`;
10
61
 
11
62
  export default function InteractiveContentPage() {
12
63
  return (
@@ -18,9 +69,10 @@ export default function InteractiveContentPage() {
18
69
  actions={<DocsHeaderActions />}
19
70
  />
20
71
  <DocsGuidance
21
- overview="InteractiveContent renders assistant-style plain text with inline formatting applied: markdown emphasis such as bold and italic, and bare URLs converted into clickable links. The inline variant restricts formatting to what is safe within a single line."
72
+ overview="InteractiveContent renders assistant-style plain text with inline formatting: bold and italic emphasis, inline code via <code> tags or backticks, markdown and HTML links, and bare URLs converted into clickable links. The inline variant omits block-level features such as headings and markdown bullets."
22
73
  whenToUse={[
23
74
  'To display assistant or model-generated text that may contain markdown emphasis and raw URLs.',
75
+ 'For release note bullets and other compact labels that need lightweight inline formatting.',
24
76
  'When plain text needs lightweight formatting without a full markdown renderer.',
25
77
  ]}
26
78
  whenNotToUse={[
@@ -28,11 +80,47 @@ export default function InteractiveContentPage() {
28
80
  'For static UI copy that needs no formatting; render the text directly.',
29
81
  ]}
30
82
  doNotes={[
31
- 'Use the inline variant when the text sits inside a sentence or compact label.',
83
+ 'Use the inline variant when the text sits inside a sentence, list item, or compact label.',
84
+ 'In release notes markdown, write list bullets as "- item text" in the source file; the parser strips the leading "- " and renders each item inside a list — do not repeat "- " inside the item string.',
85
+ 'Wrap inline code with <code>…</code> or backticks (`…`); both render as monospace code.',
32
86
  ]}
33
87
  />
34
- <PageContentSection>
35
- <InteractiveContent text={SAMPLE} />
88
+ <PageContentSection
89
+ style={{ display: 'flex', flexDirection: 'column', gap: '1.5rem' }}
90
+ >
91
+ {SHOWCASE_ROWS.map(row => (
92
+ <section key={row.label}>
93
+ <h3 style={{ marginBottom: '0.5rem', fontSize: '0.875rem' }}>
94
+ {row.label}
95
+ </h3>
96
+ <p
97
+ style={{
98
+ margin: '0 0 0.5rem',
99
+ fontSize: '0.75rem',
100
+ color: 'var(--muted-foreground)',
101
+ }}
102
+ >
103
+ <code>{row.source}</code>
104
+ </p>
105
+ <InteractiveContent text={row.source} variant={row.variant} />
106
+ </section>
107
+ ))}
108
+ </PageContentSection>
109
+ <PageContentSection
110
+ style={{ display: 'flex', flexDirection: 'column', gap: '0.75rem' }}
111
+ >
112
+ <h3 style={{ fontSize: '0.875rem' }}>Full variant (default)</h3>
113
+ <p
114
+ style={{
115
+ margin: 0,
116
+ fontSize: '0.75rem',
117
+ color: 'var(--muted-foreground)',
118
+ }}
119
+ >
120
+ Supports headings, markdown bullets (<code>- item</code>), and the
121
+ same inline formats.
122
+ </p>
123
+ <InteractiveContent text={FULL_VARIANT_SAMPLE} />
36
124
  </PageContentSection>
37
125
  </>
38
126
  );
@@ -36,6 +36,46 @@ function hasForecastValue(point: ChartDataPoint, id: number): boolean {
36
36
  return v !== null && v !== undefined && typeof v === 'number';
37
37
  }
38
38
 
39
+ /**
40
+ * First forecast month for bridge logic — skips synthetic connection rows already
41
+ * injected upstream (forecast equals historical on the month before the next forecast).
42
+ */
43
+ function findFirstForecastDateForBridge(
44
+ rows: ChartDataPoint[],
45
+ id: number,
46
+ ): string | null {
47
+ const dataKey = forecastSeriesKey(id);
48
+ const withForecast = rows
49
+ .filter(row => hasForecastValue(row, id))
50
+ .sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
51
+
52
+ for (let i = 0; i < withForecast.length; i++) {
53
+ const row = withForecast[i];
54
+ const next = withForecast[i + 1];
55
+ if (!next) {
56
+ return row.date;
57
+ }
58
+
59
+ const expectedBridgeDate = normalizeToMonthStart(
60
+ getPreviousMonth(next.date),
61
+ );
62
+ const forecastVal = row[dataKey];
63
+ const isSyntheticBridge =
64
+ normalizeToMonthStart(row.date) === expectedBridgeDate &&
65
+ row.historical != null &&
66
+ typeof forecastVal === 'number' &&
67
+ forecastVal === row.historical;
68
+
69
+ if (!isSyntheticBridge) {
70
+ return row.date;
71
+ }
72
+ }
73
+
74
+ return withForecast.length > 0
75
+ ? withForecast[withForecast.length - 1].date
76
+ : null;
77
+ }
78
+
39
79
  /**
40
80
  * Injects `forecast_{id}` on the row before each series’ first forecast month (historical value)
41
81
  * so dashed forecast lines meet the historical line. Matches sybilion-client bridge behavior.
@@ -65,18 +105,11 @@ export function ensureChartForecastBridge(
65
105
 
66
106
  for (const id of seriesIds) {
67
107
  const dataKey = forecastSeriesKey(id);
68
- let firstForecastDate: string | null = null;
69
- for (const row of rows) {
70
- if (hasForecastValue(row, id)) {
71
- firstForecastDate = row.date;
72
- break;
73
- }
74
- }
108
+ const firstForecastDate = findFirstForecastDateForBridge(rows, id);
75
109
  if (!firstForecastDate) continue;
76
110
 
77
- const prevMonthNorm = normalizeToMonthStart(
78
- getPreviousMonth(firstForecastDate),
79
- );
111
+ const prevMonthRaw = getPreviousMonth(firstForecastDate);
112
+ const prevMonthNorm = normalizeToMonthStart(prevMonthRaw);
80
113
 
81
114
  const prevMonthIdx = rows.findIndex(
82
115
  row => normalizeToMonthStart(row.date) === prevMonthNorm,