@ai-matrx/records-ui 0.116.27 → 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 +1 -1
- package/dist/{chunk-6GJLCWSO.js → chunk-5EFM2G2O.js} +99 -21
- package/dist/chunk-5EFM2G2O.js.map +1 -0
- package/dist/index.cjs +202 -96
- 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 +98 -20
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-6GJLCWSO.js.map +0 -1
package/dist/pickers.cjs
CHANGED
|
@@ -9662,6 +9662,16 @@ var LIST_TERMS = [
|
|
|
9662
9662
|
{ op: "is_empty", label: "is empty" },
|
|
9663
9663
|
{ op: "is_not_empty", label: "is not empty" }
|
|
9664
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
|
+
}
|
|
9665
9675
|
var VALUELESS_OPS = /* @__PURE__ */ new Set(["present", "is_empty", "is_not_empty"]);
|
|
9666
9676
|
var LINK_SEP = ">";
|
|
9667
9677
|
function linkedNode(viaId, innerId, op, value) {
|
|
@@ -9733,6 +9743,59 @@ function isChoiceColumn(f) {
|
|
|
9733
9743
|
const kind = String(editorKindFor(f.field));
|
|
9734
9744
|
return kind === "select" || kind === "multi_select";
|
|
9735
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
|
+
}
|
|
9736
9799
|
function ChoiceValue({ field, value, onChange }) {
|
|
9737
9800
|
const client = (0, import_react57.useOptionalRecordsClient)();
|
|
9738
9801
|
const [choices, setChoices] = (0, import_react56.useState)(null);
|
|
@@ -9797,7 +9860,7 @@ function conditionIsSimple(expr) {
|
|
|
9797
9860
|
if (expr === null || expr === void 0) return true;
|
|
9798
9861
|
if (relativeDayOf(expr) !== null || meOf(expr) !== null || linkedOf(expr) !== null) return true;
|
|
9799
9862
|
const node = expr;
|
|
9800
|
-
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))) {
|
|
9801
9864
|
return false;
|
|
9802
9865
|
}
|
|
9803
9866
|
if (!Array.isArray(node.args)) return false;
|
|
@@ -9884,6 +9947,7 @@ function conditionValue(typed) {
|
|
|
9884
9947
|
function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
|
|
9885
9948
|
const node = expr ?? null;
|
|
9886
9949
|
const filterTerms = (0, import_react56.useContext)(FilterTermsContext);
|
|
9950
|
+
const choiceListTerms = (0, import_react56.useContext)(ChoiceListTermsContext) || filterTerms;
|
|
9887
9951
|
const relative = relativeDayOf(expr);
|
|
9888
9952
|
const reader = meOf(expr);
|
|
9889
9953
|
const linked = linkedOf(expr);
|
|
@@ -9892,7 +9956,11 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
9892
9956
|
const value = relative || reader ? "" : linked ? linked.value : node?.args?.[1]?.const ?? "";
|
|
9893
9957
|
const chosen = fields.find((f) => f.id === onField);
|
|
9894
9958
|
const chosenKind = chosen?.field ? String(editorKindFor(chosen.field)) : "";
|
|
9895
|
-
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
|
+
];
|
|
9896
9964
|
const baseTerms = chosen?.via ? CONDITION_OPS.filter((c) => c.op === "eq" || c.op === "ne") : CONDITION_OPS;
|
|
9897
9965
|
const relativeTerm = relative ? RELATIVE_DAY_TERMS.find((t) => t.kind === relative.kind) : void 0;
|
|
9898
9966
|
function write(next) {
|
|
@@ -9915,7 +9983,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
9915
9983
|
}
|
|
9916
9984
|
const chosenOp = next.op ?? (op || (next.field ? CONDITION_OPS[0].op : ""));
|
|
9917
9985
|
const chosenField = next.field ?? onField;
|
|
9918
|
-
|
|
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] ?? "";
|
|
9919
9989
|
if (!chosenOp || !chosenField) {
|
|
9920
9990
|
onChange(null);
|
|
9921
9991
|
return;
|
|
@@ -9991,7 +10061,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
9991
10061
|
allowCreate: false
|
|
9992
10062
|
}
|
|
9993
10063
|
)
|
|
9994
|
-
) : 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)(
|
|
9995
10065
|
import_design_system32.BasicInput,
|
|
9996
10066
|
{
|
|
9997
10067
|
className: "h-8 w-28 text-xs",
|
|
@@ -10314,6 +10384,11 @@ async function forgetWrittenWords(client, tableId, key, written) {
|
|
|
10314
10384
|
|
|
10315
10385
|
// src/FieldRetype.tsx
|
|
10316
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
|
+
}
|
|
10317
10392
|
var RETYPE_TARGETS = [
|
|
10318
10393
|
{ id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
|
|
10319
10394
|
{ id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
|
|
@@ -10414,23 +10489,26 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
10414
10489
|
cancelled = true;
|
|
10415
10490
|
};
|
|
10416
10491
|
}
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
|
|
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
|
+
});
|
|
10431
10508
|
});
|
|
10432
10509
|
return () => {
|
|
10433
10510
|
cancelled = true;
|
|
10511
|
+
cancelAsk();
|
|
10434
10512
|
};
|
|
10435
10513
|
}, [client, tableId, field.key, to, person, roster]);
|
|
10436
10514
|
if (!retypeableFrom(field)) {
|
|
@@ -12731,7 +12809,7 @@ function RollupFilterQuestion({
|
|
|
12731
12809
|
"."
|
|
12732
12810
|
] }),
|
|
12733
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" })
|
|
12734
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12812
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ChoiceListTermsContext.Provider, { value: true, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12735
12813
|
ConditionGroup,
|
|
12736
12814
|
{
|
|
12737
12815
|
lead: rollupFilterLead(agg),
|
|
@@ -12740,7 +12818,7 @@ function RollupFilterQuestion({
|
|
|
12740
12818
|
fields: conditionFields,
|
|
12741
12819
|
onChange
|
|
12742
12820
|
}
|
|
12743
|
-
) });
|
|
12821
|
+
) }) });
|
|
12744
12822
|
}
|
|
12745
12823
|
function ValueOnTheOtherSide({
|
|
12746
12824
|
label,
|