@trops/dash-core 0.1.436 → 0.1.437

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
@@ -15413,18 +15413,14 @@ var LayoutBuilderConfigModal = function LayoutBuilderConfigModal(_ref) {
15413
15413
  return s.key === activeSection;
15414
15414
  }) || sections[0];
15415
15415
 
15416
- // Footer label: derive @scope/package straight from the layout
15417
- // item's scoped component id. Strict no workspace fallback.
15416
+ // Footer label: full scoped id (`scope.package.Component`) so the
15417
+ // user always sees the underlying widget identity, even when the
15418
+ // primary title is a custom per-instance label. No workspace fallback.
15418
15419
  var footerPackageLabel = function () {
15419
15420
  var scopedId = (itemSelected === null || itemSelected === void 0 ? void 0 : itemSelected.component) || "";
15420
15421
  if (typeof scopedId !== "string") return "";
15421
15422
  var parts = scopedId.split(".");
15422
- if (parts.length !== 3) return "";
15423
- var _parts = _slicedToArray(parts, 2),
15424
- scope = _parts[0],
15425
- pkg = _parts[1];
15426
- if (!scope || !pkg) return "";
15427
- return "@".concat(scope, "/").concat(pkg);
15423
+ return parts.length === 3 ? scopedId : "";
15428
15424
  }();
15429
15425
  var componentName = itemSelected ? itemSelected["component"] : "";
