@x12i/fieldkit 1.0.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 ADDED
@@ -0,0 +1,662 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ CheckIcon: () => CheckIcon,
34
+ ChevronDownIcon: () => ChevronDownIcon,
35
+ FieldKitProvider: () => FieldKitProvider,
36
+ FieldRenderer: () => FieldRenderer,
37
+ InfoIcon: () => InfoIcon,
38
+ QuestionIcon: () => QuestionIcon,
39
+ RecordView: () => RecordView,
40
+ TONE_PALETTE: () => TONE_PALETTE,
41
+ WarningIcon: () => WarningIcon,
42
+ defaultClassifySignal: () => defaultClassifySignal,
43
+ defaultTheme: () => defaultTheme,
44
+ hashTone: () => hashTone,
45
+ inferRule: () => inferRule,
46
+ labelFromKey: () => labelFromKey,
47
+ resolveField: () => resolveField,
48
+ toneHex: () => toneHex,
49
+ useFieldKitTheme: () => useFieldKitTheme
50
+ });
51
+ module.exports = __toCommonJS(index_exports);
52
+
53
+ // src/theme.tsx
54
+ var React = __toESM(require("react"), 1);
55
+ var import_jsx_runtime = require("react/jsx-runtime");
56
+ var TONE_PALETTE = {
57
+ neutral: "#8B96A3",
58
+ amber: "#E8A33D",
59
+ rose: "#E2564F",
60
+ green: "#59B87B",
61
+ blue: "#6FA8DC",
62
+ violet: "#9B8CDB",
63
+ teal: "#4FB6A8"
64
+ };
65
+ var HASHABLE_TONES = ["amber", "rose", "green", "blue", "violet", "teal"];
66
+ function hashTone(value) {
67
+ let h = 0;
68
+ for (let i = 0; i < value.length; i++) h = h * 31 + value.charCodeAt(i) >>> 0;
69
+ return HASHABLE_TONES[h % HASHABLE_TONES.length];
70
+ }
71
+ var defaultTheme = {
72
+ colors: {
73
+ background: "#0A0E13",
74
+ surface: "#10161D",
75
+ surfaceMuted: "#0D1218",
76
+ border: "rgba(255,255,255,0.07)",
77
+ textPrimary: "#F4F6F8",
78
+ textSecondary: "#C7CDD3",
79
+ textMuted: "#5B6672",
80
+ accent: "#4FB6A8"
81
+ },
82
+ fonts: {
83
+ heading: "'Space Grotesk', ui-sans-serif, sans-serif",
84
+ body: "'IBM Plex Sans', ui-sans-serif, sans-serif",
85
+ mono: "'IBM Plex Mono', ui-monospace, monospace"
86
+ },
87
+ radii: { sm: "5px", md: "8px", lg: "14px", pill: "999px" },
88
+ tonePalette: TONE_PALETTE
89
+ };
90
+ function mergeTheme(base2, override) {
91
+ if (!override) return base2;
92
+ return {
93
+ colors: { ...base2.colors, ...override.colors },
94
+ fonts: { ...base2.fonts, ...override.fonts },
95
+ radii: { ...base2.radii, ...override.radii },
96
+ tonePalette: { ...base2.tonePalette, ...override.tonePalette }
97
+ };
98
+ }
99
+ var ThemeContext = React.createContext(defaultTheme);
100
+ function FieldKitProvider({ theme, children }) {
101
+ const parent = React.useContext(ThemeContext);
102
+ const merged = React.useMemo(() => mergeTheme(parent, theme), [parent, theme]);
103
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: merged, children });
104
+ }
105
+ function useFieldKitTheme() {
106
+ return React.useContext(ThemeContext);
107
+ }
108
+ function toneHex(theme, toneKey) {
109
+ var _a, _b;
110
+ if (!toneKey) return (_a = theme.tonePalette.neutral) != null ? _a : TONE_PALETTE.neutral;
111
+ return (_b = theme.tonePalette[toneKey]) != null ? _b : TONE_PALETTE.neutral;
112
+ }
113
+
114
+ // src/infer.ts
115
+ function labelFromKey(key) {
116
+ const spaced = key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/_/g, " ").toLowerCase();
117
+ return spaced.split(" ").filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
118
+ }
119
+ var defaultClassifySignal = (text) => {
120
+ const t = text.toLowerCase();
121
+ const flagged = t.includes("unresolved") || t.includes("unknown") || t.includes("missing");
122
+ return flagged ? "warn" : "info";
123
+ };
124
+ var ENUM_LIKE = /^[A-Z0-9]+(_[A-Z0-9]+)*$/;
125
+ function inferRule(key, value) {
126
+ const label = labelFromKey(key);
127
+ const as = (() => {
128
+ if (value === null || value === void 0 || value === "") return "empty";
129
+ if (typeof value === "boolean") return "flag";
130
+ if (typeof value === "number") return "stat";
131
+ if (typeof value === "string") {
132
+ if (ENUM_LIKE.test(value)) return "pill";
133
+ if (value.length > 70 || /[.!?]\s/.test(value)) return "lead";
134
+ if (!value.includes(" ") && value.length > 12) return "mono";
135
+ return "text";
136
+ }
137
+ if (Array.isArray(value)) {
138
+ if (value.length === 0) return "empty";
139
+ if (value.every((v) => typeof v === "string")) {
140
+ if (value.every((v) => /\?\s*$/.test(v))) return "qa";
141
+ if (value.some((v) => v.split(" ").length > 6)) return "bullets";
142
+ return "tags";
143
+ }
144
+ return "json";
145
+ }
146
+ return "json";
147
+ })();
148
+ return { label, as };
149
+ }
150
+
151
+ // src/resolve.ts
152
+ function resolveTone(value, toneMap) {
153
+ var _a;
154
+ return (_a = toneMap == null ? void 0 : toneMap[value]) != null ? _a : hashTone(value);
155
+ }
156
+ function resolveField(key, value, rule, options = {}) {
157
+ var _a, _b, _c;
158
+ const label = (_a = rule.label) != null ? _a : labelFromKey(key);
159
+ const classifySignal = (_b = options.classifySignal) != null ? _b : defaultClassifySignal;
160
+ const base2 = {
161
+ key,
162
+ label,
163
+ kind: rule.as,
164
+ isLeftover: (_c = options.isLeftover) != null ? _c : false
165
+ };
166
+ switch (rule.as) {
167
+ case "lead":
168
+ return { ...base2, text: String(value != null ? value : "") };
169
+ case "bullets":
170
+ return { ...base2, items: (value != null ? value : []).map((t) => ({ text: t })) };
171
+ case "signals":
172
+ return {
173
+ ...base2,
174
+ items: (value != null ? value : []).map((t) => {
175
+ const s = classifySignal(t);
176
+ return { text: t, warn: s === "warn", info: s === "info" };
177
+ })
178
+ };
179
+ case "qa":
180
+ return { ...base2, items: (value != null ? value : []).map((t) => ({ text: t })) };
181
+ case "pill": {
182
+ const raw = String(value != null ? value : "");
183
+ return { ...base2, pillText: labelFromKey(raw.toLowerCase()), toneKey: resolveTone(raw, options.toneMap) };
184
+ }
185
+ case "mono":
186
+ return { ...base2, value: String(value != null ? value : "") };
187
+ case "text":
188
+ return { ...base2, value: String(value != null ? value : "") };
189
+ case "flag":
190
+ return { ...base2, flagOn: !!value, flagText: value ? "Yes" : "No" };
191
+ case "stat":
192
+ return { ...base2, value: String(value != null ? value : "") };
193
+ case "tags":
194
+ return { ...base2, items: (value != null ? value : []).map((t) => ({ text: t })) };
195
+ case "empty":
196
+ return base2;
197
+ case "json":
198
+ default:
199
+ return { ...base2, kind: "json", value: JSON.stringify(value, null, 2) };
200
+ }
201
+ }
202
+
203
+ // src/icons.tsx
204
+ var import_jsx_runtime2 = require("react/jsx-runtime");
205
+ var base = (size, color, style) => ({
206
+ width: size,
207
+ height: size,
208
+ viewBox: "0 0 24 24",
209
+ fill: "none",
210
+ stroke: color,
211
+ strokeWidth: 1.8,
212
+ strokeLinecap: "round",
213
+ strokeLinejoin: "round",
214
+ style
215
+ });
216
+ function CheckIcon({ size = 15, color = "currentColor", style }) {
217
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { ...base(size, color, style), children: [
218
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
219
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M8 12.3l2.6 2.6L16 9.3" })
220
+ ] });
221
+ }
222
+ function WarningIcon({ size = 15, color = "#E8A33D", style }) {
223
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { ...base(size, color, style), children: [
224
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 3 2 21h20L12 3z" }),
225
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 9.5v5" }),
226
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "17.2", r: "0.9", fill: color, stroke: "none" })
227
+ ] });
228
+ }
229
+ function InfoIcon({ size = 15, color = "#7C8894", style }) {
230
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { ...base(size, color, style), children: [
231
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
232
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", y1: "10.5", x2: "12", y2: "16.2" }),
233
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "7.6", r: "0.9", fill: color, stroke: "none" })
234
+ ] });
235
+ }
236
+ function QuestionIcon({ size = 15, color = "currentColor", style }) {
237
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { ...base(size, color, style), children: [
238
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
239
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M9.5 9.3a2.5 2.5 0 1 1 3.5 2.3c-.9.5-1 1-1 1.9" }),
240
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "17", r: "0.9", fill: color, stroke: "none" })
241
+ ] });
242
+ }
243
+ function ChevronDownIcon({ size = 14, color = "currentColor", style }) {
244
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { ...base(size, color, style), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M6 9l6 6 6-6" }) });
245
+ }
246
+
247
+ // src/components/FieldRenderer.tsx
248
+ var import_jsx_runtime3 = require("react/jsx-runtime");
249
+ function assertNever(x) {
250
+ throw new Error("Unhandled FieldKind: " + JSON.stringify(x));
251
+ }
252
+ function FieldRenderer({ field, variant = "compact", showLabel = true }) {
253
+ var _a, _b, _c, _d, _e;
254
+ const theme = useFieldKitTheme();
255
+ const isContent = variant === "content";
256
+ const labelNode = showLabel ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
257
+ "span",
258
+ {
259
+ style: {
260
+ fontFamily: theme.fonts.heading,
261
+ fontSize: isContent ? 11.5 : 10.5,
262
+ fontWeight: 600,
263
+ letterSpacing: "0.08em",
264
+ textTransform: "uppercase",
265
+ color: theme.colors.textMuted
266
+ },
267
+ children: field.label
268
+ }
269
+ ) : null;
270
+ let body;
271
+ switch (field.kind) {
272
+ case "lead":
273
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
274
+ "p",
275
+ {
276
+ style: {
277
+ margin: 0,
278
+ fontSize: isContent ? 15 : 13,
279
+ lineHeight: 1.6,
280
+ color: isContent ? theme.colors.textSecondary : theme.colors.textMuted
281
+ },
282
+ children: field.text
283
+ }
284
+ );
285
+ break;
286
+ case "bullets":
287
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: isContent ? 10 : 6 }, children: (_a = field.items) == null ? void 0 : _a.map(
288
+ (item, i) => isContent ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: 10, alignItems: "flex-start" }, children: [
289
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckIcon, { size: 15, color: theme.colors.accent, style: { flexShrink: 0, marginTop: 3 } }),
290
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontSize: 14, lineHeight: 1.55, color: theme.colors.textSecondary }, children: item.text })
291
+ ] }, i) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: 8, alignItems: "flex-start" }, children: [
292
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: theme.colors.textMuted, fontSize: 13 }, children: "\u2013" }),
293
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontSize: 13, lineHeight: 1.5, color: theme.colors.textMuted }, children: item.text })
294
+ ] }, i)
295
+ ) });
296
+ break;
297
+ case "signals":
298
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: isContent ? 8 : 6 }, children: (_b = field.items) == null ? void 0 : _b.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
299
+ "div",
300
+ {
301
+ style: {
302
+ display: "flex",
303
+ gap: 10,
304
+ alignItems: "flex-start",
305
+ background: theme.colors.surfaceMuted,
306
+ border: `1px solid ${theme.colors.border}`,
307
+ borderRadius: isContent ? 8 : 6,
308
+ padding: isContent ? "12px 14px" : "8px 10px"
309
+ },
310
+ children: [
311
+ item.warn && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WarningIcon, { size: isContent ? 15 : 13, style: { flexShrink: 0, marginTop: 2 } }),
312
+ item.info && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InfoIcon, { size: isContent ? 15 : 13, style: { flexShrink: 0, marginTop: 2 } }),
313
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
314
+ "span",
315
+ {
316
+ style: {
317
+ fontSize: isContent ? 13.5 : 13,
318
+ lineHeight: 1.55,
319
+ color: isContent ? theme.colors.textSecondary : theme.colors.textMuted
320
+ },
321
+ children: item.text
322
+ }
323
+ )
324
+ ]
325
+ },
326
+ i
327
+ )) });
328
+ break;
329
+ case "qa":
330
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
331
+ "div",
332
+ {
333
+ style: isContent ? {
334
+ display: "flex",
335
+ flexDirection: "column",
336
+ gap: 12,
337
+ background: `${theme.colors.accent}12`,
338
+ border: `1px solid ${theme.colors.accent}33`,
339
+ borderRadius: 10,
340
+ padding: "14px 16px"
341
+ } : { display: "flex", flexDirection: "column", gap: 6 },
342
+ children: (_c = field.items) == null ? void 0 : _c.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: isContent ? 10 : 8, alignItems: "flex-start" }, children: [
343
+ isContent ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(QuestionIcon, { size: 15, color: theme.colors.accent, style: { flexShrink: 0, marginTop: 2 } }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: theme.colors.accent, fontSize: 13, fontWeight: 600 }, children: "?" }),
344
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
345
+ "span",
346
+ {
347
+ style: {
348
+ fontSize: isContent ? 14 : 13,
349
+ lineHeight: 1.55,
350
+ color: isContent ? theme.colors.textSecondary : theme.colors.textMuted
351
+ },
352
+ children: item.text
353
+ }
354
+ )
355
+ ] }, i))
356
+ }
357
+ );
358
+ break;
359
+ case "pill": {
360
+ const hex = toneHex(theme, field.toneKey);
361
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
362
+ "span",
363
+ {
364
+ style: {
365
+ alignSelf: "flex-start",
366
+ padding: "3px 9px",
367
+ borderRadius: theme.radii.sm,
368
+ fontSize: 11,
369
+ fontWeight: 600,
370
+ fontFamily: theme.fonts.heading,
371
+ textTransform: "uppercase",
372
+ background: `${hex}24`,
373
+ color: hex,
374
+ border: `1px solid ${hex}55`
375
+ },
376
+ children: field.pillText
377
+ }
378
+ );
379
+ break;
380
+ }
381
+ case "mono":
382
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: theme.fonts.mono, fontSize: isContent ? 13 : 12.5, color: theme.colors.textMuted }, children: field.value });
383
+ break;
384
+ case "text":
385
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
386
+ "span",
387
+ {
388
+ style: {
389
+ fontSize: isContent ? 14 : 13,
390
+ lineHeight: 1.55,
391
+ color: isContent ? theme.colors.textSecondary : theme.colors.textMuted
392
+ },
393
+ children: field.value
394
+ }
395
+ );
396
+ break;
397
+ case "flag": {
398
+ const hex = field.flagOn ? (_d = theme.tonePalette.green) != null ? _d : "#59B87B" : theme.colors.textMuted;
399
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
400
+ "span",
401
+ {
402
+ style: {
403
+ alignSelf: "flex-start",
404
+ padding: "3px 9px",
405
+ borderRadius: theme.radii.sm,
406
+ fontSize: 11,
407
+ fontWeight: 600,
408
+ fontFamily: theme.fonts.heading,
409
+ textTransform: "uppercase",
410
+ background: `${hex}24`,
411
+ color: hex,
412
+ border: `1px solid ${hex}55`
413
+ },
414
+ children: field.flagText
415
+ }
416
+ );
417
+ break;
418
+ }
419
+ case "stat":
420
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: theme.fonts.mono, fontSize: isContent ? 16 : 15, color: theme.colors.textSecondary }, children: field.value });
421
+ break;
422
+ case "tags":
423
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: (_e = field.items) == null ? void 0 : _e.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
424
+ "span",
425
+ {
426
+ style: {
427
+ background: theme.colors.surfaceMuted,
428
+ color: theme.colors.textMuted,
429
+ border: `1px solid ${theme.colors.border}`,
430
+ padding: "3px 9px",
431
+ borderRadius: theme.radii.sm,
432
+ fontSize: 11.5
433
+ },
434
+ children: item.text
435
+ },
436
+ i
437
+ )) });
438
+ break;
439
+ case "empty":
440
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontSize: 13, color: theme.colors.textMuted, opacity: 0.6 }, children: "\u2014 not provided \u2014" });
441
+ break;
442
+ case "json":
443
+ body = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
444
+ "pre",
445
+ {
446
+ style: {
447
+ margin: 0,
448
+ fontFamily: theme.fonts.mono,
449
+ fontSize: 11.5,
450
+ color: theme.colors.textMuted,
451
+ whiteSpace: "pre-wrap",
452
+ background: theme.colors.background,
453
+ border: `1px solid ${theme.colors.border}`,
454
+ borderRadius: theme.radii.sm,
455
+ padding: "10px 12px"
456
+ },
457
+ children: field.value
458
+ }
459
+ );
460
+ break;
461
+ default:
462
+ return assertNever(field.kind);
463
+ }
464
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: isContent ? 12 : 6 }, children: [
465
+ labelNode,
466
+ body
467
+ ] });
468
+ }
469
+
470
+ // src/components/RecordView.tsx
471
+ var React2 = __toESM(require("react"), 1);
472
+ var import_jsx_runtime4 = require("react/jsx-runtime");
473
+ function RecordView({
474
+ record,
475
+ fieldRules,
476
+ contentKeys,
477
+ diagnosticKeys,
478
+ identityKeys = [],
479
+ header,
480
+ banner,
481
+ classifySignal,
482
+ toneMap,
483
+ defaultDiagnosticsOpen = false,
484
+ diagnosticsLabel = "Diagnostics",
485
+ diagnosticsHint = "Every other field this record reports, curated and unmapped alike",
486
+ style
487
+ }) {
488
+ var _a, _b, _c;
489
+ const theme = useFieldKitTheme();
490
+ const [open, setOpen] = React2.useState(defaultDiagnosticsOpen);
491
+ const contentFields = React2.useMemo(
492
+ () => contentKeys.map((key) => resolveField(key, record[key], fieldRules[key], { classifySignal, toneMap })),
493
+ [record, fieldRules, contentKeys, classifySignal, toneMap]
494
+ );
495
+ const diagnosticFields = React2.useMemo(
496
+ () => diagnosticKeys.map((key) => resolveField(key, record[key], fieldRules[key], { classifySignal, toneMap })),
497
+ [record, fieldRules, diagnosticKeys, classifySignal, toneMap]
498
+ );
499
+ const leftoverFields = React2.useMemo(() => {
500
+ const known = /* @__PURE__ */ new Set([...Object.keys(fieldRules), ...identityKeys]);
501
+ return Object.keys(record).filter((k) => !known.has(k)).map((k) => resolveField(k, record[k], inferRule(k, record[k]), { isLeftover: true, classifySignal, toneMap }));
502
+ }, [record, fieldRules, identityKeys, classifySignal, toneMap]);
503
+ const bannerContent = banner ? banner(record) : null;
504
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
505
+ "div",
506
+ {
507
+ style: {
508
+ background: theme.colors.surface,
509
+ border: `1px solid ${theme.colors.border}`,
510
+ borderRadius: theme.radii.lg,
511
+ padding: "36px 40px",
512
+ display: "flex",
513
+ flexDirection: "column",
514
+ gap: 26,
515
+ fontFamily: theme.fonts.body,
516
+ color: theme.colors.textPrimary,
517
+ ...style
518
+ },
519
+ children: [
520
+ header == null ? void 0 : header(record),
521
+ bannerContent && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
522
+ "div",
523
+ {
524
+ style: {
525
+ background: `${(_a = theme.tonePalette.rose) != null ? _a : "#E2564F"}14`,
526
+ border: `1px solid ${(_b = theme.tonePalette.rose) != null ? _b : "#E2564F"}48`,
527
+ borderRadius: 10,
528
+ padding: "16px 18px",
529
+ display: "flex",
530
+ gap: 12,
531
+ alignItems: "flex-start"
532
+ },
533
+ children: [
534
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WarningIcon, { size: 19, color: (_c = theme.tonePalette.rose) != null ? _c : "#E2564F", style: { flexShrink: 0, marginTop: 2 } }),
535
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 7 }, children: [
536
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontFamily: theme.fonts.heading, fontSize: 14, fontWeight: 600, color: theme.colors.textPrimary }, children: bannerContent.title }),
537
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: 13.5, lineHeight: 1.55, color: theme.colors.textSecondary }, children: bannerContent.body }),
538
+ bannerContent.tags && bannerContent.tags.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { display: "flex", gap: 6, marginTop: 2, flexWrap: "wrap" }, children: bannerContent.tags.map((t, i) => {
539
+ var _a2, _b2, _c2;
540
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
541
+ "span",
542
+ {
543
+ style: {
544
+ background: `${(_a2 = theme.tonePalette.rose) != null ? _a2 : "#E2564F"}24`,
545
+ color: (_b2 = theme.tonePalette.rose) != null ? _b2 : "#E2564F",
546
+ border: `1px solid ${(_c2 = theme.tonePalette.rose) != null ? _c2 : "#E2564F"}55`,
547
+ padding: "3px 8px",
548
+ borderRadius: 5,
549
+ fontFamily: theme.fonts.heading,
550
+ fontSize: 10.5,
551
+ fontWeight: 600,
552
+ letterSpacing: "0.04em",
553
+ textTransform: "uppercase"
554
+ },
555
+ children: t
556
+ },
557
+ i
558
+ );
559
+ }) })
560
+ ] })
561
+ ]
562
+ }
563
+ ),
564
+ contentFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldRenderer, { field, variant: "content" }, field.key)),
565
+ (diagnosticFields.length > 0 || leftoverFields.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
566
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { height: 1, background: theme.colors.border } }),
567
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
568
+ "button",
569
+ {
570
+ onClick: () => setOpen((v) => !v),
571
+ style: {
572
+ all: "unset",
573
+ cursor: "pointer",
574
+ display: "flex",
575
+ alignItems: "center",
576
+ justifyContent: "space-between",
577
+ width: "100%",
578
+ boxSizing: "border-box"
579
+ },
580
+ children: [
581
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 2 }, children: [
582
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontFamily: theme.fonts.heading, fontSize: 12.5, fontWeight: 600, letterSpacing: "0.04em", color: theme.colors.textSecondary }, children: diagnosticsLabel }),
583
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: 11.5, color: theme.colors.textMuted }, children: diagnosticsHint })
584
+ ] }),
585
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
586
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: 12, color: theme.colors.textMuted }, children: open ? "Hide" : "Show" }),
587
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
588
+ ChevronDownIcon,
589
+ {
590
+ size: 14,
591
+ color: theme.colors.textMuted,
592
+ style: { transform: open ? "rotate(180deg)" : "rotate(0deg)", transition: "transform 120ms ease" }
593
+ }
594
+ )
595
+ ] })
596
+ ]
597
+ }
598
+ ),
599
+ open && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
600
+ "div",
601
+ {
602
+ style: {
603
+ background: theme.colors.surfaceMuted,
604
+ border: `1px solid ${theme.colors.border}`,
605
+ borderRadius: theme.radii.md,
606
+ padding: "20px 22px",
607
+ display: "flex",
608
+ flexDirection: "column",
609
+ gap: 18
610
+ },
611
+ children: [
612
+ diagnosticFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 14 }, children: diagnosticFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldRenderer, { field, variant: "compact" }, field.key)) }),
613
+ leftoverFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
614
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { height: 1, borderTop: `1px dashed ${theme.colors.border}` } }),
615
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 3 }, children: [
616
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
617
+ "span",
618
+ {
619
+ style: {
620
+ fontFamily: theme.fonts.heading,
621
+ fontSize: 10.5,
622
+ fontWeight: 600,
623
+ letterSpacing: "0.08em",
624
+ textTransform: "uppercase",
625
+ color: theme.colors.textMuted
626
+ },
627
+ children: "Additional Fields"
628
+ }
629
+ ),
630
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: 11, color: theme.colors.textMuted, opacity: 0.7 }, children: "Not in fieldRules yet \u2014 rendered generically from each value's shape" })
631
+ ] }),
632
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 14 }, children: leftoverFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldRenderer, { field, variant: "compact" }, field.key)) })
633
+ ] })
634
+ ]
635
+ }
636
+ )
637
+ ] })
638
+ ]
639
+ }
640
+ );
641
+ }
642
+ // Annotate the CommonJS export names for ESM import in node:
643
+ 0 && (module.exports = {
644
+ CheckIcon,
645
+ ChevronDownIcon,
646
+ FieldKitProvider,
647
+ FieldRenderer,
648
+ InfoIcon,
649
+ QuestionIcon,
650
+ RecordView,
651
+ TONE_PALETTE,
652
+ WarningIcon,
653
+ defaultClassifySignal,
654
+ defaultTheme,
655
+ hashTone,
656
+ inferRule,
657
+ labelFromKey,
658
+ resolveField,
659
+ toneHex,
660
+ useFieldKitTheme
661
+ });
662
+ //# sourceMappingURL=index.cjs.map