@trops/dash-core 0.1.420 → 0.1.422

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
@@ -18812,7 +18812,32 @@ var WidgetCardHeader = function WidgetCardHeader(_ref) {
18812
18812
  var isWidgetMissing = (widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.component) && !widgetConfig;
18813
18813
 
18814
18814
  // Get widget name from config or item
18815
- var widgetName = (widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.name) || (widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.name) || (widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.component);
18815
+ var widgetName = (widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.displayName) || (widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.name) || (widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.name) || (widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.component);
18816
+
18817
+ // Build a scope/package subtitle so ambiguous component names like
18818
+ // `ProspectListColumn` (which might come from `@ai-built/…` or
18819
+ // `@trops/pipeline`) are disambiguated in the layout builder. Derives
18820
+ // from whatever identity the config / layout item carries:
18821
+ // - widgetConfig.id: e.g. "@ai-built/prospectlistcolumn.ProspectListColumn"
18822
+ // - widgetConfig.package: e.g. "@ai-built/prospectlistcolumn"
18823
+ // - widgetItem.workspace: fallback hint ("ai-built" / "@trops/pipeline")
18824
+ // Falls back to empty string so we can skip rendering if we have
18825
+ // nothing meaningful beyond the component name itself.
18826
+ var packageLabel = function () {
18827
+ var dropTrailingComponent = function dropTrailingComponent(s) {
18828
+ if (typeof s !== "string") return "";
18829
+ var lastDot = s.lastIndexOf(".");
18830
+ return lastDot > 0 ? s.slice(0, lastDot) : s;
18831
+ };
18832
+ var fromId = dropTrailingComponent((widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.id) || "");
18833
+ if (fromId) return fromId;
18834
+ if (widgetConfig !== null && widgetConfig !== void 0 && widgetConfig["package"]) return String(widgetConfig["package"]);
18835
+ var wsHint = widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.workspace;
18836
+ if (typeof wsHint === "string" && wsHint && wsHint !== "layout") {
18837
+ return wsHint.startsWith("@") ? wsHint : "@".concat(wsHint);
18838
+ }
18839
+ return "";
18840
+ }();
18816
18841
 
18817
18842
  // Get provider requirements from widget config (not from item directly)
18818
18843
  // Filter out providerClass: "api" so only user-configurable providers show badges
@@ -18951,11 +18976,18 @@ var WidgetCardHeader = function WidgetCardHeader(_ref) {
18951
18976
  children: [/*#__PURE__*/jsxRuntime.jsx(WidgetIcon, {
18952
18977
  icon: isWidgetMissing ? "triangle-exclamation" : widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.icon,
18953
18978
  className: "h-4 w-4 flex-shrink-0 ".concat(isWidgetMissing ? "text-amber-500" : "text-white/60")
18954
- }), /*#__PURE__*/jsxRuntime.jsxs("span", {
18955
- className: "font-medium text-sm text-gray-100 truncate",
18956
- children: [widgetName || cellNumber || "Empty", isWidgetMissing && /*#__PURE__*/jsxRuntime.jsx("span", {
18957
- className: "text-amber-500/70 font-normal ml-1",
18958
- children: "(not found)"
18979
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
18980
+ className: "flex flex-col min-w-0 leading-tight",
18981
+ children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
18982
+ className: "font-medium text-sm text-gray-100 truncate",
18983
+ children: [widgetName || cellNumber || "Empty", isWidgetMissing && /*#__PURE__*/jsxRuntime.jsx("span", {
18984
+ className: "text-amber-500/70 font-normal ml-1",
18985
+ children: "(not found)"
18986
+ })]
18987
+ }), packageLabel && /*#__PURE__*/jsxRuntime.jsxs("span", {
18988
+ className: "text-[10px] text-gray-500 truncate",
18989
+ title: "".concat(packageLabel, " \xB7 ").concat((widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.component) || ""),
18990
+ children: [packageLabel, widgetItem !== null && widgetItem !== void 0 && widgetItem.component && widgetItem.component !== widgetName ? " \xB7 ".concat(widgetItem.component) : ""]
18959
18991
  })]
18960
18992
  })]
18961
18993
  }), (providerRequirements.length > 0 || overflowActions.length > 0 || onMoreOptions) && /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -20710,6 +20742,17 @@ var LayoutBuilder = function LayoutBuilder(_ref) {
20710
20742
  wsRef.current = currentWorkspace;
20711
20743
  }, [currentWorkspace]);
