@tomaszjarosz/react-visualizers 0.4.3 → 0.4.5

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.cjs CHANGED
@@ -2323,7 +2323,7 @@ const BinarySearchVisualizerComponent = ({
2323
2323
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center text-green-700 font-bold mb-2", children: "target ∈ arr[left..right]" }),
2324
2324
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-gray-500 text-center", children: "If target exists, it must be within current search bounds" })
2325
2325
  ] }),
2326
- left <= right && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 p-2 bg-white rounded-lg border border-green-200", children: [
2326
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-white rounded-lg border border-green-200 min-h-[60px]", children: left <= right ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2327
2327
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center text-xs", children: [
2328
2328
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2329
2329
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-green-700", children: "Search space:" }),
@@ -2355,8 +2355,7 @@ const BinarySearchVisualizerComponent = ({
2355
2355
  ") / 2⌋ = ",
2356
2356
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-bold text-purple-600", children: mid })
2357
2357
  ] })
2358
- ] }),
2359
- found === true && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-green-100 rounded-lg border border-green-300 text-center", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-green-800 font-bold", children: [
2358
+ ] }) : found === true ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center py-1", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-green-800 font-bold", children: [
2360
2359
  "✓ Found in ",
2361
2360
  currentStep,
2362
2361
  " steps (log₂",
@@ -2364,8 +2363,7 @@ const BinarySearchVisualizerComponent = ({
2364
2363
  " ≈ ",
2365
2364
  Math.ceil(Math.log2(array.length)),
2366
2365
  " max)"
2367
- ] }) }),
2368
- found === false && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-red-100 rounded-lg border border-red-300 text-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-800 font-bold", children: "✗ Not found - search space exhausted" }) })
2366
+ ] }) }) : found === false ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center py-1", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-800 font-bold", children: "✗ Not found - search space exhausted" }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center text-xs text-gray-400 py-2", children: "Ready to search..." }) })
2369
2367
  ] }),
2370
2368
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center gap-1 flex-wrap mb-4", children: array.map((value, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
2371
2369
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -4110,7 +4108,7 @@ const DijkstraVisualizerComponent = ({
4110
4108
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-green-600 font-bold", children: "update dist[v]" })
4111
4109
  ] })
4112
4110
  ] }),
4113
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-orange-50 rounded-lg border border-orange-200", children: [
4111
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-orange-50 rounded-lg border border-orange-200 min-h-[72px]", children: [
4114
4112
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-2", children: [
4115
4113
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold text-orange-800", children: "Priority Queue (min-heap)" }),
4116
4114
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-orange-600", children: "(node:distance)" })
@@ -6034,7 +6032,7 @@ const HashMapVisualizerComponent = ({
6034
6032
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center text-indigo-700 font-bold mb-2", children: "index = hashCode(key) % capacity" }),
6035
6033
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-gray-500 text-center", children: "Same key → same index (deterministic) • Different keys may collide → chaining" })
6036
6034
  ] }),
6037
- stepData.hash !== void 0 && stepData.key && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-3 bg-white rounded-lg border border-indigo-200", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-center", children: [
6035
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-3 bg-white rounded-lg border border-indigo-200 min-h-[80px]", children: stepData.hash !== void 0 && stepData.key ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-center", children: [
6038
6036
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "font-mono mb-1", children: [
6039
6037
  "hashCode(",
6040
6038
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-indigo-600 font-bold", children: [
@@ -6057,7 +6055,7 @@ const HashMapVisualizerComponent = ({
6057
6055
  stepData.bucketIndex,
6058
6056
  "]"
6059
6057
  ] })
6060
- ] }) })
6058
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-gray-400 text-center py-4", children: "Ready to hash..." }) })
6061
6059
  ] }),
6062
6060
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", children: [
6063
6061
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-medium text-gray-700 mb-2", children: [
@@ -13667,7 +13665,7 @@ const LinkedListVisualizerComponent = ({
13667
13665
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-gray-500 font-mono ml-2", children: "← tail" })
13668
13666
  ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-16 flex items-center justify-center text-gray-400 text-sm", children: "Empty list (head = tail = null)" }) })
13669
13667
  ] }),
13670
- nodes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 p-3 bg-gray-100 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-gray-600 flex gap-4", children: [
13668
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 p-3 bg-gray-100 rounded-lg min-h-[44px]", children: nodes.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-gray-600 flex gap-4", children: [
13671
13669
  /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
13672
13670
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: "head:" }),
13673
13671
  " ",
@@ -13683,7 +13681,7 @@ const LinkedListVisualizerComponent = ({
13683
13681
  " ",
13684
13682
  nodes.length
13685
13683
  ] })
