@burdenoff/microfe-movethewheels 2026.1108.2 → 2026.1108.3

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.
@@ -1,14 +1,18 @@
1
- import { Download as e } from "../node_modules/lucide-react/dist/esm/icons/download.js";
2
- import { ExternalLink as t } from "../node_modules/lucide-react/dist/esm/icons/external-link.js";
3
- import { FileText as n } from "../node_modules/lucide-react/dist/esm/icons/file-text.js";
4
- import { Upload as r } from "../node_modules/lucide-react/dist/esm/icons/upload.js";
5
- import { useMoveTheWheels as i } from "../providers/MoveTheWheelsProvider.js";
6
- import { formatDate as a } from "../utils/formatters.js";
7
- import { useEntityDocuments as o } from "../hooks/useEntityDocuments.js";
8
- import { Button as s, Card as c, CardContent as l, CardHeader as u, CardTitle as d } from "./ui.js";
9
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
1
+ import { Check as e } from "../node_modules/lucide-react/dist/esm/icons/check.js";
2
+ import { Download as t } from "../node_modules/lucide-react/dist/esm/icons/download.js";
3
+ import { ExternalLink as n } from "../node_modules/lucide-react/dist/esm/icons/external-link.js";
4
+ import { FileSearch as r } from "../node_modules/lucide-react/dist/esm/icons/file-search.js";
5
+ import { FileText as i } from "../node_modules/lucide-react/dist/esm/icons/file-text.js";
6
+ import { Upload as a } from "../node_modules/lucide-react/dist/esm/icons/upload.js";
7
+ import { useMoveTheWheels as o } from "../providers/MoveTheWheelsProvider.js";
8
+ import { formatDate as s } from "../utils/formatters.js";
9
+ import { useEntityDocuments as c } from "../hooks/useEntityDocuments.js";
10
+ import { Badge as l, Button as u, Card as d, CardContent as f, CardHeader as p, CardTitle as m, Input as h, Select as g, SelectContent as _, SelectItem as v, SelectTrigger as y, SelectValue as b } from "./ui.js";
11
+ import { DOCUMENT_TYPE_OPTIONS as x, useDocumentExtractions as S } from "../hooks/useDocumentExtractions.js";
12
+ import { useState as C } from "react";
13
+ import { jsx as w, jsxs as T } from "react/jsx-runtime";
10
14
  //#region src/movethewheels/components/DocumentsCard.tsx
