@trops/dash-core 0.1.452 → 0.1.453

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
@@ -25461,6 +25461,7 @@ var WidgetErrorBoundary = /*#__PURE__*/function (_Component) {
25461
25461
  }, {
25462
25462
  key: "render",
25463
25463
  value: function render() {
25464
+ var _this2 = this;
25464
25465
  if (this.state.hasError) {
25465
25466
  var _this$state$error;
25466
25467
  var widgetName = this.props.widgetName;
@@ -25468,33 +25469,64 @@ var WidgetErrorBoundary = /*#__PURE__*/function (_Component) {
25468
25469
 
25469
25470
  // Check if it's a WidgetContext error
25470
25471
  var isContextError = errorMessage.includes("Widget ID not found in Context") || errorMessage.includes("WidgetContext");
25472
+
25473
+ // AI-built widgets live under @ai-built/* — they get an "Open
25474
+ // in AI Builder" recovery button that dispatches the existing
25475
+ // dash:edit-widget-with-ai event (dash-electron's Dash.js
25476
+ // listens for it and reopens the failing widget in remix mode).
25477
+ var isAiBuilt = typeof widgetName === "string" && /(^|[./])ai-built\b/i.test(widgetName);
25478
+ var openInBuilder = function openInBuilder() {
25479
+ try {
25480
+ window.dispatchEvent(new CustomEvent("dash:edit-widget-with-ai", {
25481
+ detail: {
25482
+ widgetComponentName: widgetName
25483
+ }
25484
+ }));
25485
+ } catch (err) {
25486
+ }
25487
+ };
25471
25488
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
25472
- className: "flex flex-col h-full w-full bg-red-900 border-2 border-red-600 rounded p-4 text-red-100",
25489
+ className: "flex flex-col h-full w-full bg-amber-950 border border-amber-700 rounded p-4 text-amber-100",
25473
25490
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
25474
- className: "text-xl font-bold mb-2",
25475
- children: "\u26A0\uFE0F Widget Error"
25476
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
25477
- className: "text-sm mb-3",
25478
- children: [/*#__PURE__*/jsxRuntime.jsx("strong", {
25479
- children: "Widget:"
25480
- }), " ", widgetName]
25491
+ className: "text-base font-semibold mb-2 text-amber-200",
25492
+ children: "Widget couldn't render"
25481
25493
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
25482
- className: "text-sm mb-3",
25483
- children: [/*#__PURE__*/jsxRuntime.jsx("strong", {
25484
- children: "Error:"
25485
- }), " ", errorMessage]
25494
+ className: "text-xs mb-2 break-words",
25495
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
25496
+ className: "text-amber-300",
25497
+ children: widgetName
25498
+ }), " threw", " ", /*#__PURE__*/jsxRuntime.jsx("span", {
25499
+ className: "font-mono",
25500
+ children: errorMessage
25501
+ })]
25486
25502
  }), isContextError && /*#__PURE__*/jsxRuntime.jsxs("div", {
25487
- className: "text-sm bg-red-800 border border-red-700 rounded p-3 mt-2",
25503
+ className: "text-xs bg-amber-900 border border-amber-700 rounded p-2 mt-2 mb-2",
25488
25504
  children: [/*#__PURE__*/jsxRuntime.jsx("strong", {
25489
25505
  children: "Fix:"
25490
25506
  }), " This widget uses ", /*#__PURE__*/jsxRuntime.jsx("code", {
25491
25507
  children: "WidgetContext"
25492
25508
  }), " ", "but is missing the ", /*#__PURE__*/jsxRuntime.jsx("code", {
25493
25509
  children: "<Widget>"
25494
- }), " wrapper.", /*#__PURE__*/jsxRuntime.jsx("br", {}), /*#__PURE__*/jsxRuntime.jsx("br", {}), "Add the wrapper in your widget component:", /*#__PURE__*/jsxRuntime.jsx("pre", {
25510
+ }), " wrapper.", /*#__PURE__*/jsxRuntime.jsx("br", {}), "Add the wrapper in your widget component:", /*#__PURE__*/jsxRuntime.jsx("pre", {
25495
25511
  className: "bg-gray-900 p-2 rounded mt-2 text-xs overflow-auto",
25496
25512
  children: "import { Widget } from \"@trops/dash-react\";\n\nexport const ".concat(widgetName, " = (props) => {\n return (\n <Widget {...props}>\n {/* Your widget content */}\n </Widget>\n );\n};")
25497
25513
  })]
25514
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
25515
+ className: "flex items-center gap-2 mt-2",
25516
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
25517
+ onClick: function onClick() {
25518
+ return _this2.setState({
25519
+ hasError: false,
25520
+ error: null
25521
+ });
25522
+ },
25523
+ className: "px-3 py-1 rounded text-xs bg-amber-700 hover:bg-amber-600 text-amber-100 transition-colors",
25524
+ children: "Retry"
25525
+ }), isAiBuilt && /*#__PURE__*/jsxRuntime.jsx("button", {
25526
+ onClick: openInBuilder,
25527
+ className: "px-3 py-1 rounded text-xs bg-indigo-600 hover:bg-indigo-500 text-white transition-colors",
25528
+ children: "Open in AI Builder"
25529
+ })]
25498
25530
  })]
25499
25531
  });
25500
25532
  }