13686
- ] }) })
13684
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-gray-400 text-center", children: "head = tail = null, size = 0" }) })
13687
13685
  ] });
13688
13686
  return /* @__PURE__ */ jsxRuntime.jsx(
13689
13687
  BaseVisualizerLayout,
@@ -14164,7 +14162,7 @@ const LinkedHashMapVisualizerComponent = ({
14164
14162
  linkedOrder.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 pt-2 border-t border-orange-200 text-[10px] text-gray-500 text-center", children: "Doubly linked: each entry has prev/next pointers" })
14165
14163
  ] })
14166
14164
  ] }),
14167
- accessOrder && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 p-3 bg-blue-50 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-blue-700", children: [
14165
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 p-3 bg-blue-50 rounded-lg min-h-[52px]", children: accessOrder ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-blue-700", children: [
14168
14166
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "LRU Cache Usage:" }),
14169
14167
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-[11px]", children: linkedOrder.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14170
14168
  "Least Recently Used: ",
@@ -14172,7 +14170,7 @@ const LinkedHashMapVisualizerComponent = ({
14172
14170
  " | Most Recently Used: ",
14173
14171
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: linkedOrder[linkedOrder.length - 1] })
14174
14172
  ] }) : "Cache empty" })
14175
- ] }) })
14173
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-gray-400 text-center", children: "Insertion order mode (switch to access order for LRU behavior)" }) })
14176
14174
  ] });
14177
14175
  return /* @__PURE__ */ jsxRuntime.jsx(
14178
14176
  BaseVisualizerLayout,
@@ -14438,6 +14436,35 @@ const ArrayListVisualizerComponent = ({
14438
14436
  return copyUrlToClipboard({ step: currentStep });
14439
14437
  }, [copyUrlToClipboard, currentStep]);
14440
14438
  const visualization = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14439
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-gray-100 rounded-lg", children: [
14440
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 bg-gray-200 rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ jsxRuntime.jsx(
14441
+ "div",
14442
+ {
14443
+ className: "h-full bg-orange-500 transition-all",
14444
+ style: { width: `${size / capacity * 100}%` }
14445
+ }
14446
+ ) }),
14447
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-6 text-xs", children: [
14448
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
14449
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-gray-700", children: "size:" }),
14450
+ " ",
14451
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-orange-600 font-mono", children: size })
14452
+ ] }),
14453
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
14454
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-gray-700", children: "capacity:" }),
14455
+ " ",
14456
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-amber-600 font-mono", children: capacity })
14457
+ ] }),
14458
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
14459
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-gray-700", children: "load:" }),
14460
+ " ",
14461
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono", children: [
14462
+ Math.round(size / capacity * 100),
14463
+ "%"
14464
+ ] })
14465
+ ] })
14466
+ ] })
14467
+ ] }),
14441
14468
  operation === "resize" && oldArray && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-4 bg-gradient-to-r from-red-50 to-orange-50 rounded-xl border-2 border-red-200", children: [
14442
14469
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-bold text-red-700 mb-3 flex items-center gap-2", children: [
14443
14470
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl", children: "⚠️" }),
@@ -14503,35 +14530,6 @@ const ArrayListVisualizerComponent = ({
14503
14530
  "]"
14504
14531
  ] })
14505
14532
  ] }, idx)) }) })
14506
- ] }),
14507
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-gray-100 rounded-lg", children: [
14508
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-6 text-xs", children: [
14509
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
14510
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-gray-700", children: "size:" }),
14511
- " ",
14512
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-orange-600 font-mono", children: size })
14513
- ] }),
14514
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
14515
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-gray-700", children: "capacity:" }),
14516
- " ",
14517
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-amber-600 font-mono", children: capacity })
14518
- ] }),
14519
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
14520
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-gray-700", children: "load:" }),
14521
- " ",
14522
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono", children: [
14523
- Math.round(size / capacity * 100),
14524
- "%"
14525
- ] })
14526
- ] })
14527
- ] }),
14528
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 h-2 bg-gray-200 rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
14529
- "div",
14530
- {
14531
- className: "h-full bg-orange-500 transition-all",
14532
- style: { width: `${size / capacity * 100}%` }
14533
- }
14534
- ) })
14535
14533
  ] })
14536
14534
  ] });
14537
14535
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -15372,23 +15370,12 @@ const TreeSetVisualizerComponent = ({
15372
15370
  ] }),
15373
15371
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-gray-500 text-center", children: "All values in left subtree are smaller • All values in right subtree are larger" })
15374
15372
  ] }),
