@ai-matrx/records-ui 0.115.43 → 0.115.44
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 +6 -0
- package/dist/index.cjs +2528 -2358
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +291 -121
- package/dist/index.js.map +1 -1
- package/dist/object-actions.cjs.map +1 -1
- package/dist/object-actions.d.cts +1 -1
- package/dist/object-actions.d.ts +1 -1
- package/dist/object-actions.js.map +1 -1
- package/dist/{objectActions-ac0_y8UY.d.cts → objectActions-Ds2NA5Jn.d.cts} +1 -1
- package/dist/{objectActions-ac0_y8UY.d.ts → objectActions-Ds2NA5Jn.d.ts} +1 -1
- package/dist/pickers.cjs +102 -7
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +102 -7
- package/dist/pickers.js.map +1 -1
- package/package.json +3 -3
package/dist/pickers.js
CHANGED
|
@@ -2063,6 +2063,29 @@ function columnNameTakenBy(name, others) {
|
|
|
2063
2063
|
function columnNameTakenLine(taken, noun = "column") {
|
|
2064
2064
|
return `Another ${noun} is already called \u201C${taken}\u201D`;
|
|
2065
2065
|
}
|
|
2066
|
+
var COLUMN_NAME_MAX = 80;
|
|
2067
|
+
var KEPT_NAMES = {
|
|
2068
|
+
id: "Reference number",
|
|
2069
|
+
created_at: "Date added",
|
|
2070
|
+
updated_at: "Last updated",
|
|
2071
|
+
deleted_at: "Date removed",
|
|
2072
|
+
created_by: "Added by",
|
|
2073
|
+
updated_by: "Changed by",
|
|
2074
|
+
organization_id: "Organization",
|
|
2075
|
+
table_id: "Table",
|
|
2076
|
+
version: "Version number",
|
|
2077
|
+
data: "Details",
|
|
2078
|
+
metadata: "More details",
|
|
2079
|
+
data_class: "Category"
|
|
2080
|
+
};
|
|
2081
|
+
var asKept = (name) => said(name).toLowerCase().replace(/[^a-z0-9\s_]/g, "").replace(/\s+/g, "_").replace(/^_+|_+$/g, "").replace(/_+/g, "_");
|
|
2082
|
+
function columnNameProblemLine(name, noun = "column") {
|
|
2083
|
+
const wanted = said(name);
|
|
2084
|
+
if (wanted === "") return null;
|
|
2085
|
+
if (wanted.length > COLUMN_NAME_MAX) return `${wanted.length} characters; a ${noun} name takes up to ${COLUMN_NAME_MAX}`;
|
|
2086
|
+
const instead = KEPT_NAMES[asKept(wanted)];
|
|
2087
|
+
return instead ? `\u201C${wanted}\u201D is kept by every table. Try \u201C${instead}\u201D` : null;
|
|
2088
|
+
}
|
|
2066
2089
|
|
|
2067
2090
|
// src/FieldEditor.tsx
|
|
2068
2091
|
import { useEffect as useEffect17, useMemo as useMemo10, useRef as useRef12, useState as useState23 } from "react";
|
|
@@ -2588,6 +2611,7 @@ function FormulaTextEditor({
|
|
|
2588
2611
|
onChecked,
|
|
2589
2612
|
columns,
|
|
2590
2613
|
sampleRecordId,
|
|
2614
|
+
purpose,
|
|
2591
2615
|
className
|
|
2592
2616
|
}) {
|
|
2593
2617
|
const client = useRecordsClient4();
|
|
@@ -2663,7 +2687,8 @@ function FormulaTextEditor({
|
|
|
2663
2687
|
columns,
|
|
2664
2688
|
mistake: parsed && !parsed.ok ? parsed.error : error ? refusalSentence(error) : null,
|
|
2665
2689
|
functions: FORMULA_FUNCTION_NAMES,
|
|
2666
|
-
onFormula: onText
|
|
2690
|
+
onFormula: onText,
|
|
2691
|
+
...purpose ? { purpose } : {}
|
|
2667
2692
|
}) }) : null
|
|
2668
2693
|
] }),
|
|
2669
2694
|
/* @__PURE__ */ jsx12(
|
|
@@ -6173,6 +6198,12 @@ var KINDS_WITH_A_DEFAULT = /* @__PURE__ */ new Set([
|
|
|
6173
6198
|
function takesADefault(field) {
|
|
6174
6199
|
return KINDS_WITH_A_DEFAULT.has(String(pickableTypeOf(field) ?? editorKindFor(field)));
|
|
6175
6200
|
}
|
|
6201
|
+
function newColumnTakesADefault(type) {
|
|
6202
|
+
return KINDS_WITH_A_DEFAULT.has(type);
|
|
6203
|
+
}
|
|
6204
|
+
function newColumnDefaultGoes(type) {
|
|
6205
|
+
return type === "select" || type === "multi_select" || type === "status" ? "right-after" : "in-the-create";
|
|
6206
|
+
}
|
|
6176
6207
|
function defaultToKeep(value) {
|
|
6177
6208
|
if (value === void 0 || value === null) return null;
|
|
6178
6209
|
if (typeof value === "string") {
|
|
@@ -6358,6 +6389,10 @@ function FieldEditor(props) {
|
|
|
6358
6389
|
const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
|
|
6359
6390
|
const choice = fieldTypeChoice(type);
|
|
6360
6391
|
const editing = Boolean(field);
|
|
6392
|
+
useEffect17(() => {
|
|
6393
|
+
if (!editing) setStartsWith(null);
|
|
6394
|
+
}, [type, editing]);
|
|
6395
|
+
const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
|
|
6361
6396
|
const farFieldsOfLink = useFields2(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6362
6397
|
const farTable = useTable(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6363
6398
|
const linkReaders = useMemo10(
|
|
@@ -6378,6 +6413,7 @@ function FieldEditor(props) {
|
|
|
6378
6413
|
const formulaMissing = type !== "formula" || !formulaWritten ? null : editing && !formulaChanged ? null : formulaText.trim() === "" ? "Write the formula this column works out." : formulaOk === false ? "The formula has a mistake \u2014 it is marked above." : formulaOk === null ? "Checking the formula\u2026" : null;
|
|
6379
6414
|
const noun = onEntity ? "field" : "column";
|
|
6380
6415
|
const nameTaken = columnNameTakenBy(label, others.map(fieldName));
|
|
6416
|
+
const nameLine = nameTaken ? columnNameTakenLine(nameTaken, noun) : columnNameProblemLine(label, noun);
|
|
6381
6417
|
const listsChoices = type === "select" || type === "multi_select" || type === "status";
|
|
6382
6418
|
const buttonMissing = type === "button" && buttonSettings.do ? buttonNeeds(buttonSettings) : null;
|
|
6383
6419
|
const missing = buttonMissing ?? (editing ? formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(choiceList) : null) : formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(newChoices) : null) ?? (type === "formula" && formulaWritten ? null : whatIsMissing(
|
|
@@ -6517,6 +6553,7 @@ function FieldEditor(props) {
|
|
|
6517
6553
|
...type === "rollup" ? { via, agg, ...agg === "count" ? {} : { of }, ...rollupFilter ? { filter: rollupFilter } : {} } : {},
|
|
6518
6554
|
...type === "formula" ? formulaWritten ? { formula_text: formulaText.trim() } : { expr: formulaExpression(formulaOp, formulaFields, formulaSeparator) } : {}
|
|
6519
6555
|
};
|
|
6556
|
+
if (newDefault !== null && newColumnDefaultGoes(type) === "in-the-create") spec.default = newDefault;
|
|
6520
6557
|
const written = onEntity ? await entityMutation.declare({ token: entityToken, spec }) : await tableMutation.declare({ table_id: tableId, spec });
|
|
6521
6558
|
if (written === null) return;
|
|
6522
6559
|
const landed = onEntity ? await client.entityFields({ token: entityToken }) : await client.fields({ table_id: tableId });
|
|
@@ -6525,6 +6562,14 @@ function FieldEditor(props) {
|
|
|
6525
6562
|
return;
|
|
6526
6563
|
}
|
|
6527
6564
|
setNotLanded(false);
|
|
6565
|
+
if (newDefault !== null && newColumnDefaultGoes(type) === "right-after") {
|
|
6566
|
+
const defaulted = await client.fieldUpdate({ field_id: written, patch: { default: newDefault } });
|
|
6567
|
+
if (!defaulted.ok) {
|
|
6568
|
+
tableShapeChanged3(tableId);
|
|
6569
|
+
setBackfillError(defaulted.error);
|
|
6570
|
+
return;
|
|
6571
|
+
}
|
|
6572
|
+
}
|
|
6528
6573
|
if (type === "autonumber") {
|
|
6529
6574
|
const numbered = await client.autonumberBackfill({ field_id: written });
|
|
6530
6575
|
if (!numbered.ok) {
|
|
@@ -6578,10 +6623,19 @@ function FieldEditor(props) {
|
|
|
6578
6623
|
if (to?.textContent === "Cancel") return;
|
|
6579
6624
|
setAttempted(true);
|
|
6580
6625
|
},
|
|
6581
|
-
...
|
|
6626
|
+
...nameLine ? { "aria-invalid": true, "aria-describedby": "field-editor-name-taken" } : {}
|
|
6582
6627
|
}
|
|
6583
6628
|
),
|
|
6584
|
-
|
|
6629
|
+
nameLine ? /* @__PURE__ */ jsx32(
|
|
6630
|
+
"span",
|
|
6631
|
+
{
|
|
6632
|
+
id: "field-editor-name-taken",
|
|
6633
|
+
...nameTaken ? { "data-field-editor-name-taken": "" } : { "data-field-editor-name-problem": "" },
|
|
6634
|
+
className: "truncate text-[11px] text-destructive",
|
|
6635
|
+
title: nameLine,
|
|
6636
|
+
children: nameLine
|
|
6637
|
+
}
|
|
6638
|
+
) : null
|
|
6585
6639
|
] }),
|
|
6586
6640
|
/* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
|
|
6587
6641
|
/* @__PURE__ */ jsx32(Label8, { className: "text-xs", children: "What it holds" }),
|
|
@@ -6793,6 +6847,7 @@ function FieldEditor(props) {
|
|
|
6793
6847
|
"A value that is not one of the choices is added to them"
|
|
6794
6848
|
] }) : null
|
|
6795
6849
|
] }),
|
|
6850
|
+
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */ jsx32(NewColumnDefault, { type, choices: options, value: startsWith, onChange: setStartsWith }) : null,
|
|
6796
6851
|
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", "data-records-field-default": "", children: [
|
|
6797
6852
|
/* @__PURE__ */ jsx32(Label8, { htmlFor: "records-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
6798
6853
|
/* @__PURE__ */ jsx32(
|
|
@@ -7351,6 +7406,35 @@ function entityReferenceKindsOf(field) {
|
|
|
7351
7406
|
const raw = (field?.config ?? {})["allowed_types"];
|
|
7352
7407
|
return Array.isArray(raw) ? raw.filter((t) => typeof t === "string") : [];
|
|
7353
7408
|
}
|
|
7409
|
+
function NewColumnDefault({
|
|
7410
|
+
type,
|
|
7411
|
+
choices,
|
|
7412
|
+
value,
|
|
7413
|
+
onChange
|
|
7414
|
+
}) {
|
|
7415
|
+
const none = "__none__";
|
|
7416
|
+
return /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", "data-records-field-default": "", "data-records-new-field-default": "", children: [
|
|
7417
|
+
/* @__PURE__ */ jsx32(Label8, { htmlFor: "records-new-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
7418
|
+
type === "checkbox" ? /* @__PURE__ */ jsxs30("label", { className: "flex items-center gap-2", children: [
|
|
7419
|
+
/* @__PURE__ */ jsx32(Checkbox4, { id: "records-new-field-default", "aria-label": DEFAULT_LABEL, checked: value === true, onCheckedChange: (on) => onChange(on === true ? true : null) }),
|
|
7420
|
+
/* @__PURE__ */ jsx32("span", { children: "Ticked" })
|
|
7421
|
+
] }) : type === "select" || type === "multi_select" || type === "status" ? /* @__PURE__ */ jsxs30(Select6, { value: typeof value === "string" && choices.includes(value) ? value : none, onValueChange: (v) => onChange(v === none ? null : v), children: [
|
|
7422
|
+
/* @__PURE__ */ jsx32(SelectTrigger6, { id: "records-new-field-default", size: "sm", "aria-label": DEFAULT_LABEL, children: /* @__PURE__ */ jsx32(SelectValue6, {}) }),
|
|
7423
|
+
/* @__PURE__ */ jsxs30(SelectContent6, { children: [
|
|
7424
|
+
/* @__PURE__ */ jsx32(SelectItem6, { value: none, children: "Nothing" }),
|
|
7425
|
+
choices.map((c) => /* @__PURE__ */ jsx32(SelectItem6, { value: c, children: c }, c))
|
|
7426
|
+
] })
|
|
7427
|
+
] }) : /* @__PURE__ */ jsx32(
|
|
7428
|
+
BasicInput9,
|
|
7429
|
+
{
|
|
7430
|
+
id: "records-new-field-default",
|
|
7431
|
+
value: typeof value === "string" ? value : value === null || value === void 0 ? "" : String(value),
|
|
7432
|
+
placeholder: "Nothing",
|
|
7433
|
+
onChange: (e) => onChange(e.target.value)
|
|
7434
|
+
}
|
|
7435
|
+
)
|
|
7436
|
+
] });
|
|
7437
|
+
}
|
|
7354
7438
|
|
|
7355
7439
|
// src/buttonCell.tsx
|
|
7356
7440
|
import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
@@ -8254,6 +8338,17 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
|
|
|
8254
8338
|
case "json":
|
|
8255
8339
|
return /* @__PURE__ */ jsx38(JsonControl, { field, value, onChange, disabled, id: inputId });
|
|
8256
8340
|
case "long_text":
|
|
8341
|
+
if (host.textBox) {
|
|
8342
|
+
return host.textBox({
|
|
8343
|
+
value: value === null || value === void 0 ? "" : String(value),
|
|
8344
|
+
onChange: (next) => onChange(next === "" ? null : next),
|
|
8345
|
+
label: fieldName(field),
|
|
8346
|
+
rows: 3,
|
|
8347
|
+
where: asForm ? "form" : "cell",
|
|
8348
|
+
id: inputId,
|
|
8349
|
+
disabled
|
|
8350
|
+
});
|
|
8351
|
+
}
|
|
8257
8352
|
return /* @__PURE__ */ jsx38(
|
|
8258
8353
|
BasicTextarea4,
|
|
8259
8354
|
{
|
|
@@ -8989,10 +9084,10 @@ function TablePicker({ dataSource, value, onChange, disabled, tables }) {
|
|
|
8989
9084
|
const pickerOptions = options.map((t) => {
|
|
8990
9085
|
const twin = (sameName.get(`${t.organization_id}|${t.table_name.trim().toLowerCase()}`) ?? 0) > 1;
|
|
8991
9086
|
const row = t;
|
|
8992
|
-
const
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
].filter(Boolean).join(" \xB7 ");
|
|
9087
|
+
const secondOf = (r) => [r.created_by_name ? `by ${r.created_by_name}` : null, r.updated_at ? `changed ${new Date(r.updated_at).toLocaleDateString()}` : null].filter(Boolean).join(" \xB7 ");
|
|
9088
|
+
const base = secondOf(row);
|
|
9089
|
+
const alike = options.filter((o) => o.organization_id === t.organization_id && o.table_name.trim().toLowerCase() === t.table_name.trim().toLowerCase() && secondOf(o) === base).length;
|
|
9090
|
+
const second = alike > 1 ? [base, `#${t.table_id.slice(0, 4)}`].filter(Boolean).join(" \xB7 ") : base;
|
|
8996
9091
|
return {
|
|
8997
9092
|
value: t.table_id,
|
|
8998
9093
|
// The organization hint already tells two same-named tables apart across organizations.
|