20712
20744
 
20745
+ // Stable ref to onWorkspaceChange so the window-event handlers below can
20746
+ // propagate mutations upstream without resubscribing on every render.
20747
+ // Without this, swap/place handlers only update LayoutBuilder-local
20748
+ // state — the parent (PinnedSidebar / PageLayoutBuilder) never learns
20749
+ // about the change, so the next parent re-render reverts it via the
20750
+ // `[workspace]` useEffect above and the save path reads stale state.
20751
+ var onWorkspaceChangeRef = React.useRef(onWorkspaceChange);
20752
+ React.useEffect(function () {
20753
+ onWorkspaceChangeRef.current = onWorkspaceChange;
20754
+ }, [onWorkspaceChange]);
20755
+
20713
20756
  // Listen for AI widget builder placement — modifies layout state directly
20714
20757
  React.useEffect(function () {
20715
20758
  var handler = function handler(e) {
@@ -20746,6 +20789,9 @@ var LayoutBuilder = function LayoutBuilder(_ref) {
20746
20789
  var newWorkspace = JSON.parse(JSON.stringify(ws));
20747
20790
  newWorkspace.layout = newLayout;
20748
20791
  setCurrentWorkspace(newWorkspace);
20792
+ if (typeof onWorkspaceChangeRef.current === "function") {
20793
+ onWorkspaceChangeRef.current(newWorkspace);
20794
+ }
20749
20795
  } catch (err) {
20750
20796
  }
20751
20797
  };
@@ -20780,6 +20826,9 @@ var LayoutBuilder = function LayoutBuilder(_ref) {
20780
20826
  var newWorkspace = JSON.parse(JSON.stringify(ws));
20781
20827
  newWorkspace.layout = newLayout;
20782
20828
  setCurrentWorkspace(newWorkspace);
20829
+ if (typeof onWorkspaceChangeRef.current === "function") {
20830
+ onWorkspaceChangeRef.current(newWorkspace);
20831
+ }
20783
20832
  } catch (err) {
20784
20833
  }
20785
20834
  };
@@ -55809,13 +55858,31 @@ function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t
55809
55858
  * widget currently in the workspace's layout tree. Keys drive
55810
55859
  * listener pruning; the itemId set drives provider-binding pruning
55811
55860
  * (selectedProviders is keyed by raw widgetId).
55861
+ *
55862
+ * Listener event strings are written as `${component}[${itemId}].${event}`
55863
+ * where `itemId` is whichever id-ish field the emitter had at wire time
55864
+ * (in practice `itemIdOf` prefers numeric `id`). `canonicalItemKey`'s
55865
+ * preference order (uuidString → uuid → id) doesn't match that, and
55866
+ * `LayoutModel` decorates every persisted item with a composite
55867
+ * `uuid = "${dashboardId}-${component}-${id}"` while leaving
55868
+ * `uuidString` unset — so canonicalItemKey would produce
55869
+ * `Component|{dashId}-{Component}-{123}` while the event string produces
55870
+ * `Component|123`. Record every id-ish form as a separate live key so
55871
+ * reconciliation is tolerant of whichever shape the stored binding
55872
+ * carries.
55812
55873
  */
55813
55874
  function collectLiveIdentity(workspace) {
55814
55875
  var liveCanonicalKeys = new Set();
55815
55876
  var liveItemIds = new Set();
55816
55877
  forEachWidget(workspace, function (item) {
55817
- var key = canonicalItemKey(item);
55818
- if (key) liveCanonicalKeys.add(key);
55878
+ var comp = item.component;
55879
+ if (comp) {
55880
+ if (item.id != null) liveCanonicalKeys.add("".concat(comp, "|").concat(item.id));
55881
+ if (item.uuidString) {
55882
+ liveCanonicalKeys.add("".concat(comp, "|").concat(item.uuidString));
55883
+ }
55884
+ if (item.uuid) liveCanonicalKeys.add("".concat(comp, "|").concat(item.uuid));
55885
+ }
55819
55886
  // Track every id-ish the runtime might key by. selectedProviders
55820
55887
  // uses `item.uuidString` or `item.uuid` or `item.id` depending on
55821
55888
  // when the binding was written, so accept any of them.