15375
- currentStepData.operation === "add" && currentStepData.value !== void 0 && currentNode !== void 0 && currentNode !== currentStepData.value && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-white rounded-lg border border-emerald-200", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-center", children: [
15376
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-emerald-700", children: "Comparing:" }),
15377
- " ",
15378
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono", children: [
15379
- currentStepData.value,
15380
- " ",
15381
- currentStepData.value < currentNode ? "<" : ">",
15382
- " ",
15383
- currentNode
15384
- ] }),
15385
- " → ",
15386
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: `font-bold ${currentStepData.value < currentNode ? "text-blue-600" : "text-orange-600"}`, children: [
15387
- "Go ",
15388
- currentStepData.value < currentNode ? "LEFT" : "RIGHT"
15389
- ] })
15390
- ] }) }),
15391
- currentStepData.operation === "contains" && currentStepData.value !== void 0 && currentNode !== void 0 && !found && path.length > 0 && path[path.length - 1] !== currentStepData.value && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-white rounded-lg border border-emerald-200", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-center", children: [
15373
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-white rounded-lg border border-emerald-200 min-h-[40px]", children: found === true ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-center text-green-800 font-bold bg-green-100 rounded p-1", children: [
15374
+ " Found! ",
15375
+ currentStepData.value,
15376
+ " == ",
15377
+ currentNode
15378
+ ] }) : found === false ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-center text-red-800 font-bold bg-red-100 rounded p-1", children: "✗ Not found! Reached null (no more children to check)" }) : (currentStepData.operation === "add" || currentStepData.operation === "contains") && currentStepData.value !== void 0 && currentNode !== void 0 && currentNode !== currentStepData.value ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-center", children: [
15392
15379
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-emerald-700", children: "Comparing:" }),
15393
15380
  " ",
15394
15381
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono", children: [
@@ -15403,14 +15390,7 @@ const TreeSetVisualizerComponent = ({
15403
15390
  "Go ",
15404
15391
  currentStepData.value < currentNode ? "LEFT" : "RIGHT"
15405
15392
  ] })
15406
- ] }) }),
15407
- found === true && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-green-100 rounded-lg border border-green-300", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-center text-green-800 font-bold", children: [
15408
- "✓ Found! ",
15409
- currentStepData.value,
15410
- " == ",
15411
- currentNode
15412
- ] }) }),
15413
- found === false && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-red-100 rounded-lg border border-red-300", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-center text-red-800 font-bold", children: "✗ Not found! Reached null (no more children to check)" }) })
15393
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-center text-gray-400", children: "Ready for operation..." }) })
15414
15394
  ] }),
15415
15395
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", children: [
15416
15396
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-gray-700 mb-2", children: "Binary Search Tree" }),
@@ -16212,7 +16192,7 @@ const PriorityQueueVisualizerComponent = ({ showControls = true, showCode = true
16212
16192
  ] })
16213
16193
  ] })
16214
16194
  ] }),
16215
- currentIndex !== void 0 && currentIndex >= 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-white rounded-lg border border-purple-200", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-gray-600 text-center", children: [
16195
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-white rounded-lg border border-purple-200 min-h-[36px]", children: currentIndex !== void 0 && currentIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-gray-600 text-center", children: [
16216
16196
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-semibold text-purple-700", children: [
16217
16197
  "Current: i = ",
16218
16198
  currentIndex
@@ -16231,7 +16211,7 @@ const PriorityQueueVisualizerComponent = ({ showControls = true, showCode = true
16231
16211
  ") = ",
16232
16212
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-600 font-bold", children: 2 * currentIndex + 1 })
16233
16213
  ] })
16234
- ] }) })
16214
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-gray-400 text-center", children: "Ready for heap operations..." }) })
16235
16215
  ] }),
16236
16216
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", children: [
16237
16217
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-gray-700 mb-2", children: "Binary Heap Structure" }),
@@ -16679,7 +16659,7 @@ const ConcurrentHashMapVisualizerComponent = ({ showControls = true, showCode =
16679
16659
  seg.lockOwner
16680
16660
  ] })
16681
16661
  ] }),
16682
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: seg.entries.length > 0 ? seg.entries.map((entry, eIdx) => /* @__PURE__ */ jsxRuntime.jsxs(
16662
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1 min-h-[60px]", children: seg.entries.length > 0 ? seg.entries.map((entry, eIdx) => /* @__PURE__ */ jsxRuntime.jsxs(
16683
16663
  "div",
16684
16664
  {
16685
16665
  className: "flex justify-between px-2 py-1 bg-white rounded text-xs border border-gray-200",