@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.esm.js +46 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +46 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -25443,6 +25443,7 @@ var WidgetErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
25443
25443
|
}, {
|
|
25444
25444
|
key: "render",
|
|
25445
25445
|
value: function render() {
|
|
25446
|
+
var _this2 = this;
|
|
25446
25447
|
if (this.state.hasError) {
|
|
25447
25448
|
var _this$state$error;
|
|
25448
25449
|
var widgetName = this.props.widgetName;
|
|
@@ -25450,33 +25451,64 @@ var WidgetErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
25450
25451
|
|
|
25451
25452
|
// Check if it's a WidgetContext error
|
|
25452
25453
|
var isContextError = errorMessage.includes("Widget ID not found in Context") || errorMessage.includes("WidgetContext");
|
|
25454
|
+
|
|
25455
|
+
// AI-built widgets live under @ai-built/* — they get an "Open
|
|
25456
|
+
// in AI Builder" recovery button that dispatches the existing
|
|
25457
|
+
// dash:edit-widget-with-ai event (dash-electron's Dash.js
|
|
25458
|
+
// listens for it and reopens the failing widget in remix mode).
|
|
25459
|
+
var isAiBuilt = typeof widgetName === "string" && /(^|[./])ai-built\b/i.test(widgetName);
|
|
25460
|
+
var openInBuilder = function openInBuilder() {
|
|
25461
|
+
try {
|
|
25462
|
+
window.dispatchEvent(new CustomEvent("dash:edit-widget-with-ai", {
|
|
25463
|
+
detail: {
|
|
25464
|
+
widgetComponentName: widgetName
|
|
25465
|
+
}
|
|
25466
|
+
}));
|
|
25467
|
+
} catch (err) {
|
|
25468
|
+
}
|
|
25469
|
+
};
|
|
25453
25470
|
return /*#__PURE__*/jsxs("div", {
|
|
25454
|
-
className: "flex flex-col h-full w-full bg-
|
|
25471
|
+
className: "flex flex-col h-full w-full bg-amber-950 border border-amber-700 rounded p-4 text-amber-100",
|
|
25455
25472
|
children: [/*#__PURE__*/jsx("div", {
|
|
25456
|
-
className: "text-
|
|
25457
|
-
children: "
|
|
25458
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
25459
|
-
className: "text-sm mb-3",
|
|
25460
|
-
children: [/*#__PURE__*/jsx("strong", {
|
|
25461
|
-
children: "Widget:"
|
|
25462
|
-
}), " ", widgetName]
|
|
25473
|
+
className: "text-base font-semibold mb-2 text-amber-200",
|
|
25474
|
+
children: "Widget couldn't render"
|
|
25463
25475
|
}), /*#__PURE__*/jsxs("div", {
|
|
25464
|
-
className: "text-
|
|
25465
|
-
children: [/*#__PURE__*/jsx("
|
|
25466
|
-
|
|
25467
|
-
|
|
25476
|
+
className: "text-xs mb-2 break-words",
|
|
25477
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
25478
|
+
className: "text-amber-300",
|
|
25479
|
+
children: widgetName
|
|
25480
|
+
}), " threw", " ", /*#__PURE__*/jsx("span", {
|
|
25481
|
+
className: "font-mono",
|
|
25482
|
+
children: errorMessage
|
|
25483
|
+
})]
|
|
25468
25484
|
}), isContextError && /*#__PURE__*/jsxs("div", {
|
|
25469
|
-
className: "text-
|
|
25485
|
+
className: "text-xs bg-amber-900 border border-amber-700 rounded p-2 mt-2 mb-2",
|
|
25470
25486
|
children: [/*#__PURE__*/jsx("strong", {
|
|
25471
25487
|
children: "Fix:"
|
|
25472
25488
|
}), " This widget uses ", /*#__PURE__*/jsx("code", {
|
|
25473
25489
|
children: "WidgetContext"
|
|
25474
25490
|
}), " ", "but is missing the ", /*#__PURE__*/jsx("code", {
|
|
25475
25491
|
children: "<Widget>"
|
|
25476
|
-
}), " wrapper.", /*#__PURE__*/jsx("br", {}),
|
|
25492
|
+
}), " wrapper.", /*#__PURE__*/jsx("br", {}), "Add the wrapper in your widget component:", /*#__PURE__*/jsx("pre", {
|
|
25477
25493
|
className: "bg-gray-900 p-2 rounded mt-2 text-xs overflow-auto",
|
|
25478
25494
|
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};")
|
|
25479
25495
|
})]
|
|
25496
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
25497
|
+
className: "flex items-center gap-2 mt-2",
|
|
25498
|
+
children: [/*#__PURE__*/jsx("button", {
|
|
25499
|
+
onClick: function onClick() {
|
|
25500
|
+
return _this2.setState({
|
|
25501
|
+
hasError: false,
|
|
25502
|
+
error: null
|
|
25503
|
+
});
|
|
25504
|
+
},
|
|
25505
|
+
className: "px-3 py-1 rounded text-xs bg-amber-700 hover:bg-amber-600 text-amber-100 transition-colors",
|
|
25506
|
+
children: "Retry"
|
|
25507
|
+
}), isAiBuilt && /*#__PURE__*/jsx("button", {
|
|
25508
|
+
onClick: openInBuilder,
|
|
25509
|
+
className: "px-3 py-1 rounded text-xs bg-indigo-600 hover:bg-indigo-500 text-white transition-colors",
|
|
25510
|
+
children: "Open in AI Builder"
|
|
25511
|
+
})]
|
|
25480
25512
|
})]
|
|
25481
25513
|
});
|
|
25482
25514
|
}
|