@trops/dash-core 0.1.730 → 0.1.731
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 +81 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -50351,6 +50351,21 @@ function noAiOptions(type) {
|
|
|
50351
50351
|
return [].concat(_toConsumableArray(NO_AI_BY_TYPE[type] || []), NO_AI_COMMON);
|
|
50352
50352
|
}
|
|
50353
50353
|
|
|
50354
|
+
/** How many recent widget drafts the start screen offers to continue. */
|
|
50355
|
+
var RECENT_DRAFTS = 3;
|
|
50356
|
+
|
|
50357
|
+
/** "just now" · "5m ago" · "3h ago" · "2d ago" for a draft's updatedAt. */
|
|
50358
|
+
function draftAge(updatedAt) {
|
|
50359
|
+
var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
|
|
50360
|
+
var ms = Math.max(0, now - Number(updatedAt || 0));
|
|
50361
|
+
var min = Math.floor(ms / 60000);
|
|
50362
|
+
if (min < 1) return "just now";
|
|
50363
|
+
if (min < 60) return "".concat(min, "m ago");
|
|
50364
|
+
var hours = Math.floor(min / 60);
|
|
50365
|
+
if (hours < 24) return "".concat(hours, "h ago");
|
|
50366
|
+
return "".concat(Math.floor(hours / 24), "d ago");
|
|
50367
|
+
}
|
|
50368
|
+
|
|
50354
50369
|
/** Whether Send can run: a prompt, and an AI for types that need one. */
|
|
50355
50370
|
function canSend(_ref) {
|
|
50356
50371
|
var type = _ref.type,
|
|
@@ -50461,6 +50476,11 @@ var CreateModal = function CreateModal(_ref) {
|
|
|
50461
50476
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
50462
50477
|
bots = _useState8[0],
|
|
50463
50478
|
setBots = _useState8[1];
|
|
50479
|
+
// Recent Widget Builder drafts (newest first) — "Continue a draft".
|
|
50480
|
+
var _useState9 = React.useState(EMPTY$6),
|
|
50481
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
50482
|
+
drafts = _useState0[0],
|
|
50483
|
+
setDrafts = _useState0[1];
|
|
50464
50484
|
|
|
50465
50485
|
// Each open starts fresh on the requested type.
|
|
50466
50486
|
React.useEffect(function () {
|
|
@@ -50483,6 +50503,22 @@ var CreateModal = function CreateModal(_ref) {
|
|
|
50483
50503
|
};
|
|
50484
50504
|
}, [open, botForm]);
|
|
50485
50505
|
|
|
50506
|
+
// Widget drafts to continue (the host's drafts store; none outside the
|
|
50507
|
+
// app).
|
|
50508
|
+
React.useEffect(function () {
|
|
50509
|
+
var _api$drafts;
|
|
50510
|
+
if (!open || type !== "widget") return undefined;
|
|
50511
|
+
var alive = true;
|
|
50512
|
+
var api = typeof window !== "undefined" ? window.mainApi : null;
|
|
50513
|
+
if (!(api !== null && api !== void 0 && (_api$drafts = api.drafts) !== null && _api$drafts !== void 0 && _api$drafts.list)) return undefined;
|
|
50514
|
+
Promise.resolve(api.drafts.list()).then(function (list) {
|
|
50515
|
+
if (alive && Array.isArray(list)) setDrafts(list);
|
|
50516
|
+
})["catch"](function () {});
|
|
50517
|
+
return function () {
|
|
50518
|
+
alive = false;
|
|
50519
|
+
};
|
|
50520
|
+
}, [open, type]);
|
|
50521
|
+
|
|
50486
50522
|
// Other bots → "Another bot" events in the bot form's picker.
|
|
50487
50523
|
React.useEffect(function () {
|
|
50488
50524
|
var _api$bots;
|
|
@@ -50528,6 +50564,17 @@ var CreateModal = function CreateModal(_ref) {
|
|
|
50528
50564
|
});
|
|
50529
50565
|
}
|
|
50530
50566
|
};
|
|
50567
|
+
var continueDraft = function continueDraft(draft) {
|
|
50568
|
+
close();
|
|
50569
|
+
window.dispatchEvent(new CustomEvent("dash:open-widget-builder", {
|
|
50570
|
+
detail: {
|
|
50571
|
+
resumeDraftId: draft.id
|
|
50572
|
+
}
|
|
50573
|
+
}));
|
|
50574
|
+
};
|
|
50575
|
+
var recentDrafts = type === "widget" ? _toConsumableArray(drafts).sort(function (a, b) {
|
|
50576
|
+
return (b.updatedAt || 0) - (a.updatedAt || 0);
|
|
50577
|
+
}).slice(0, RECENT_DRAFTS) : EMPTY$6;
|
|
50531
50578
|
var startWithoutAi = function startWithoutAi(key) {
|
|
50532
50579
|
if (key === "blank-bot") {
|
|
50533
50580
|
setBotForm({
|
|
@@ -50638,6 +50685,37 @@ var CreateModal = function CreateModal(_ref) {
|
|
|
50638
50685
|
onOpenAiSettings();
|
|
50639
50686
|
}
|
|
50640
50687
|
})]
|
|
50688
|
+
}), recentDrafts.length > 0 && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
50689
|
+
className: "flex flex-col gap-2",
|
|
50690
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.SectionLabel, {
|
|
50691
|
+
children: "Continue a draft"
|
|
50692
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
50693
|
+
className: "flex flex-row flex-wrap gap-2",
|
|
50694
|
+
children: [recentDrafts.map(function (d) {
|
|
50695
|
+
return /*#__PURE__*/jsxRuntime.jsx(DashReact.Button3, {
|
|
50696
|
+
size: "sm",
|
|
50697
|
+
onClick: function onClick() {
|
|
50698
|
+
return continueDraft(d);
|
|
50699
|
+
},
|
|
50700
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
50701
|
+
className: "inline-flex items-center gap-2",
|
|
50702
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
|
|
50703
|
+
icon: "pen-to-square",
|
|
50704
|
+
className: "h-3.5 w-3.5"
|
|
50705
|
+
}), d.name || "Untitled draft", /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
50706
|
+
className: muted,
|
|
50707
|
+
children: ["\xB7 ", draftAge(d.updatedAt)]
|
|
50708
|
+
})]
|
|
50709
|
+
})
|
|
50710
|
+
}, d.id);
|
|
50711
|
+
}), drafts.length > RECENT_DRAFTS && /*#__PURE__*/jsxRuntime.jsx(DashReact.Button3, {
|
|
50712
|
+
size: "sm",
|
|
50713
|
+
title: "All ".concat(drafts.length, " drafts"),
|
|
50714
|
+
onClick: function onClick() {
|
|
50715
|
+
return startWithoutAi("widget-drafts");
|
|
50716
|
+
}
|
|
50717
|
+
})]
|
|
50718
|
+
})]
|
|
50641
50719
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
50642
50720
|
className: "flex flex-col gap-2",
|
|
50643
50721
|
children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.SectionLabel, {
|
|
@@ -77932,6 +78010,9 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
77932
78010
|
setThemeEditorKey(null);
|
|
77933
78011
|
setThemeStartInCreate(true);
|
|
77934
78012
|
setIsThemeManagerOpen(true);
|
|
78013
|
+
} else if (key === "widget-drafts") {
|
|
78014
|
+
// Drafts are listed (with Resume) on the Widgets page.
|
|
78015
|
+
handleOpenPageGuarded("widgets");
|
|
77935
78016
|
} else if (WIDGET_INSTALL_ACTIONS[key]) {
|
|
77936
78017
|
handleOpenPageGuarded("widgets", {
|
|
77937
78018
|
widgetLink: {
|