@ai-matrx/records-ui 0.115.108 → 0.116.1
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/CHANGELOG.md +28 -1
- package/dist/SaveToTable-3VDK4U5M.js +20 -0
- package/dist/{chunk-W3EU7H4V.js → chunk-42VA6SWA.js} +93 -512
- package/dist/chunk-42VA6SWA.js.map +1 -0
- package/dist/chunk-B5S5F5NH.js +445 -0
- package/dist/chunk-B5S5F5NH.js.map +1 -0
- package/dist/chunk-IUUZVQZD.js +95 -0
- package/dist/chunk-IUUZVQZD.js.map +1 -0
- package/dist/{chunk-6NSGVKYL.js → chunk-NJYJEAQC.js} +1 -91
- package/dist/chunk-NJYJEAQC.js.map +1 -0
- package/dist/{chunk-VGNQBI2J.js → chunk-QRZ4RW2T.js} +56 -31
- package/dist/chunk-QRZ4RW2T.js.map +1 -0
- package/dist/chunk-SPPATZSR.js +288 -0
- package/dist/chunk-SPPATZSR.js.map +1 -0
- package/dist/{chunk-W5SOKJ5P.js → chunk-TNIC2SGW.js} +5 -3
- package/dist/{chunk-W5SOKJ5P.js.map → chunk-TNIC2SGW.js.map} +1 -1
- package/dist/{chunk-4U2JCICC.js → chunk-VCAOXQ5K.js} +2 -283
- package/dist/chunk-VCAOXQ5K.js.map +1 -0
- package/dist/chunk-Z6WTP467.js +245 -0
- package/dist/chunk-Z6WTP467.js.map +1 -0
- package/dist/first-page.cjs.map +1 -1
- package/dist/first-page.js.map +1 -1
- package/dist/helpers.cjs +813 -8
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +478 -4
- package/dist/helpers.d.ts +478 -4
- package/dist/helpers.js +755 -10
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +4610 -3878
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +357 -175
- package/dist/index.d.ts +357 -175
- package/dist/index.js +5891 -5405
- package/dist/index.js.map +1 -1
- package/dist/object-actions.js +3 -2
- package/dist/pickers.cjs +111 -72
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +6 -3
- package/dist/skeleton.cjs +261 -0
- package/dist/skeleton.cjs.map +1 -0
- package/dist/skeleton.d.cts +50 -0
- package/dist/skeleton.d.ts +50 -0
- package/dist/skeleton.js +26 -0
- package/dist/skeleton.js.map +1 -0
- package/package.json +16 -5
- package/dist/SaveToTable-V3R7QVKV.js +0 -18
- package/dist/chunk-4U2JCICC.js.map +0 -1
- package/dist/chunk-6NSGVKYL.js.map +0 -1
- package/dist/chunk-VGNQBI2J.js.map +0 -1
- package/dist/chunk-W3EU7H4V.js.map +0 -1
- /package/dist/{SaveToTable-V3R7QVKV.js.map → SaveToTable-3VDK4U5M.js.map} +0 -0
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
NOT_ANSWERED_YET,
|
|
4
|
-
fieldTypeChoice,
|
|
5
|
-
isSystemFieldKind,
|
|
6
4
|
whatYouMayDo,
|
|
7
5
|
whatYouMayDoWithTable
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IUUZVQZD.js";
|
|
9
7
|
import {
|
|
10
8
|
__reExport
|
|
11
9
|
} from "./chunk-HKYEHBQT.js";
|
|
@@ -371,172 +369,6 @@ function refusalIsMissingInput(error) {
|
|
|
371
369
|
return error.sqlstate === "22023" || error.code === "invalid_argument";
|
|
372
370
|
}
|
|
373
371
|
|
|
374
|
-
// src/docs.ts
|
|
375
|
-
function fieldToken(fieldId) {
|
|
376
|
-
return `{{field:${fieldId}}}`;
|
|
377
|
-
}
|
|
378
|
-
function bodyFromKeys(body, fields) {
|
|
379
|
-
const byKey = new Map(fields.map((f) => [f.key, f.id]));
|
|
380
|
-
return body.replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g, (whole, key) => {
|
|
381
|
-
const id = byKey.get(key);
|
|
382
|
-
return id ? fieldToken(id) : whole;
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
function bodyForReading(body, fields) {
|
|
386
|
-
const byId = new Map(fields.map((f) => [f.id, f.label || f.key]));
|
|
387
|
-
return body.replace(/\{\{\s*field:([0-9a-fA-F-]{36})\s*\}\}/g, (whole, id) => {
|
|
388
|
-
const label = byId.get(id);
|
|
389
|
-
return label ? `{{${label}}}` : whole;
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
function isSignatureField(field) {
|
|
393
|
-
return field.type === "text" && (field.format ?? "").toLowerCase() === "signature";
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// src/choiceLooks.ts
|
|
397
|
-
import { newerKindOf } from "@ai-matrx/records/field-kinds";
|
|
398
|
-
import { CHOICE_CHIP_CLASS, NEUTRAL_CHIP_CLASS, STYLE_COLORS } from "@ai-matrx/design-system/data-table/table-style";
|
|
399
|
-
function displayFormatOf(field) {
|
|
400
|
-
const raw = field.display_format;
|
|
401
|
-
if (!raw || typeof raw !== "object") return null;
|
|
402
|
-
const id = raw.id;
|
|
403
|
-
if (typeof id !== "string" || id === "") return null;
|
|
404
|
-
const options = raw.options;
|
|
405
|
-
return { id, options: options && typeof options === "object" ? options : {} };
|
|
406
|
-
}
|
|
407
|
-
function isStyleColor(v) {
|
|
408
|
-
return typeof v === "string" && STYLE_COLORS.includes(v);
|
|
409
|
-
}
|
|
410
|
-
function choiceLooksOf(field) {
|
|
411
|
-
const display = displayFormatOf(field);
|
|
412
|
-
const choices = display?.options["choices"];
|
|
413
|
-
if (!Array.isArray(choices)) return [];
|
|
414
|
-
const out = [];
|
|
415
|
-
for (const c of choices) {
|
|
416
|
-
if (!c || typeof c !== "object") continue;
|
|
417
|
-
const value = c.value;
|
|
418
|
-
if (typeof value !== "string" || value.trim() === "") continue;
|
|
419
|
-
const color = c.color;
|
|
420
|
-
const label = c.label;
|
|
421
|
-
out.push({
|
|
422
|
-
value: value.trim(),
|
|
423
|
-
...typeof label === "string" && label.trim() !== "" ? { label: label.trim() } : {},
|
|
424
|
-
...isStyleColor(color) ? { color } : {}
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
return out;
|
|
428
|
-
}
|
|
429
|
-
function choiceWord(value) {
|
|
430
|
-
return String(value ?? "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
431
|
-
}
|
|
432
|
-
var STATUS_GROUP_COLOR = { todo: "gray", in_progress: "blue", done: "green" };
|
|
433
|
-
function statusGroupColor(field, value) {
|
|
434
|
-
if (newerKindOf(field) !== "status" || value === null || value === void 0 || value === "") return void 0;
|
|
435
|
-
const word = choiceWord(value);
|
|
436
|
-
if (word === "") return void 0;
|
|
437
|
-
const groups = (field.config ?? {})["status_groups"];
|
|
438
|
-
if (groups && typeof groups === "object") {
|
|
439
|
-
for (const [key, group] of Object.entries(groups)) {
|
|
440
|
-
if (choiceWord(key) !== word) continue;
|
|
441
|
-
return group === "in_progress" ? STATUS_GROUP_COLOR.in_progress : group === "done" ? STATUS_GROUP_COLOR.done : STATUS_GROUP_COLOR.todo;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
return STATUS_GROUP_COLOR.todo;
|
|
445
|
-
}
|
|
446
|
-
function storedChoiceColor(field, value) {
|
|
447
|
-
if (value === null || value === void 0 || value === "") return void 0;
|
|
448
|
-
const word = choiceWord(value);
|
|
449
|
-
if (word === "") return void 0;
|
|
450
|
-
for (const look of choiceLooksOf(field)) {
|
|
451
|
-
if (!look.color) continue;
|
|
452
|
-
if (choiceWord(look.value) === word || look.label && choiceWord(look.label) === word) return look.color;
|
|
453
|
-
}
|
|
454
|
-
return statusGroupColor(field, value);
|
|
455
|
-
}
|
|
456
|
-
function storedChoiceColorLookup(fields, fallback) {
|
|
457
|
-
const byKey = new Map(fields.map((f) => [f.key, f]));
|
|
458
|
-
return (fieldKey, value) => {
|
|
459
|
-
const field = byKey.get(fieldKey);
|
|
460
|
-
return (field ? storedChoiceColor(field, value) : void 0) ?? fallback(fieldKey, value);
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
var NEW_CHOICE_PALETTE = ["blue", "green", "amber", "red", "violet", "teal", "slate"];
|
|
464
|
-
function nextChoiceColor(worn) {
|
|
465
|
-
const taken = new Set(worn.filter((c) => Boolean(c)));
|
|
466
|
-
const free = NEW_CHOICE_PALETTE.find((c) => !taken.has(c));
|
|
467
|
-
return free ?? NEW_CHOICE_PALETTE[worn.length % NEW_CHOICE_PALETTE.length];
|
|
468
|
-
}
|
|
469
|
-
function choiceChipLookOf(field, ...words) {
|
|
470
|
-
for (const word of words) {
|
|
471
|
-
const color = storedChoiceColor(field, word);
|
|
472
|
-
if (color) return { className: CHOICE_CHIP_CLASS[color], color };
|
|
473
|
-
}
|
|
474
|
-
return { className: NEUTRAL_CHIP_CLASS, color: null };
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// src/parity.ts
|
|
478
|
-
import {
|
|
479
|
-
KERNEL_TABLES,
|
|
480
|
-
PARITY_FIELD_TYPES,
|
|
481
|
-
fieldKindFor,
|
|
482
|
-
newerKindOf as newerKindOf2,
|
|
483
|
-
isButtonField
|
|
484
|
-
} from "@ai-matrx/records/field-kinds";
|
|
485
|
-
import { humanizeIdentifier as humanizeIdentifier2 } from "@ai-matrx/kit/text-case";
|
|
486
|
-
var kernelId = (name) => KERNEL_TABLES.find((t) => t.name === name)?.id ?? "";
|
|
487
|
-
var KERNEL_FILE_TABLE = kernelId("File");
|
|
488
|
-
var KERNEL_PERSON_TABLE = kernelId("Person");
|
|
489
|
-
var PARITY_LABEL = {
|
|
490
|
-
attachment: "Attachment",
|
|
491
|
-
checkbox: "Yes / no",
|
|
492
|
-
currency: "Currency",
|
|
493
|
-
datetime: "Date",
|
|
494
|
-
email: "Email",
|
|
495
|
-
formula: "Formula",
|
|
496
|
-
lookup: "Lookup",
|
|
497
|
-
member: "Person",
|
|
498
|
-
multi_select: "Multi-select",
|
|
499
|
-
percent: "Percent",
|
|
500
|
-
phone: "Phone",
|
|
501
|
-
rollup: "Rollup",
|
|
502
|
-
select: "Select",
|
|
503
|
-
url: "Link"
|
|
504
|
-
};
|
|
505
|
-
var PARITY_MADE_OF = Object.fromEntries(
|
|
506
|
-
PARITY_FIELD_TYPES.map((p) => [p.parity_type, p.made_of])
|
|
507
|
-
);
|
|
508
|
-
var KERNEL = { file: KERNEL_FILE_TABLE, person: KERNEL_PERSON_TABLE };
|
|
509
|
-
function editorKindFor(field) {
|
|
510
|
-
return fieldKindFor(field, KERNEL);
|
|
511
|
-
}
|
|
512
|
-
function pickableTypeOf(field) {
|
|
513
|
-
if (isSignatureField(field)) return "signature";
|
|
514
|
-
if (isButtonField(field)) return "button";
|
|
515
|
-
const newer = newerKindOf2(field);
|
|
516
|
-
if (newer) return newer;
|
|
517
|
-
const look = displayFormatOf(field)?.id;
|
|
518
|
-
if (look === "rating" && field.type === "range") return "rating";
|
|
519
|
-
if (look === "time" && field.type === "text") return "time";
|
|
520
|
-
const system = field.config?.["system"];
|
|
521
|
-
if (field.type === "formula" && typeof system === "string" && isSystemFieldKind(system)) return system;
|
|
522
|
-
const kind = editorKindFor(field);
|
|
523
|
-
return fieldTypeChoice(kind) ? kind : void 0;
|
|
524
|
-
}
|
|
525
|
-
function fieldTypeLabel(field) {
|
|
526
|
-
const kind = pickableTypeOf(field) ?? editorKindFor(field);
|
|
527
|
-
const known = fieldTypeChoice(kind)?.label;
|
|
528
|
-
if (known) return field.multi && kind !== "multi_select" ? `${known} (many)` : known;
|
|
529
|
-
const plain = {
|
|
530
|
-
// `boolean` is the BEHAVIOUR word; `checkbox` is the type a person picks. Both are
|
|
531
|
-
// written the way a person writes them, never as a raw token.
|
|
532
|
-
boolean: "Yes / no",
|
|
533
|
-
date: "Date",
|
|
534
|
-
json: "Structured data",
|
|
535
|
-
relation: "Link to a record"
|
|
536
|
-
};
|
|
537
|
-
return plain[kind] ?? humanizeIdentifier2(kind);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
372
|
// src/Refusal.tsx
|
|
541
373
|
import { archivedOrganizationId } from "@ai-matrx/records/core";
|
|
542
374
|
import { Alert as Alert2, AlertDescription as AlertDescription2, AlertTitle as AlertTitle2, ErrorBox, cn as cn2 } from "@ai-matrx/design-system";
|
|
@@ -1097,90 +929,6 @@ function ShowListsToggle({
|
|
|
1097
929
|
] });
|
|
1098
930
|
}
|
|
1099
931
|
|
|
1100
|
-
// src/dates.ts
|
|
1101
|
-
import { formatFieldValue } from "@ai-matrx/design-system/field-formats";
|
|
1102
|
-
var BARE_CALENDAR_DATE = /^(\d{4})-(\d{2})-(\d{2})(?:[T ]00:00(?::00(?:\.0+)?)?)?$/;
|
|
1103
|
-
function systemStampOf(field) {
|
|
1104
|
-
if (field.type !== "formula") return null;
|
|
1105
|
-
const system = String((field.config ?? {})["system"] ?? "");
|
|
1106
|
-
return system === "autonumber" || system === "created_time" || system === "modified_time" ? system : null;
|
|
1107
|
-
}
|
|
1108
|
-
function carriesTimeOfDay(field, value) {
|
|
1109
|
-
if (value !== void 0 && value !== null && value !== "") return hasTimePart(value);
|
|
1110
|
-
const stamp = systemStampOf(field);
|
|
1111
|
-
if (stamp === "created_time" || stamp === "modified_time") return true;
|
|
1112
|
-
return (field.format ?? "").toLowerCase() === "datetime";
|
|
1113
|
-
}
|
|
1114
|
-
function timeOfDayWords(value) {
|
|
1115
|
-
if (!hasTimePart(value)) return null;
|
|
1116
|
-
const at = value instanceof Date ? value : new Date(value);
|
|
1117
|
-
return Number.isNaN(at.getTime()) ? null : at.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
|
|
1118
|
-
}
|
|
1119
|
-
function hasTimePart(value) {
|
|
1120
|
-
if (value instanceof Date || typeof value === "number") return true;
|
|
1121
|
-
if (typeof value !== "string") return false;
|
|
1122
|
-
const trimmed = value.trim();
|
|
1123
|
-
if (BARE_CALENDAR_DATE.test(trimmed)) return false;
|
|
1124
|
-
return /^\d{4}-\d{2}-\d{2}[T ]\d/.test(trimmed);
|
|
1125
|
-
}
|
|
1126
|
-
function isDateField(field) {
|
|
1127
|
-
const stamp = systemStampOf(field);
|
|
1128
|
-
if (stamp === "created_time" || stamp === "modified_time") return true;
|
|
1129
|
-
if (field.type !== "range") return false;
|
|
1130
|
-
const kind = String((field.config ?? {})["kind"] ?? "");
|
|
1131
|
-
return kind === "date" || kind === "datetime";
|
|
1132
|
-
}
|
|
1133
|
-
function dateFormatFor(field, value) {
|
|
1134
|
-
if (!isDateField(field)) return void 0;
|
|
1135
|
-
return carriesTimeOfDay(field, value) ? { id: "datetime" } : { id: "date" };
|
|
1136
|
-
}
|
|
1137
|
-
function dateText(field, value) {
|
|
1138
|
-
const format = dateFormatFor(field, value) ?? (isDateLike(value) ? { id: hasTimePart(value) ? "datetime" : "date" } : void 0);
|
|
1139
|
-
if (!format) return null;
|
|
1140
|
-
const result = formatFieldValue(value, format);
|
|
1141
|
-
return result.ok && !result.empty ? result.text : null;
|
|
1142
|
-
}
|
|
1143
|
-
function isDateLike(value) {
|
|
1144
|
-
return typeof value === "string" && /^\d{4}-\d{2}-\d{2}/.test(value.trim());
|
|
1145
|
-
}
|
|
1146
|
-
function pad(n) {
|
|
1147
|
-
return n < 10 ? `0${n}` : String(n);
|
|
1148
|
-
}
|
|
1149
|
-
function calendarDayOf(value) {
|
|
1150
|
-
if (typeof value === "string") {
|
|
1151
|
-
const trimmed = value.trim();
|
|
1152
|
-
const bare = BARE_CALENDAR_DATE.exec(trimmed);
|
|
1153
|
-
if (bare) return `${bare[1]}-${bare[2]}-${bare[3]}`;
|
|
1154
|
-
if (trimmed === "") return null;
|
|
1155
|
-
} else if (typeof value !== "number" && !(value instanceof Date)) {
|
|
1156
|
-
return null;
|
|
1157
|
-
}
|
|
1158
|
-
const at = value instanceof Date ? value : new Date(value);
|
|
1159
|
-
if (Number.isNaN(at.getTime())) return null;
|
|
1160
|
-
return `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())}`;
|
|
1161
|
-
}
|
|
1162
|
-
function calendarDayLabel(day) {
|
|
1163
|
-
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(day);
|
|
1164
|
-
if (!m) return day;
|
|
1165
|
-
const at = new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]));
|
|
1166
|
-
return at.toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
|
|
1167
|
-
}
|
|
1168
|
-
function dayKeyOf(at) {
|
|
1169
|
-
return `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())}`;
|
|
1170
|
-
}
|
|
1171
|
-
function dayAt(day) {
|
|
1172
|
-
const [y, m, d] = day.split("-").map(Number);
|
|
1173
|
-
return new Date(y, (m ?? 1) - 1, d ?? 1);
|
|
1174
|
-
}
|
|
1175
|
-
function addDays(day, n) {
|
|
1176
|
-
const at = dayAt(day);
|
|
1177
|
-
at.setDate(at.getDate() + n);
|
|
1178
|
-
return dayKeyOf(at);
|
|
1179
|
-
}
|
|
1180
|
-
function daysBetween(from, to) {
|
|
1181
|
-
return Math.round((dayAt(to).getTime() - dayAt(from).getTime()) / 864e5);
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
932
|
// src/refusals.ts
|
|
1185
933
|
var refusals_exports = {};
|
|
1186
934
|
__reExport(refusals_exports, versions_star2);
|
|
@@ -1597,22 +1345,6 @@ export {
|
|
|
1597
1345
|
refusalForAPerson,
|
|
1598
1346
|
refusalLineForAPerson,
|
|
1599
1347
|
refusalIsMissingInput,
|
|
1600
|
-
displayFormatOf,
|
|
1601
|
-
choiceLooksOf,
|
|
1602
|
-
choiceWord,
|
|
1603
|
-
storedChoiceColor,
|
|
1604
|
-
storedChoiceColorLookup,
|
|
1605
|
-
nextChoiceColor,
|
|
1606
|
-
choiceChipLookOf,
|
|
1607
|
-
fieldToken,
|
|
1608
|
-
bodyFromKeys,
|
|
1609
|
-
bodyForReading,
|
|
1610
|
-
isSignatureField,
|
|
1611
|
-
PARITY_LABEL,
|
|
1612
|
-
PARITY_MADE_OF,
|
|
1613
|
-
editorKindFor,
|
|
1614
|
-
pickableTypeOf,
|
|
1615
|
-
fieldTypeLabel,
|
|
1616
1348
|
hintIsMachineIdentity,
|
|
1617
1349
|
hintForAPerson,
|
|
1618
1350
|
RefusalNotice,
|
|
@@ -1631,19 +1363,6 @@ export {
|
|
|
1631
1363
|
tablePickerEntries,
|
|
1632
1364
|
usePickerTables,
|
|
1633
1365
|
ShowListsToggle,
|
|
1634
|
-
systemStampOf,
|
|
1635
|
-
carriesTimeOfDay,
|
|
1636
|
-
timeOfDayWords,
|
|
1637
|
-
hasTimePart,
|
|
1638
|
-
isDateField,
|
|
1639
|
-
dateFormatFor,
|
|
1640
|
-
dateText,
|
|
1641
|
-
calendarDayOf,
|
|
1642
|
-
calendarDayLabel,
|
|
1643
|
-
dayKeyOf,
|
|
1644
|
-
dayAt,
|
|
1645
|
-
addDays,
|
|
1646
|
-
daysBetween,
|
|
1647
1366
|
refusals_exports,
|
|
1648
1367
|
WORK_DUE_STATES,
|
|
1649
1368
|
DUE_STATE_LABEL,
|
|
@@ -1678,4 +1397,4 @@ export {
|
|
|
1678
1397
|
choiceNudgeOf,
|
|
1679
1398
|
useChoiceNudge
|
|
1680
1399
|
};
|
|
1681
|
-
//# sourceMappingURL=chunk-
|
|
1400
|
+
//# sourceMappingURL=chunk-VCAOXQ5K.js.map
|