@ai-matrx/records-ui 0.93.153 → 0.95.3
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 +89 -0
- package/dist/index.cjs +9633 -6279
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +413 -50
- package/dist/index.d.ts +413 -50
- package/dist/index.js +9369 -5970
- package/dist/index.js.map +1 -1
- package/dist/object-actions.cjs +34 -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 +34 -1
- package/dist/object-actions.js.map +1 -1
- package/dist/{objectActions-Dgdr0E4b.d.cts → objectActions-DozKWxks.d.cts} +27 -1
- package/dist/{objectActions-Dgdr0E4b.d.ts → objectActions-DozKWxks.d.ts} +27 -1
- package/dist/pickers.cjs +119 -87
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.d.cts +4 -1
- package/dist/pickers.d.ts +4 -1
- package/dist/pickers.js +120 -88
- package/dist/pickers.js.map +1 -1
- package/package.json +3 -3
package/dist/pickers.cjs
CHANGED
|
@@ -409,6 +409,59 @@ function BarcodeControl({ value, onChange, disabled, id }) {
|
|
|
409
409
|
] });
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
+
// src/choiceLooks.ts
|
|
413
|
+
var import_data_table = require("@ai-matrx/design-system/data-table");
|
|
414
|
+
function displayFormatOf(field) {
|
|
415
|
+
const raw = field.display_format;
|
|
416
|
+
if (!raw || typeof raw !== "object") return null;
|
|
417
|
+
const id = raw.id;
|
|
418
|
+
if (typeof id !== "string" || id === "") return null;
|
|
419
|
+
const options = raw.options;
|
|
420
|
+
return { id, options: options && typeof options === "object" ? options : {} };
|
|
421
|
+
}
|
|
422
|
+
function isStyleColor(v) {
|
|
423
|
+
return typeof v === "string" && import_data_table.STYLE_COLORS.includes(v);
|
|
424
|
+
}
|
|
425
|
+
function choiceLooksOf(field) {
|
|
426
|
+
const display = displayFormatOf(field);
|
|
427
|
+
const choices = display?.options["choices"];
|
|
428
|
+
if (!Array.isArray(choices)) return [];
|
|
429
|
+
const out = [];
|
|
430
|
+
for (const c of choices) {
|
|
431
|
+
if (!c || typeof c !== "object") continue;
|
|
432
|
+
const value = c.value;
|
|
433
|
+
if (typeof value !== "string" || value.trim() === "") continue;
|
|
434
|
+
const color = c.color;
|
|
435
|
+
const label = c.label;
|
|
436
|
+
out.push({
|
|
437
|
+
value: value.trim(),
|
|
438
|
+
...typeof label === "string" && label.trim() !== "" ? { label: label.trim() } : {},
|
|
439
|
+
...isStyleColor(color) ? { color } : {}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
return out;
|
|
443
|
+
}
|
|
444
|
+
function choiceWord(value) {
|
|
445
|
+
return String(value ?? "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
446
|
+
}
|
|
447
|
+
function storedChoiceColor(field, value) {
|
|
448
|
+
if (value === null || value === void 0 || value === "") return void 0;
|
|
449
|
+
const word = choiceWord(value);
|
|
450
|
+
if (word === "") return void 0;
|
|
451
|
+
for (const look of choiceLooksOf(field)) {
|
|
452
|
+
if (!look.color) continue;
|
|
453
|
+
if (choiceWord(look.value) === word || look.label && choiceWord(look.label) === word) return look.color;
|
|
454
|
+
}
|
|
455
|
+
return void 0;
|
|
456
|
+
}
|
|
457
|
+
function choiceChipLookOf(field, ...words) {
|
|
458
|
+
for (const word of words) {
|
|
459
|
+
const color = storedChoiceColor(field, word);
|
|
460
|
+
if (color) return { className: import_data_table.CHOICE_CHIP_CLASS[color], color };
|
|
461
|
+
}
|
|
462
|
+
return { className: import_data_table.NEUTRAL_CHIP_CLASS, color: null };
|
|
463
|
+
}
|
|
464
|
+
|
|
412
465
|
// src/parity.ts
|
|
413
466
|
var import_records2 = require("@ai-matrx/records");
|
|
414
467
|
var import_text_case = require("@ai-matrx/kit/text-case");
|
|
@@ -2437,7 +2490,7 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
|
|
|
2437
2490
|
}
|
|
2438
2491
|
|
|
2439
2492
|
// src/presentation.ts
|
|
2440
|
-
var
|
|
2493
|
+
var import_data_table2 = require("@ai-matrx/design-system/data-table");
|
|
2441
2494
|
var import_field_formats2 = require("@ai-matrx/design-system/field-formats");
|
|
2442
2495
|
var import_records8 = require("@ai-matrx/records");
|
|
2443
2496
|
var DRAWN_KINDS = /* @__PURE__ */ new Set(["select", "multi_select", "relation", "member", "person", "attachment", "file", "entity_reference", "checkbox", "boolean", "signature", "json"]);
|
|
@@ -2505,7 +2558,7 @@ var import_field_formats4 = require("@ai-matrx/design-system/field-formats");
|
|
|
2505
2558
|
|
|
2506
2559
|
// src/formattedValue.tsx
|
|
2507
2560
|
var import_react19 = require("react");
|
|
2508
|
-
var
|
|
2561
|
+
var import_data_table3 = require("@ai-matrx/design-system/data-table");
|
|
2509
2562
|
var import_field_formats3 = require("@ai-matrx/design-system/field-formats");
|
|
2510
2563
|
var import_design_system11 = require("@ai-matrx/design-system");
|
|
2511
2564
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
@@ -2580,7 +2633,7 @@ function rich(id, text, raw, format) {
|
|
|
2580
2633
|
case "url":
|
|
2581
2634
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("a", { href: text.includes("://") ? text : `https://${text}`, target: "_blank", rel: "noopener noreferrer", className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate", children: text }) });
|
|
2582
2635
|
case "phone":
|
|
2583
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("a", { href: `tel:${text.replace(/[^\d+]/g, "")}`, className: LINK, onClick: own2, title: text, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate tabular-nums", children: formatPhone(text) }) });
|
|
2636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("a", { href: `tel:${text.replace(/[^\d+]/g, "")}`, className: LINK, onClick: own2, title: text, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate tabular-nums", children: (0, import_field_formats3.formatPhone)(text) }) });
|
|
2584
2637
|
case "address":
|
|
2585
2638
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2586
2639
|
"a",
|
|
@@ -2643,18 +2696,8 @@ function FormattedValue({
|
|
|
2643
2696
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(RatingStars, { value, max: format.options?.ratingMax ?? 5, onRate, selectFirst });
|
|
2644
2697
|
}
|
|
2645
2698
|
const result = (0, import_field_formats3.formatFieldValue)(value, format);
|
|
2646
|
-
if (!result.ok || result.empty || !def?.rich) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2647
|
-
return rich(def.id, result.text, value, format) ?? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2648
|
-
}
|
|
2649
|
-
function formatPhone(raw) {
|
|
2650
|
-
const text = raw.trim();
|
|
2651
|
-
const digits = text.replace(/\D/g, "");
|
|
2652
|
-
if (/[a-z]/i.test(text.replace(/ext\.?|x/gi, ""))) return text;
|
|
2653
|
-
if (digits.length === 10 && !text.startsWith("+")) return `(${digits.slice(0, 3)}) ${digits.slice(3, 6)}-${digits.slice(6)}`;
|
|
2654
|
-
if (digits.length === 11 && digits.startsWith("1") && (text.startsWith("+1") || text.startsWith("1") || !text.startsWith("+"))) {
|
|
2655
|
-
return `+1 (${digits.slice(1, 4)}) ${digits.slice(4, 7)}-${digits.slice(7)}`;
|
|
2656
|
-
}
|
|
2657
|
-
return text;
|
|
2699
|
+
if (!result.ok || result.empty || !def?.rich) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_data_table3.FormattedCell, { result });
|
|
2700
|
+
return rich(def.id, result.text, value, format) ?? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_data_table3.FormattedCell, { result });
|
|
2658
2701
|
}
|
|
2659
2702
|
function linkChipText(raw) {
|
|
2660
2703
|
try {
|
|
@@ -2940,59 +2983,6 @@ function useChoiceNudge(enabled = true) {
|
|
|
2940
2983
|
return nudge;
|
|
2941
2984
|
}
|
|
2942
2985
|
|
|
2943
|
-
// src/choiceLooks.ts
|
|
2944
|
-
var import_data_table3 = require("@ai-matrx/design-system/data-table");
|
|
2945
|
-
function displayFormatOf(field) {
|
|
2946
|
-
const raw = field.display_format;
|
|
2947
|
-
if (!raw || typeof raw !== "object") return null;
|
|
2948
|
-
const id = raw.id;
|
|
2949
|
-
if (typeof id !== "string" || id === "") return null;
|
|
2950
|
-
const options = raw.options;
|
|
2951
|
-
return { id, options: options && typeof options === "object" ? options : {} };
|
|
2952
|
-
}
|
|
2953
|
-
function isStyleColor(v) {
|
|
2954
|
-
return typeof v === "string" && import_data_table3.STYLE_COLORS.includes(v);
|
|
2955
|
-
}
|
|
2956
|
-
function choiceLooksOf(field) {
|
|
2957
|
-
const display = displayFormatOf(field);
|
|
2958
|
-
const choices = display?.options["choices"];
|
|
2959
|
-
if (!Array.isArray(choices)) return [];
|
|
2960
|
-
const out = [];
|
|
2961
|
-
for (const c of choices) {
|
|
2962
|
-
if (!c || typeof c !== "object") continue;
|
|
2963
|
-
const value = c.value;
|
|
2964
|
-
if (typeof value !== "string" || value.trim() === "") continue;
|
|
2965
|
-
const color = c.color;
|
|
2966
|
-
const label = c.label;
|
|
2967
|
-
out.push({
|
|
2968
|
-
value: value.trim(),
|
|
2969
|
-
...typeof label === "string" && label.trim() !== "" ? { label: label.trim() } : {},
|
|
2970
|
-
...isStyleColor(color) ? { color } : {}
|
|
2971
|
-
});
|
|
2972
|
-
}
|
|
2973
|
-
return out;
|
|
2974
|
-
}
|
|
2975
|
-
function choiceWord(value) {
|
|
2976
|
-
return String(value ?? "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
2977
|
-
}
|
|
2978
|
-
function storedChoiceColor(field, value) {
|
|
2979
|
-
if (value === null || value === void 0 || value === "") return void 0;
|
|
2980
|
-
const word = choiceWord(value);
|
|
2981
|
-
if (word === "") return void 0;
|
|
2982
|
-
for (const look of choiceLooksOf(field)) {
|
|
2983
|
-
if (!look.color) continue;
|
|
2984
|
-
if (choiceWord(look.value) === word || look.label && choiceWord(look.label) === word) return look.color;
|
|
2985
|
-
}
|
|
2986
|
-
return void 0;
|
|
2987
|
-
}
|
|
2988
|
-
function choiceChipLookOf(field, ...words) {
|
|
2989
|
-
for (const word of words) {
|
|
2990
|
-
const color = storedChoiceColor(field, word);
|
|
2991
|
-
if (color) return { className: import_data_table3.CHOICE_CHIP_CLASS[color], color };
|
|
2992
|
-
}
|
|
2993
|
-
return { className: import_data_table3.NEUTRAL_CHIP_CLASS, color: null };
|
|
2994
|
-
}
|
|
2995
|
-
|
|
2996
2986
|
// src/editors.tsx
|
|
2997
2987
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2998
2988
|
var CHOICE_EDITOR_ADDS_WHAT_IS_TYPED = true;
|
|
@@ -3894,25 +3884,43 @@ function madeOn(stamp) {
|
|
|
3894
3884
|
|
|
3895
3885
|
// src/TablePickers.tsx
|
|
3896
3886
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3887
|
+
var SHARED_FOR_MS = 5e3;
|
|
3888
|
+
var sharedReads = /* @__PURE__ */ new WeakMap();
|
|
3889
|
+
function readTablesAnywhere(dataSource) {
|
|
3890
|
+
const held = sharedReads.get(dataSource);
|
|
3891
|
+
if (held && Date.now() - held.at < SHARED_FOR_MS) return held.read;
|
|
3892
|
+
const read = Promise.resolve(dataSource.rpc("data_home_tables", {}, { schema: "custom" })).then(
|
|
3893
|
+
({ data, error }) => {
|
|
3894
|
+
if (error) {
|
|
3895
|
+
return {
|
|
3896
|
+
loading: false,
|
|
3897
|
+
error: refusalSentence({ message: String(error["message"] ?? "") }) || "Tables could not be read.",
|
|
3898
|
+
rows: []
|
|
3899
|
+
};
|
|
3900
|
+
}
|
|
3901
|
+
const rows = (Array.isArray(data) ? data : []).slice();
|
|
3902
|
+
rows.sort((a, b) => a.table_name.localeCompare(b.table_name));
|
|
3903
|
+
return { loading: false, error: null, rows };
|
|
3904
|
+
},
|
|
3905
|
+
(thrown) => ({
|
|
3906
|
+
loading: false,
|
|
3907
|
+
error: String(thrown?.message ?? thrown) || "Tables could not be read.",
|
|
3908
|
+
rows: []
|
|
3909
|
+
})
|
|
3910
|
+
);
|
|
3911
|
+
sharedReads.set(dataSource, { at: Date.now(), read });
|
|
3912
|
+
void read.then((result) => {
|
|
3913
|
+
if (result.error && sharedReads.get(dataSource)?.read === read) sharedReads.delete(dataSource);
|
|
3914
|
+
});
|
|
3915
|
+
return read;
|
|
3916
|
+
}
|
|
3897
3917
|
function useTablesAnywhere(dataSource) {
|
|
3898
3918
|
const [state, setState] = (0, import_react30.useState)({ loading: true, error: null, rows: [] });
|
|
3899
3919
|
(0, import_react30.useEffect)(() => {
|
|
3900
3920
|
let live = true;
|
|
3901
|
-
void
|
|
3902
|
-
(
|
|
3903
|
-
|
|
3904
|
-
if (error) {
|
|
3905
|
-
setState({ loading: false, error: refusalSentence({ message: String(error["message"] ?? "") }) || "Tables could not be read.", rows: [] });
|
|
3906
|
-
return;
|
|
3907
|
-
}
|
|
3908
|
-
const rows = (Array.isArray(data) ? data : []).slice();
|
|
3909
|
-
rows.sort((a, b) => a.table_name.localeCompare(b.table_name));
|
|
3910
|
-
setState({ loading: false, error: null, rows });
|
|
3911
|
-
},
|
|
3912
|
-
(thrown) => {
|
|
3913
|
-
if (live) setState({ loading: false, error: String(thrown?.message ?? thrown), rows: [] });
|
|
3914
|
-
}
|
|
3915
|
-
);
|
|
3921
|
+
void readTablesAnywhere(dataSource).then((result) => {
|
|
3922
|
+
if (live) setState(result);
|
|
3923
|
+
});
|
|
3916
3924
|
return () => {
|
|
3917
3925
|
live = false;
|
|
3918
3926
|
};
|
|
@@ -3952,10 +3960,11 @@ function TablePicker({ dataSource, value, onChange, disabled, tables }) {
|
|
|
3952
3960
|
missing && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-destructive", children: "This table is archived or not shared with you." })
|
|
3953
3961
|
] });
|
|
3954
3962
|
}
|
|
3955
|
-
function TableScope({ dataSource, userId, tableId, children, fallback = null, tables }) {
|
|
3963
|
+
function TableScope({ dataSource, userId, tableId, children, fallback = null, unavailable, tables }) {
|
|
3956
3964
|
const own3 = useTablesAnywhere(dataSource);
|
|
3957
3965
|
const list = tables ?? own3;
|
|
3958
3966
|
const organizationId = list.rows.find((t) => t.table_id === tableId)?.organization_id ?? null;
|
|
3967
|
+
if (tableId && !organizationId && !list.loading) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: unavailable ?? fallback });
|
|
3959
3968
|
if (!tableId || !organizationId) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: fallback });
|
|
3960
3969
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react31.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children });
|
|
3961
3970
|
}
|
|
@@ -4384,6 +4393,9 @@ function WholeValueCell({ words, pointer }) {
|
|
|
4384
4393
|
] });
|
|
4385
4394
|
}
|
|
4386
4395
|
|
|
4396
|
+
// src/values.tsx
|
|
4397
|
+
var import_field_formats6 = require("@ai-matrx/design-system/field-formats");
|
|
4398
|
+
|
|
4387
4399
|
// src/ReferenceChips.tsx
|
|
4388
4400
|
var import_records13 = require("@ai-matrx/records");
|
|
4389
4401
|
var import_design_system19 = require("@ai-matrx/design-system");
|
|
@@ -4628,7 +4640,7 @@ function renderValue(field, value, document2, labels, stillWaitingFor) {
|
|
|
4628
4640
|
title: value,
|
|
4629
4641
|
"data-records-phone": "",
|
|
4630
4642
|
onClick: (event) => event.stopPropagation(),
|
|
4631
|
-
children: formatPhone(value)
|
|
4643
|
+
children: (0, import_field_formats6.formatPhone)(value)
|
|
4632
4644
|
}
|
|
4633
4645
|
);
|
|
4634
4646
|
}
|
|
@@ -4694,7 +4706,17 @@ function ColumnValuesText({
|
|
|
4694
4706
|
value
|
|
4695
4707
|
}) {
|
|
4696
4708
|
if (!tableId) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2014" });
|
|
4697
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4710
|
+
TableScope,
|
|
4711
|
+
{
|
|
4712
|
+
dataSource,
|
|
4713
|
+
userId,
|
|
4714
|
+
tableId,
|
|
4715
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2026" }),
|
|
4716
|
+
unavailable: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "Couldn't load this table's columns" }),
|
|
4717
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(RecordLabelProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ColumnValuesWords, { tableId, value }) })
|
|
4718
|
+
}
|
|
4719
|
+
);
|
|
4698
4720
|
}
|
|
4699
4721
|
function ColumnValuesWords({ tableId, value }) {
|
|
4700
4722
|
const fields = (0, import_react35.useFields)(tableId);
|
|
@@ -4723,7 +4745,17 @@ function RecordNameText({
|
|
|
4723
4745
|
recordId
|
|
4724
4746
|
}) {
|
|
4725
4747
|
if (!tableId || !recordId) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2014" });
|
|
4726
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4749
|
+
TableScope,
|
|
4750
|
+
{
|
|
4751
|
+
dataSource,
|
|
4752
|
+
userId,
|
|
4753
|
+
tableId,
|
|
4754
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2026" }),
|
|
4755
|
+
unavailable: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "Couldn't load this record" }),
|
|
4756
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(RecordNameWords, { tableId, recordId })
|
|
4757
|
+
}
|
|
4758
|
+
);
|
|
4727
4759
|
}
|
|
4728
4760
|
function RecordNameWords({ tableId, recordId }) {
|
|
4729
4761
|
const table = (0, import_react35.useTable)(tableId);
|