@cjlapao/ui-kit 0.2.20 → 0.2.21

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.js CHANGED
@@ -42,7 +42,7 @@ var mergeClassTokens = (...groups) => {
42
42
  var hasExplicitSize = (value) => Boolean(value) && /\b(?:min-|max-)?(?:w|h)-/.test(value);
43
43
 
44
44
  // src/components/CustomIcon.tsx
45
- import { useMemo } from "react";
45
+ import { useMemo, useSyncExternalStore } from "react";
46
46
 
47
47
  // src/icons/components/Accordion.tsx
48
48
  import { forwardRef } from "react";
@@ -4582,6 +4582,55 @@ var iconRegistry = {
4582
4582
  Windows
4583
4583
  };
4584
4584
 
4585
+ // src/icons/customRegistry.ts
4586
+ var customIcons = /* @__PURE__ */ new Map();
4587
+ var listeners = /* @__PURE__ */ new Set();
4588
+ var revision = 0;
4589
+ var notify = () => {
4590
+ revision += 1;
4591
+ listeners.forEach((listener) => listener());
4592
+ };
4593
+ var subscribeIcons = (listener) => {
4594
+ listeners.add(listener);
4595
+ return () => {
4596
+ listeners.delete(listener);
4597
+ };
4598
+ };
4599
+ var getIconRevision = () => revision;
4600
+ var getServerIconRevision = () => 0;
4601
+ function resolveIcon(name) {
4602
+ const registrations = customIcons.get(name);
4603
+ return registrations?.[registrations.length - 1]?.component ?? (Object.prototype.hasOwnProperty.call(iconRegistry, name) ? iconRegistry[name] : void 0);
4604
+ }
4605
+ function registerIcons(icons, options = {}) {
4606
+ const entries = Object.entries(icons);
4607
+ for (const [name, component] of entries) {
4608
+ if (!name.trim() || !component) throw new Error("An icon needs a name and SVG component.");
4609
+ if (!options.override && (customIcons.has(name) || Object.prototype.hasOwnProperty.call(iconRegistry, name))) {
4610
+ throw new Error(`Icon already registered: ${name}. Use { override: true } to replace it.`);
4611
+ }
4612
+ }
4613
+ const registrations = entries.map(([name, component]) => {
4614
+ const registration = { component };
4615
+ customIcons.set(name, [...customIcons.get(name) ?? [], registration]);
4616
+ return { name, registration };
4617
+ });
4618
+ if (entries.length) notify();
4619
+ let disposed = false;
4620
+ return () => {
4621
+ if (disposed) return;
4622
+ disposed = true;
4623
+ let changed = false;
4624
+ for (const { name, registration } of registrations) {
4625
+ const remaining = customIcons.get(name)?.filter((entry) => entry !== registration);
4626
+ if (remaining?.length) customIcons.set(name, remaining);
4627
+ else customIcons.delete(name);
4628
+ changed = true;
4629
+ }
4630
+ if (changed) notify();
4631
+ };
4632
+ }
4633
+
4585
4634
  // src/components/CustomIcon.tsx
4586
4635
  import { jsx as jsx145 } from "react/jsx-runtime";
4587
4636
  var SIZE_CLASS_MAP = {
@@ -4608,7 +4657,8 @@ var CustomIcon = ({
4608
4657
  style,
4609
4658
  ...rest
4610
4659
  }) => {
4611
- const IconComponent = iconRegistry[icon];
4660
+ useSyncExternalStore(subscribeIcons, getIconRevision, getServerIconRevision);
4661
+ const IconComponent = typeof icon === "string" ? resolveIcon(icon) : icon;
4612
4662
  const dimension = useMemo(() => {
4613
4663
  if (!customSize) return void 0;
4614
4664
  return typeof customSize === "number" ? `${customSize}px` : customSize;
@@ -4646,9 +4696,9 @@ var CustomIcon = ({
4646
4696
  // The fallback used to drop every computed class, so a missing icon had no
4647
4697
  // size at all unless `customSize` was given — it collapsed the layout
4648
4698
  // around it.
4649
- /* @__PURE__ */ jsx145("span", { className: "grid h-full w-full place-items-center rounded bg-neutral-100 text-[0.6em] font-bold uppercase text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400", children: icon?.charAt(0) || "?" })
4699
+ /* @__PURE__ */ jsx145("span", { className: "grid h-full w-full place-items-center rounded bg-neutral-100 text-[0.6em] font-bold uppercase text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400", children: typeof icon === "string" ? icon.charAt(0) || "?" : "?" })
4650
4700
  );
4651
- if (!IconComponent && icon && !warned.has(icon)) {
4701
+ if (!IconComponent && typeof icon === "string" && icon && !warned.has(icon)) {
4652
4702
  warned.add(icon);
4653
4703
  console.warn(`Icon not found in registry: ${icon}`);
4654
4704
  }
@@ -7039,7 +7089,7 @@ import {
7039
7089
  createContext as createContext2,
7040
7090
  useContext as useContext2,
7041
7091
  useMemo as useMemo3,
7042
- useSyncExternalStore
7092
+ useSyncExternalStore as useSyncExternalStore2
7043
7093
  } from "react";
7044
7094
 
7045
7095
  // ../common/i18n/storage.ts
@@ -7880,8 +7930,8 @@ function deriveMonths(locale, short) {
7880
7930
  if (cached !== void 0) return cached;
7881
7931
  let names = null;
7882
7932
  try {
7883
- const format2 = new Intl.DateTimeFormat(locale, { month: short ? "short" : "long" });
7884
- names = Array.from({ length: 12 }, (_, i) => format2.format(new Date(2026, i, 15)));
7933
+ const format3 = new Intl.DateTimeFormat(locale, { month: short ? "short" : "long" });
7934
+ names = Array.from({ length: 12 }, (_, i) => format3.format(new Date(2026, i, 15)));
7885
7935
  } catch {
7886
7936
  names = null;
7887
7937
  }
@@ -7894,11 +7944,11 @@ function deriveWeekdays(locale, short) {
7894
7944
  if (cached !== void 0) return cached;
7895
7945
  let names = null;
7896
7946
  try {
7897
- const format2 = new Intl.DateTimeFormat(locale, { weekday: short ? "short" : "long" });
7947
+ const format3 = new Intl.DateTimeFormat(locale, { weekday: short ? "short" : "long" });
7898
7948
  const start = firstSundayOf(new Date(2026, 8, 1));
7899
7949
  names = Array.from(
7900
7950
  { length: 7 },
7901
- (_, i) => format2.format(new Date(start.getFullYear(), start.getMonth(), start.getDate() + i))
7951
+ (_, i) => format3.format(new Date(start.getFullYear(), start.getMonth(), start.getDate() + i))
7902
7952
  );
7903
7953
  } catch {
7904
7954
  names = null;
@@ -10060,7 +10110,7 @@ function createI18n(config) {
10060
10110
  if (!available.has(locale)) locale = "en";
10061
10111
  let isRTL = isRTLLocale(locale);
10062
10112
  let version = 0;
10063
- const listeners = /* @__PURE__ */ new Set();
10113
+ const listeners2 = /* @__PURE__ */ new Set();
10064
10114
  const messageCache = /* @__PURE__ */ new Map();
10065
10115
  const renderMessage = (key, source, values) => {
10066
10116
  const cacheKey = `${locale}\0${source}`;
@@ -10124,7 +10174,7 @@ function createI18n(config) {
10124
10174
  locale = resolved;
10125
10175
  isRTL = isRTLLocale(locale);
10126
10176
  version += 1;
10127
- for (const listener of [...listeners]) listener();
10177
+ for (const listener of [...listeners2]) listener();
10128
10178
  },
10129
10179
  formatNumber(value, options) {
10130
10180
  try {
@@ -10161,9 +10211,9 @@ function createI18n(config) {
10161
10211
  return isRTL;
10162
10212
  },
10163
10213
  subscribe(listener) {
10164
- listeners.add(listener);
10214
+ listeners2.add(listener);
10165
10215
  return () => {
10166
- listeners.delete(listener);
10216
+ listeners2.delete(listener);
10167
10217
  };
10168
10218
  },
10169
10219
  getVersion() {
@@ -10242,7 +10292,7 @@ function I18nProvider(props) {
10242
10292
  }
10243
10293
  var warnedOutsideProvider = false;
10244
10294
  function subscribeTo(engine) {
10245
- useSyncExternalStore(engine.subscribe, engine.getVersion, engine.getVersion);
10295
+ useSyncExternalStore2(engine.subscribe, engine.getVersion, engine.getVersion);
10246
10296
  }
10247
10297
  function useI18n() {
10248
10298
  const contextEngine = useContext2(I18nContext);
@@ -26292,7 +26342,7 @@ function computeRadarGeometry(input) {
26292
26342
  };
26293
26343
  }
26294
26344
  function computeRadarGrid(input) {
26295
- const { axes, cx, cy, R, rings, domainMax, format: format2 } = input;
26345
+ const { axes, cx, cy, R, rings, domainMax, format: format3 } = input;
26296
26346
  const n = axes.length;
26297
26347
  const ringValues = [];
26298
26348
  const ringPaths = [];
@@ -26320,7 +26370,7 @@ function computeRadarGrid(input) {
26320
26370
  const tickLabels = ringValues.map((v, k) => ({
26321
26371
  x: cx - 7,
26322
26372
  y: cy - R * (k + 1) / rings + 4,
26323
- text: format2 ? format2(v) : String(Math.round(v * 10) / 10)
26373
+ text: format3 ? format3(v) : String(Math.round(v * 10) / 10)
26324
26374
  }));
26325
26375
  return { cx, cy, R, ringValues, ringPaths, spokes, tickLabels };
26326
26376
  }
@@ -26548,7 +26598,7 @@ function framePolarSweep(geometry, progress, input) {
26548
26598
  return { ...geometry, segments };
26549
26599
  }
26550
26600
  function computePolarGrid(input) {
26551
- const { categories, cx, cy, R, rings, domainMax, shape: shape2, format: format2, innerR = 0 } = input;
26601
+ const { categories, cx, cy, R, rings, domainMax, shape: shape2, format: format3, innerR = 0 } = input;
26552
26602
  const n = categories.length;
26553
26603
  const ringValues = [];
26554
26604
  const ringPaths = [];
@@ -26561,7 +26611,7 @@ function computePolarGrid(input) {
26561
26611
  tickLabels.push({
26562
26612
  x: cx - 7,
26563
26613
  y: cy - r + 4,
26564
- text: format2 ? format2(v) : String(Math.round(v * 10) / 10)
26614
+ text: format3 ? format3(v) : String(Math.round(v * 10) / 10)
26565
26615
  });
26566
26616
  if (shape2 === "circle") {
26567
26617
  ringPaths.push(
@@ -32723,8 +32773,8 @@ function ticksFor(xScale, props) {
32723
32773
  }
32724
32774
  const cont = xScale;
32725
32775
  const ticks = cont.ticks(props.tickCount);
32726
- const format2 = props.format ?? (cont.type === "time" ? timeTickFormat(cont) : (t) => formatSI(Number(t)));
32727
- return ticks.map((t) => ({ x: cont.map(t), label: format2(t) }));
32776
+ const format3 = props.format ?? (cont.type === "time" ? timeTickFormat(cont) : (t) => formatSI(Number(t)));
32777
+ return ticks.map((t) => ({ x: cont.map(t), label: format3(t) }));
32728
32778
  }
32729
32779
  function edgeAnchor(label, x, left, right) {
32730
32780
  const half = label.length * 6.1 / 2;
@@ -32887,7 +32937,7 @@ function YAxis(props = {}) {
32887
32937
  return;
32888
32938
  }
32889
32939
  const ticks2 = scale.ticks(props.tickCount ?? 5);
32890
- const format3 = props.format ?? ((t) => formatSI(t));
32940
+ const format4 = props.format ?? ((t) => formatSI(t));
32891
32941
  const left2 = onRight ? area2.x + area2.width : area2.x;
32892
32942
  if (props.grid !== false && !onRight) {
32893
32943
  const spec = resolveGrid(props, theme.gridColor);
@@ -32920,7 +32970,7 @@ function YAxis(props = {}) {
32920
32970
  for (const t of ticks2) {
32921
32971
  const y = scale.map(t);
32922
32972
  c.textAlign = onRight ? "left" : "right";
32923
- c.fillText(format3(Number(t)), onRight ? left2 + 8 : left2 - 8, y);
32973
+ c.fillText(format4(Number(t)), onRight ? left2 + 8 : left2 - 8, y);
32924
32974
  }
32925
32975
  }
32926
32976
  };
@@ -32958,7 +33008,7 @@ function YAxis(props = {}) {
32958
33008
  ] });
32959
33009
  }
32960
33010
  const ticks = scale.ticks(props.tickCount ?? 5);
32961
- const format2 = props.format ?? ((t) => formatSI(t));
33011
+ const format3 = props.format ?? ((t) => formatSI(t));
32962
33012
  return /* @__PURE__ */ jsxs114("g", { "data-chart-feature": `yaxis-${onRight ? "right" : "left"}`, children: [
32963
33013
  (() => {
32964
33014
  const spec = resolveGrid(props, theme.gridColor);
@@ -32997,7 +33047,7 @@ function YAxis(props = {}) {
32997
33047
  dominantBaseline: "middle",
32998
33048
  fontSize: 11,
32999
33049
  fill: theme.textColor,
33000
- children: format2(Number(t))
33050
+ children: format3(Number(t))
33001
33051
  },
33002
33052
  i
33003
33053
  )),
@@ -39061,7 +39111,7 @@ var DatePicker = forwardRef160(
39061
39111
  value: valueProp,
39062
39112
  defaultValue,
39063
39113
  onChange,
39064
- format: format2 = DEFAULT_DATE_FORMAT,
39114
+ format: format3 = DEFAULT_DATE_FORMAT,
39065
39115
  minDate,
39066
39116
  maxDate,
39067
39117
  disabledDays,
@@ -39133,10 +39183,10 @@ var DatePicker = forwardRef160(
39133
39183
  );
39134
39184
  const syncText = useCallback23(
39135
39185
  (next) => {
39136
- setText(formatValue(next, format2));
39186
+ setText(formatValue(next, format3));
39137
39187
  setTextInvalid(false);
39138
39188
  },
39139
- [format2]
39189
+ [format3]
39140
39190
  );
39141
39191
  const [viewDate, setViewDate] = useState44(
39142
39192
  () => getViewDate(initialValue, constraints)
@@ -39167,7 +39217,7 @@ var DatePicker = forwardRef160(
39167
39217
  setViewDate(getViewDate(currentValue, constraints));
39168
39218
  }
39169
39219
  }, [currentValue, constraints]);
39170
- const [text2, setText] = useState44(() => formatValue(initialValue, format2));
39220
+ const [text2, setText] = useState44(() => formatValue(initialValue, format3));
39171
39221
  const [textInvalid, setTextInvalid] = useState44(false);
39172
39222
  const [focused, setFocused] = useState44(false);
39173
39223
  const focusedRef = useRef43(false);
@@ -39177,10 +39227,10 @@ var DatePicker = forwardRef160(
39177
39227
  onInvalidRef.current = onInvalidInputChange;
39178
39228
  useEffect47(() => {
39179
39229
  if (!focusedRef.current) {
39180
- setText(formatValue(currentValue, format2));
39230
+ setText(formatValue(currentValue, format3));
39181
39231
  setTextInvalid(false);
39182
39232
  }
39183
- }, [currentValue, format2]);
39233
+ }, [currentValue, format3]);
39184
39234
  const isParseValid = useCallback23(
39185
39235
  (parsed) => {
39186
39236
  if (Array.isArray(parsed)) {
@@ -39204,7 +39254,7 @@ var DatePicker = forwardRef160(
39204
39254
  const parsed = parseValueText(
39205
39255
  next,
39206
39256
  selectionMode,
39207
- format2,
39257
+ format3,
39208
39258
  /* @__PURE__ */ new Date(),
39209
39259
  i18n.parseNames(i18n.locale)
39210
39260
  );
@@ -39220,7 +39270,7 @@ var DatePicker = forwardRef160(
39220
39270
  const handleBlur = (event) => {
39221
39271
  focusedRef.current = false;
39222
39272
  setFocused(false);
39223
- setText(formatValue(currentValueRef.current, format2));
39273
+ setText(formatValue(currentValueRef.current, format3));
39224
39274
  setTextInvalid(false);
39225
39275
  onBlur?.(event);
39226
39276
  };
@@ -39326,7 +39376,7 @@ var DatePicker = forwardRef160(
39326
39376
  const parsed = parseValueText(
39327
39377
  text2,
39328
39378
  selectionMode,
39329
- format2,
39379
+ format3,
39330
39380
  /* @__PURE__ */ new Date(),
39331
39381
  i18n.parseNames(i18n.locale)
39332
39382
  );
@@ -40254,13 +40304,13 @@ var createToastStore = (options = {}) => {
40254
40304
  let viewportCount = 0;
40255
40305
  let nextViewportHandle = 1;
40256
40306
  let warnedNoViewport = false;
40257
- const listeners = /* @__PURE__ */ new Set();
40307
+ const listeners2 = /* @__PURE__ */ new Set();
40258
40308
  const closeHandlers = /* @__PURE__ */ new Set();
40259
40309
  const lifeHandlers = /* @__PURE__ */ new Set();
40260
40310
  const lifeTimers = /* @__PURE__ */ new Map();
40261
40311
  const emit = () => {
40262
40312
  snapshot = { messages: [...messages] };
40263
- for (const listener of listeners) listener();
40313
+ for (const listener of listeners2) listener();
40264
40314
  };
40265
40315
  const find = (id) => messages.find((m) => m.id === id);
40266
40316
  const inGroup = (m, group) => m.group === group;
@@ -40420,8 +40470,8 @@ var createToastStore = (options = {}) => {
40420
40470
  };
40421
40471
  return {
40422
40472
  subscribe(listener) {
40423
- listeners.add(listener);
40424
- return () => listeners.delete(listener);
40473
+ listeners2.add(listener);
40474
+ return () => listeners2.delete(listener);
40425
40475
  },
40426
40476
  getSnapshot: () => snapshot,
40427
40477
  show,
@@ -40508,7 +40558,7 @@ import {
40508
40558
  useMemo as useMemo26,
40509
40559
  useRef as useRef46,
40510
40560
  useState as useState47,
40511
- useSyncExternalStore as useSyncExternalStore2
40561
+ useSyncExternalStore as useSyncExternalStore3
40512
40562
  } from "react";
40513
40563
  import { createPortal as createPortal10 } from "react-dom";
40514
40564
  import classNames75 from "classnames";
@@ -40830,7 +40880,7 @@ var ToastViewport = ({
40830
40880
  style
40831
40881
  }) => {
40832
40882
  const store = useToastStore();
40833
- const { messages } = useSyncExternalStore2(store.subscribe, store.getSnapshot);
40883
+ const { messages } = useSyncExternalStore3(store.subscribe, store.getSnapshot);
40834
40884
  const slice = useMemo26(
40835
40885
  () => messages.filter((m) => m.group === group),
40836
40886
  [messages, group]
@@ -67527,6 +67577,215 @@ function reorderDragSubtree(rows, dragKey) {
67527
67577
  return out;
67528
67578
  }
67529
67579
 
67580
+ // ../common/gantt/crossings.ts
67581
+ var BUCKET_HEIGHT = 44;
67582
+ var MIN_JUMP_RADIUS = 2.5;
67583
+ var SAMPLE_STEPS = 6;
67584
+ var format2 = (value) => Number(value.toFixed(2)).toString();
67585
+ var cornerRadii = (points, radius) => points.map((point, index) => {
67586
+ if (index === 0 || index === points.length - 1) return 0;
67587
+ const previous = points[index - 1];
67588
+ const next = points[index + 1];
67589
+ return Math.min(
67590
+ radius,
67591
+ Math.hypot(point[0] - previous[0], point[1] - previous[1]) / 2,
67592
+ Math.hypot(next[0] - point[0], next[1] - point[1]) / 2
67593
+ );
67594
+ });
67595
+ var bucketRange = (segment) => {
67596
+ const low = Math.floor(Math.min(segment.a[1], segment.b[1]) / BUCKET_HEIGHT);
67597
+ const high = Math.floor(Math.max(segment.a[1], segment.b[1]) / BUCKET_HEIGHT);
67598
+ const buckets = [];
67599
+ for (let bucket = low; bucket <= high; bucket += 1) buckets.push(bucket);
67600
+ return buckets;
67601
+ };
67602
+ var pushJump = (jumps, route, jump) => {
67603
+ const current = jumps.get(route);
67604
+ if (current) current.push(jump);
67605
+ else jumps.set(route, [jump]);
67606
+ };
67607
+ var packJumps = (jumps) => {
67608
+ const bySegment = /* @__PURE__ */ new Map();
67609
+ for (const jump of jumps) {
67610
+ const current = bySegment.get(jump.segment);
67611
+ if (current) current.push(jump);
67612
+ else bySegment.set(jump.segment, [jump]);
67613
+ }
67614
+ const packed = [];
67615
+ for (const segment of bySegment.values()) {
67616
+ segment.sort((a, b) => a.at - b.at);
67617
+ const unique = segment.filter(
67618
+ (jump, index) => index === 0 || Math.abs(jump.at - segment[index - 1].at) > 0.01
67619
+ );
67620
+ for (let index = 0; index < unique.length; index += 1) {
67621
+ const jump = unique[index];
67622
+ const before = index === 0 ? Infinity : (jump.at - unique[index - 1].at) / 2 - 0.5;
67623
+ const after = index === unique.length - 1 ? Infinity : (unique[index + 1].at - jump.at) / 2 - 0.5;
67624
+ const radius = Math.min(jump.radius, before, after);
67625
+ if (radius >= 1) packed.push({ ...jump, radius });
67626
+ }
67627
+ }
67628
+ return packed;
67629
+ };
67630
+ var jumpsBySegment = (jumps) => {
67631
+ const result = /* @__PURE__ */ new Map();
67632
+ for (const jump of jumps) {
67633
+ const current = result.get(jump.segment);
67634
+ if (current) current.push(jump);
67635
+ else result.set(jump.segment, [jump]);
67636
+ }
67637
+ return result;
67638
+ };
67639
+ var pathWithJumps = (points, cornerRadius, jumps) => {
67640
+ if (points.length === 0) return "";
67641
+ if (points.length === 1) return `M ${format2(points[0][0])} ${format2(points[0][1])}`;
67642
+ const bySegment = jumpsBySegment(jumps);
67643
+ let d = `M ${format2(points[0][0])} ${format2(points[0][1])}`;
67644
+ for (let index = 1; index < points.length; index += 1) {
67645
+ const previous = points[index - 1];
67646
+ const current = points[index];
67647
+ if (previous[1] === current[1]) {
67648
+ const direction = current[0] >= previous[0] ? 1 : -1;
67649
+ const segmentJumps = (bySegment.get(index - 1) ?? []).slice().sort((a, b) => (a.at - b.at) * direction);
67650
+ for (const jump of segmentJumps) {
67651
+ d += ` L ${format2(jump.at - direction * jump.radius)} ${format2(current[1])}`;
67652
+ d += ` A ${format2(jump.radius)} ${format2(jump.radius)} 0 0 ${direction === 1 ? 0 : 1} ${format2(jump.at + direction * jump.radius)} ${format2(current[1])}`;
67653
+ }
67654
+ }
67655
+ if (index === points.length - 1) {
67656
+ d += ` L ${format2(current[0])} ${format2(current[1])}`;
67657
+ continue;
67658
+ }
67659
+ const next = points[index + 1];
67660
+ const incomingX = current[0] - previous[0];
67661
+ const incomingY = current[1] - previous[1];
67662
+ const outgoingX = next[0] - current[0];
67663
+ const outgoingY = next[1] - current[1];
67664
+ const incomingLength = Math.hypot(incomingX, incomingY);
67665
+ const outgoingLength = Math.hypot(outgoingX, outgoingY);
67666
+ if (incomingLength < 0.5 || outgoingLength < 0.5) {
67667
+ d += ` L ${format2(current[0])} ${format2(current[1])}`;
67668
+ continue;
67669
+ }
67670
+ const radius = Math.min(cornerRadius, incomingLength / 2, outgoingLength / 2);
67671
+ const before = [
67672
+ current[0] - incomingX / incomingLength * radius,
67673
+ current[1] - incomingY / incomingLength * radius
67674
+ ];
67675
+ const after = [
67676
+ current[0] + outgoingX / outgoingLength * radius,
67677
+ current[1] + outgoingY / outgoingLength * radius
67678
+ ];
67679
+ d += ` L ${format2(before[0])} ${format2(before[1])}`;
67680
+ d += ` Q ${format2(current[0])} ${format2(current[1])} ${format2(after[0])} ${format2(after[1])}`;
67681
+ }
67682
+ return d;
67683
+ };
67684
+ var hitPointsWithJumps = (points, jumps) => {
67685
+ if (points.length === 0) return [];
67686
+ const bySegment = jumpsBySegment(jumps);
67687
+ const result = [[...points[0]]];
67688
+ for (let index = 1; index < points.length; index += 1) {
67689
+ const previous = points[index - 1];
67690
+ const current = points[index];
67691
+ if (previous[1] === current[1]) {
67692
+ const direction = current[0] >= previous[0] ? 1 : -1;
67693
+ const segmentJumps = (bySegment.get(index - 1) ?? []).slice().sort((a, b) => (a.at - b.at) * direction);
67694
+ for (const jump of segmentJumps) {
67695
+ result.push(...sampleHop(jump, current[1], direction));
67696
+ }
67697
+ }
67698
+ result.push([...current]);
67699
+ }
67700
+ return result;
67701
+ };
67702
+ var sampleHop = (jump, y, direction) => {
67703
+ const points = [[jump.at - direction * jump.radius, y]];
67704
+ for (let step = 1; step < SAMPLE_STEPS; step += 1) {
67705
+ const progress = step / SAMPLE_STEPS;
67706
+ const theta = direction === 1 ? Math.PI * (1 - progress) : Math.PI * progress;
67707
+ points.push([
67708
+ jump.at + jump.radius * Math.cos(theta),
67709
+ y - jump.radius * Math.sin(theta)
67710
+ ]);
67711
+ }
67712
+ points.push([jump.at + direction * jump.radius, y]);
67713
+ return points;
67714
+ };
67715
+ var hopPointGroups = (points, jumps) => {
67716
+ const groups = [];
67717
+ for (const jump of jumps) {
67718
+ const start = points[jump.segment];
67719
+ const end = points[jump.segment + 1];
67720
+ const direction = end[0] >= start[0] ? 1 : -1;
67721
+ groups.push(sampleHop(jump, start[1], direction));
67722
+ }
67723
+ return groups;
67724
+ };
67725
+ function ganttCrossingPaths(routes, cornerRadius, jumpRadius = cornerRadius) {
67726
+ const radii = routes.map((route) => cornerRadii(route.points, cornerRadius));
67727
+ const horizontal = [];
67728
+ const verticalByBucket = /* @__PURE__ */ new Map();
67729
+ routes.forEach((route, routeIndex) => {
67730
+ for (let segmentIndex = 0; segmentIndex + 1 < route.points.length; segmentIndex += 1) {
67731
+ const segment = {
67732
+ route: routeIndex,
67733
+ segment: segmentIndex,
67734
+ a: route.points[segmentIndex],
67735
+ b: route.points[segmentIndex + 1]
67736
+ };
67737
+ if (segment.a[1] === segment.b[1] && segment.a[0] !== segment.b[0]) {
67738
+ horizontal.push(segment);
67739
+ } else if (segment.a[0] === segment.b[0] && segment.a[1] !== segment.b[1]) {
67740
+ for (const bucket of bucketRange(segment)) {
67741
+ const current = verticalByBucket.get(bucket);
67742
+ if (current) current.push(segment);
67743
+ else verticalByBucket.set(bucket, [segment]);
67744
+ }
67745
+ }
67746
+ }
67747
+ });
67748
+ const jumps = /* @__PURE__ */ new Map();
67749
+ const seen = /* @__PURE__ */ new Set();
67750
+ for (const h of horizontal) {
67751
+ const bucket = Math.floor(h.a[1] / BUCKET_HEIGHT);
67752
+ for (const v of verticalByBucket.get(bucket) ?? []) {
67753
+ if (h.route === v.route) continue;
67754
+ const key = `${h.route}:${h.segment}:${v.route}:${v.segment}`;
67755
+ if (seen.has(key)) continue;
67756
+ seen.add(key);
67757
+ const left = Math.min(h.a[0], h.b[0]);
67758
+ const right = Math.max(h.a[0], h.b[0]);
67759
+ const top = Math.min(v.a[1], v.b[1]);
67760
+ const bottom = Math.max(v.a[1], v.b[1]);
67761
+ const crossingX = v.a[0];
67762
+ const crossingY = h.a[1];
67763
+ if (crossingX <= left || crossingX >= right || crossingY <= top || crossingY >= bottom) {
67764
+ continue;
67765
+ }
67766
+ const hStartRoom = Math.abs(crossingX - h.a[0]) - radii[h.route][h.segment] - 1;
67767
+ const hEndRoom = Math.abs(crossingX - h.b[0]) - radii[h.route][h.segment + 1] - 1;
67768
+ const vStartRoom = Math.abs(crossingY - v.a[1]) - radii[v.route][v.segment] - 1;
67769
+ const vEndRoom = Math.abs(crossingY - v.b[1]) - radii[v.route][v.segment + 1] - 1;
67770
+ const radius = Math.min(jumpRadius, hStartRoom, hEndRoom);
67771
+ if (radius < MIN_JUMP_RADIUS || vStartRoom < 0 || vEndRoom < 0) continue;
67772
+ pushJump(jumps, h.route, { segment: h.segment, at: crossingX, radius });
67773
+ }
67774
+ }
67775
+ const result = /* @__PURE__ */ new Map();
67776
+ for (const [routeIndex, routeJumps] of jumps) {
67777
+ const packed = packJumps(routeJumps);
67778
+ if (packed.length === 0) continue;
67779
+ const route = routes[routeIndex];
67780
+ result.set(route.id, {
67781
+ d: pathWithJumps(route.points, cornerRadius, packed),
67782
+ hitPoints: hitPointsWithJumps(route.points, packed),
67783
+ hopPoints: hopPointGroups(route.points, packed)
67784
+ });
67785
+ }
67786
+ return result;
67787
+ }
67788
+
67530
67789
  // ../common/gantt/drag.ts
67531
67790
  var MIN_TASK_MS = 36e5;
67532
67791
  function applyDragDates(state, deltaX, pxPerDay, snap2) {
@@ -67564,6 +67823,7 @@ function progressFromPointer(pointerX, barLeft, barWidth) {
67564
67823
  }
67565
67824
  var LINK_PORT_R = 3.5;
67566
67825
  var LINK_PASS_PADDING = 6;
67826
+ var LINK_LANE_SPACING = 16;
67567
67827
  var LINK_ELBOW_R = 6;
67568
67828
  var LINK_HEAD = 7;
67569
67829
  var LINK_PORT_CLEAR = LINK_PORT_R + 2.5 + 2;
@@ -67743,6 +68003,7 @@ var LINK_FAN_MAX_SPREAD = 16;
67743
68003
  var LINK_FAN_INSET = 4;
67744
68004
  var LINK_HANDLE_OVERHANG = 4;
67745
68005
  var LINK_RIGHT_GUTTER = 24;
68006
+ var LINK_BOUNDS_PADDING = 8;
67746
68007
  function fanBarHeight(g) {
67747
68008
  return Math.min(g.height, LINK_BAR_HEIGHT);
67748
68009
  }
@@ -67809,7 +68070,7 @@ function fanHandleOffset(barHeight, taken) {
67809
68070
  for (const iv of free) if (iv[1] - iv[0] > best[1] - best[0]) best = iv;
67810
68071
  return (best[0] + best[1]) / 2;
67811
68072
  }
67812
- function alignVerticalChannels(routes, bars) {
68073
+ function allocateVerticalLanes(routes, bars) {
67813
68074
  const chans = [];
67814
68075
  routes.forEach((r, ri) => {
67815
68076
  for (const ch of r.channels) {
@@ -67822,7 +68083,8 @@ function alignVerticalChannels(routes, bars) {
67822
68083
  y1: Math.min(a[1], b[1]),
67823
68084
  y2: Math.max(a[1], b[1]),
67824
68085
  lo: ch.lo,
67825
- hi: ch.hi
68086
+ hi: ch.hi,
68087
+ orderKey: `${r.orderKey}:${ch.seg}`
67826
68088
  });
67827
68089
  }
67828
68090
  });
@@ -67847,36 +68109,23 @@ function alignVerticalChannels(routes, bars) {
67847
68109
  });
67848
68110
  for (const idxs of groups.values()) {
67849
68111
  if (idxs.length < 2) continue;
67850
- const runs = idxs.map((i) => chans[i]);
67851
- const yLo = Math.min(...runs.map((r) => r.y1));
67852
- const yHi = Math.max(...runs.map((r) => r.y2));
67853
- const interLo = Math.max(...runs.map((r) => r.lo));
67854
- const interHi = Math.min(...runs.map((r) => r.hi));
67855
- if (interLo >= interHi) continue;
67856
- if (Math.max(...runs.map((r) => r.x)) - Math.min(...runs.map((r) => r.x)) < 0.5) {
67857
- continue;
67858
- }
67859
- const blocked = blockedIntervals(bars, yLo, yHi, LINK_PASS_PADDING);
67860
- const meanX = runs.reduce((s, r) => s + r.x, 0) / runs.length;
67861
- const merged = clipMerge(interLo, interHi, blocked);
67862
- let targetX = null;
67863
- let bestDist = Infinity;
67864
- for (const [a, b] of merged) {
67865
- for (const cand of [a, b]) {
67866
- if (cand <= interLo || cand >= interHi) continue;
67867
- const d = Math.abs(cand - meanX);
67868
- if (d < bestDist) {
67869
- bestDist = d;
67870
- targetX = cand;
67871
- }
67872
- }
67873
- }
67874
- if (targetX == null) targetX = findClearX(interLo, interHi, meanX, merged);
67875
- if (targetX == null) continue;
67876
- for (const r of runs) {
67877
- const pts = routes[r.route].points;
67878
- pts[r.seg][0] = targetX;
67879
- pts[r.seg + 1][0] = targetX;
68112
+ const runs = idxs.map((i) => chans[i]).sort((a, b) => a.orderKey.localeCompare(b.orderKey));
68113
+ const allocated = [];
68114
+ for (const run of runs) {
68115
+ const barBlocks = blockedIntervals(bars, run.y1, run.y2, LINK_PASS_PADDING);
68116
+ const laneBlocks = allocated.filter((other) => Math.max(run.y1, other.y1) < Math.min(run.y2, other.y2)).map((other) => [
68117
+ other.x - LINK_LANE_SPACING,
68118
+ other.x + LINK_LANE_SPACING
68119
+ ]);
68120
+ const targetX = findClearX(run.lo, run.hi, run.x, [
68121
+ ...barBlocks,
68122
+ ...laneBlocks
68123
+ ]);
68124
+ if (targetX != null) run.x = targetX;
68125
+ const pts = routes[run.route].points;
68126
+ pts[run.seg][0] = run.x;
68127
+ pts[run.seg + 1][0] = run.x;
68128
+ allocated.push(run);
67880
68129
  }
67881
68130
  }
67882
68131
  }
@@ -67890,6 +68139,7 @@ function computeLinkPaths(links, bars, defaultColor) {
67890
68139
  const to = bars.get(link.target);
67891
68140
  if (!from || !to) continue;
67892
68141
  const type = link.type ?? "fs";
68142
+ const orderKey = link.id ?? `${link.source}\0${link.target}\0${type}`;
67893
68143
  const fanSrcY = fan.perLink[li].src;
67894
68144
  const fanTgtY = fan.perLink[li].tgt;
67895
68145
  const fr = from.left + from.width;
@@ -67906,6 +68156,8 @@ function computeLinkPaths(links, bars, defaultColor) {
67906
68156
  }
67907
68157
  const { points, channels, arrow } = routePoints(from, to, fanSrcY, fanTgtY, obstacles);
67908
68158
  routes.push({
68159
+ routeId: `${orderKey}\0${li}`,
68160
+ orderKey,
67909
68161
  link,
67910
68162
  points,
67911
68163
  channels,
@@ -67916,13 +68168,19 @@ function computeLinkPaths(links, bars, defaultColor) {
67916
68168
  type
67917
68169
  });
67918
68170
  }
67919
- alignVerticalChannels(routes, allBars);
68171
+ allocateVerticalLanes(routes, allBars);
68172
+ const crossings = ganttCrossingPaths(
68173
+ routes.map((route) => ({ id: route.routeId, points: route.points })),
68174
+ LINK_ELBOW_R
68175
+ );
67920
68176
  const paths = [];
67921
68177
  for (const r of routes) {
68178
+ const crossing = crossings.get(r.routeId);
67922
68179
  paths.push({
67923
68180
  link: r.link,
67924
- d: roundedPath2(r.points, LINK_ELBOW_R),
67925
- points: r.points,
68181
+ d: crossing?.d ?? roundedPath2(r.points, LINK_ELBOW_R),
68182
+ points: crossing?.hitPoints ?? r.points,
68183
+ hopPoints: crossing?.hopPoints,
67926
68184
  arrow: r.arrow,
67927
68185
  from: r.fromPt,
67928
68186
  to: r.toPt,
@@ -67932,6 +68190,27 @@ function computeLinkPaths(links, bars, defaultColor) {
67932
68190
  }
67933
68191
  return paths;
67934
68192
  }
68193
+ function ganttLinkLayerWidth(paths, timelineWidth) {
68194
+ let furthest = timelineWidth;
68195
+ for (const path of paths) {
68196
+ for (const point of path.points) furthest = Math.max(furthest, point[0]);
68197
+ furthest = Math.max(
68198
+ furthest,
68199
+ path.from.x + LINK_BOUNDS_PADDING,
68200
+ path.to.x + LINK_BOUNDS_PADDING
68201
+ );
68202
+ if (path.arrow) {
68203
+ const values = path.arrow.match(/-?\d+(?:\.\d+)?/g)?.map(Number) ?? [];
68204
+ for (let index = 0; index + 1 < values.length; index += 2) {
68205
+ furthest = Math.max(furthest, values[index]);
68206
+ }
68207
+ }
68208
+ }
68209
+ return Math.max(
68210
+ timelineWidth + LINK_RIGHT_GUTTER,
68211
+ furthest + LINK_BOUNDS_PADDING
68212
+ );
68213
+ }
67935
68214
  function rubberLinkPath(source, px, py, target, obstacles = [], fromOffset = 0) {
67936
68215
  if (target) {
67937
68216
  return linkPath(source, target, "fs", 0, 0, obstacles);
@@ -67979,6 +68258,18 @@ function linkDistance(points, x, y) {
67979
68258
  return best;
67980
68259
  }
67981
68260
  function pickLinkAt(paths, x, y, radius = LINK_HIT_RADIUS) {
68261
+ let hopBest = null;
68262
+ let hopBestDist = Infinity;
68263
+ for (const path of paths) {
68264
+ for (const hop of path.hopPoints ?? []) {
68265
+ const distance = linkDistance(hop, x, y);
68266
+ if (distance <= radius && distance < hopBestDist) {
68267
+ hopBestDist = distance;
68268
+ hopBest = path;
68269
+ }
68270
+ }
68271
+ }
68272
+ if (hopBest) return hopBest;
67982
68273
  let best = null;
67983
68274
  let bestDist = Infinity;
67984
68275
  for (const p of paths) {
@@ -68301,6 +68592,7 @@ var GanttLinkLayer = forwardRef162(
68301
68592
  "div",
68302
68593
  {
68303
68594
  ref,
68595
+ "data-gantt-link-layer": true,
68304
68596
  className: "pointer-events-none absolute top-0 z-10",
68305
68597
  style: { left: offsetLeft, width, height },
68306
68598
  children: [
@@ -69825,6 +70117,13 @@ var Gantt = ({
69825
70117
  () => computeLinkPaths(links, liveLinkBars, color),
69826
70118
  [links, liveLinkBars, color]
69827
70119
  );
70120
+ const linkLayerWidth = useMemo61(
70121
+ () => ganttLinkLayerWidth(linkPaths, timelineWidth),
70122
+ [linkPaths, timelineWidth]
70123
+ );
70124
+ useEffect73(() => {
70125
+ syncHeaderScale();
70126
+ }, [linkLayerWidth, syncHeaderScale]);
69828
70127
  const linkFan = useMemo61(() => computeLinkFanOffsets(links, bars), [links, bars]);
69829
70128
  return /* @__PURE__ */ jsx319(
69830
70129
  Panel_default,
@@ -69987,7 +70286,7 @@ var Gantt = ({
69987
70286
  ref: scrollRef,
69988
70287
  className: `gantt-scroller min-h-0 flex-1 overflow-auto overscroll-contain [&::-webkit-scrollbar]:h-1.5 ${THIN_SCROLLBAR}`,
69989
70288
  onScroll: syncHeaderScale,
69990
- children: /* @__PURE__ */ jsx319("div", { style: { width: leftWidth + timelineWidth + LINK_RIGHT_GUTTER, minWidth: "100%" }, children: loading ? /* @__PURE__ */ jsx319(GanttSkeleton, { rows: 12, rowHeight: rowHeight2, leftWidth }) : isEmpty2 ? /* @__PURE__ */ jsx319("div", { className: "flex items-center justify-center text-sm text-neutral-500", style: { height: bodyHeight || 160, width: leftWidth + timelineWidth }, children: emptyState ?? allLabels.empty }) : /* @__PURE__ */ jsxs197("div", { className: "relative", style: { height: bodyHeight }, children: [
70289
+ children: /* @__PURE__ */ jsx319("div", { style: { width: leftWidth + linkLayerWidth, minWidth: "100%" }, children: loading ? /* @__PURE__ */ jsx319(GanttSkeleton, { rows: 12, rowHeight: rowHeight2, leftWidth }) : isEmpty2 ? /* @__PURE__ */ jsx319("div", { className: "flex items-center justify-center text-sm text-neutral-500", style: { height: bodyHeight || 160, width: leftWidth + timelineWidth }, children: emptyState ?? allLabels.empty }) : /* @__PURE__ */ jsxs197("div", { className: "relative", style: { height: bodyHeight }, children: [
69991
70290
  /* @__PURE__ */ jsxs197(
69992
70291
  "div",
69993
70292
  {
@@ -70082,7 +70381,7 @@ var Gantt = ({
70082
70381
  GanttLinkLayer,
70083
70382
  {
70084
70383
  ref: overlayRef,
70085
- width: timelineWidth + LINK_RIGHT_GUTTER,
70384
+ width: linkLayerWidth,
70086
70385
  height: bodyHeight,
70087
70386
  offsetLeft: leftWidth,
70088
70387
  paths: linkPaths,
@@ -70123,7 +70422,7 @@ var Gantt = ({
70123
70422
  style: {
70124
70423
  left: drag.clientX - (drag.grabOffset?.x ?? 0),
70125
70424
  top: drag.clientY - (drag.grabOffset?.y ?? 0),
70126
- width: leftWidth + timelineWidth + LINK_RIGHT_GUTTER
70425
+ width: leftWidth + linkLayerWidth
70127
70426
  },
70128
70427
  children: /* @__PURE__ */ jsx319(
70129
70428
  "div",
@@ -77010,6 +77309,7 @@ export {
77010
77309
  radarPath,
77011
77310
  readAccessor,
77012
77311
  registerEasing,
77312
+ registerIcons,
77013
77313
  relLuminance,
77014
77314
  renderIcon,
77015
77315
  resetI18nProviderWarns,