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