@bian-womp/spark-workbench 0.3.44 → 0.3.46

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/lib/cjs/index.cjs CHANGED
@@ -5331,6 +5331,13 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
5331
5331
  return String(value ?? "");
5332
5332
  }
5333
5333
  };
5334
+ const unwrapForDisplay = (declaredTypeId, value) => {
5335
+ if (sparkGraph.isTyped(value)) {
5336
+ const t = sparkGraph.unwrapTypeId(value) ?? declaredTypeId;
5337
+ return { typeId: t, value: sparkGraph.unwrapValue(value) };
5338
+ }
5339
+ return { typeId: declaredTypeId, value };
5340
+ };
5334
5341
  const { wb, registryVersion, selectedNodeId, selectedEdgeId, inputsMap, inputDefaultsMap, outputsMap, outputTypesMap, nodeStatus, edgeStatus, validationByNode, validationByEdge, validationGlobal, valuesTick, updateEdgeType, systemErrors, registryErrors, inputValidationErrors, clearSystemErrors, clearRegistryErrors, clearInputValidationErrors, removeSystemError, removeRegistryError, removeInputValidationError, handlesMap, } = useWorkbenchContext();
5335
5342
  const nodeValidationIssues = validationByNode.issues;
5336
5343
  const edgeValidationIssues = validationByEdge.issues;
@@ -5460,7 +5467,8 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
5460
5467
  for (const h of handles) {
5461
5468
  const typeId = sparkGraph.getInputTypeId(effectiveHandles.inputs, h);
5462
5469
  const current = nodeInputs[h];
5463
- const display = safeToString(typeId, current);
5470
+ const { typeId: displayTypeId, value: displayValue } = unwrapForDisplay(typeId, current);
5471
+ const display = safeToString(displayTypeId, displayValue);
5464
5472
  const wasOriginal = originals[h];
5465
5473
  const isDirty = drafts[h] !== undefined &&
5466
5474
  wasOriginal !== undefined &&
@@ -5512,18 +5520,19 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
5512
5520
  .filter((e) => e.target.nodeId === selectedNodeId &&
5513
5521
  e.target.handle === h)
5514
5522
  .map((e) => e.target.handle));
5523
+ const { typeId: defaultTypeId, value: defaultValue } = unwrapForDisplay(typeId, nodeInputsDefaults[h]);
5515
5524
  const hasDefault = !inbound.has(h) && nodeInputsDefaults[h] !== undefined;
5516
5525
  const defaultStr = hasDefault
5517
- ? safeToString(typeId, nodeInputsDefaults[h])
5526
+ ? safeToString(defaultTypeId, defaultValue)
5518
5527
  : undefined;
5519
5528
  const commonProps = {
5520
5529
  style: { flex: 1 },
5521
5530
  disabled: isLinked,
5522
5531
  };
5523
5532
  const current = nodeInputs[h];
5524
- const hasValue = current !== undefined && current !== null;
5525
- const value = drafts[h] ?? safeToString(typeId, current);
5526
- const displayValue = value;
5533
+ const { typeId: displayTypeId, value: displayValue } = unwrapForDisplay(typeId, current);
5534
+ const hasValue = displayValue !== undefined && displayValue !== null;
5535
+ const value = drafts[h] ?? safeToString(displayTypeId, displayValue);
5527
5536
  const placeholder = hasDefault ? defaultStr : undefined;
5528
5537
  const onChangeText = (text) => setDrafts((d) => ({ ...d, [h]: text }));
5529
5538
  const commit = () => {
@@ -5549,7 +5558,7 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
5549
5558
  setDrafts((d) => ({ ...d, [h]: "" }));
5550
5559
  setOriginals((o) => ({ ...o, [h]: "" }));
5551
5560
  };
5552
- const isEnum = typeId?.startsWith("enum:");
5561
+ const isEnum = displayTypeId?.startsWith("enum:");
5553
5562
  const inIssues = selectedNodeHandleValidation.inputs.filter((m) => m.handle === h);
5554
5563
  const hasValidation = inIssues.length > 0;
5555
5564
  const hasErr = inIssues.some((m) => m.level === "error");
@@ -5570,9 +5579,9 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
5570
5579
  ? `Default: ${placeholder}`
5571
5580
  : "(select)" }), wb.registry.enums
5572
5581
  .get(typeId)
5573
- ?.options.map((opt) => (jsxRuntime.jsx("option", { value: String(opt.value), children: opt.label }, opt.value)))] }), hasValue && !isLinked && (jsxRuntime.jsx("button", { className: "flex-shrink-0 p-1 hover:bg-gray-100 rounded text-gray-500 hover:text-gray-700", onClick: clearInput, title: "Clear input value", children: jsxRuntime.jsx(react$1.XCircleIcon, { size: 16 }) }))] })) : isLinked ? (jsxRuntime.jsx("div", { className: "flex items-center gap-1 flex-1", children: jsxRuntime.jsx("div", { className: "flex-1 min-w-0", children: renderLinkedInputDisplay(typeId, current) }) })) : (jsxRuntime.jsxs("div", { className: "flex items-center gap-1 flex-1", children: [jsxRuntime.jsx("input", { className: "border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500 flex-1 select-text", placeholder: placeholder
5582
+ ?.options.map((opt) => (jsxRuntime.jsx("option", { value: String(opt.value), children: opt.label }, opt.value)))] }), hasValue && !isLinked && (jsxRuntime.jsx("button", { className: "flex-shrink-0 p-1 hover:bg-gray-100 rounded text-gray-500 hover:text-gray-700", onClick: clearInput, title: "Clear input value", children: jsxRuntime.jsx(react$1.XCircleIcon, { size: 16 }) }))] })) : isLinked ? (jsxRuntime.jsx("div", { className: "flex items-center gap-1 flex-1", children: jsxRuntime.jsx("div", { className: "flex-1 min-w-0", children: renderLinkedInputDisplay(displayTypeId, displayValue) }) })) : (jsxRuntime.jsxs("div", { className: "flex items-center gap-1 flex-1", children: [jsxRuntime.jsx("input", { className: "border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500 flex-1 select-text", placeholder: placeholder
5574
5583
  ? `Default: ${placeholder}`
5575
- : undefined, value: displayValue, onChange: (e) => onChangeText(e.target.value), onBlur: commit, onKeyDown: (e) => {
5584
+ : undefined, value: value, onChange: (e) => onChangeText(e.target.value), onBlur: commit, onKeyDown: (e) => {
5576
5585
  if (e.key === "Enter")
5577
5586
  commit();
5578
5587
  if (e.key === "Escape")