11
- function m(e) {
15
+ function E(e) {
12
16
  if (!Number.isFinite(e) || e <= 0) return "—";
13
17
  let t = [
14
18
  "B",
@@ -19,72 +23,196 @@ function m(e) {
19
23
  for (; n >= 1024 && r < t.length - 1;) n /= 1024, r += 1;
20
24
  return `${n.toFixed(n >= 10 || r === 0 ? 0 : 1)} ${t[r]}`;
21
25
  }
22
- function h({ entityType: h, entityId: g }) {
23
- let { navigate: _ } = i(), { documents: v, hasMore: y, isLoading: b, loadMore: x } = o(h, g), S = () => _("/files/browse");
24
- return /* @__PURE__ */ p(c, { children: [/* @__PURE__ */ p(u, {
26
+ function D(e) {
27
+ return e === "APPLIED" ? "Applied" : e === "PARTIALLY_APPLIED" ? "Partially applied" : "Proposed";
28
+ }
29
+ function O({ fileId: t }) {
30
+ let { extractions: n, isLoading: i, error: a, extracting: o, extractError: c, extract: d, apply: f } = S(t), [p, m] = C("BILL_OF_LADING"), [E, O] = C({}), [k, A] = C(null), j = n[0] ?? null, M = async (e, t) => {
31
+ A(null);
32
+ let n = E[t]?.trim(), r = n ? [{
33
+ key: t,
34
+ value: n
35
+ }] : null;
36
+ await f(e.id, [t], r) || A(`Accepting "${t}" failed — refresh and try again`);
37
+ };
38
+ return /* @__PURE__ */ T("div", {
39
+ className: "mt-2 space-y-2 border-t border-border-seam pt-2",
40
+ children: [
41
+ /* @__PURE__ */ T("div", {
42
+ className: "flex items-center gap-2",
43
+ children: [/* @__PURE__ */ T(g, {
44
+ value: p,
45
+ onValueChange: (e) => m(e),
46
+ children: [/* @__PURE__ */ w(y, {
47
+ className: "w-40",
48
+ "aria-label": "Document type",
49
+ children: /* @__PURE__ */ w(b, {})
50
+ }), /* @__PURE__ */ w(_, { children: x.map((e) => /* @__PURE__ */ w(v, {
51
+ value: e.value,
52
+ children: e.label
53
+ }, e.value)) })]
54
+ }), /* @__PURE__ */ T(u, {
55
+ variant: "outline",
56
+ size: "sm",
57
+ disabled: o,
58
+ onClick: () => void d(t, p),
59
+ children: [
60
+ /* @__PURE__ */ w(r, { size: 14 }),
61
+ " ",
62
+ o ? "Reading…" : "Extract fields"
63
+ ]
64
+ })]
65
+ }),
66
+ (c ?? k) && /* @__PURE__ */ w("p", {
67
+ className: "text-sm text-text-danger",
68
+ children: c ?? k
69
+ }),
70
+ i ? /* @__PURE__ */ w("p", {
71
+ className: "text-sm text-text-secondary",
72
+ children: "Loading extraction…"
73
+ }) : j ? /* @__PURE__ */ T("div", {
74
+ className: "space-y-2",
75
+ children: [
76
+ /* @__PURE__ */ T("div", {
77
+ className: "flex items-center gap-2 text-sm",
78
+ children: [/* @__PURE__ */ w(l, {
79
+ variant: j.status === "APPLIED" ? "default" : "secondary",
80
+ children: D(j.status)
81
+ }), /* @__PURE__ */ T("span", {
82
+ className: "text-text-secondary",
83
+ children: [
84
+ x.find((e) => e.value === j.docType)?.label,
85
+ " ·",
86
+ " ",
87
+ s(j.createdAt, "relative"),
88
+ " · ",
89
+ j.model,
90
+ j.costMicroUsd ? ` · ${(Number(j.costMicroUsd) / 1e6).toFixed(4)} USD` : ""
91
+ ]
92
+ })]
93
+ }),
94
+ a && /* @__PURE__ */ w("p", {
95
+ className: "text-sm text-text-danger",
96
+ children: a
97
+ }),
98
+ /* @__PURE__ */ w("ul", {
99
+ className: "space-y-1",
100
+ children: j.fields.map((t) => {
101
+ let n = j.acceptedFields.includes(t.key), r = E[t.key];
102
+ return /* @__PURE__ */ T("li", {
103
+ className: "flex items-center gap-2 text-sm",
104
+ children: [
105
+ /* @__PURE__ */ w("span", {
106
+ className: "w-40 shrink-0 truncate text-text-secondary",
107
+ title: t.label,
108
+ children: t.label
109
+ }),
110
+ /* @__PURE__ */ w(h, {
111
+ className: "h-7 flex-1",
112
+ defaultValue: r ?? t.value ?? "",
113
+ placeholder: "Not shown on document",
114
+ disabled: n,
115
+ onChange: (e) => O((n) => ({
116
+ ...n,
117
+ [t.key]: e.target.value
118
+ }))
119
+ }),
120
+ /* @__PURE__ */ T("span", {
121
+ className: "w-12 shrink-0 text-right text-text-secondary",
122
+ children: [Math.round(t.confidence * 100), "%"]
123
+ }),
124
+ n ? /* @__PURE__ */ T(l, {
125
+ variant: "outline",
126
+ className: "flex items-center gap-1",
127
+ children: [/* @__PURE__ */ w(e, { size: 12 }), " Accepted"]
128
+ }) : /* @__PURE__ */ T(u, {
129
+ variant: "ghost",
130
+ size: "sm",
131
+ onClick: () => void M(j, t.key),
132
+ children: [/* @__PURE__ */ w(e, { size: 14 }), " Accept"]
133
+ })
134
+ ]
135
+ }, t.key);
136
+ })
137
+ }, j.id),
138
+ /* @__PURE__ */ w("p", {
139
+ className: "text-xs text-text-secondary",
140
+ children: "Accepting writes only what that field maps to — a delivery time closes the shipment, invoice lines reconcile on Finance. Editing a value first corrects it on acceptance."
141
+ })
142
+ ]
143
+ }) : null
144
+ ]
145
+ });
146
+ }
147
+ function k({ entityType: e, entityId: r }) {
148
+ let { navigate: l } = o(), { documents: h, hasMore: g, isLoading: _, loadMore: v } = c(e, r), y = () => l("/files/browse");
149
+ return /* @__PURE__ */ T(d, { children: [/* @__PURE__ */ T(p, {
25
150
  className: "flex flex-row items-center justify-between",
26
- children: [/* @__PURE__ */ p(d, {
151
+ children: [/* @__PURE__ */ T(m, {
27
152
  className: "flex items-center gap-2",
28
- children: [/* @__PURE__ */ f(n, { size: 18 }), " Documents"]
29
- }), /* @__PURE__ */ p(s, {
153
+ children: [/* @__PURE__ */ w(i, { size: 18 }), " Documents"]
154
+ }), /* @__PURE__ */ T(u, {
30
155
  variant: "outline",
31
156
  size: "sm",
32
- onClick: S,
33
- children: [/* @__PURE__ */ f(r, { size: 14 }), " Add / Manage"]
157
+ onClick: y,
158
+ children: [/* @__PURE__ */ w(a, { size: 14 }), " Add / Manage"]
34
159
  })]
35
- }), /* @__PURE__ */ f(l, { children: b ? /* @__PURE__ */ f("p", {
160
+ }), /* @__PURE__ */ w(f, { children: _ ? /* @__PURE__ */ w("p", {
36
161
  className: "text-text-secondary text-center py-4",
37
162
  children: "Loading documents…"
38
- }) : v.length > 0 ? /* @__PURE__ */ p("div", {
163
+ }) : h.length > 0 ? /* @__PURE__ */ T("div", {
39
164
  className: "space-y-3",
40
- children: [v.map((n) => /* @__PURE__ */ p("div", {
41
- className: "flex items-center justify-between gap-3 p-3 border rounded-lg",
42
- children: [/* @__PURE__ */ p("div", {
43
- className: "min-w-0",
44
- children: [/* @__PURE__ */ f("p", {
45
- className: "font-medium truncate",
46
- children: n.name
47
- }), /* @__PURE__ */ p("p", {
48
- className: "text-sm text-text-secondary",
49
- children: [
50
- m(n.size),
51
- " · ",
52
- a(n.createdAt, "relative")
53
- ]
165
+ children: [h.map((e) => /* @__PURE__ */ T("div", {
166
+ className: "p-3 border rounded-lg",
167
+ children: [/* @__PURE__ */ T("div", {
168
+ className: "flex items-center justify-between gap-3",
169
+ children: [/* @__PURE__ */ T("div", {
170
+ className: "min-w-0",
171
+ children: [/* @__PURE__ */ w("p", {
172
+ className: "font-medium truncate",
173
+ children: e.name
174
+ }), /* @__PURE__ */ T("p", {
175
+ className: "text-sm text-text-secondary",
176
+ children: [
177
+ E(e.size),
178
+ " · ",
179
+ s(e.createdAt, "relative")
180
+ ]
181
+ })]
182
+ }), e.downloadUrl ? /* @__PURE__ */ T("a", {
183
+ href: e.downloadUrl,
184
+ target: "_blank",
185
+ rel: "noopener noreferrer",
186
+ className: "shrink-0 inline-flex items-center gap-1 text-sm text-primary hover:underline",
187
+ children: [/* @__PURE__ */ w(t, { size: 14 }), " Open"]
188
+ }) : /* @__PURE__ */ T(u, {
189
+ variant: "ghost",
190
+ size: "sm",
191
+ onClick: y,
192
+ children: [/* @__PURE__ */ w(n, { size: 14 }), " View"]
54
193
  })]
55
- }), n.downloadUrl ? /* @__PURE__ */ p("a", {
56
- href: n.downloadUrl,
57
- target: "_blank",
58
- rel: "noopener noreferrer",
59
- className: "shrink-0 inline-flex items-center gap-1 text-sm text-primary hover:underline",
60
- children: [/* @__PURE__ */ f(e, { size: 14 }), " Open"]
61
- }) : /* @__PURE__ */ p(s, {
62
- variant: "ghost",
63
- size: "sm",
64
- onClick: S,
65
- children: [/* @__PURE__ */ f(t, { size: 14 }), " View"]
66
- })]
67
- }, n.id)), y && /* @__PURE__ */ f(s, {
194
+ }), /* @__PURE__ */ w(O, { fileId: e.id })]
195
+ }, e.id)), g && /* @__PURE__ */ w(u, {
68
196
  variant: "outline",
69
197
  size: "sm",
70
- onClick: x,
71
- disabled: b,
198
+ onClick: v,
199
+ disabled: _,
72
200
  children: "Load more documents"
73
201
  })]
74
- }) : /* @__PURE__ */ p("div", {
202
+ }) : /* @__PURE__ */ T("div", {
75
203
  className: "text-center py-6",
76
204
  children: [
77
- /* @__PURE__ */ f(n, {
205
+ /* @__PURE__ */ w(i, {
78
206
  size: 32,
79
207
  className: "mx-auto mb-2 text-text-secondary opacity-50"
80
208
  }),
81
- /* @__PURE__ */ f("p", {
209
+ /* @__PURE__ */ w("p", {
82
210
  className: "text-text-secondary",
83
211
  children: "No documents yet"
84
212
  }),
85
- /* @__PURE__ */ f("button", {
213
+ /* @__PURE__ */ w("button", {
86
214
  type: "button",
87
- onClick: S,
215
+ onClick: y,
88
216
  className: "mt-1 text-sm text-primary hover:underline",
89
217
  children: "Add them in Files"
90
218
  })
@@ -92,4 +220,4 @@ function h({ entityType: h, entityId: g }) {
92
220
  }) })] });
93
221
  }
94
222
  //#endregion
95
- export { h as DocumentsCard };
223
+ export { k as DocumentsCard };