@ai-matrx/records-ui 0.116.26 → 0.116.28
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 +15 -1
- package/dist/{chunk-4NJUW3VM.js → chunk-5EFM2G2O.js} +114 -27
- package/dist/chunk-5EFM2G2O.js.map +1 -0
- package/dist/index.cjs +217 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -6
- package/dist/index.d.ts +1 -6
- package/dist/index.js +108 -79
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +113 -26
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-4NJUW3VM.js.map +0 -1
package/dist/pickers.cjs
CHANGED
|
@@ -5589,6 +5589,15 @@ function RelationPicker({ field, value, onChange, disabled, id, className, allow
|
|
|
5589
5589
|
);
|
|
5590
5590
|
}
|
|
5591
5591
|
|
|
5592
|
+
// src/readableLink.ts
|
|
5593
|
+
function readableLink(raw) {
|
|
5594
|
+
try {
|
|
5595
|
+
return decodeURI(raw).replace(/%40/gi, "@");
|
|
5596
|
+
} catch {
|
|
5597
|
+
return raw;
|
|
5598
|
+
}
|
|
5599
|
+
}
|
|
5600
|
+
|
|
5592
5601
|
// src/buttonCell.tsx
|
|
5593
5602
|
var import_react68 = require("react");
|
|
5594
5603
|
var import_design_system40 = require("@ai-matrx/design-system");
|
|
@@ -8017,7 +8026,7 @@ function RatingStars({
|
|
|
8017
8026
|
function rich(id, text, raw, format) {
|
|
8018
8027
|
switch (id) {
|
|
8019
8028
|
case "email":
|
|
8020
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("a", { href: `mailto:${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "truncate", children: text }) });
|
|
8029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("a", { href: `mailto:${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "truncate", children: readableLink(text) }) });
|
|
8021
8030
|
case "url":
|
|
8022
8031
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_outbound_react3.OutboundLink, { href: text.includes("://") ? text : `https://${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "truncate", children: text }) });
|
|
8023
8032
|
case "phone":
|
|
@@ -9097,7 +9106,7 @@ function Scalar({ value, keyName, dense }) {
|
|
|
9097
9106
|
if (isImageUrl(text, keyName)) return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Thumb, { src: text, size: dense ? "sm" : "md" });
|
|
9098
9107
|
if (isUrl(text)) return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(LinkChip, { href: text, dense });
|
|
9099
9108
|
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(text)) {
|
|
9100
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("a", { href: `mailto:${text}`, onClick: stop, className: "text-primary underline-offset-2 hover:underline", children: text });
|
|
9109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("a", { href: `mailto:${text}`, onClick: stop, className: "text-primary underline-offset-2 hover:underline", children: readableLink(text) });
|
|
9101
9110
|
}
|
|
9102
9111
|
const date = dateWords(text);
|
|
9103
9112
|
if (date) return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { title: text, children: date });
|
|
@@ -9406,7 +9415,7 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look, roo
|
|
|
9406
9415
|
{
|
|
9407
9416
|
className: "inline-flex min-w-0 max-w-full items-center gap-1 rounded-md border border-border bg-muted/60 px-1.5 py-0.5 text-[11px] text-foreground hover:bg-accent",
|
|
9408
9417
|
href,
|
|
9409
|
-
title: value,
|
|
9418
|
+
title: readableLink(value),
|
|
9410
9419
|
"data-records-link-chip": "",
|
|
9411
9420
|
onClick: (event) => event.stopPropagation(),
|
|
9412
9421
|
children: [
|
|
@@ -9430,7 +9439,7 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look, roo
|
|
|
9430
9439
|
);
|
|
9431
9440
|
}
|
|
9432
9441
|
if (kind === "email" && typeof value === "string") {
|
|
9433
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
|
|
9442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: readableLink(value) });
|
|
9434
9443
|
}
|
|
9435
9444
|
if (typeof value === "boolean") {
|
|
9436
9445
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
|
|
@@ -9653,6 +9662,16 @@ var LIST_TERMS = [
|
|
|
9653
9662
|
{ op: "is_empty", label: "is empty" },
|
|
9654
9663
|
{ op: "is_not_empty", label: "is not empty" }
|
|
9655
9664
|
];
|
|
9665
|
+
var CHOICE_LIST_TERMS = [
|
|
9666
|
+
{ op: "has_any", label: "is any of" },
|
|
9667
|
+
{ op: "has_none", label: "is none of" }
|
|
9668
|
+
];
|
|
9669
|
+
var ChoiceListTermsContext = (0, import_react56.createContext)(false);
|
|
9670
|
+
var CHOICE_LIST_OPS = /* @__PURE__ */ new Set(["has_any", "has_none"]);
|
|
9671
|
+
function wordsOfValue(value) {
|
|
9672
|
+
if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
|
|
9673
|
+
return typeof value === "string" && value !== "" ? [value] : [];
|
|
9674
|
+
}
|
|
9656
9675
|
var VALUELESS_OPS = /* @__PURE__ */ new Set(["present", "is_empty", "is_not_empty"]);
|
|
9657
9676
|
var LINK_SEP = ">";
|
|
9658
9677
|
function linkedNode(viaId, innerId, op, value) {
|
|
@@ -9724,6 +9743,59 @@ function isChoiceColumn(f) {
|
|
|
9724
9743
|
const kind = String(editorKindFor(f.field));
|
|
9725
9744
|
return kind === "select" || kind === "multi_select";
|
|
9726
9745
|
}
|
|
9746
|
+
function ChoiceValues({ field, value, onChange }) {
|
|
9747
|
+
const client = (0, import_react57.useOptionalRecordsClient)();
|
|
9748
|
+
const [choices, setChoices] = (0, import_react56.useState)(null);
|
|
9749
|
+
(0, import_react56.useEffect)(() => {
|
|
9750
|
+
if (!client) return;
|
|
9751
|
+
let cancelled = false;
|
|
9752
|
+
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
|
|
9753
|
+
if (cancelled) return;
|
|
9754
|
+
setChoices(got.ok ? (got.data ?? []).map((o) => ({ key: (0, import_records18.optionKey)(o), label: (0, import_records18.optionLabel)(o) ?? "" })).filter((c) => c.label !== "") : []);
|
|
9755
|
+
});
|
|
9756
|
+
return () => {
|
|
9757
|
+
cancelled = true;
|
|
9758
|
+
};
|
|
9759
|
+
}, [client, field.id]);
|
|
9760
|
+
const lower = value.map((w) => w.toLowerCase());
|
|
9761
|
+
const isOn = (c) => lower.includes(c.key.toLowerCase()) || lower.includes(c.label.toLowerCase());
|
|
9762
|
+
const known = (choices ?? []).flatMap((c) => [c.key.toLowerCase(), c.label.toLowerCase()]);
|
|
9763
|
+
const strays = value.filter((w) => !known.includes(w.toLowerCase()));
|
|
9764
|
+
const toggle = (c) => {
|
|
9765
|
+
const rest = value.filter((w) => w.toLowerCase() !== c.key.toLowerCase() && w.toLowerCase() !== c.label.toLowerCase());
|
|
9766
|
+
const next = isOn(c) ? rest : [...rest, c.label];
|
|
9767
|
+
const order = (choices ?? []).map((x) => x.label);
|
|
9768
|
+
onChange([...next].sort((a, b) => (order.indexOf(a) === -1 ? 1e6 : order.indexOf(a)) - (order.indexOf(b) === -1 ? 1e6 : order.indexOf(b))));
|
|
9769
|
+
};
|
|
9770
|
+
if (!choices || choices.length === 0) {
|
|
9771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
9772
|
+
import_design_system32.BasicInput,
|
|
9773
|
+
{
|
|
9774
|
+
className: "h-8 w-40 text-xs",
|
|
9775
|
+
"aria-label": "Condition values, separated by commas",
|
|
9776
|
+
value: value.join(", "),
|
|
9777
|
+
onChange: (e) => onChange(e.target.value.split(",").map((w) => w.trim()).filter((w) => w !== ""))
|
|
9778
|
+
}
|
|
9779
|
+
);
|
|
9780
|
+
}
|
|
9781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("span", { className: "inline-flex flex-wrap items-center gap-1", "data-records-condition-choices": "", "data-pick-values": value.join("|"), children: [
|
|
9782
|
+
choices.map((c) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
9783
|
+
import_design_system32.Button,
|
|
9784
|
+
{
|
|
9785
|
+
type: "button",
|
|
9786
|
+
size: "sm",
|
|
9787
|
+
variant: isOn(c) ? "default" : "outline",
|
|
9788
|
+
className: "h-7 px-2 text-xs",
|
|
9789
|
+
"aria-pressed": isOn(c),
|
|
9790
|
+
"aria-label": `${c.label} for ${field.label || field.key}`,
|
|
9791
|
+
onClick: () => toggle(c),
|
|
9792
|
+
children: c.label
|
|
9793
|
+
},
|
|
9794
|
+
c.key
|
|
9795
|
+
)),
|
|
9796
|
+
strays.map((w) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_design_system32.Button, { type: "button", size: "sm", variant: "default", className: "h-7 px-2 text-xs", "aria-pressed": true, "aria-label": `${w} (not a choice of this column)`, onClick: () => onChange(value.filter((x) => x !== w)), children: w }, `stray-${w}`))
|
|
9797
|
+
] });
|
|
9798
|
+
}
|
|
9727
9799
|
function ChoiceValue({ field, value, onChange }) {
|
|
9728
9800
|
const client = (0, import_react57.useOptionalRecordsClient)();
|
|
9729
9801
|
const [choices, setChoices] = (0, import_react56.useState)(null);
|
|
@@ -9788,7 +9860,7 @@ function conditionIsSimple(expr) {
|
|
|
9788
9860
|
if (expr === null || expr === void 0) return true;
|
|
9789
9861
|
if (relativeDayOf(expr) !== null || meOf(expr) !== null || linkedOf(expr) !== null) return true;
|
|
9790
9862
|
const node = expr;
|
|
9791
|
-
if (typeof node.op !== "string" || !(CONDITION_OPS.some((c) => c.op === node.op) || LIST_TERMS.some((c) => c.op === node.op))) {
|
|
9863
|
+
if (typeof node.op !== "string" || !(CONDITION_OPS.some((c) => c.op === node.op) || LIST_TERMS.some((c) => c.op === node.op) || CHOICE_LIST_OPS.has(node.op))) {
|
|
9792
9864
|
return false;
|
|
9793
9865
|
}
|
|
9794
9866
|
if (!Array.isArray(node.args)) return false;
|
|
@@ -9875,6 +9947,7 @@ function conditionValue(typed) {
|
|
|
9875
9947
|
function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
|
|
9876
9948
|
const node = expr ?? null;
|
|
9877
9949
|
const filterTerms = (0, import_react56.useContext)(FilterTermsContext);
|
|
9950
|
+
const choiceListTerms = (0, import_react56.useContext)(ChoiceListTermsContext) || filterTerms;
|
|
9878
9951
|
const relative = relativeDayOf(expr);
|
|
9879
9952
|
const reader = meOf(expr);
|
|
9880
9953
|
const linked = linkedOf(expr);
|
|
@@ -9883,7 +9956,11 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
9883
9956
|
const value = relative || reader ? "" : linked ? linked.value : node?.args?.[1]?.const ?? "";
|
|
9884
9957
|
const chosen = fields.find((f) => f.id === onField);
|
|
9885
9958
|
const chosenKind = chosen?.field ? String(editorKindFor(chosen.field)) : "";
|
|
9886
|
-
const
|
|
9959
|
+
const choiceTerms = choiceListTerms && !chosen?.via && (chosenKind === "select" || chosenKind === "multi_select") ? CHOICE_LIST_TERMS : [];
|
|
9960
|
+
const extraTerms = [
|
|
9961
|
+
...!filterTerms || chosen?.via ? [] : chosenKind === "datetime" ? RELATIVE_DAY_TERMS.map((t) => ({ op: `rel:${t.kind}`, label: t.label })) : chosenKind === "member" ? [{ op: "me", label: "is me" }, { op: "not_me", label: "is not me" }] : chosenKind === "multi_select" ? LIST_TERMS : [],
|
|
9962
|
+
...choiceTerms
|
|
9963
|
+
];
|
|
9887
9964
|
const baseTerms = chosen?.via ? CONDITION_OPS.filter((c) => c.op === "eq" || c.op === "ne") : CONDITION_OPS;
|
|
9888
9965
|
const relativeTerm = relative ? RELATIVE_DAY_TERMS.find((t) => t.kind === relative.kind) : void 0;
|
|
9889
9966
|
function write(next) {
|
|
@@ -9906,7 +9983,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
9906
9983
|
}
|
|
9907
9984
|
const chosenOp = next.op ?? (op || (next.field ? CONDITION_OPS[0].op : ""));
|
|
9908
9985
|
const chosenField = next.field ?? onField;
|
|
9909
|
-
|
|
9986
|
+
let chosenValue = next.value ?? value;
|
|
9987
|
+
if (CHOICE_LIST_OPS.has(chosenOp)) chosenValue = wordsOfValue(chosenValue);
|
|
9988
|
+
else if (Array.isArray(chosenValue)) chosenValue = wordsOfValue(chosenValue)[0] ?? "";
|
|
9910
9989
|
if (!chosenOp || !chosenField) {
|
|
9911
9990
|
onChange(null);
|
|
9912
9991
|
return;
|
|
@@ -9982,7 +10061,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
9982
10061
|
allowCreate: false
|
|
9983
10062
|
}
|
|
9984
10063
|
)
|
|
9985
|
-
) : isChoiceColumn(chosen) && (op === "eq" || op === "ne" || op === "contains" || op === "not_contains") ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChoiceValue, { field: chosen.field, value: String(value ?? ""), onChange: (word) => write({ value: word }) }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
10064
|
+
) : isChoiceColumn(chosen) && CHOICE_LIST_OPS.has(op) ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChoiceValues, { field: chosen.field, value: wordsOfValue(value), onChange: (words) => write({ value: words }) }) : isChoiceColumn(chosen) && (op === "eq" || op === "ne" || op === "contains" || op === "not_contains") ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChoiceValue, { field: chosen.field, value: String(value ?? ""), onChange: (word) => write({ value: word }) }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
9986
10065
|
import_design_system32.BasicInput,
|
|
9987
10066
|
{
|
|
9988
10067
|
className: "h-8 w-28 text-xs",
|
|
@@ -10305,6 +10384,11 @@ async function forgetWrittenWords(client, tableId, key, written) {
|
|
|
10305
10384
|
|
|
10306
10385
|
// src/FieldRetype.tsx
|
|
10307
10386
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
10387
|
+
var RETYPE_PREVIEW_DEBOUNCE_MS = 300;
|
|
10388
|
+
function scheduleRetypePreview(ask, ms = RETYPE_PREVIEW_DEBOUNCE_MS) {
|
|
10389
|
+
const timer = setTimeout(ask, ms);
|
|
10390
|
+
return () => clearTimeout(timer);
|
|
10391
|
+
}
|
|
10308
10392
|
var RETYPE_TARGETS = [
|
|
10309
10393
|
{ id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
|
|
10310
10394
|
{ id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
|
|
@@ -10405,23 +10489,26 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
10405
10489
|
cancelled = true;
|
|
10406
10490
|
};
|
|
10407
10491
|
}
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
|
|
10414
|
-
|
|
10415
|
-
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10492
|
+
const cancelAsk = scheduleRetypePreview(() => {
|
|
10493
|
+
void client.fieldRetypePreview({ field_id: field.id, patch: retypePatch(to) }).then((answer) => {
|
|
10494
|
+
if (cancelled) return;
|
|
10495
|
+
setAsking(false);
|
|
10496
|
+
if (!answer.ok) {
|
|
10497
|
+
setRefusal(answer.error);
|
|
10498
|
+
return;
|
|
10499
|
+
}
|
|
10500
|
+
if (answer.data.limited || answer.data.converts === null || answer.data.kept_aside === null) {
|
|
10501
|
+
setLimitedHeld(answer.data.held_before);
|
|
10502
|
+
setPreview({ converts: answer.data.held_before, keptAside: 0, examples: [], partial: false });
|
|
10503
|
+
return;
|
|
10504
|
+
}
|
|
10505
|
+
setLimitedHeld(null);
|
|
10506
|
+
setPreview({ converts: answer.data.converts, keptAside: answer.data.kept_aside, examples: answer.data.examples, partial: false });
|
|
10507
|
+
});
|
|
10422
10508
|
});
|
|
10423
10509
|
return () => {
|
|
10424
10510
|
cancelled = true;
|
|
10511
|
+
cancelAsk();
|
|
10425
10512
|
};
|
|
10426
10513
|
}, [client, tableId, field.key, to, person, roster]);
|
|
10427
10514
|
if (!retypeableFrom(field)) {
|
|
@@ -12722,7 +12809,7 @@ function RollupFilterQuestion({
|
|
|
12722
12809
|
"."
|
|
12723
12810
|
] }),
|
|
12724
12811
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_design_system39.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onChange(null), children: "Clear" })
|
|
12725
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12812
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ChoiceListTermsContext.Provider, { value: true, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12726
12813
|
ConditionGroup,
|
|
12727
12814
|
{
|
|
12728
12815
|
lead: rollupFilterLead(agg),
|
|
@@ -12731,7 +12818,7 @@ function RollupFilterQuestion({
|
|
|
12731
12818
|
fields: conditionFields,
|
|
12732
12819
|
onChange
|
|
12733
12820
|
}
|
|
12734
|
-
) });
|
|
12821
|
+
) }) });
|
|
12735
12822
|
}
|
|
12736
12823
|
function ValueOnTheOtherSide({
|
|
12737
12824
|
label,
|
|
@@ -12810,7 +12897,7 @@ var import_outbound_react7 = require("@ai-matrx/kit/outbound-react");
|
|
|
12810
12897
|
var import_outbound2 = require("@ai-matrx/kit/outbound");
|
|
12811
12898
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
12812
12899
|
function buttonPressWords(label, pressed) {
|
|
12813
|
-
if (pressed.do === "open_url") return `${label} opened ${pressed.url}`;
|
|
12900
|
+
if (pressed.do === "open_url") return `${label} opened ${readableLink(pressed.url)}`;
|
|
12814
12901
|
if (pressed.do === "add_row") return `${label}: a row was added.`;
|
|
12815
12902
|
if (pressed.do === "run_action") {
|
|
12816
12903
|
const n = Number(pressed.result?.ran ?? 1);
|
|
@@ -13024,7 +13111,7 @@ function ButtonValue({ field, recordId, inCell, beforeSave }) {
|
|
|
13024
13111
|
said2.value ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(StructuredValueView, { structured: said2.value, label: b.label }) : null,
|
|
13025
13112
|
said2.says,
|
|
13026
13113
|
" ",
|
|
13027
|
-
said2.link ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_outbound_react7.OutboundLink, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
|
|
13114
|
+
said2.link ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_outbound_react7.OutboundLink, { href: said2.link, className: "text-primary underline", children: readableLink(said2.link) }) : null
|
|
13028
13115
|
] }) : null,
|
|
13029
13116
|
said2?.kind === "needs" ? /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
|
13030
13117
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { children: said2.says }),
|