15430
15426
  var footerLeftContent = footerPackageLabel ? /*#__PURE__*/jsxRuntime.jsxs("span", {
@@ -19727,24 +19723,40 @@ var WidgetCardHeader = function WidgetCardHeader(_ref) {
19727
19723
  // Detect missing widgets (component key exists but not in ComponentManager)
19728
19724
  var isWidgetMissing = (widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.component) && !widgetConfig;
19729
19725
 
19730
- // Get widget name from config or item
19731
- 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);
19726
+ // Display name priority: per-instance user title → widget's default
19727
+ // title developer's friendly displayName widget config name
19728
+ // bare component name (last segment) → full scoped id (last resort).
19729
+ // Mirrors WidgetsTab so the same widget shows the same name in both
19730
+ // surfaces.
19731
+ var widgetName = function (_widgetItem$userPrefs, _widgetConfig$userCon) {
19732
+ var prefsTitle = widgetItem === null || widgetItem === void 0 || (_widgetItem$userPrefs = widgetItem.userPrefs) === null || _widgetItem$userPrefs === void 0 ? void 0 : _widgetItem$userPrefs.title;
19733
+ if (typeof prefsTitle === "string" && prefsTitle.trim()) return prefsTitle;
19734
+ var configDefault = widgetConfig === null || widgetConfig === void 0 || (_widgetConfig$userCon = widgetConfig.userConfig) === null || _widgetConfig$userCon === void 0 || (_widgetConfig$userCon = _widgetConfig$userCon.title) === null || _widgetConfig$userCon === void 0 ? void 0 : _widgetConfig$userCon.defaultValue;
19735
+ if (typeof configDefault === "string" && configDefault.trim()) {
19736
+ return configDefault;
19737
+ }
19738
+ if (widgetConfig !== null && widgetConfig !== void 0 && widgetConfig.displayName) return widgetConfig.displayName;
19739
+ if (widgetConfig !== null && widgetConfig !== void 0 && widgetConfig.name) return widgetConfig.name;
19740
+ if (widgetItem !== null && widgetItem !== void 0 && widgetItem.name) return widgetItem.name;
19741
+ var comp = widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.component;
19742
+ if (typeof comp === "string") {
19743
+ var parts = comp.split(".");
19744
+ if (parts.length === 3) return parts[2];
19745
+ return comp;
19746
+ }
19747
+ return "Widget";
19748
+ }();
19732
19749
 
19733
- // Derive the "@scope/package" label from the layout item's scoped
19734
- // component id (`scope.package.Component`). Strict the layout item
19735
- // is the source of truth. If the item isn't scoped (a legacy layout
19736
- // that LayoutModel couldn't migrate, or a missing widget) the label
19737
- // is empty rather than guessed from the workspace category.
19750
+ // Show the full scoped registry id (`scope.package.Component`) as
19751
+ // the subtitle. The friendly title on line 1 may be a custom user
19752
+ // title that doesn't reveal which widget is mounted; the subtitle
19753
+ // pins down the underlying identity. Strict the layout item is
19754
+ // the source of truth.
19738
19755
  var packageLabel = function () {
19739
19756
  var scopedId = (widgetItem === null || widgetItem === void 0 ? void 0 : widgetItem.component) || (widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.id) || "";
19740
19757
  if (typeof scopedId !== "string") return "";
19741
19758
  var parts = scopedId.split(".");
19742
- if (parts.length !== 3) return "";
19743
- var _parts = _slicedToArray(parts, 2),
19744
- scope = _parts[0],
19745
- pkg = _parts[1];
19746
- if (!scope || !pkg) return "";
19747
- return "@".concat(scope, "/").concat(pkg);
19759
+ return parts.length === 3 ? scopedId : "";
19748
19760
  }();
19749
19761
 
19750
19762
  // Get provider requirements from widget config (not from item directly)
@@ -55224,21 +55236,53 @@ function _arrayLikeToArray$5(r, a) { (null == a || a > r.length) && (a = r.lengt
55224
55236
  var ALL_WIDGETS_ID = "__ALL__";
55225
55237
 
55226
55238
  /**
55227
- * Build the scoped registry identifier for a widget. Surfaces the
55228
- * `scope.packageName.component` triple in the settings UI so users
55229
- * can verify what a widget's registry identity is useful when
55230
- * diagnosing dashboard-install warnings ("why didn't this widget
55231
- * install?" → scoped id in the warning vs scoped id shown here).
55232
- * Returns just the component name when scope/package metadata is
55233
- * unavailable (e.g. bare built-ins).
55239
+ * Pick the most user-friendly display name for a widget instance.
55240
+ * Priority: per-instance user title widget's default title → widget
55241
+ * developer's friendly displayName widget config name the bare
55242
+ * component name (last segment of the scoped id) → the full scoped
55243
+ * id (last resort, never preferred but always present).
55244
+ *
55245
+ * This is what shows on the primary line of the WidgetsTab list and
55246
+ * detail header. The full scoped registry id (`scope.package.X`) is
55247
+ * surfaced separately via `pickWidgetRef` below, so the user sees
55248
+ * BOTH a friendly name and an unambiguous reference.
55234
55249
  */
55235
- function buildScopedId(widget) {
55236
- if (!(widget !== null && widget !== void 0 && widget.component)) return null;
55237
- var scope = widget.scope ? String(widget.scope).replace(/^@/, "") : null;
55238
- var pkg = widget.packageName ? scope ? String(widget.packageName).replace(new RegExp("^@?".concat(scope, "/")), "") : String(widget.packageName).replace(/^@/, "") : null;
55239
- if (scope && pkg) return "".concat(scope, ".").concat(pkg, ".").concat(widget.component);
55240
- if (pkg) return "".concat(pkg, ".").concat(widget.component);
55241
- return widget.component;
55250
+ function pickDisplayName(item, cfg) {
55251
+ var _item$userPrefs, _item$userConfig;
55252
+ var prefsTitle = item === null || item === void 0 || (_item$userPrefs = item.userPrefs) === null || _item$userPrefs === void 0 ? void 0 : _item$userPrefs.title;
55253
+ if (typeof prefsTitle === "string" && prefsTitle.trim()) return prefsTitle;
55254
+ var configDefault = item === null || item === void 0 || (_item$userConfig = item.userConfig) === null || _item$userConfig === void 0 || (_item$userConfig = _item$userConfig.title) === null || _item$userConfig === void 0 ? void 0 : _item$userConfig.defaultValue;
55255
+ if (typeof configDefault === "string" && configDefault.trim()) {
55256
+ return configDefault;
55257
+ }
55258
+ if (cfg !== null && cfg !== void 0 && cfg.displayName) return cfg.displayName;
55259
+ if (cfg !== null && cfg !== void 0 && cfg.name) return cfg.name;
55260
+ var bare = bareComponentName(item === null || item === void 0 ? void 0 : item.component);
55261
+ if (bare) return bare;
55262
+ return (item === null || item === void 0 ? void 0 : item.component) || "Widget";
55263
+ }
55264
+
55265
+ /**
55266
+ * Format the full scoped registry id (`scope.package.Component`) for
55267
+ * the subtitle. The friendly display name on line 1 may be a custom
55268
+ * per-instance title that doesn't reveal which widget is actually
55269
+ * mounted — the subtitle pins down the underlying widget identity so
55270
+ * the user can always see "this 'Q4 Pipeline' is actually a
55271
+ * `trops.pipeline.SalesPipeline`".
55272
+ *
55273
+ * Falls back to the cfg fields when the layout item is non-canonical
55274
+ * (legacy bare names that LayoutModel couldn't migrate). Returns
55275
+ * null when even those are missing — caller hides the subtitle.
55276
+ */
55277
+ function pickWidgetRef(item, cfg) {
55278
+ if (parseScopedComponentId(item === null || item === void 0 ? void 0 : item.component)) return item.component;
55279
+ var scope = (cfg === null || cfg === void 0 ? void 0 : cfg.scope) || (item === null || item === void 0 ? void 0 : item.scope);
55280
+ var pkg = (cfg === null || cfg === void 0 ? void 0 : cfg.packageName) || (item === null || item === void 0 ? void 0 : item.packageName);
55281
+ var comp = bareComponentName(item === null || item === void 0 ? void 0 : item.component) || (cfg === null || cfg === void 0 ? void 0 : cfg.name);
55282
+ if (!scope || !pkg || !comp) return (item === null || item === void 0 ? void 0 : item.component) || null;
55283
+ var bareScope = String(scope).replace(/^@/, "");
55284
+ var barePkg = String(pkg).replace(new RegExp("^@?".concat(bareScope, "/")), "");
55285
+ return "".concat(bareScope, ".").concat(barePkg, ".").concat(comp);
55242
55286
  }
55243
55287
 
55244
55288
  /**
@@ -55285,13 +55329,11 @@ var WidgetsTab = function WidgetsTab(_ref) {
55285
55329
  result.push({
55286
55330
  id: id,
55287
55331
  component: item.component,
55288
- displayName: item.name || cfg.name || cfg.displayName || item.component,
55332
+ displayName: pickDisplayName(item, cfg),
55333
+ widgetRef: pickWidgetRef(item, cfg),
55289
55334
  section: section,
55290
55335
  userConfig: cfg.userConfig || {},
55291
55336
  userPrefs: item.userPrefs || {},
55292
- // Identity fields for the registry-identifier label. Prefer
55293
- // values from the widget's component manager entry since the
55294
- // layout item itself often doesn't carry scope/packageName.
55295
55337
  scope: cfg.scope || item.scope || null,
55296
55338
  packageName: cfg.packageName || cfg.name || item.packageName || null
55297
55339
  });
@@ -55429,6 +55471,10 @@ var WidgetsTab = function WidgetsTab(_ref) {
55429
55471
  className: "text-[10px] bg-amber-500/20 text-amber-300 px-1.5 rounded",
55430
55472
  children: stagedForWidget
55431
55473
  })]
55474
+ }), w.widgetRef && /*#__PURE__*/jsxRuntime.jsx("div", {
55475
+ className: "text-[10px] text-gray-500 font-mono truncate mt-0.5",
55476
+ title: w.widgetRef,
55477
+ children: w.widgetRef
55432
55478
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
55433
55479
  className: "text-[10px] text-gray-600 mt-0.5",
55434
55480
  children: fieldCount === 0 ? "No configurable fields" : "".concat(fieldCount, " field").concat(fieldCount === 1 ? "" : "s")
@@ -55461,20 +55507,19 @@ function SingleWidgetPane(_ref4) {
55461
55507
  effectivePrefs = _ref4.effectivePrefs,
55462
55508
  onFieldChange = _ref4.onFieldChange;
55463
55509
  var hasFields = Object.keys(widget.userConfig).length > 0;
55464
- var scopedId = buildScopedId(widget);
55465
55510
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
55466
55511
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
55467
55512
  className: "mb-3",
55468
55513
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
55469
55514
  className: "text-gray-200 font-semibold",
55470
55515
  children: widget.displayName
55471
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
55472
- className: "text-xs text-gray-500",
55473
- children: [widget.component, " \xB7 ", widget.section]
55474
- }), scopedId && scopedId !== widget.component && /*#__PURE__*/jsxRuntime.jsx("code", {
55475
- className: "block mt-1 text-[11px] text-gray-500 font-mono truncate",
55476
- title: scopedId,
55477
- children: scopedId
55516
+ }), widget.widgetRef && /*#__PURE__*/jsxRuntime.jsx("div", {
55517
+ className: "text-xs text-gray-500 font-mono truncate mt-0.5",
55518
+ title: widget.widgetRef,
55519
+ children: widget.widgetRef
55520
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
55521
+ className: "text-xs text-gray-600 mt-0.5",
55522
+ children: widget.section
55478
55523
  })]
55479
55524
  }), hasFields ? /*#__PURE__*/jsxRuntime.jsx(PanelEditForm, {
55480
55525
  userConfig: widget.userConfig,
@@ -55720,11 +55765,11 @@ var DashboardConfigModal = function DashboardConfigModal(_ref) {
55720
55765
  var derivePackage = function derivePackage(item) {
55721
55766
  var scopedId = typeof (item === null || item === void 0 ? void 0 : item.component) === "string" ? item.component : "";
55722
55767
  var parts = scopedId.split(".");
55723
- if (parts.length === 3) {
55724
- var _parts = _slicedToArray(parts, 2),
55725
- scope = _parts[0],
55726
- pkg = _parts[1];
55727
- if (scope && pkg) return "@".concat(scope, "/").concat(pkg);
55768
+ if (parts.length === 3 && parts[0] && parts[1]) {
55769
+ // Group rows by `@scope/package` so two widgets from the same
55770
+ // package show up under one heading. The full scoped id is
55771
+ // surfaced per-row in the table (column-level identity).
55772
+ return "@".concat(parts[0], "/").concat(parts[1]);
55728
55773
  }
55729
55774
  // Defensive: an explicit packageId on the item still wins for
55730
55775
  // legacy items the migration couldn't auto-resolve.