@ai-matrx/records-ui 0.116.1 → 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 +23 -1
- package/dist/{chunk-Z6WTP467.js → chunk-32TUVT57.js} +3 -2
- package/dist/chunk-32TUVT57.js.map +1 -0
- package/dist/{chunk-42VA6SWA.js → chunk-TCRNJVGZ.js} +2 -2
- package/dist/{chunk-42VA6SWA.js.map → chunk-TCRNJVGZ.js.map} +1 -1
- package/dist/helpers.cjs +2 -3
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.js +2 -3
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +1648 -1647
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +61 -61
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/dist/skeleton.cjs +31 -30
- package/dist/skeleton.cjs.map +1 -1
- package/dist/skeleton.js +1 -1
- package/package.json +7 -7
- package/dist/chunk-Z6WTP467.js.map +0 -1
package/dist/pickers.cjs
CHANGED
|
@@ -4929,7 +4929,7 @@ function AddChoicesInline({ field, onAdded, disabled = false }) {
|
|
|
4929
4929
|
|
|
4930
4930
|
// src/editors.tsx
|
|
4931
4931
|
var import_react67 = require("react");
|
|
4932
|
-
var
|
|
4932
|
+
var import_records28 = require("@ai-matrx/records");
|
|
4933
4933
|
var import_react68 = require("@ai-matrx/records/react");
|
|
4934
4934
|
var import_design_system39 = require("@ai-matrx/design-system");
|
|
4935
4935
|
init_dates();
|
|
@@ -5574,7 +5574,7 @@ function RelationPicker({ field, value, onChange, disabled, id, className, allow
|
|
|
5574
5574
|
var import_react62 = require("react");
|
|
5575
5575
|
var import_design_system36 = require("@ai-matrx/design-system");
|
|
5576
5576
|
var import_data_table6 = require("@ai-matrx/design-system/data-table");
|
|
5577
|
-
var
|
|
5577
|
+
var import_records26 = require("@ai-matrx/records");
|
|
5578
5578
|
var import_react63 = require("@ai-matrx/records/react");
|
|
5579
5579
|
init_Refusal();
|
|
5580
5580
|
|
|
@@ -10160,7 +10160,7 @@ function nextFieldSort(fields) {
|
|
|
10160
10160
|
|
|
10161
10161
|
// src/FieldEditor.tsx
|
|
10162
10162
|
init_enumLabels();
|
|
10163
|
-
var
|
|
10163
|
+
var import_records24 = require("@ai-matrx/records");
|
|
10164
10164
|
|
|
10165
10165
|
// src/ButtonSettings.tsx
|
|
10166
10166
|
var import_react58 = require("react");
|
|
@@ -10421,12 +10421,12 @@ function NewRowAction({
|
|
|
10421
10421
|
}
|
|
10422
10422
|
|
|
10423
10423
|
// src/FieldEditor.tsx
|
|
10424
|
-
var
|
|
10424
|
+
var import_records25 = require("@ai-matrx/records");
|
|
10425
10425
|
|
|
10426
10426
|
// src/standardFieldChoices.ts
|
|
10427
|
-
var
|
|
10427
|
+
var import_field_kinds7 = require("@ai-matrx/records/field-kinds");
|
|
10428
10428
|
init_fieldTypes();
|
|
10429
|
-
var STORE_BEHAVIOUR = new Map(
|
|
10429
|
+
var STORE_BEHAVIOUR = new Map(import_field_kinds7.DECLARABLE_FIELD_KINDS.map((row) => [row.kind, row.behavior]));
|
|
10430
10430
|
function holdsAValueOnAStandardTable(kind) {
|
|
10431
10431
|
if (isSystemFieldKind(kind)) return false;
|
|
10432
10432
|
const behaviour = STORE_BEHAVIOUR.get(kind);
|
|
@@ -10443,8 +10443,8 @@ var ADDABLE_TYPES = STANDARD_TABLE_FIELD_CHOICES.map((choice) => ({
|
|
|
10443
10443
|
// src/FieldEditor.tsx
|
|
10444
10444
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
10445
10445
|
var RULE_KINDS = FIELD_RULE_KIND_VALUES.map((kind) => ({ kind, label: FIELD_RULE_KIND_LABEL[kind] }));
|
|
10446
|
-
var SENSITIVITIES =
|
|
10447
|
-
var AGENT_VISIBILITY =
|
|
10446
|
+
var SENSITIVITIES = import_records25.FIELD_SENSITIVITIES.map((value) => ({ value, label: FIELD_SENSITIVITY_LABEL[value] }));
|
|
10447
|
+
var AGENT_VISIBILITY = import_records25.CONTEXT_POLICIES.map((value) => ({ value, label: CONTEXT_POLICY_LABEL[value] }));
|
|
10448
10448
|
var ROLLUP_OPERATIONS = ROLLUP_AGG_VALUES.map((value) => ({
|
|
10449
10449
|
value,
|
|
10450
10450
|
label: ROLLUP_AGG_LABEL[value]
|
|
@@ -10554,20 +10554,20 @@ function FieldEditor(props) {
|
|
|
10554
10554
|
const [contextPolicy, setContextPolicy] = (0, import_react60.useState)(String(start?.context_policy ?? "include"));
|
|
10555
10555
|
const [rules, setRules] = (0, import_react60.useState)(start?.rules ?? []);
|
|
10556
10556
|
const [startsWith, setStartsWith] = (0, import_react60.useState)(start?.default ?? null);
|
|
10557
|
-
const [ratingMax, setRatingMax] = (0, import_react60.useState)(() => start ? (0,
|
|
10557
|
+
const [ratingMax, setRatingMax] = (0, import_react60.useState)(() => start ? (0, import_records25.ratingMaxOf)(start) : 5);
|
|
10558
10558
|
const savedRules = (0, import_react60.useMemo)(
|
|
10559
|
-
() => field ? type === "rating" ? (0,
|
|
10559
|
+
() => field ? type === "rating" ? (0, import_records25.rulesWithTopStar)(field.rules ?? [], (0, import_records25.ratingMaxOf)(field)) : field.rules ?? [] : [],
|
|
10560
10560
|
[field, type]
|
|
10561
10561
|
);
|
|
10562
|
-
const editedRules = (0, import_react60.useMemo)(() => type === "rating" ? (0,
|
|
10562
|
+
const editedRules = (0, import_react60.useMemo)(() => type === "rating" ? (0, import_records25.rulesWithTopStar)(rules, ratingMax) : rules, [type, rules, ratingMax]);
|
|
10563
10563
|
const [statusGroups, setStatusGroups] = (0, import_react60.useState)({});
|
|
10564
10564
|
const [statusKeys, setStatusKeys] = (0, import_react60.useState)({});
|
|
10565
10565
|
const [symbology, setSymbology] = (0, import_react60.useState)(String(start?.config?.["symbology"] ?? ""));
|
|
10566
10566
|
const descriptionStart = String(start?.config?.["description"] ?? "");
|
|
10567
10567
|
const [description, setDescription] = (0, import_react60.useState)(descriptionStart);
|
|
10568
|
-
const buttonStart = (0, import_react60.useMemo)(() => (0,
|
|
10568
|
+
const buttonStart = (0, import_react60.useMemo)(() => (0, import_records24.buttonOf)(start) ?? { label: "" }, [start]);
|
|
10569
10569
|
const [buttonSettings, setButtonSettings] = (0, import_react60.useState)(buttonStart);
|
|
10570
|
-
const prefixStart = (0,
|
|
10570
|
+
const prefixStart = (0, import_records24.autonumberPrefixOf)(start);
|
|
10571
10571
|
const [numberPrefix, setNumberPrefix] = (0, import_react60.useState)(prefixStart);
|
|
10572
10572
|
const dependencyStart = start?.config?.["dependency"] === true;
|
|
10573
10573
|
const [dependency, setDependency] = (0, import_react60.useState)(dependencyStart);
|
|
@@ -10575,7 +10575,7 @@ function FieldEditor(props) {
|
|
|
10575
10575
|
if (!field || type !== "status") return;
|
|
10576
10576
|
let live = true;
|
|
10577
10577
|
void client.fieldOptions({ field_id: field.id }).then((got) => {
|
|
10578
|
-
if (live && got.ok) setStatusKeys(Object.fromEntries((got.data ?? []).map((o) => [String(o.id), (0,
|
|
10578
|
+
if (live && got.ok) setStatusKeys(Object.fromEntries((got.data ?? []).map((o) => [String(o.id), (0, import_records25.optionKey)(o)])));
|
|
10579
10579
|
});
|
|
10580
10580
|
return () => {
|
|
10581
10581
|
live = false;
|
|
@@ -10698,7 +10698,7 @@ function FieldEditor(props) {
|
|
|
10698
10698
|
const nameTaken = columnNameTakenBy(label, others.map(fieldName));
|
|
10699
10699
|
const nameLine = nameTaken ? columnNameTakenLine(nameTaken, noun) : columnNameProblemLine(label, noun);
|
|
10700
10700
|
const listsChoices = type === "select" || type === "multi_select" || type === "status";
|
|
10701
|
-
const buttonMissing = type === "button" && buttonSettings.do ? (0,
|
|
10701
|
+
const buttonMissing = type === "button" && buttonSettings.do ? (0, import_records24.buttonNeeds)(buttonSettings) : null;
|
|
10702
10702
|
const missing = buttonMissing ?? (editing ? formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(choiceList) : null) : formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(newChoices) : null) ?? (type === "formula" && formulaWritten ? null : whatIsMissing(
|
|
10703
10703
|
type === "count" ? { type: "rollup", label, options, via, pick, agg: "count", of, relations: totalSources, formulaFields, relationTarget, allowedTypes, noun } : { type, label, options, via, pick, agg, of, relations: sourcesFor(type), formulaFields, relationTarget, allowedTypes, noun }
|
|
10704
10704
|
)));
|
|
@@ -10740,7 +10740,7 @@ function FieldEditor(props) {
|
|
|
10740
10740
|
...statusGroupsChanged ? { status_groups: statusGroupsSent } : {},
|
|
10741
10741
|
// V11 #4/#10: a rating's top star goes as `max`, the word custom.field_update now takes the way
|
|
10742
10742
|
// custom.field_declare does; the store writes the max Rule and sets aside any score above it.
|
|
10743
|
-
...type === "rating" && ratingMax !== (0,
|
|
10743
|
+
...type === "rating" && ratingMax !== (0, import_records25.ratingMaxOf)(field) ? { max: ratingMax } : {},
|
|
10744
10744
|
...type === "barcode" && symbology !== String(field.config?.["symbology"] ?? "") ? { symbology: symbology === "" ? null : symbology } : {},
|
|
10745
10745
|
...type === "button" && JSON.stringify(buttonSettings) !== JSON.stringify(buttonStart) ? { button: buttonSettings } : {},
|
|
10746
10746
|
...field.type === "relation" && dependency !== dependencyStart ? { dependency } : {},
|
|
@@ -11787,7 +11787,7 @@ function runAnswer(label, run) {
|
|
|
11787
11787
|
var stop2 = (event) => event.stopPropagation();
|
|
11788
11788
|
function ButtonValue({ field, recordId, inCell }) {
|
|
11789
11789
|
const client = (0, import_react63.useOptionalRecordsClient)();
|
|
11790
|
-
const b = (0,
|
|
11790
|
+
const b = (0, import_records26.buttonOf)(field);
|
|
11791
11791
|
const [busy, setBusy] = (0, import_react62.useState)(false);
|
|
11792
11792
|
const [said2, setSaid] = (0, import_react62.useState)(null);
|
|
11793
11793
|
const [settingUp, setSettingUp] = (0, import_react62.useState)(false);
|
|
@@ -11795,7 +11795,7 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
11795
11795
|
(0, import_react62.useEffect)(() => () => void (waitingOn.current += 1), []);
|
|
11796
11796
|
if (!b) return null;
|
|
11797
11797
|
const color = (0, import_data_table6.isStyleColor)(b.color) ? import_data_table6.CHOICE_CHIP_CLASS[b.color] : import_data_table6.NEUTRAL_CHIP_CLASS;
|
|
11798
|
-
const needs = (0,
|
|
11798
|
+
const needs = (0, import_records26.buttonNeeds)(b);
|
|
11799
11799
|
const tableId = field.entity_definition_id;
|
|
11800
11800
|
const press = async () => {
|
|
11801
11801
|
if (!client || !recordId) return setSaid({ kind: "public" });
|
|
@@ -12089,7 +12089,7 @@ function formatControl(args) {
|
|
|
12089
12089
|
// src/typedDateHelper.tsx
|
|
12090
12090
|
var import_react66 = require("react");
|
|
12091
12091
|
var import_design_system38 = require("@ai-matrx/design-system");
|
|
12092
|
-
var
|
|
12092
|
+
var import_records27 = require("@ai-matrx/records");
|
|
12093
12093
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
12094
12094
|
var WEEK = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
12095
12095
|
var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
@@ -12098,12 +12098,12 @@ function pad(n) {
|
|
|
12098
12098
|
}
|
|
12099
12099
|
function readBox(text, kind) {
|
|
12100
12100
|
if (kind === "time") {
|
|
12101
|
-
const t = (0,
|
|
12101
|
+
const t = (0, import_records27.readTypedTime)(text);
|
|
12102
12102
|
if (!t.ok) return { day: null, time: null };
|
|
12103
12103
|
const [h, m] = t.value.split(":").map(Number);
|
|
12104
12104
|
return { day: null, time: { h, m } };
|
|
12105
12105
|
}
|
|
12106
|
-
const read = (0,
|
|
12106
|
+
const read = (0, import_records27.readTypedDate)(text, { withTime: kind === "datetime" });
|
|
12107
12107
|
if (!read.ok) return { day: null, time: null };
|
|
12108
12108
|
if (kind === "datetime" && read.instant) {
|
|
12109
12109
|
const at = new Date(read.instant);
|
|
@@ -12112,10 +12112,10 @@ function readBox(text, kind) {
|
|
|
12112
12112
|
return { day: read.day, time: null };
|
|
12113
12113
|
}
|
|
12114
12114
|
function wordsFor2(kind, day, time) {
|
|
12115
|
-
if (kind === "time") return time ? (0,
|
|
12115
|
+
if (kind === "time") return time ? (0, import_records27.typedTimeText)(time.h, time.m) : "";
|
|
12116
12116
|
if (!day) return "";
|
|
12117
|
-
const dayText = (0,
|
|
12118
|
-
return kind === "datetime" && time ? `${dayText} ${(0,
|
|
12117
|
+
const dayText = (0, import_records27.typedDateText)(day);
|
|
12118
|
+
return kind === "datetime" && time ? `${dayText} ${(0, import_records27.typedTimeText)(time.h, time.m)}` : dayText;
|
|
12119
12119
|
}
|
|
12120
12120
|
var keepFocus = { onMouseDown: (e) => e.preventDefault(), tabIndex: -1 };
|
|
12121
12121
|
function CalendarGlyph() {
|
|
@@ -12237,7 +12237,7 @@ function TypedDateHelper({
|
|
|
12237
12237
|
held.time && held.time.h === t.h && held.time.m === t.m ? "bg-primary text-primary-foreground" : ""
|
|
12238
12238
|
),
|
|
12239
12239
|
onClick: () => pickTime(t),
|
|
12240
|
-
children: (0,
|
|
12240
|
+
children: (0, import_records27.typedTimeText)(t.h, t.m)
|
|
12241
12241
|
},
|
|
12242
12242
|
`${t.h}:${t.m}`
|
|
12243
12243
|
)) })
|
|
@@ -12308,21 +12308,21 @@ function judgeTyped(field, text, choices, nudge) {
|
|
|
12308
12308
|
const format = formatForField(field);
|
|
12309
12309
|
if (trimmed === "") return { value: null };
|
|
12310
12310
|
if (format && format.id === "time") {
|
|
12311
|
-
const read2 = (0,
|
|
12311
|
+
const read2 = (0, import_records28.readTypedTime)(trimmed);
|
|
12312
12312
|
return read2.ok ? { value: read2.value } : { refusal: SHORT_REFUSAL.time, why: `${fieldName(field)} holds a time of day, and ${read2.why}` };
|
|
12313
12313
|
}
|
|
12314
12314
|
if (kind === "select" || kind === "multi_select") {
|
|
12315
12315
|
if (!choices || nudge === null) return null;
|
|
12316
12316
|
const several = field.multi || kind === "multi_select";
|
|
12317
12317
|
const words = several ? trimmed.split(/\s*[,;\n]\s*/).filter(Boolean) : [trimmed];
|
|
12318
|
-
const allowOther = (0,
|
|
12318
|
+
const allowOther = (0, import_records28.allowsOtherValues)(field);
|
|
12319
12319
|
const parts = [];
|
|
12320
12320
|
const add = [];
|
|
12321
12321
|
const ask = [];
|
|
12322
12322
|
const notChoices = [];
|
|
12323
12323
|
let keepOffered = allowOther;
|
|
12324
12324
|
for (const word of words) {
|
|
12325
|
-
const decided = (0,
|
|
12325
|
+
const decided = (0, import_records28.decideTypedChoice)({ words: word, options: choices, allowOther, nudge });
|
|
12326
12326
|
if (decided.decision === "empty") continue;
|
|
12327
12327
|
if (decided.decision === "chosen") parts.push(decided.key);
|
|
12328
12328
|
else {
|
|
@@ -12355,7 +12355,7 @@ function judgeTyped(field, text, choices, nudge) {
|
|
|
12355
12355
|
return usual && digits.length >= 7 && digits.length <= 20 ? { value: trimmed } : { refusal: SHORT_REFUSAL.phone };
|
|
12356
12356
|
}
|
|
12357
12357
|
const showsAsPercent = Boolean(format && (format.id === "percent" || format.id === "progress"));
|
|
12358
|
-
const read = (0,
|
|
12358
|
+
const read = (0, import_records28.coerceTypedAnswer)(field, text, { label: fieldName(field), showsAsPercent });
|
|
12359
12359
|
if ("refusal" in read) {
|
|
12360
12360
|
if (kind === "email" || kind === "url") return { refusal: SHORT_REFUSAL[kind] };
|
|
12361
12361
|
const short = kind === "datetime" ? SHORT_REFUSAL.date : kind === "number" || kind === "currency" || kind === "percent" || showsAsPercent ? SHORT_REFUSAL.number : read.refusal.length <= 32 ? read.refusal : SHORT_REFUSAL.value;
|
|
@@ -12376,12 +12376,12 @@ function openingText(field, value) {
|
|
|
12376
12376
|
if (value === null || value === void 0 || value === "") return "";
|
|
12377
12377
|
const helper = dateHelperKind(field, value);
|
|
12378
12378
|
if (helper === "time") {
|
|
12379
|
-
const read = (0,
|
|
12379
|
+
const read = (0, import_records28.readTypedTime)(String(value));
|
|
12380
12380
|
if (!read.ok) return String(value);
|
|
12381
12381
|
const [h, m] = read.value.split(":").map(Number);
|
|
12382
|
-
return (0,
|
|
12382
|
+
return (0, import_records28.typedTimeText)(h, m);
|
|
12383
12383
|
}
|
|
12384
|
-
if (helper) return (0,
|
|
12384
|
+
if (helper) return (0, import_records28.typedDateText)(value, { withTime: helper === "datetime" });
|
|
12385
12385
|
const format = formatForField(field);
|
|
12386
12386
|
return format ? typedText(format, value) : String(value);
|
|
12387
12387
|
}
|
|
@@ -12470,7 +12470,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
|
|
|
12470
12470
|
" ",
|
|
12471
12471
|
needsChoices ? String(
|
|
12472
12472
|
(Array.isArray(withoutAddition(judged.value).value) ? withoutAddition(judged.value).value : [withoutAddition(judged.value).value]).map((k) => {
|
|
12473
|
-
const option = choices?.find((o) => (0,
|
|
12473
|
+
const option = choices?.find((o) => (0, import_records28.optionKey)(o) === k);
|
|
12474
12474
|
return option ? recordName(option.data, null, String(k)) : String(k);
|
|
12475
12475
|
}).join(", ")
|
|
12476
12476
|
) : (() => {
|
|
@@ -12491,7 +12491,7 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
|
|
|
12491
12491
|
const ownDetails = (0, import_react68.useOptionalRecordsClient)() === null;
|
|
12492
12492
|
if (isTypedDraft(value)) return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TypedTextControl, { field, value, onChange, disabled, id: inputId, onCommit, onCancel });
|
|
12493
12493
|
if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SignaturePad, { id: inputId, value, onChange, disabled });
|
|
12494
|
-
if ((0,
|
|
12494
|
+
if ((0, import_records28.isButtonField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ButtonValue, { field });
|
|
12495
12495
|
const newerControl = newerKindControl({ field, value, onChange, disabled, id: inputId });
|
|
12496
12496
|
if (newerControl !== void 0) return newerControl;
|
|
12497
12497
|
const format = formatForField(field);
|
|
@@ -12661,7 +12661,7 @@ function TypedWordsControl({ field, value, onChange, disabled, id }) {
|
|
|
12661
12661
|
function typedDatePlaceholder(helper) {
|
|
12662
12662
|
const time = "h:mm AM";
|
|
12663
12663
|
if (helper === "time") return time;
|
|
12664
|
-
const pattern = (0,
|
|
12664
|
+
const pattern = (0, import_records28.typedDateText)("2026-11-22").replace("2026", "YYYY").replace("11", "MM").replace("22", "DD");
|
|
12665
12665
|
return helper === "datetime" ? `${pattern} ${time}` : pattern;
|
|
12666
12666
|
}
|
|
12667
12667
|
function CheckboxControl({ field, value, onChange, disabled, id }) {
|
|
@@ -12831,15 +12831,15 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
12831
12831
|
ChoiceAnswer,
|
|
12832
12832
|
{
|
|
12833
12833
|
field,
|
|
12834
|
-
choices: options.map((option) => ({ key: (0,
|
|
12834
|
+
choices: options.map((option) => ({ key: (0, import_records28.optionKey)(option), label: titled(option) })),
|
|
12835
12835
|
value,
|
|
12836
12836
|
onChange,
|
|
12837
12837
|
disabled,
|
|
12838
12838
|
id,
|
|
12839
12839
|
onChosen,
|
|
12840
12840
|
isChosen: (choice, v) => {
|
|
12841
|
-
const option = options.find((o) => (0,
|
|
12842
|
-
return option ? (0,
|
|
12841
|
+
const option = options.find((o) => (0, import_records28.optionKey)(o) === choice.key);
|
|
12842
|
+
return option ? (0, import_records28.isTheChosen)(option, v) : false;
|
|
12843
12843
|
}
|
|
12844
12844
|
}
|
|
12845
12845
|
);
|
|
@@ -12872,7 +12872,7 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
12872
12872
|
onCancel,
|
|
12873
12873
|
initialSearch,
|
|
12874
12874
|
addsChoices,
|
|
12875
|
-
allowOther: (0,
|
|
12875
|
+
allowOther: (0, import_records28.allowsOtherValues)(field),
|
|
12876
12876
|
onChoicesChanged: () => {
|
|
12877
12877
|
if (client) (0, askOnce_exports.forgetAsked)(client, `field_options:${field.id}`);
|
|
12878
12878
|
setReread((n) => n + 1);
|
|
@@ -12886,19 +12886,19 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
12886
12886
|
}
|
|
12887
12887
|
const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
|
|
12888
12888
|
if (field.multi) {
|
|
12889
|
-
const chosen = options.filter((option) => (0,
|
|
12890
|
-
const picked = new Set(chosen.map((option) => (0,
|
|
12889
|
+
const chosen = options.filter((option) => (0, import_records28.choiceValuesOf)(value).some((v) => (0, import_records28.isTheChosen)(option, v)));
|
|
12890
|
+
const picked = new Set(chosen.map((option) => (0, import_records28.optionKey)(option)));
|
|
12891
12891
|
const toggles = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { id: autoOpen ? void 0 : id, className: "flex flex-wrap gap-1", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
12892
12892
|
import_design_system39.Button,
|
|
12893
12893
|
{
|
|
12894
12894
|
type: "button",
|
|
12895
12895
|
size: "sm",
|
|
12896
|
-
variant: picked.has((0,
|
|
12896
|
+
variant: picked.has((0, import_records28.optionKey)(option)) ? "default" : "outline",
|
|
12897
12897
|
disabled,
|
|
12898
12898
|
onClick: () => {
|
|
12899
12899
|
const next = new Set(picked);
|
|
12900
|
-
if (next.has((0,
|
|
12901
|
-
else next.add((0,
|
|
12900
|
+
if (next.has((0, import_records28.optionKey)(option))) next.delete((0, import_records28.optionKey)(option));
|
|
12901
|
+
else next.add((0, import_records28.optionKey)(option));
|
|
12902
12902
|
onChange(next.size === 0 ? null : [...next]);
|
|
12903
12903
|
},
|
|
12904
12904
|
children: titleOf(option)
|
|
@@ -12920,11 +12920,11 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
12920
12920
|
}
|
|
12921
12921
|
);
|
|
12922
12922
|
}
|
|
12923
|
-
const current = options.find((option) => (0,
|
|
12923
|
+
const current = options.find((option) => (0, import_records28.isTheChosen)(option, value));
|
|
12924
12924
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
12925
12925
|
import_design_system39.Select,
|
|
12926
12926
|
{
|
|
12927
|
-
value: current ? (0,
|
|
12927
|
+
value: current ? (0, import_records28.optionKey)(current) : "",
|
|
12928
12928
|
disabled: disabled ?? false,
|
|
12929
12929
|
onValueChange: (next) => onChange(next === "" ? null : next),
|
|
12930
12930
|
...autoOpen ? {
|
|
@@ -12936,7 +12936,7 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
12936
12936
|
} : {},
|
|
12937
12937
|
children: [
|
|
12938
12938
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_design_system39.SelectTrigger, { id, size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_design_system39.SelectValue, { placeholder: "Choose" }) }),
|
|
12939
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_design_system39.SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_design_system39.SelectItem, { value: (0,
|
|
12939
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_design_system39.SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_design_system39.SelectItem, { value: (0, import_records28.optionKey)(option), children: titleOf(option) }, option.id)) })
|
|
12940
12940
|
]
|
|
12941
12941
|
}
|
|
12942
12942
|
);
|
|
@@ -12970,23 +12970,23 @@ function OpenChoicePicker({
|
|
|
12970
12970
|
const [addRefused, setAddRefused] = (0, import_react67.useState)(null);
|
|
12971
12971
|
const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
|
|
12972
12972
|
const held = withoutAddition(value);
|
|
12973
|
-
const current = (0,
|
|
12973
|
+
const current = (0, import_records28.choiceValuesOf)(held.value);
|
|
12974
12974
|
const pickedWords = current.map((v) => {
|
|
12975
|
-
const option = options.find((o) => (0,
|
|
12975
|
+
const option = options.find((o) => (0, import_records28.isTheChosen)(o, v));
|
|
12976
12976
|
return option ? titleOf(option) : String(v);
|
|
12977
12977
|
});
|
|
12978
|
-
const chipOf = (option, word) => option ? choiceChipLookOf(field, (0,
|
|
12978
|
+
const chipOf = (option, word) => option ? choiceChipLookOf(field, (0, import_records28.optionKey)(option), titleOf(option)) : choiceChipLookOf(field, word);
|
|
12979
12979
|
const q = search.trim();
|
|
12980
|
-
const visible = (0,
|
|
12981
|
-
const decided = (0,
|
|
12980
|
+
const visible = (0, import_records28.rankTypedMatches)(options, q, titleOf);
|
|
12981
|
+
const decided = (0, import_records28.decideTypedChoice)({ words: q, options, allowOther, nudge: nudge ?? "ask" });
|
|
12982
12982
|
const choose = (word, addingIt = false) => {
|
|
12983
12983
|
const pending = held.add.filter((w) => w.toLowerCase() !== word.toLowerCase());
|
|
12984
12984
|
let next;
|
|
12985
12985
|
let add2 = [...pending];
|
|
12986
12986
|
if (field.multi) {
|
|
12987
12987
|
const existing = current.map((v) => {
|
|
12988
|
-
const option = options.find((o) => (0,
|
|
12989
|
-
return option ? (0,
|
|
12988
|
+
const option = options.find((o) => (0, import_records28.isTheChosen)(o, v));
|
|
12989
|
+
return option ? (0, import_records28.optionKey)(option) : String(v);
|
|
12990
12990
|
});
|
|
12991
12991
|
const has = existing.some((v) => v.toLowerCase() === word.toLowerCase());
|
|
12992
12992
|
const list = has ? existing.filter((v) => v.toLowerCase() !== word.toLowerCase()) : [...existing, word];
|
|
@@ -13022,7 +13022,7 @@ function OpenChoicePicker({
|
|
|
13022
13022
|
const foot = null;
|
|
13023
13023
|
const add = offList && (decided.decision === "ask" || decided.decision === "add") ? { label: `Create \u201C${q}\u201D`, onAdd: addTyped, disabled: adding } : offList && decided.decision === "keep_as_typed" ? { label: `Use \u201C${q}\u201D`, onAdd: () => choose(q) } : null;
|
|
13024
13024
|
const listed = visible;
|
|
13025
|
-
const pickedOptions = current.map((v) => options.find((o) => (0,
|
|
13025
|
+
const pickedOptions = current.map((v) => options.find((o) => (0, import_records28.isTheChosen)(o, v)));
|
|
13026
13026
|
const cellChips = pickedWords.map((word, i) => {
|
|
13027
13027
|
const chip = chipOf(pickedOptions[i], word);
|
|
13028
13028
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_design_system39.Badge, { variant: "outline", className: (0, import_design_system39.cn)("text-[11px]", chip.className), "data-records-choice-chip": "", children: word }, word);
|
|
@@ -13034,7 +13034,7 @@ function OpenChoicePicker({
|
|
|
13034
13034
|
label: word,
|
|
13035
13035
|
chip: chipOf(option, word).className,
|
|
13036
13036
|
onRemove: () => {
|
|
13037
|
-
if (field.multi) choose(option ? (0,
|
|
13037
|
+
if (field.multi) choose(option ? (0, import_records28.optionKey)(option) : String(current[i]));
|
|
13038
13038
|
else onChange(null);
|
|
13039
13039
|
}
|
|
13040
13040
|
};
|
|
@@ -13065,11 +13065,11 @@ function OpenChoicePicker({
|
|
|
13065
13065
|
id: option.id,
|
|
13066
13066
|
label: titleOf(option),
|
|
13067
13067
|
chip: chipOf(option, titleOf(option)).className,
|
|
13068
|
-
picked: current.some((v) => (0,
|
|
13068
|
+
picked: current.some((v) => (0, import_records28.isTheChosen)(option, v))
|
|
13069
13069
|
})),
|
|
13070
13070
|
onPick: (optionId) => {
|
|
13071
13071
|
const option = options.find((o) => o.id === optionId);
|
|
13072
|
-
if (option) choose((0,
|
|
13072
|
+
if (option) choose((0, import_records28.optionKey)(option));
|
|
13073
13073
|
},
|
|
13074
13074
|
empty: q === "" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "No choices yet \u2014 type one to add it." }) : null,
|
|
13075
13075
|
add,
|
|
@@ -13125,7 +13125,7 @@ function ChoiceAnswer({
|
|
|
13125
13125
|
onChosen
|
|
13126
13126
|
}) {
|
|
13127
13127
|
const [search, setSearch] = (0, import_react67.useState)("");
|
|
13128
|
-
const held = field.multi ? (0,
|
|
13128
|
+
const held = field.multi ? (0, import_records28.choiceValuesOf)(value) : value === null || value === void 0 || value === "" ? [] : [value];
|
|
13129
13129
|
const on = (choice) => held.some((v) => isChosen ? isChosen(choice, v) : String(v) === choice.key || String(v) === choice.label);
|
|
13130
13130
|
const press = (choice) => {
|
|
13131
13131
|
if (!field.multi) {
|
|
@@ -13475,7 +13475,7 @@ function RecordPicker({ tableId, value, onChange, disabled }) {
|
|
|
13475
13475
|
|
|
13476
13476
|
// src/DataBindingPicker.tsx
|
|
13477
13477
|
var import_react73 = require("react");
|
|
13478
|
-
var
|
|
13478
|
+
var import_records29 = require("@ai-matrx/records");
|
|
13479
13479
|
var import_react74 = require("@ai-matrx/records/react");
|
|
13480
13480
|
var import_design_system41 = require("@ai-matrx/design-system");
|
|
13481
13481
|
init_names();
|
|
@@ -13510,7 +13510,7 @@ function isCompleteDataBinding(binding) {
|
|
|
13510
13510
|
}
|
|
13511
13511
|
function bindingPlaceholdersFor(field) {
|
|
13512
13512
|
const label = fieldName(field);
|
|
13513
|
-
if ((0,
|
|
13513
|
+
if ((0, import_records29.isEntityReferenceConfig)(field.config)) {
|
|
13514
13514
|
return [
|
|
13515
13515
|
{ token: `{${field.key}.name}`, label: `${label} \xB7 name` },
|
|
13516
13516
|
{ token: `{${field.key}.id}`, label: `${label} \xB7 id` }
|