@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
package/dist/helpers.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { globalSlot } from '@ai-matrx/kit/global-slot';
|
|
2
|
-
import { setColorRuleTimeZone } from '@ai-matrx/design-system/data-table/table-style';
|
|
2
|
+
import { tableStyleIsEmpty, parseTableStyle, setColorRuleTimeZone } from '@ai-matrx/design-system/data-table/table-style';
|
|
3
3
|
import { DECLARABLE_FIELD_KINDS, NEWER_FIELD_KINDS, PARITY_FIELD_TYPES, KERNEL_TABLES, atLeast, fieldKindFor, isButtonField, newerKindOf } from '@ai-matrx/records/field-kinds';
|
|
4
4
|
export { DEFAULT_FIELDS, addFields, declareTable, fieldDeclarationFor, tokenFor } from '@ai-matrx/records/field-kinds';
|
|
5
5
|
import { isUuidShape } from '@ai-matrx/kit/uuid';
|
|
6
6
|
import { humanizeIdentifier } from '@ai-matrx/kit/text-case';
|
|
7
7
|
import { formatRelativeTime } from '@ai-matrx/kit/format';
|
|
8
8
|
import '@ai-matrx/design-system/field-formats';
|
|
9
|
+
import { DECLARABLE_FIELD_KINDS as DECLARABLE_FIELD_KINDS$1, newerKindOf as newerKindOf$1 } from '@ai-matrx/records';
|
|
10
|
+
import * as base from '@ai-matrx/records/views';
|
|
11
|
+
export { endingsFromDocument, hiddenFromLink, themeFromDocument, welcomeFromDocument } from '@ai-matrx/records/forms';
|
|
12
|
+
import { toDelimited } from '@ai-matrx/kit/delimited';
|
|
13
|
+
import { formatShortcut } from '@ai-matrx/design-system/tap-target';
|
|
9
14
|
|
|
10
15
|
// src/dataSource.ts
|
|
11
16
|
function personActor(userId) {
|
|
@@ -127,6 +132,9 @@ var NEEDS = {
|
|
|
127
132
|
// custom.field_declare / field_update / field_retire / table settings
|
|
128
133
|
structure: "admin"
|
|
129
134
|
};
|
|
135
|
+
function levelNeededFor(what) {
|
|
136
|
+
return NEEDS[what];
|
|
137
|
+
}
|
|
130
138
|
var NOT_YET = "Still asking the store what you may do here. Nothing is offered until it has answered.";
|
|
131
139
|
var NOTHING_AT_ALL = "You have not been given this. Ask somebody who administers it to share it with you.";
|
|
132
140
|
function sentenceFor(what, level) {
|
|
@@ -385,7 +393,7 @@ var FIELD_TYPE_CATALOGUE = [
|
|
|
385
393
|
{ id: "modified_by", group: "Worked out", label: "Last changed by", explanation: "Who last changed each record. Nobody types it." }
|
|
386
394
|
];
|
|
387
395
|
var GATED_KINDS = /* @__PURE__ */ new Set(["entity_reference", ...NEWER_FIELD_KINDS]);
|
|
388
|
-
FIELD_TYPE_CATALOGUE.filter(
|
|
396
|
+
var FIELD_TYPE_CHOICES = FIELD_TYPE_CATALOGUE.filter(
|
|
389
397
|
(c) => !GATED_KINDS.has(c.id) || storePublishesKind(c.id) || c.id in LOOK_KINDS
|
|
390
398
|
);
|
|
391
399
|
var BY_ID = new Map(FIELD_TYPE_CATALOGUE.map((c) => [c.id, c]));
|
|
@@ -492,6 +500,207 @@ function madeOn(stamp) {
|
|
|
492
500
|
if (Number.isNaN(at.getTime())) return null;
|
|
493
501
|
return new Intl.DateTimeFormat(void 0, { month: "short", day: "numeric", year: "numeric" }).format(at);
|
|
494
502
|
}
|
|
503
|
+
function parseGanttLook(raw) {
|
|
504
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
505
|
+
const v = raw;
|
|
506
|
+
const out = {};
|
|
507
|
+
if (v["mode"] === true) out.mode = true;
|
|
508
|
+
if (v["critical"] === true) out.critical = true;
|
|
509
|
+
for (const k of ["progress", "milestone", "baselineStart", "baselineEnd", "dependency"]) {
|
|
510
|
+
const x = v[k];
|
|
511
|
+
if (typeof x === "string" && x !== "") out[k] = x;
|
|
512
|
+
}
|
|
513
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
514
|
+
}
|
|
515
|
+
var MIN_ROW_HEIGHT = 24;
|
|
516
|
+
var MAX_ROW_HEIGHT = 240;
|
|
517
|
+
var AGGREGATE_KINDS = [
|
|
518
|
+
"count",
|
|
519
|
+
"sum",
|
|
520
|
+
"average",
|
|
521
|
+
"min",
|
|
522
|
+
"max",
|
|
523
|
+
"empty",
|
|
524
|
+
"filled",
|
|
525
|
+
"unique",
|
|
526
|
+
"checked",
|
|
527
|
+
"unchecked",
|
|
528
|
+
"percentFilled"
|
|
529
|
+
];
|
|
530
|
+
var GROUP_ORDERS = [
|
|
531
|
+
"value-asc",
|
|
532
|
+
"value-desc",
|
|
533
|
+
"count-desc",
|
|
534
|
+
"first-seen"
|
|
535
|
+
];
|
|
536
|
+
function isRecord(v) {
|
|
537
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
538
|
+
}
|
|
539
|
+
function parseGridPresentation(raw) {
|
|
540
|
+
let value = raw;
|
|
541
|
+
if (typeof value === "string") {
|
|
542
|
+
const trimmed = value.trim();
|
|
543
|
+
if (trimmed === "") return {};
|
|
544
|
+
try {
|
|
545
|
+
value = JSON.parse(trimmed);
|
|
546
|
+
} catch {
|
|
547
|
+
return {};
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (!isRecord(value)) return {};
|
|
551
|
+
const out = {};
|
|
552
|
+
const style = parseTableStyle(value["style"]);
|
|
553
|
+
if (!tableStyleIsEmpty(style)) out.style = style;
|
|
554
|
+
if (isRecord(value["formats"])) {
|
|
555
|
+
const formats = {};
|
|
556
|
+
for (const [key, cfg] of Object.entries(value["formats"])) {
|
|
557
|
+
if (!isRecord(cfg)) continue;
|
|
558
|
+
const id = cfg["id"];
|
|
559
|
+
if (typeof id !== "string") continue;
|
|
560
|
+
const options = cfg["options"];
|
|
561
|
+
formats[key] = isRecord(options) ? {
|
|
562
|
+
id,
|
|
563
|
+
options
|
|
564
|
+
} : { id };
|
|
565
|
+
}
|
|
566
|
+
if (Object.keys(formats).length > 0) out.formats = formats;
|
|
567
|
+
}
|
|
568
|
+
if (Array.isArray(value["frozen"])) {
|
|
569
|
+
const frozen = value["frozen"].filter((k) => typeof k === "string");
|
|
570
|
+
if (frozen.length > 0) out.frozen = frozen;
|
|
571
|
+
}
|
|
572
|
+
const grouping = parseGrouping(value["grouping"]);
|
|
573
|
+
if (grouping) out.grouping = grouping;
|
|
574
|
+
if (isRecord(value["widths"])) {
|
|
575
|
+
const widths = {};
|
|
576
|
+
for (const [key, raw2] of Object.entries(value["widths"])) {
|
|
577
|
+
if (typeof raw2 !== "number" || !Number.isFinite(raw2) || raw2 <= 0) continue;
|
|
578
|
+
widths[key] = Math.round(raw2);
|
|
579
|
+
}
|
|
580
|
+
if (Object.keys(widths).length > 0) out.widths = widths;
|
|
581
|
+
}
|
|
582
|
+
const rowHeight = value["rowHeight"];
|
|
583
|
+
if (typeof rowHeight === "number" && Number.isFinite(rowHeight) && rowHeight >= MIN_ROW_HEIGHT && rowHeight <= MAX_ROW_HEIGHT) {
|
|
584
|
+
out.rowHeight = Math.round(rowHeight);
|
|
585
|
+
}
|
|
586
|
+
if (Array.isArray(value["hiddenFields"])) {
|
|
587
|
+
const hiddenFields = value["hiddenFields"].filter((k) => typeof k === "string");
|
|
588
|
+
if (hiddenFields.length > 0) out.hiddenFields = hiddenFields;
|
|
589
|
+
}
|
|
590
|
+
if (Array.isArray(value["cardHidden"])) {
|
|
591
|
+
out.cardHidden = value["cardHidden"].filter((k) => typeof k === "string");
|
|
592
|
+
}
|
|
593
|
+
if (Array.isArray(value["columnOrder"])) {
|
|
594
|
+
const columnOrder = value["columnOrder"].filter((k) => typeof k === "string");
|
|
595
|
+
if (columnOrder.length > 0) out.columnOrder = columnOrder;
|
|
596
|
+
}
|
|
597
|
+
const gallerySize = value["gallerySize"];
|
|
598
|
+
if (gallerySize === "small" || gallerySize === "medium" || gallerySize === "large") {
|
|
599
|
+
out.gallerySize = gallerySize;
|
|
600
|
+
}
|
|
601
|
+
const boardSize = value["boardSize"];
|
|
602
|
+
if (boardSize === "small" || boardSize === "medium" || boardSize === "large") out.boardSize = boardSize;
|
|
603
|
+
if (typeof value["boardPreview"] === "string" && value["boardPreview"] !== "") out.boardPreview = value["boardPreview"];
|
|
604
|
+
if (typeof value["boardHideEmpty"] === "boolean") out.boardHideEmpty = value["boardHideEmpty"];
|
|
605
|
+
if (typeof value["boardColorColumns"] === "boolean") out.boardColorColumns = value["boardColorColumns"];
|
|
606
|
+
if (typeof value["boardCounts"] === "boolean") out.boardCounts = value["boardCounts"];
|
|
607
|
+
if (value["locked"] === true) out.locked = true;
|
|
608
|
+
if (Array.isArray(value["boardLanesShut"])) {
|
|
609
|
+
const shut = value["boardLanesShut"].filter((k) => typeof k === "string");
|
|
610
|
+
if (shut.length > 0) out.boardLanesShut = shut;
|
|
611
|
+
}
|
|
612
|
+
if (typeof value["wrap"] === "boolean") out.wrap = value["wrap"];
|
|
613
|
+
if (typeof value["headerWrap"] === "boolean") out.headerWrap = value["headerWrap"];
|
|
614
|
+
if (Array.isArray(value["wrapColumns"])) {
|
|
615
|
+
const wrapColumns = value["wrapColumns"].filter((k) => typeof k === "string");
|
|
616
|
+
if (wrapColumns.length > 0) out.wrapColumns = wrapColumns;
|
|
617
|
+
}
|
|
618
|
+
const fit = value["fit"];
|
|
619
|
+
if (fit === "auto" || fit === "fit" || fit === "scroll") out.fit = fit;
|
|
620
|
+
if (typeof value["freezeFirst"] === "boolean") out.freezeFirst = value["freezeFirst"];
|
|
621
|
+
const footer = value["footer"];
|
|
622
|
+
if (footer === "sticky" || footer === "inline") out.footer = footer;
|
|
623
|
+
{
|
|
624
|
+
const gantt = parseGanttLook(value["gantt"]);
|
|
625
|
+
if (gantt) out.gantt = gantt;
|
|
626
|
+
}
|
|
627
|
+
if (isRecord(value["summaries"])) {
|
|
628
|
+
const summaries = {};
|
|
629
|
+
for (const [key, op] of Object.entries(value["summaries"])) {
|
|
630
|
+
if (typeof op === "string" && op.trim() !== "") summaries[key] = op;
|
|
631
|
+
}
|
|
632
|
+
if (Object.keys(summaries).length > 0) out.summaries = summaries;
|
|
633
|
+
}
|
|
634
|
+
return out;
|
|
635
|
+
}
|
|
636
|
+
function parseGrouping(raw) {
|
|
637
|
+
if (!isRecord(raw)) return void 0;
|
|
638
|
+
const field = raw["field"];
|
|
639
|
+
if (typeof field !== "string" || field.trim() === "") return void 0;
|
|
640
|
+
const out = { field };
|
|
641
|
+
if (isRecord(raw["aggregates"])) {
|
|
642
|
+
const aggregates = {};
|
|
643
|
+
for (const [key, spec] of Object.entries(raw["aggregates"])) {
|
|
644
|
+
if (!isRecord(spec)) continue;
|
|
645
|
+
const kind = spec["kind"];
|
|
646
|
+
if (typeof kind !== "string") continue;
|
|
647
|
+
if (!AGGREGATE_KINDS.includes(kind)) continue;
|
|
648
|
+
const label = spec["label"];
|
|
649
|
+
aggregates[key] = typeof label === "string" ? { kind, label } : { kind };
|
|
650
|
+
}
|
|
651
|
+
if (Object.keys(aggregates).length > 0) out.aggregates = aggregates;
|
|
652
|
+
}
|
|
653
|
+
const order = raw["order"];
|
|
654
|
+
if (typeof order === "string" && GROUP_ORDERS.includes(order)) {
|
|
655
|
+
out.order = order;
|
|
656
|
+
}
|
|
657
|
+
if (Array.isArray(raw["collapsed"])) {
|
|
658
|
+
const collapsed = raw["collapsed"].filter((k) => typeof k === "string");
|
|
659
|
+
if (collapsed.length > 0) out.collapsed = collapsed;
|
|
660
|
+
}
|
|
661
|
+
if (typeof raw["showColumn"] === "boolean") out.showColumn = raw["showColumn"];
|
|
662
|
+
if (Array.isArray(raw["then"])) {
|
|
663
|
+
const then = [];
|
|
664
|
+
for (const level of raw["then"]) {
|
|
665
|
+
if (!isRecord(level)) continue;
|
|
666
|
+
const sub = level["field"];
|
|
667
|
+
if (typeof sub !== "string" || sub.trim() === "") continue;
|
|
668
|
+
const subOrder = level["order"];
|
|
669
|
+
const subGrain = level["grain"];
|
|
670
|
+
then.push({
|
|
671
|
+
field: sub,
|
|
672
|
+
...typeof subOrder === "string" && GROUP_ORDERS.includes(subOrder) ? { order: subOrder } : {},
|
|
673
|
+
...typeof subGrain === "string" && subGrain !== "" ? { grain: subGrain } : {}
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
if (then.length > 0) out.then = then.slice(0, 2);
|
|
677
|
+
}
|
|
678
|
+
const grain = raw["grain"];
|
|
679
|
+
if (typeof grain === "string" && grain !== "") out.grain = grain;
|
|
680
|
+
const across = raw["across"];
|
|
681
|
+
if (typeof across === "string" && across.trim() !== "") out.across = across;
|
|
682
|
+
if (Array.isArray(raw["show"])) {
|
|
683
|
+
const show = raw["show"].filter((k) => typeof k === "string" && k !== "");
|
|
684
|
+
if (show.length > 0) out.show = show;
|
|
685
|
+
}
|
|
686
|
+
if (Array.isArray(raw["trail"])) {
|
|
687
|
+
const trail = [];
|
|
688
|
+
for (const step of raw["trail"]) {
|
|
689
|
+
if (!isRecord(step) || typeof step["dim"] !== "string" || step["dim"] === "") continue;
|
|
690
|
+
const value = step["value"];
|
|
691
|
+
if (value !== null && typeof value !== "string") continue;
|
|
692
|
+
trail.push({ dim: step["dim"], value });
|
|
693
|
+
}
|
|
694
|
+
if (trail.length > 0) out.trail = trail;
|
|
695
|
+
}
|
|
696
|
+
return out;
|
|
697
|
+
}
|
|
698
|
+
function presentationIsEmpty(p) {
|
|
699
|
+
return (p.style === void 0 || tableStyleIsEmpty(p.style)) && Object.keys(p.formats ?? {}).length === 0 && (p.frozen?.length ?? 0) === 0 && p.grouping === void 0 && Object.keys(p.widths ?? {}).length === 0 && p.rowHeight === void 0 && (p.hiddenFields?.length ?? 0) === 0 && p.cardHidden === void 0 && (p.columnOrder?.length ?? 0) === 0 && p.gallerySize === void 0 && p.boardSize === void 0 && p.boardPreview === void 0 && p.boardHideEmpty === void 0 && p.boardColorColumns === void 0 && p.boardCounts === void 0 && (p.boardLanesShut?.length ?? 0) === 0 && p.locked === void 0 && p.wrap === void 0 && p.headerWrap === void 0 && p.fit === void 0 && p.freezeFirst === void 0 && p.footer === void 0 && Object.keys(p.summaries ?? {}).length === 0 && p.gantt === void 0;
|
|
700
|
+
}
|
|
701
|
+
function presentationDocument(p) {
|
|
702
|
+
return presentationIsEmpty(p) ? "" : JSON.stringify(p);
|
|
703
|
+
}
|
|
495
704
|
function styleFromDecorations(decorations, fields) {
|
|
496
705
|
if (!decorations) return { version: 1 };
|
|
497
706
|
const keyOf = (id) => fields.find((f) => f.id === id)?.key;
|
|
@@ -537,13 +746,13 @@ function styleFromDecorations(decorations, fields) {
|
|
|
537
746
|
return style;
|
|
538
747
|
}
|
|
539
748
|
function resolveTableStyle(decorations, fields, viewStyle) {
|
|
540
|
-
const
|
|
541
|
-
if (!viewStyle) return
|
|
542
|
-
const colorBy = viewStyle.colorBy ??
|
|
543
|
-
const rules = viewStyle.rules ??
|
|
544
|
-
const rows = viewStyle.rows ??
|
|
545
|
-
const columns = viewStyle.columns ??
|
|
546
|
-
const cells = viewStyle.cells ??
|
|
749
|
+
const base2 = styleFromDecorations(decorations, fields);
|
|
750
|
+
if (!viewStyle) return base2;
|
|
751
|
+
const colorBy = viewStyle.colorBy ?? base2.colorBy;
|
|
752
|
+
const rules = viewStyle.rules ?? base2.rules;
|
|
753
|
+
const rows = viewStyle.rows ?? base2.rows;
|
|
754
|
+
const columns = viewStyle.columns ?? base2.columns;
|
|
755
|
+
const cells = viewStyle.cells ?? base2.cells;
|
|
547
756
|
return {
|
|
548
757
|
version: 1,
|
|
549
758
|
...colorBy !== void 0 ? { colorBy } : {},
|
|
@@ -553,7 +762,543 @@ function resolveTableStyle(decorations, fields, viewStyle) {
|
|
|
553
762
|
...cells !== void 0 ? { cells } : {}
|
|
554
763
|
};
|
|
555
764
|
}
|
|
765
|
+
var PAGE_KIND = "page";
|
|
766
|
+
function isPage(row) {
|
|
767
|
+
const p = row.presentation;
|
|
768
|
+
return !!p && typeof p === "object" && p["kind"] === PAGE_KIND;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// src/interfaces.ts
|
|
772
|
+
var INTERFACE_KIND = "interface";
|
|
773
|
+
function isInterface(row) {
|
|
774
|
+
const p = row.presentation;
|
|
775
|
+
return !!p && typeof p === "object" && p["kind"] === INTERFACE_KIND;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// src/tableLanes.ts
|
|
779
|
+
var PLATFORM_TABLE_PREFIX2 = "records_ui_";
|
|
780
|
+
function platformOwned(table) {
|
|
781
|
+
const t = table;
|
|
782
|
+
return t.platform_owned === true || t.kept_by_the_app === true;
|
|
783
|
+
}
|
|
784
|
+
function laneFor(table) {
|
|
785
|
+
if (table.is_kernel) return "system";
|
|
786
|
+
if ((table.slug ?? "").startsWith(PLATFORM_TABLE_PREFIX2) || platformOwned(table)) return "app";
|
|
787
|
+
if (publishedToWeb(table)) return "community";
|
|
788
|
+
if (shownToOnlyMe(table)) return "mine";
|
|
789
|
+
return "organization";
|
|
790
|
+
}
|
|
791
|
+
function publishedToWeb(table) {
|
|
792
|
+
if (typeof table.published_to_web === "boolean") return table.published_to_web;
|
|
793
|
+
return table.visibility === "public" || table.visibility === "link";
|
|
794
|
+
}
|
|
795
|
+
function shownToOnlyMe(table) {
|
|
796
|
+
if (table.shown_to !== void 0) return table.shown_to === "only_me";
|
|
797
|
+
return table.visibility === "personal";
|
|
798
|
+
}
|
|
799
|
+
var BODY_NAMES = /^(notes?|page|body|content|page content|details|description)$/i;
|
|
800
|
+
function bodyFieldOf(fields) {
|
|
801
|
+
const rich = fields.filter((field) => newerKindOf$1(field) === "rich_text");
|
|
802
|
+
return rich.find((field) => BODY_NAMES.test((field.label ?? field.key).trim()) || BODY_NAMES.test(field.key.replace(/_/g, " "))) ?? rich[0];
|
|
803
|
+
}
|
|
804
|
+
var gridPresentationCodec = {
|
|
805
|
+
parse: parseGridPresentation,
|
|
806
|
+
isEmpty: presentationIsEmpty,
|
|
807
|
+
toDocument: (presentation) => JSON.parse(presentationDocument(presentation))
|
|
808
|
+
};
|
|
809
|
+
var boundViews = base.bindViewCodec(gridPresentationCodec);
|
|
810
|
+
var { viewSettings, viewSettingsPatch } = boundViews;
|
|
811
|
+
var { lookDocument, lookFromDocument, readLooks, keepLook } = boundViews;
|
|
812
|
+
var { viewDocument, viewFromRow, declareView, saveViewPatch, viewPatchDocument } = boundViews;
|
|
813
|
+
|
|
814
|
+
// src/viewAddressParams.ts
|
|
815
|
+
var VIEW_ADDRESS_KEYS = ["sort", "cf", "q", "hide", "page"];
|
|
816
|
+
function isViewAddressEmpty(state2) {
|
|
817
|
+
if (!state2) return true;
|
|
818
|
+
return !state2.sort && Object.keys(state2.filters ?? {}).length === 0 && !(state2.search ?? "").trim() && (state2.hidden?.length ?? 0) === 0 && !(state2.page && state2.page > 1);
|
|
819
|
+
}
|
|
820
|
+
function viewAddressToParams(state2) {
|
|
821
|
+
const out = {};
|
|
822
|
+
if (!state2) return out;
|
|
823
|
+
if (state2.sort) out["sort"] = `${state2.sort.field}:${state2.sort.direction}`;
|
|
824
|
+
const filters = Object.fromEntries(Object.entries(state2.filters ?? {}).filter(([, v]) => v !== void 0 && v !== null));
|
|
825
|
+
if (Object.keys(filters).length > 0) out["cf"] = JSON.stringify(filters);
|
|
826
|
+
if ((state2.search ?? "").trim()) out["q"] = (state2.search ?? "").trim();
|
|
827
|
+
if (state2.hidden && state2.hidden.length > 0) out["hide"] = JSON.stringify(state2.hidden);
|
|
828
|
+
if (state2.page && state2.page > 1) out["page"] = String(Math.floor(state2.page));
|
|
829
|
+
return out;
|
|
830
|
+
}
|
|
831
|
+
function viewAddressFromParams(get) {
|
|
832
|
+
const out = {};
|
|
833
|
+
const sort = get("sort");
|
|
834
|
+
if (sort) {
|
|
835
|
+
const at = sort.lastIndexOf(":");
|
|
836
|
+
const field = at > 0 ? sort.slice(0, at) : "";
|
|
837
|
+
const dir = at > 0 ? sort.slice(at + 1) : "";
|
|
838
|
+
if (field && (dir === "asc" || dir === "desc")) out.sort = { field, direction: dir };
|
|
839
|
+
}
|
|
840
|
+
const cf = get("cf");
|
|
841
|
+
if (cf) {
|
|
842
|
+
try {
|
|
843
|
+
const parsed = JSON.parse(cf);
|
|
844
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) out.filters = parsed;
|
|
845
|
+
} catch {
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
const q = get("q");
|
|
849
|
+
if (q && q.trim()) out.search = q.trim();
|
|
850
|
+
const hide = get("hide");
|
|
851
|
+
if (hide) {
|
|
852
|
+
try {
|
|
853
|
+
const parsed = JSON.parse(hide);
|
|
854
|
+
if (Array.isArray(parsed)) {
|
|
855
|
+
const keys = parsed.filter((k) => typeof k === "string");
|
|
856
|
+
if (keys.length > 0) out.hidden = keys;
|
|
857
|
+
}
|
|
858
|
+
} catch {
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
const page = Number(get("page"));
|
|
862
|
+
if (Number.isInteger(page) && page > 1) out.page = page;
|
|
863
|
+
return isViewAddressEmpty(out) ? null : out;
|
|
864
|
+
}
|
|
865
|
+
function sameViewAddress(a, b) {
|
|
866
|
+
return JSON.stringify(viewAddressToParams(a)) === JSON.stringify(viewAddressToParams(b));
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// src/calendarFeed.ts
|
|
870
|
+
function webcalUrl(httpsUrl) {
|
|
871
|
+
return httpsUrl.replace(/^https?:\/\//i, "webcal://");
|
|
872
|
+
}
|
|
873
|
+
function googleCalendarUrl(httpsUrl) {
|
|
874
|
+
return `https://calendar.google.com/calendar/r?cid=${encodeURIComponent(webcalUrl(httpsUrl))}`;
|
|
875
|
+
}
|
|
876
|
+
var FIELD_SENSITIVITY_LABEL = {
|
|
877
|
+
public: "Anyone who can open the record",
|
|
878
|
+
internal: "People in this organization",
|
|
879
|
+
confidential: "People who have been given the record",
|
|
880
|
+
restricted: "Owners and administrators only"
|
|
881
|
+
};
|
|
882
|
+
var STORE_BEHAVIOUR = new Map(DECLARABLE_FIELD_KINDS$1.map((row) => [row.kind, row.behavior]));
|
|
883
|
+
function holdsAValueOnAStandardTable(kind) {
|
|
884
|
+
if (isSystemFieldKind(kind)) return false;
|
|
885
|
+
const behaviour = STORE_BEHAVIOUR.get(kind);
|
|
886
|
+
return behaviour !== void 0 && behaviour !== "formula";
|
|
887
|
+
}
|
|
888
|
+
var STANDARD_TABLE_FIELD_CHOICES = FIELD_TYPE_CHOICES.filter(
|
|
889
|
+
(c) => holdsAValueOnAStandardTable(c.id)
|
|
890
|
+
);
|
|
891
|
+
var ADDABLE_TYPES = STANDARD_TABLE_FIELD_CHOICES.map((choice) => ({
|
|
892
|
+
value: choice.id,
|
|
893
|
+
label: choice.label
|
|
894
|
+
}));
|
|
895
|
+
|
|
896
|
+
// src/plainWords.ts
|
|
897
|
+
var MACHINE_IDENTITY = [
|
|
898
|
+
/\b[A-Z]{2,4}-\d{1,3}\b/,
|
|
899
|
+
// A build lane's tag: capital words joined by hyphens, then a colon ("STORE-TAILS-3:",
|
|
900
|
+
// "MOVE-AND-OUTSIDER:"). A person never reads which lane wrote a sentence.
|
|
901
|
+
/\b[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+:/,
|
|
902
|
+
/\b(?:custom|platform|iam|history|public|auth|campaign_watch)\.[a-z_]+/,
|
|
903
|
+
/\b(?:config|data|document|spec|patch)\.[a-z_]+/,
|
|
904
|
+
/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/i,
|
|
905
|
+
/\b[a-z][a-z0-9]*(?:_[a-z0-9]+)+\b/,
|
|
906
|
+
// Five characters of digits and capitals, at least one a digit — so `23514`
|
|
907
|
+
// and `PT409` match and an emphatic `NEVER` does not.
|
|
908
|
+
/\b(?=[0-9A-Z]{5}\b)(?=[0-9A-Z]*\d)[0-9A-Z]{5}\b/
|
|
909
|
+
];
|
|
910
|
+
function isMachineIdentity(text) {
|
|
911
|
+
return MACHINE_IDENTITY.some((shape) => shape.test(text));
|
|
912
|
+
}
|
|
913
|
+
var TITLE = {
|
|
914
|
+
stale_write: "Someone else wrote first",
|
|
915
|
+
door: "You do not have access to this",
|
|
916
|
+
door_absent: "That is not built yet",
|
|
917
|
+
refused_by_rule: "That value was not accepted",
|
|
918
|
+
invalid_argument: "That was not accepted",
|
|
919
|
+
not_found: "Not there any more",
|
|
920
|
+
missing_reference: "That points at something that is not there",
|
|
921
|
+
already_exists: "That already exists",
|
|
922
|
+
not_supported: "That cannot be done here",
|
|
923
|
+
store_limit: "This has got as big as it can",
|
|
924
|
+
// 🚨 NOT "THE SWITCH IS OFF" (lane 7 W1 fix round 1). PGRST202 / PGRST205 land here, and the
|
|
925
|
+
// commonest cause is a door this screen asks for that the database it talks to does not serve
|
|
926
|
+
// YET — a release in flight. Telling the person her organization has its store switched off was
|
|
927
|
+
// false (the switch is answered by its own door, `platform.unified_data_store_on`). Honest:
|
|
928
|
+
// nothing happened, and it is ours, and it passes.
|
|
929
|
+
store_not_served: "This isn't available right now",
|
|
930
|
+
unreachable: "We could not reach your data",
|
|
931
|
+
needs_approval: "This is waiting on someone's approval",
|
|
932
|
+
stale_read: "Your view of this is a moment behind",
|
|
933
|
+
timed_out: "That took too long to answer",
|
|
934
|
+
internal: "Something went wrong at our end"
|
|
935
|
+
};
|
|
936
|
+
var REMEDY = {
|
|
937
|
+
stale_write: "Look at what they wrote. Keep theirs, or try again and yours goes on top.",
|
|
938
|
+
door: "Ask somebody who administers this to share it with you at the level you need.",
|
|
939
|
+
door_absent: "There is nothing to do here yet. It is on our list, not yours.",
|
|
940
|
+
refused_by_rule: "Change the value so it passes, then try again.",
|
|
941
|
+
invalid_argument: "Change what you entered, then try again.",
|
|
942
|
+
not_found: "It may have been deleted. Go back to the list and open it again from there.",
|
|
943
|
+
missing_reference: "Pick something that is still there.",
|
|
944
|
+
already_exists: "Use a different name.",
|
|
945
|
+
not_supported: "There is another way to do this \u2014 ask, and we will point you at it.",
|
|
946
|
+
store_limit: "Split it up, or ask us to raise the ceiling for your organization.",
|
|
947
|
+
store_not_served: "Nothing was changed. Try again in a few minutes.",
|
|
948
|
+
// 🚨 NOTHING WAS WRITTEN AND NOTHING WAS REFUSED (lane TAILS-6). The call
|
|
949
|
+
// never arrived, so "try again" is the honest instruction rather than a
|
|
950
|
+
// consolation — and saying nothing changed is the half a person actually
|
|
951
|
+
// worries about.
|
|
952
|
+
unreachable: "Nothing was changed. Check your connection and open this again.",
|
|
953
|
+
needs_approval: "Nothing was changed yet. The people who can approve it have been asked.",
|
|
954
|
+
stale_read: "Open this again in a moment and it will be up to date.",
|
|
955
|
+
// 🚨 ONE REMEDY THAT IS TRUE OF EVERY DOOR (lane CHAIR-STORE-PERF, 2026-10-03). The store cancels the
|
|
956
|
+
// WHOLE statement at its clock, so a timed-out door wrote nothing — a create, a column add and a page
|
|
957
|
+
// read alike. "Try a smaller page" was written for the page read and was printed to a person adding
|
|
958
|
+
// one row to a three-row table (clone walk, 2026-10-03; the clock was a lock another lane's
|
|
959
|
+
// rehearsal held, not the row). A door whose page can shrink says so in its own hint, which wins here.
|
|
960
|
+
timed_out: "Nothing was changed. Try again in a moment.",
|
|
961
|
+
internal: "Nothing you did caused this. Try again, and tell us if it keeps happening."
|
|
962
|
+
};
|
|
963
|
+
var ENGINEER_TEXT = [
|
|
964
|
+
/@ai-matrx\//,
|
|
965
|
+
/\bSQLSTATE\b/i,
|
|
966
|
+
/\bPostgREST\b/i,
|
|
967
|
+
/\bIndexedDB\b/i,
|
|
968
|
+
// `<RecordsUiProvider>` — a component, on a screen.
|
|
969
|
+
/<\/?[A-Z][A-Za-z0-9]*\s*\/?>/,
|
|
970
|
+
// `savedViews`, `openRecords`, `onReask` — an identifier, however it is
|
|
971
|
+
// quoted. English does not write camelCase; code does.
|
|
972
|
+
/\b[a-z][a-z0-9]*[A-Z][A-Za-z0-9]*\b/,
|
|
973
|
+
// A backticked token is a thing you type into an editor, not a thing you do.
|
|
974
|
+
/`[A-Za-z_][A-Za-z0-9_.]*`/,
|
|
975
|
+
// "bind X on Y", "pass X", "import X" — an instruction to whoever maintains
|
|
976
|
+
// the app, arriving on the screen of somebody who cannot act on it.
|
|
977
|
+
/\bbind\s+[`'"A-Za-z]/i
|
|
978
|
+
];
|
|
979
|
+
function isDeveloperHint(hint) {
|
|
980
|
+
const text = hint.trim();
|
|
981
|
+
if (text === "") return false;
|
|
982
|
+
if (text.includes("```")) return true;
|
|
983
|
+
if (/\n\s+at\s+\S+/.test(text)) return true;
|
|
984
|
+
if (text.length > 600) return true;
|
|
985
|
+
return isEngineerText(text);
|
|
986
|
+
}
|
|
987
|
+
function isEngineerText(text) {
|
|
988
|
+
return ENGINEER_TEXT.some((shape) => shape.test(text));
|
|
989
|
+
}
|
|
990
|
+
function withoutMachineClauses(sentence) {
|
|
991
|
+
const dropped = [];
|
|
992
|
+
const footnotes = [];
|
|
993
|
+
const withoutFootnotes = sentence.replace(/\s*\((?:see\s+)?[A-Z]{2,5}-[A-Z0-9-]{1,8}\)/g, (hit) => {
|
|
994
|
+
footnotes.push(hit.trim());
|
|
995
|
+
return "";
|
|
996
|
+
});
|
|
997
|
+
dropped.push(...footnotes);
|
|
998
|
+
const clauses = withoutFootnotes.split(/(?:,\s+so\s+|\s+—\s+|\s+--\s+|\s*\|\s*)/).map((clause) => clause.trim()).filter((clause) => clause !== "");
|
|
999
|
+
const kept = clauses.filter((clause) => {
|
|
1000
|
+
if (!isMachineIdentity(clause)) return true;
|
|
1001
|
+
dropped.push(clause);
|
|
1002
|
+
return false;
|
|
1003
|
+
});
|
|
1004
|
+
if (kept.length === 0) return { kept: null, dropped };
|
|
1005
|
+
if (dropped.length === 0) return { kept: sentence.trim(), dropped };
|
|
1006
|
+
let joined = kept.join(". ").replace(/\.\.+/g, ".").trim();
|
|
1007
|
+
if (!/[.!?]$/.test(joined)) joined = `${joined}.`;
|
|
1008
|
+
return { kept: joined, dropped };
|
|
1009
|
+
}
|
|
1010
|
+
function peopleSentence(message) {
|
|
1011
|
+
const [lead = "", ...tail] = message.split(/\s+—\s+|\s+--\s+/);
|
|
1012
|
+
const sentences = lead.trim().split(/(?<=(?<!\b(?:Dr|Mr|Mrs|Ms|St|vs|No|e\.g|i\.e|etc|[A-Z]))[.!?])\s+/);
|
|
1013
|
+
const first = sentences[0] ?? "";
|
|
1014
|
+
const rest = [...sentences.slice(1), ...tail].map((part) => part.trim()).filter((part) => part !== "");
|
|
1015
|
+
const cleaned = plainSentence(first);
|
|
1016
|
+
return { kept: cleaned.kept, dropped: [...cleaned.dropped, ...rest] };
|
|
1017
|
+
}
|
|
1018
|
+
function refusalSentence(error) {
|
|
1019
|
+
return refusalForAPerson(error).sentence;
|
|
1020
|
+
}
|
|
1021
|
+
function plainSentence(message) {
|
|
1022
|
+
const dropped = [];
|
|
1023
|
+
const kept = [];
|
|
1024
|
+
for (const raw of message.split(/(?<=[.!?])\s+/)) {
|
|
1025
|
+
const sentence = raw.trim();
|
|
1026
|
+
if (sentence === "") continue;
|
|
1027
|
+
const cleaned = withoutMachineClauses(sentence);
|
|
1028
|
+
dropped.push(...cleaned.dropped);
|
|
1029
|
+
if (cleaned.kept) kept.push(cleaned.kept);
|
|
1030
|
+
}
|
|
1031
|
+
return { kept: kept.length === 0 ? null : kept.join(" "), dropped };
|
|
1032
|
+
}
|
|
1033
|
+
function exampleOf(error) {
|
|
1034
|
+
const detail = error.detail;
|
|
1035
|
+
if (!detail || typeof detail !== "object") return null;
|
|
1036
|
+
const example = detail.example;
|
|
1037
|
+
return typeof example === "string" && example.trim() !== "" ? example.trim() : null;
|
|
1038
|
+
}
|
|
1039
|
+
function refusalForAPerson(error) {
|
|
1040
|
+
const code = error.code ?? "internal";
|
|
1041
|
+
const ours = error.ours === true;
|
|
1042
|
+
const hint = plainSentence(String(error.hint ?? ""));
|
|
1043
|
+
const message = ours ? plainSentence(String(error.message ?? "")) : peopleSentence(String(error.message ?? ""));
|
|
1044
|
+
const title = TITLE[code] ?? "The store refused this";
|
|
1045
|
+
const hintIsForEngineers = isDeveloperHint(String(error.hint ?? ""));
|
|
1046
|
+
const example = exampleOf(error);
|
|
1047
|
+
const remedy = (example ? `Enter it like ${example}.` : null) ?? (hintIsForEngineers ? null : hint.kept) ?? REMEDY[code] ?? REMEDY["internal"];
|
|
1048
|
+
const messageIsForEngineers = isEngineerText(String(error.message ?? ""));
|
|
1049
|
+
const said = (messageIsForEngineers ? "" : message.kept ?? "").trim();
|
|
1050
|
+
const forEngineers = [
|
|
1051
|
+
error.sqlstate ? `SQLSTATE ${error.sqlstate}.` : null,
|
|
1052
|
+
// The client's own note about a class it did not recognise, or a call that
|
|
1053
|
+
// never reached the store. It is rendered out of sight, never as a sentence.
|
|
1054
|
+
error.diagnostic ? error.diagnostic : null,
|
|
1055
|
+
messageIsForEngineers ? `Message: ${error.message}` : null,
|
|
1056
|
+
error.hint && (hintIsForEngineers || hint.kept !== error.hint) ? `Hint: ${error.hint}` : null,
|
|
1057
|
+
message.dropped.length > 0 || hint.dropped.length > 0 ? `Dropped from the person's view: ${[...message.dropped, ...hint.dropped].join(" | ")}` : null
|
|
1058
|
+
].filter(Boolean).join(" ");
|
|
1059
|
+
return {
|
|
1060
|
+
title,
|
|
1061
|
+
// Nothing invented. When every clause was machine identity the title says
|
|
1062
|
+
// what happened and the remedy says what to do; a made-up diagnosis would
|
|
1063
|
+
// be worse than the identifier it replaced.
|
|
1064
|
+
sentence: said === "" ? `${title}.` : said,
|
|
1065
|
+
remedy,
|
|
1066
|
+
storeSaid: said !== "",
|
|
1067
|
+
forEngineers
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// src/codeDependsRefusal.ts
|
|
1072
|
+
function codeDependsRefusal(error) {
|
|
1073
|
+
if (!error) return null;
|
|
1074
|
+
const d = error.detail;
|
|
1075
|
+
if (!d || d["code_depends"] !== true || typeof d["slug"] !== "string") return null;
|
|
1076
|
+
const where = d["declared_in"];
|
|
1077
|
+
const declaredIn = Array.isArray(where) ? where.map(String).join(", ") : typeof where === "string" ? where : null;
|
|
1078
|
+
return { slug: d["slug"], declaredIn };
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// src/announceTableArchived.ts
|
|
1082
|
+
var TableRestoreRefused = class extends Error {
|
|
1083
|
+
refusal;
|
|
1084
|
+
sentence;
|
|
1085
|
+
constructor(refusal) {
|
|
1086
|
+
const sentence = refusalSentence(refusal);
|
|
1087
|
+
super(sentence);
|
|
1088
|
+
this.name = "TableRestoreRefused";
|
|
1089
|
+
this.refusal = refusal;
|
|
1090
|
+
this.sentence = sentence;
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
function announceTableArchived({ notify, client, tableId, name, onRestored }) {
|
|
1094
|
+
const undo = async () => {
|
|
1095
|
+
const back = await client.tableRestoreWhole({ table_id: tableId });
|
|
1096
|
+
if (!back.ok) throw new TableRestoreRefused(back.error);
|
|
1097
|
+
onRestored?.();
|
|
1098
|
+
};
|
|
1099
|
+
if (notify?.reversible) {
|
|
1100
|
+
notify.reversible({ verb: "archive", noun: "table", subject: name, undo });
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
notify?.success(`Archived \u201C${name}\u201D`, {
|
|
1104
|
+
label: "Undo",
|
|
1105
|
+
run: () => {
|
|
1106
|
+
void undo().then(
|
|
1107
|
+
() => notify?.success(`Restored \u201C${name}\u201D`),
|
|
1108
|
+
// The store's refusal is already a person's sentence; anything else never prints raw.
|
|
1109
|
+
(thrown) => notify?.error(thrown instanceof TableRestoreRefused ? thrown.sentence : `Couldn\u2019t restore \u201C${name}\u201D`)
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// src/skeletonLayout.ts
|
|
1116
|
+
var RECORDS_SKELETON_LAYOUTS = [
|
|
1117
|
+
"grid",
|
|
1118
|
+
"kanban",
|
|
1119
|
+
"gallery",
|
|
1120
|
+
"list",
|
|
1121
|
+
"calendar",
|
|
1122
|
+
"timeline",
|
|
1123
|
+
"map",
|
|
1124
|
+
"orgchart",
|
|
1125
|
+
"form",
|
|
1126
|
+
"record",
|
|
1127
|
+
"chart",
|
|
1128
|
+
"home"
|
|
1129
|
+
];
|
|
1130
|
+
function skeletonLayoutFor(layout) {
|
|
1131
|
+
if (layout === "board" || layout === "pipeline") return "kanban";
|
|
1132
|
+
return RECORDS_SKELETON_LAYOUTS.includes(layout ?? "") ? layout : "grid";
|
|
1133
|
+
}
|
|
1134
|
+
function recordOf(table, row) {
|
|
1135
|
+
const document = row.document ?? {};
|
|
1136
|
+
return { id: row.id, title: recordNameIn(table, document), document };
|
|
1137
|
+
}
|
|
1138
|
+
function gridContextSnapshot(args) {
|
|
1139
|
+
const { table, rows } = args;
|
|
1140
|
+
const byKey = new Map(args.fields.map((f) => [f.key, f]));
|
|
1141
|
+
const fields = args.shownKeys.map((k) => byKey.get(k)).filter((f) => f !== void 0);
|
|
1142
|
+
const byId = new Map(rows.map((r) => [r.id, r]));
|
|
1143
|
+
let currentCell = null;
|
|
1144
|
+
if (args.editing) {
|
|
1145
|
+
currentCell = { rowId: args.editing.rowId, key: args.editing.key, value: args.editing.draft ?? null };
|
|
1146
|
+
} else if (args.cursor && byId.has(args.cursor.active.rowId) && byKey.has(args.cursor.active.columnId)) {
|
|
1147
|
+
const row = byId.get(args.cursor.active.rowId);
|
|
1148
|
+
const key = args.cursor.active.columnId;
|
|
1149
|
+
currentCell = { rowId: row.id, key, value: (row.document ?? {})[key] ?? null };
|
|
1150
|
+
}
|
|
1151
|
+
const currentRowSource = currentCell ? byId.get(currentCell.rowId) : void 0;
|
|
1152
|
+
let selectedRange = null;
|
|
1153
|
+
if (args.cursor && args.cursor.cellCount > 1) {
|
|
1154
|
+
const keys = args.cursor.columnIds.filter((k) => byKey.has(k));
|
|
1155
|
+
selectedRange = {
|
|
1156
|
+
tsv: `${toDelimited([keys], { format: "tsv", spreadsheetSafe: false })}
|
|
1157
|
+
${args.cursor.tsv}`,
|
|
1158
|
+
cellCount: args.cursor.cellCount,
|
|
1159
|
+
rowIds: args.cursor.rowIds.filter((id) => byId.has(id)),
|
|
1160
|
+
keys
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
const description = table?.metadata?.["description"];
|
|
1164
|
+
return {
|
|
1165
|
+
tableId: args.tableId,
|
|
1166
|
+
tableName: table ? tableName(table) : "",
|
|
1167
|
+
tableDescription: typeof description === "string" && description.trim() ? description : null,
|
|
1168
|
+
titleField: table?.title_field ?? null,
|
|
1169
|
+
fields,
|
|
1170
|
+
rowActions: [...args.rowActions],
|
|
1171
|
+
canWrite: args.canWrite,
|
|
1172
|
+
currentCell,
|
|
1173
|
+
currentRow: currentRowSource ? recordOf(table, currentRowSource) : null,
|
|
1174
|
+
selectedRange,
|
|
1175
|
+
selectedRows: args.selectedIds.map((id) => byId.get(id)).filter((r) => r !== void 0).map((r) => recordOf(table, r)),
|
|
1176
|
+
visibleRows: rows.map((r) => recordOf(table, r)),
|
|
1177
|
+
total: args.total,
|
|
1178
|
+
search: args.search
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
var OBJECT_ACTION_GROUPS = [
|
|
1182
|
+
{ id: "open", submenu: false },
|
|
1183
|
+
{ id: "organize", submenu: false },
|
|
1184
|
+
{ id: "share", submenu: false },
|
|
1185
|
+
{ id: "manage", submenu: false },
|
|
1186
|
+
{ id: "built-on", label: "Built on it", icon: "blocks", submenu: true },
|
|
1187
|
+
{ id: "danger", submenu: false }
|
|
1188
|
+
];
|
|
1189
|
+
var GROUP_IDS = new Set(OBJECT_ACTION_GROUPS.map((g) => g.id));
|
|
1190
|
+
var DEFAULT_ACTION_ORIGIN = "https://www.aimatrx.com";
|
|
1191
|
+
var ACTION_NOT_HERE_REASON = "Not available here";
|
|
1192
|
+
var ACTION_CHECKING_ACCESS_REASON = "Checking your access\u2026";
|
|
1193
|
+
var ACTION_NO_ACCESS_REASON = "You don't have access";
|
|
1194
|
+
function rightsReason(rights, what, table) {
|
|
1195
|
+
if (!rights.known) return ACTION_CHECKING_ACCESS_REASON;
|
|
1196
|
+
if (rights[what]) return null;
|
|
1197
|
+
if (rights.level === null) return ACTION_NO_ACCESS_REASON;
|
|
1198
|
+
return `Needs ${LEVEL_WORD[levelNeededFor(what)]} access`;
|
|
1199
|
+
}
|
|
1200
|
+
var TABLE_ACTION_CHORDS = {
|
|
1201
|
+
"copy-link": { code: "KeyL", chord: "alt+shift+l" },
|
|
1202
|
+
rename: { code: "KeyR", chord: "alt+shift+r" },
|
|
1203
|
+
duplicate: { code: "KeyD", chord: "alt+shift+d" },
|
|
1204
|
+
move: { code: "KeyM", chord: "alt+shift+m" },
|
|
1205
|
+
favorite: { code: "KeyF", chord: "alt+shift+f" },
|
|
1206
|
+
share: { code: "KeyS", chord: "alt+shift+s" },
|
|
1207
|
+
export: { code: "KeyE", chord: "alt+shift+e" },
|
|
1208
|
+
import: { code: "KeyI", chord: "alt+shift+i" },
|
|
1209
|
+
settings: { code: "Comma", chord: "alt+shift+," },
|
|
1210
|
+
history: { code: "KeyH", chord: "alt+shift+h" },
|
|
1211
|
+
archive: { code: "Backspace", chord: "alt+shift+backspace" }
|
|
1212
|
+
};
|
|
1213
|
+
Object.fromEntries(
|
|
1214
|
+
Object.entries(TABLE_ACTION_CHORDS).map(([id, { code, chord }]) => [id, { code, label: formatShortcut(chord) }])
|
|
1215
|
+
);
|
|
1216
|
+
function withExtensions(base2, extra) {
|
|
1217
|
+
if (extra.length === 0) return [...base2];
|
|
1218
|
+
const seen = new Set(base2.map((a) => a.id));
|
|
1219
|
+
for (const entry of extra) {
|
|
1220
|
+
if (entry.group === "danger") {
|
|
1221
|
+
throw new Error(`Object action "${entry.id}": the danger group is closed to extensions.`);
|
|
1222
|
+
}
|
|
1223
|
+
if (!GROUP_IDS.has(entry.group)) {
|
|
1224
|
+
throw new Error(`Object action "${entry.id}": "${String(entry.group)}" is not a group.`);
|
|
1225
|
+
}
|
|
1226
|
+
if (seen.has(entry.id)) {
|
|
1227
|
+
throw new Error(`Object action "${entry.id}" is already in the list.`);
|
|
1228
|
+
}
|
|
1229
|
+
seen.add(entry.id);
|
|
1230
|
+
}
|
|
1231
|
+
const out = [];
|
|
1232
|
+
for (const group of OBJECT_ACTION_GROUPS) {
|
|
1233
|
+
out.push(...base2.filter((a) => a.group === group.id), ...extra.filter((a) => a.group === group.id));
|
|
1234
|
+
}
|
|
1235
|
+
return out;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// src/recordActions.ts
|
|
1239
|
+
function recordLink(tableId, recordId, origin = DEFAULT_ACTION_ORIGIN) {
|
|
1240
|
+
return `${origin.replace(/\/+$/, "")}/data/${encodeURIComponent(tableId)}?record=${encodeURIComponent(recordId)}`;
|
|
1241
|
+
}
|
|
1242
|
+
var NOOP = () => {
|
|
1243
|
+
};
|
|
1244
|
+
function action(base2, needs, input, perform) {
|
|
1245
|
+
const refused = rightsReason(input.rights, needs);
|
|
1246
|
+
if (refused !== null) return { ...base2, disabledReason: refused, run: NOOP };
|
|
1247
|
+
if (perform === void 0) {
|
|
1248
|
+
return { ...base2, disabledReason: input.host.unavailableReasons?.[base2.id] ?? ACTION_NOT_HERE_REASON, run: NOOP };
|
|
1249
|
+
}
|
|
1250
|
+
return { ...base2, run: perform };
|
|
1251
|
+
}
|
|
1252
|
+
function bind(handler, record) {
|
|
1253
|
+
return handler ? () => handler(record) : void 0;
|
|
1254
|
+
}
|
|
1255
|
+
function recordActions(input) {
|
|
1256
|
+
const { record, host } = input;
|
|
1257
|
+
const origin = (host.origin ?? DEFAULT_ACTION_ORIGIN).replace(/\/+$/, "");
|
|
1258
|
+
const url = host.href ? /^https?:/.test(host.href) ? host.href : `${origin}${host.href}` : recordLink(record.tableId, record.id, host.origin);
|
|
1259
|
+
const openInNewTab = host.openInNewTab;
|
|
1260
|
+
const copyText = host.copyText;
|
|
1261
|
+
const built = [
|
|
1262
|
+
action({ id: "open", label: "Open", icon: "folder-open", group: "open", verb: "open" }, "read", input, bind(host.open, record)),
|
|
1263
|
+
action(
|
|
1264
|
+
{ id: "open-new-tab", label: "Open in new tab", icon: "external-link", group: "open", verb: "open-new-tab" },
|
|
1265
|
+
"read",
|
|
1266
|
+
input,
|
|
1267
|
+
openInNewTab ? () => openInNewTab(url, record) : void 0
|
|
1268
|
+
),
|
|
1269
|
+
action(
|
|
1270
|
+
{ id: "copy-link", label: "Copy link", icon: "link", group: "open", verb: "copy-link" },
|
|
1271
|
+
"read",
|
|
1272
|
+
input,
|
|
1273
|
+
copyText ? () => copyText(url, record) : void 0
|
|
1274
|
+
),
|
|
1275
|
+
action({ id: "duplicate", label: "Duplicate", icon: "copy", group: "organize", verb: "duplicate" }, "organise", input, bind(host.duplicate, record)),
|
|
1276
|
+
action(
|
|
1277
|
+
{ id: "merge", label: "Merge with\u2026", icon: "git-merge", group: "organize" },
|
|
1278
|
+
"organise",
|
|
1279
|
+
input,
|
|
1280
|
+
bind(host.merge, record)
|
|
1281
|
+
),
|
|
1282
|
+
action({ id: "split", label: "Split\u2026", icon: "split", group: "organize" }, "organise", input, bind(host.split, record)),
|
|
1283
|
+
action(
|
|
1284
|
+
{ id: "extract-parent", label: "Extract parent\u2026", icon: "arrow-up-from-line", group: "organize" },
|
|
1285
|
+
"organise",
|
|
1286
|
+
input,
|
|
1287
|
+
bind(host.extractParent, record)
|
|
1288
|
+
),
|
|
1289
|
+
// A link is an edge beside the record, never a change to it: reading the record is enough.
|
|
1290
|
+
action({ id: "link-record", label: "Link a record\u2026", icon: "link-2", group: "organize" }, "read", input, bind(host.link, record)),
|
|
1291
|
+
action({ id: "history", label: "History", icon: "history", group: "manage", verb: "history" }, "read", input, bind(host.history, record)),
|
|
1292
|
+
action(
|
|
1293
|
+
{ id: "archive", label: "Archive record", icon: "archive", group: "danger", destructive: true, verb: "archive" },
|
|
1294
|
+
"remove",
|
|
1295
|
+
input,
|
|
1296
|
+
bind(host.archive, record)
|
|
1297
|
+
)
|
|
1298
|
+
];
|
|
1299
|
+
return withExtensions(built, host.extend ? host.extend(record, input.rights) : []);
|
|
1300
|
+
}
|
|
556
1301
|
|
|
557
|
-
export { NO_RIGHTS, PARITY_LABEL, PARITY_MADE_OF, SOMEBODY, THE_SYSTEM, UNREAD_RECORD_LABEL, WITHHELD_RECORD_LABEL, WITHHELD_WORD, actorBadge, actorWords, cardTitleField, editorKindFor, fieldName, fieldTypeLabel, getPersonTimeZone, isKeptTable, isValueSet, lastChangeSentence, looksLikeId, personActor, personWallNow, pickableTypeOf, recordName, recordNameIn, recordsDataSource, resolveTableStyle, rowName, rowNameIn, setPersonTimeZone, singularNoun, styleFromDecorations, subscribePersonTimeZone, tableName, tablePickerEntries, tableRightsAt, whenWords, withheldNoticeOf, withheldSentence };
|
|
1302
|
+
export { ADDABLE_TYPES as CUSTOM_FIELD_ADDABLE_TYPES, FIELD_SENSITIVITY_LABEL, NO_RIGHTS, PARITY_LABEL, PARITY_MADE_OF, RECORDS_SKELETON_LAYOUTS, SOMEBODY, THE_SYSTEM, UNREAD_RECORD_LABEL, VIEW_ADDRESS_KEYS, WITHHELD_RECORD_LABEL, WITHHELD_WORD, actorBadge, actorWords, announceTableArchived, bodyFieldOf, cardTitleField, codeDependsRefusal, editorKindFor, fieldName, fieldTypeLabel, getPersonTimeZone, googleCalendarUrl, gridContextSnapshot, isInterface, isKeptTable, isPage, isValueSet, isViewAddressEmpty, laneFor, lastChangeSentence, looksLikeId, personActor, personWallNow, pickableTypeOf, platformOwned, readLooks, recordActions, recordName, recordNameIn, recordsDataSource, refusalForAPerson, resolveTableStyle, rowName, rowNameIn, sameViewAddress, setPersonTimeZone, singularNoun, skeletonLayoutFor, styleFromDecorations, subscribePersonTimeZone, tableName, tablePickerEntries, tableRightsAt, viewAddressFromParams, viewAddressToParams, viewFromRow, webcalUrl, whatYouMayDo, whenWords, withheldNoticeOf, withheldSentence };
|
|
558
1303
|
//# sourceMappingURL=helpers.js.map
|
|
559
1304
|
//# sourceMappingURL=helpers.js.map
|