@flytedan/flytebot-design-system 0.77.0 → 0.78.0

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.cjs CHANGED
@@ -14323,9 +14323,44 @@ function JsonView({ value }) {
14323
14323
  }
14324
14324
  return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(CodeBlock, { code: text, language: "json", collapseAfter: 18 });
14325
14325
  }
14326
- function PacketCard({ packet, schema, render, onApply, applied }) {
14326
+ function DecisionFooter({ packet, decision, state }) {
14327
+ const [pending, setPending] = React76.useState(null);
14328
+ const [failure, setFailure] = React76.useState(null);
14329
+ const mounted = React76.useRef(true);
14330
+ React76.useEffect(() => {
14331
+ mounted.current = true;
14332
+ return () => {
14333
+ mounted.current = false;
14334
+ };
14335
+ }, []);
14336
+ const press = (action) => {
14337
+ if (pending) return;
14338
+ setPending(action);
14339
+ setFailure(null);
14340
+ decision.onDecide(action, packet).then(
14341
+ () => {
14342
+ if (mounted.current) setPending(null);
14343
+ },
14344
+ (e) => {
14345
+ if (!mounted.current) return;
14346
+ setPending(null);
14347
+ setFailure(e instanceof Error && e.message ? e.message : "That didn\u2019t go through.");
14348
+ }
14349
+ );
14350
+ };
14351
+ const error = failure !== null ? failure : state.error;
14352
+ return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [
14353
+ error ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "fdc-packet-decision-msg", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Banner, { tone: "danger", title: error }) }) : null,
14354
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("footer", { className: "fdc-packet-foot fdc-packet-decision", children: [
14355
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { variant: "secondary", size: "sm", loading: pending === "dismiss", disabled: pending === "confirm", onClick: () => press("dismiss"), children: decision.dismissLabel || "Dismiss" }),
14356
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { variant: "primary", size: "sm", loading: pending === "confirm", disabled: pending === "dismiss", onClick: () => press("confirm"), children: decision.confirmLabel || "Confirm" })
14357
+ ] })
14358
+ ] });
14359
+ }
14360
+ function PacketCard({ packet, schema, render, onApply, applied, decision }) {
14327
14361
  if (!packet) return null;
14328
14362
  const s = schema || {};
14363
+ const state = decision ? decision.state(packet) : {};
14329
14364
  const invalid = packet.valid === false;
14330
14365
  const title = s.heading || packet.type;
14331
14366
  return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("section", { className: "fdc-packet" + (invalid ? " is-invalid" : ""), "aria-label": title, children: [
@@ -14333,13 +14368,14 @@ function PacketCard({ packet, schema, render, onApply, applied }) {
14333
14368
  /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("i", { className: "ph ph-" + (s.icon || "package"), "aria-hidden": "true" }),
14334
14369
  /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "fdc-packet-title", title: truncationTitle(title), children: title }),
14335
14370
  packet.repaired ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "fdc-packet-badge", children: "Repaired" }) : null,
14336
- invalid ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "fdc-packet-badge is-danger", children: "Invalid" }) : null
14371
+ invalid ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "fdc-packet-badge is-danger", children: "Invalid" }) : null,
14372
+ decision && state.status ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Badge, { tone: state.status.tone, children: state.status.label }) : null
14337
14373
  ] }),
14338
14374
  invalid ? /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "fdc-packet-alert", role: "alert", children: [
14339
14375
  /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("i", { className: "ph ph-warning-circle", "aria-hidden": "true" }),
14340
14376
  /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { children: packet.error || "This result failed validation and can\u2019t be applied." })
14341
14377
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "fdc-packet-body", children: render ? render(packet) : /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(JsonView, { value: packet.payload }) }),
14342
- !invalid && onApply && s.apply !== false ? /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("footer", { className: "fdc-packet-foot", children: [
14378
+ !invalid && decision ? state.outcome ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "fdc-packet-decision-msg", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Banner, { tone: state.outcome.tone === "success" ? "ok" : "danger", role: "status", title: state.outcome.message }) }) : /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(DecisionFooter, { packet, decision, state }) : !invalid && onApply && s.apply !== false ? /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("footer", { className: "fdc-packet-foot", children: [
14343
14379
  packet.repaired ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "fdc-packet-note", children: "Corrected by the backend after a first attempt." }) : /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", {}),
14344
14380
  /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("button", { type: "button", className: "fd-btn fd-btn-primary fd-btn-sm", disabled: applied, onClick: () => onApply(packet), children: [
14345
14381
  /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("i", { className: "ph ph-" + (applied ? "check" : "arrow-square-in"), "aria-hidden": "true" }),
@@ -14421,6 +14457,7 @@ function MessageBody({ message: m, ctx }) {
14421
14457
  schema: (ctx.packetSchemas || {})[m.packet.type],
14422
14458
  render: (ctx.packetRenderers || {})[m.packet.type],
14423
14459
  onApply: ctx.onApplyPacket,
14460
+ decision: (ctx.packetDecisions || {})[m.packet.type],
14424
14461
  applied: ctx.appliedPackets && ctx.appliedPackets[m.id]
14425
14462
  }
14426
14463
  ) : null,
@@ -15139,6 +15176,7 @@ function AgentChatPanel({
15139
15176
  renderEmpty,
15140
15177
  packetSchemas,
15141
15178
  packetRenderers,
15179
+ packetDecisions,
15142
15180
  onApplyPacket,
15143
15181
  pendingTimeoutMs,
15144
15182
  describeWaiting,
@@ -15228,6 +15266,7 @@ function AgentChatPanel({
15228
15266
  showThinking,
15229
15267
  packetSchemas,
15230
15268
  packetRenderers,
15269
+ packetDecisions,
15231
15270
  appliedPackets: applied,
15232
15271
  narrow,
15233
15272
  onOpenAttachment,