@ai-matrx/records-ui 0.115.17 → 0.115.18
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 +253 -233
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -6
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +131 -111
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +26 -6
- package/dist/pickers.js.map +1 -1
- package/package.json +4 -4
package/dist/pickers.cjs
CHANGED
|
@@ -53,7 +53,7 @@ __reExport(askOnce_exports, require("@ai-matrx/records/versions"));
|
|
|
53
53
|
|
|
54
54
|
// src/editors.tsx
|
|
55
55
|
var import_react53 = require("react");
|
|
56
|
-
var
|
|
56
|
+
var import_records29 = require("@ai-matrx/records");
|
|
57
57
|
var import_react54 = require("@ai-matrx/records/react");
|
|
58
58
|
var import_design_system33 = require("@ai-matrx/design-system");
|
|
59
59
|
|
|
@@ -1719,7 +1719,7 @@ function RelationPicker({ field, value, onChange, disabled, id, className, allow
|
|
|
1719
1719
|
var import_react44 = require("react");
|
|
1720
1720
|
var import_design_system29 = require("@ai-matrx/design-system");
|
|
1721
1721
|
var import_data_table8 = require("@ai-matrx/design-system/data-table");
|
|
1722
|
-
var
|
|
1722
|
+
var import_records26 = require("@ai-matrx/records");
|
|
1723
1723
|
var import_react45 = require("@ai-matrx/records/react");
|
|
1724
1724
|
|
|
1725
1725
|
// src/columnName.ts
|
|
@@ -2169,10 +2169,30 @@ function ReferenceBuilder({
|
|
|
2169
2169
|
// src/FormulaTextEditor.tsx
|
|
2170
2170
|
var import_react12 = require("react");
|
|
2171
2171
|
var import_react13 = require("@ai-matrx/records/react");
|
|
2172
|
-
var
|
|
2172
|
+
var import_records9 = require("@ai-matrx/records");
|
|
2173
2173
|
var import_design_system9 = require("@ai-matrx/design-system");
|
|
2174
2174
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2175
|
-
var
|
|
2175
|
+
var NOT_TYPED_BY_NAME = /* @__PURE__ */ new Set([
|
|
2176
|
+
"fx.add",
|
|
2177
|
+
"fx.sub",
|
|
2178
|
+
"fx.mul",
|
|
2179
|
+
"fx.div",
|
|
2180
|
+
"fx.mod",
|
|
2181
|
+
"fx.neg",
|
|
2182
|
+
"fx.eq",
|
|
2183
|
+
"fx.ne",
|
|
2184
|
+
"fx.lt",
|
|
2185
|
+
"fx.lte",
|
|
2186
|
+
"fx.gt",
|
|
2187
|
+
"fx.gte",
|
|
2188
|
+
"fx.autonumber",
|
|
2189
|
+
"fx.created_time",
|
|
2190
|
+
"fx.modified_time"
|
|
2191
|
+
]);
|
|
2192
|
+
function formulaFunctionNames(kinds) {
|
|
2193
|
+
return [...new Set(kinds.map((row) => row.node))].filter((node) => node.startsWith("fx.") && !NOT_TYPED_BY_NAME.has(node)).map((node) => node.slice(3).toUpperCase()).sort();
|
|
2194
|
+
}
|
|
2195
|
+
var FORMULA_FUNCTION_NAMES = formulaFunctionNames(import_records9.RULE_NODE_KINDS);
|
|
2176
2196
|
var RESULT_WORD = {
|
|
2177
2197
|
number: "a number",
|
|
2178
2198
|
text: "text",
|
|
@@ -2269,7 +2289,7 @@ function FormulaTextEditor({
|
|
|
2269
2289
|
text,
|
|
2270
2290
|
columns,
|
|
2271
2291
|
mistake: parsed && !parsed.ok ? parsed.error : error ? refusalSentence(error) : null,
|
|
2272
|
-
functions:
|
|
2292
|
+
functions: FORMULA_FUNCTION_NAMES,
|
|
2273
2293
|
onFormula: onText
|
|
2274
2294
|
}) }) : null
|
|
2275
2295
|
] }),
|
|
@@ -2316,13 +2336,13 @@ function FormulaTextEditor({
|
|
|
2316
2336
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-[11px] text-muted-foreground", children: "Columns:" }),
|
|
2317
2337
|
columns.map((f) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system9.Button, { type: "button", size: "sm", variant: "outline", className: "h-6 px-1.5 text-[11px]", onClick: () => insert(`{${fieldName(f)}}`), children: fieldName(f) }, f.id))
|
|
2318
2338
|
] }),
|
|
2319
|
-
|
|
2339
|
+
FORMULA_FUNCTION_NAMES.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("details", { className: "text-[11px] text-muted-foreground", children: [
|
|
2320
2340
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("summary", { className: "cursor-pointer", children: [
|
|
2321
2341
|
"Functions the store works out (",
|
|
2322
|
-
|
|
2342
|
+
FORMULA_FUNCTION_NAMES.length,
|
|
2323
2343
|
")"
|
|
2324
2344
|
] }),
|
|
2325
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mt-1 flex flex-wrap gap-1", children:
|
|
2345
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mt-1 flex flex-wrap gap-1", children: FORMULA_FUNCTION_NAMES.map((name) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system9.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-1.5 font-mono text-[11px]", onClick: () => insert(`${name}()`), children: name }, name)) })
|
|
2326
2346
|
] }) : null
|
|
2327
2347
|
] });
|
|
2328
2348
|
}
|
|
@@ -2431,7 +2451,7 @@ var import_react16 = require("react");
|
|
|
2431
2451
|
var import_table_style = require("@ai-matrx/design-system/data-table/table-style");
|
|
2432
2452
|
var import_data_table2 = require("@ai-matrx/design-system/data-table");
|
|
2433
2453
|
var import_field_formats2 = require("@ai-matrx/design-system/field-formats");
|
|
2434
|
-
var
|
|
2454
|
+
var import_records10 = require("@ai-matrx/records");
|
|
2435
2455
|
var DRAWN_KINDS = /* @__PURE__ */ new Set(["select", "multi_select", "relation", "member", "person", "attachment", "file", "entity_reference", "checkbox", "boolean", "signature", "json"]);
|
|
2436
2456
|
function shownAsOf(field) {
|
|
2437
2457
|
if (DRAWN_KINDS.has(String(editorKindFor(field)))) return void 0;
|
|
@@ -2444,8 +2464,8 @@ function shownAsOf(field) {
|
|
|
2444
2464
|
}
|
|
2445
2465
|
function formatForField(field) {
|
|
2446
2466
|
const shownAs = shownAsOf(field);
|
|
2447
|
-
if ((0,
|
|
2448
|
-
return { id: "rating", options: { ...shownAs?.options ?? {}, ratingMax: (0,
|
|
2467
|
+
if ((0, import_records10.newerKindOf)(field) === "rating" && (!shownAs || shownAs.id === "rating")) {
|
|
2468
|
+
return { id: "rating", options: { ...shownAs?.options ?? {}, ratingMax: (0, import_records10.ratingMaxOf)(field) } };
|
|
2449
2469
|
}
|
|
2450
2470
|
if (shownAs) return shownAs;
|
|
2451
2471
|
const stamp = dateFormatFor(field);
|
|
@@ -2510,8 +2530,8 @@ var EMBEDDED_TABLE_CLASS = [
|
|
|
2510
2530
|
// src/labels.tsx
|
|
2511
2531
|
var import_react19 = require("react");
|
|
2512
2532
|
var import_react20 = require("@ai-matrx/records/react");
|
|
2513
|
-
var import_records10 = require("@ai-matrx/records");
|
|
2514
2533
|
var import_records11 = require("@ai-matrx/records");
|
|
2534
|
+
var import_records12 = require("@ai-matrx/records");
|
|
2515
2535
|
var import_uuid2 = require("@ai-matrx/kit/uuid");
|
|
2516
2536
|
|
|
2517
2537
|
// src/signature.tsx
|
|
@@ -2870,7 +2890,7 @@ function RecordLabelProvider({ children }) {
|
|
|
2870
2890
|
for (const option of result.data ?? []) {
|
|
2871
2891
|
const words = recordName(option.data, null, "Unnamed choice");
|
|
2872
2892
|
next[option.id] = words;
|
|
2873
|
-
const key = (0,
|
|
2893
|
+
const key = (0, import_records12.optionKey)(option);
|
|
2874
2894
|
if (key) next[choiceKeyName(field.id, key)] = words;
|
|
2875
2895
|
}
|
|
2876
2896
|
return next;
|
|
@@ -3060,7 +3080,7 @@ var ABSENCE_WORD_LABEL = {
|
|
|
3060
3080
|
|
|
3061
3081
|
// src/EntityReferenceControl.tsx
|
|
3062
3082
|
var import_react22 = require("react");
|
|
3063
|
-
var
|
|
3083
|
+
var import_records13 = require("@ai-matrx/records");
|
|
3064
3084
|
var import_react23 = require("@ai-matrx/records/react");
|
|
3065
3085
|
var import_design_system13 = require("@ai-matrx/design-system");
|
|
3066
3086
|
|
|
@@ -3156,7 +3176,7 @@ var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
|
3156
3176
|
var WITHHELD_ENTITY_LABEL = "Something you have not been given access to";
|
|
3157
3177
|
var ENTITY_REFERENCE_EMPTY = "Nothing is pointed at yet.";
|
|
3158
3178
|
function entityReferenceText(value) {
|
|
3159
|
-
const refs = (0,
|
|
3179
|
+
const refs = (0, import_records13.entityRefsOf)(value);
|
|
3160
3180
|
if (refs.length === 0) return "\u2014";
|
|
3161
3181
|
return refs.map((r) => r.label ?? WITHHELD_ENTITY_LABEL).join(", ");
|
|
3162
3182
|
}
|
|
@@ -3170,7 +3190,7 @@ function EntityReferenceControl(props) {
|
|
|
3170
3190
|
return client ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(WithWords, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Chips, { ...props, words: null, picker: null });
|
|
3171
3191
|
}
|
|
3172
3192
|
function WithWords(props) {
|
|
3173
|
-
const refs = (0, import_react22.useMemo)(() => (0,
|
|
3193
|
+
const refs = (0, import_react22.useMemo)(() => (0, import_records13.entityRefsOf)(props.value), [props.value]);
|
|
3174
3194
|
const [known, setKnown] = (0, import_react22.useState)([]);
|
|
3175
3195
|
const withKnown = refs.map((r) => r.label === null ? known.find((k) => k.token === r.token && k.id === r.id) ?? r : r);
|
|
3176
3196
|
const unlabelled = (0, import_react22.useMemo)(
|
|
@@ -3188,7 +3208,7 @@ function WithWords(props) {
|
|
|
3188
3208
|
setKnown((k) => [...k.filter((x) => !(x.token === picked.token && x.id === picked.id)), picked]);
|
|
3189
3209
|
const multi = Boolean(props.field.multi);
|
|
3190
3210
|
const next = multi ? [...withKnown.filter((x) => !(x.token === picked.token && x.id === picked.id)), picked] : [picked];
|
|
3191
|
-
props.onChange((0,
|
|
3211
|
+
props.onChange((0, import_records13.entityRefsToWrite)(next, multi));
|
|
3192
3212
|
}
|
|
3193
3213
|
}
|
|
3194
3214
|
);
|
|
@@ -3277,7 +3297,7 @@ function Chips({
|
|
|
3277
3297
|
words,
|
|
3278
3298
|
picker
|
|
3279
3299
|
}) {
|
|
3280
|
-
const refs = (0, import_react22.useMemo)(() => (0,
|
|
3300
|
+
const refs = (0, import_react22.useMemo)(() => (0, import_records13.entityRefsOf)(value), [value]);
|
|
3281
3301
|
const labelOf = (token, refId, own3) => {
|
|
3282
3302
|
if (own3) return own3;
|
|
3283
3303
|
const read = words?.data?.find((w) => w.token === token && w.id === refId)?.label;
|
|
@@ -3301,7 +3321,7 @@ function Chips({
|
|
|
3301
3321
|
"aria-label": `Take ${label} off`,
|
|
3302
3322
|
onClick: () => {
|
|
3303
3323
|
const rest = refs.filter((x) => !(x.token === r.token && x.id === r.id));
|
|
3304
|
-
onChange((0,
|
|
3324
|
+
onChange((0, import_records13.entityRefsToWrite)(rest, multi));
|
|
3305
3325
|
},
|
|
3306
3326
|
children: "\xD7"
|
|
3307
3327
|
}
|
|
@@ -3762,7 +3782,7 @@ function AttachmentControl({
|
|
|
3762
3782
|
}
|
|
3763
3783
|
|
|
3764
3784
|
// src/ReferenceChips.tsx
|
|
3765
|
-
var
|
|
3785
|
+
var import_records14 = require("@ai-matrx/records");
|
|
3766
3786
|
var import_design_system18 = require("@ai-matrx/design-system");
|
|
3767
3787
|
|
|
3768
3788
|
// src/kindValues.ts
|
|
@@ -3834,7 +3854,7 @@ function iconOf(pair) {
|
|
|
3834
3854
|
}
|
|
3835
3855
|
function referencesOf(field, value, kind, labels) {
|
|
3836
3856
|
if (kind === "entity_reference") {
|
|
3837
|
-
return (0,
|
|
3857
|
+
return (0, import_records14.entityRefsOf)(value).map((r) => ({ token: r.token, id: r.id, label: r.label }));
|
|
3838
3858
|
}
|
|
3839
3859
|
const ids = (Array.isArray(value) ? value : [value]).filter(isId).map(String);
|
|
3840
3860
|
const tableId = typeof field.relation_target === "string" ? field.relation_target : void 0;
|
|
@@ -3920,7 +3940,7 @@ function KindValueCell({
|
|
|
3920
3940
|
}
|
|
3921
3941
|
|
|
3922
3942
|
// src/formulaNames.ts
|
|
3923
|
-
var
|
|
3943
|
+
var import_records15 = require("@ai-matrx/records");
|
|
3924
3944
|
function fieldRefsOf(expr) {
|
|
3925
3945
|
const out = [];
|
|
3926
3946
|
const walk = (node) => {
|
|
@@ -3970,14 +3990,14 @@ function formulaSourceArchived(field, document2) {
|
|
|
3970
3990
|
const keys = (field.config ?? {})[FORMULA_INPUT_KEYS];
|
|
3971
3991
|
if (!Array.isArray(keys) || !document2) return null;
|
|
3972
3992
|
for (const key of keys) {
|
|
3973
|
-
const state = (0,
|
|
3993
|
+
const state = (0, import_records15.sourceArchivedOf)(document2[String(key)]);
|
|
3974
3994
|
if (state) return state;
|
|
3975
3995
|
}
|
|
3976
3996
|
return null;
|
|
3977
3997
|
}
|
|
3978
3998
|
|
|
3979
3999
|
// src/values.tsx
|
|
3980
|
-
var
|
|
4000
|
+
var import_records16 = require("@ai-matrx/records");
|
|
3981
4001
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3982
4002
|
function statusMark(field, item, document2) {
|
|
3983
4003
|
const mark = statusMarkOf(field, item, document2);
|
|
@@ -4031,7 +4051,7 @@ function SourceArchivedValue({ state }) {
|
|
|
4031
4051
|
}
|
|
4032
4052
|
var ABSENCE_WORDS = ABSENCE_WORD_LABEL;
|
|
4033
4053
|
function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
4034
|
-
const archivedSource = (0,
|
|
4054
|
+
const archivedSource = (0, import_records16.sourceArchivedOf)(value);
|
|
4035
4055
|
if (archivedSource) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SourceArchivedValue, { state: archivedSource });
|
|
4036
4056
|
const envelope = envelopeFor(document2, field.key);
|
|
4037
4057
|
if (envelope?.absent) {
|
|
@@ -4054,7 +4074,7 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4054
4074
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
4055
4075
|
}
|
|
4056
4076
|
if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SignatureValue, { value, fieldKey: field.key, document: document2 });
|
|
4057
|
-
if ((0,
|
|
4077
|
+
if ((0, import_records16.isButtonField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ButtonValue, { field });
|
|
4058
4078
|
const newer = newerKindValue(field, value);
|
|
4059
4079
|
if (newer !== void 0) return newer;
|
|
4060
4080
|
const whole = typeof value === "string" ? (0, import_core5.wholeValueOf)(document2, field.key) : null;
|
|
@@ -4141,10 +4161,10 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4141
4161
|
}
|
|
4142
4162
|
function scalarText(field, value, labels, stillWaitingFor) {
|
|
4143
4163
|
if (value === null || value === void 0) return "\u2014";
|
|
4144
|
-
if ((0,
|
|
4164
|
+
if ((0, import_records16.sourceArchivedOf)(value)) return SOURCE_ARCHIVED_WORDS;
|
|
4145
4165
|
if (isSignatureField(field)) return signatureWords(value) ?? "\u2014";
|
|
4146
|
-
if ((0,
|
|
4147
|
-
const newerWords = (0,
|
|
4166
|
+
if ((0, import_records16.autonumberPrefixOf)(field)) return (0, import_records16.autonumberWords)(field, value) ?? String(value);
|
|
4167
|
+
const newerWords = (0, import_records16.newerKindWords)(field, value);
|
|
4148
4168
|
if (newerWords !== null) return newerWords;
|
|
4149
4169
|
const kind = editorKindFor(field);
|
|
4150
4170
|
if (kind === "entity_reference") return entityReferenceText(value);
|
|
@@ -4234,7 +4254,7 @@ function SourceArchivedNotice({ fieldId, tableId }) {
|
|
|
4234
4254
|
// src/Condition.tsx
|
|
4235
4255
|
var import_react32 = require("react");
|
|
4236
4256
|
var import_design_system21 = require("@ai-matrx/design-system");
|
|
4237
|
-
var
|
|
4257
|
+
var import_records17 = require("@ai-matrx/records");
|
|
4238
4258
|
var import_react33 = require("@ai-matrx/records/react");
|
|
4239
4259
|
|
|
4240
4260
|
// src/personTime.ts
|
|
@@ -4343,7 +4363,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4343
4363
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
|
|
4344
4364
|
if (cancelled) return;
|
|
4345
4365
|
setChoices(
|
|
4346
|
-
got.ok ? (got.data ?? []).map((o) => ({ key: (0,
|
|
4366
|
+
got.ok ? (got.data ?? []).map((o) => ({ key: (0, import_records17.optionKey)(o), label: (0, import_records17.optionLabel)(o) ?? "" })).filter((c) => c.label !== "") : []
|
|
4347
4367
|
);
|
|
4348
4368
|
});
|
|
4349
4369
|
return () => {
|
|
@@ -4361,7 +4381,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4361
4381
|
}
|
|
4362
4382
|
);
|
|
4363
4383
|
}
|
|
4364
|
-
const shown2 = (0,
|
|
4384
|
+
const shown2 = (0, import_records17.rankTypedMatches)(choices, search.trim(), (c) => c.label);
|
|
4365
4385
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "inline-flex min-w-0", "data-records-condition-choice": "", "data-pick-value": value, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
4366
4386
|
PickOrAdd,
|
|
4367
4387
|
{
|
|
@@ -4771,7 +4791,7 @@ function ConditionGroup({
|
|
|
4771
4791
|
|
|
4772
4792
|
// src/FieldRetype.tsx
|
|
4773
4793
|
var import_react34 = require("react");
|
|
4774
|
-
var
|
|
4794
|
+
var import_records18 = require("@ai-matrx/records");
|
|
4775
4795
|
var import_react35 = require("@ai-matrx/records/react");
|
|
4776
4796
|
var import_design_system22 = require("@ai-matrx/design-system");
|
|
4777
4797
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
@@ -4833,7 +4853,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
4833
4853
|
return;
|
|
4834
4854
|
}
|
|
4835
4855
|
const groups = answer.data.map((row) => ({ value: row.groups[field.key] ?? null, count: row.row_count }));
|
|
4836
|
-
setPreview((0,
|
|
4856
|
+
setPreview((0, import_records18.previewRetype)({ type: to.behaviour, kind: to.kind }, groups, answer.data.length >= PREVIEW_GROUPS));
|
|
4837
4857
|
});
|
|
4838
4858
|
return () => {
|
|
4839
4859
|
cancelled = true;
|
|
@@ -4919,7 +4939,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
4919
4939
|
|
|
4920
4940
|
// src/FieldRulePreview.tsx
|
|
4921
4941
|
var import_react36 = require("react");
|
|
4922
|
-
var
|
|
4942
|
+
var import_records19 = require("@ai-matrx/records");
|
|
4923
4943
|
var import_react37 = require("@ai-matrx/records/react");
|
|
4924
4944
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4925
4945
|
var PREVIEW_GROUPS2 = 1e3;
|
|
@@ -4958,7 +4978,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
4958
4978
|
}
|
|
4959
4979
|
const numbers = holdsNumbers(field);
|
|
4960
4980
|
const groups = answer.data.map((row) => ({ value: groupValue(row.groups[field.key] ?? null, numbers), count: row.row_count }));
|
|
4961
|
-
setPreview((0,
|
|
4981
|
+
setPreview((0, import_records19.previewRuleChange)(latest.current, groups, answer.data.length >= PREVIEW_GROUPS2));
|
|
4962
4982
|
});
|
|
4963
4983
|
}, 300);
|
|
4964
4984
|
return () => {
|
|
@@ -5067,7 +5087,7 @@ function choiceLookForNewList(multi, rows) {
|
|
|
5067
5087
|
|
|
5068
5088
|
// src/ChoiceListEditor.tsx
|
|
5069
5089
|
var import_react38 = require("react");
|
|
5070
|
-
var
|
|
5090
|
+
var import_records20 = require("@ai-matrx/records");
|
|
5071
5091
|
var import_react39 = require("@ai-matrx/records/react");
|
|
5072
5092
|
var import_design_system23 = require("@ai-matrx/design-system");
|
|
5073
5093
|
var import_data_table5 = require("@ai-matrx/design-system/data-table");
|
|
@@ -5076,7 +5096,7 @@ var rowSeed = 0;
|
|
|
5076
5096
|
var nextRow = () => `new-${rowSeed += 1}`;
|
|
5077
5097
|
function choiceRowsFrom(options, field) {
|
|
5078
5098
|
return inTheStoresOrder([...options]).map((option) => {
|
|
5079
|
-
const words = (0,
|
|
5099
|
+
const words = (0, import_records20.optionLabel)(option);
|
|
5080
5100
|
const key = option.data?.key;
|
|
5081
5101
|
const color = field ? storedChoiceColor(field, words) ?? storedChoiceColor(field, key) : void 0;
|
|
5082
5102
|
return { id: option.id, words, row: option.id, color: color ?? null };
|
|
@@ -5246,11 +5266,11 @@ function ChoiceListEditor({
|
|
|
5246
5266
|
"div",
|
|
5247
5267
|
{
|
|
5248
5268
|
role: "group",
|
|
5249
|
-
"aria-label": (0,
|
|
5269
|
+
"aria-label": (0, import_records20.recordsUseSentence)(heldBy(asking), asking.words.trim()),
|
|
5250
5270
|
"data-records-choice-removal-ask": "",
|
|
5251
5271
|
className: "flex flex-col gap-1 rounded border bg-muted/40 p-2",
|
|
5252
5272
|
children: [
|
|
5253
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-xs", children: (0,
|
|
5273
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-xs", children: (0, import_records20.recordsUseSentence)(heldBy(asking), asking.words.trim()) }),
|
|
5254
5274
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
5255
5275
|
targets.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
5256
5276
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_design_system23.Button, { type: "button", size: "sm", className: "h-7 px-2 text-xs", disabled: moveTo === "", onClick: () => answer({ then: "move", to: moveTo }), children: "Move them to" }),
|
|
@@ -5269,7 +5289,7 @@ function ChoiceListEditor({
|
|
|
5269
5289
|
) : null,
|
|
5270
5290
|
Object.entries(rehome).map(
|
|
5271
5291
|
([id, spec]) => removed[id] ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center justify-between gap-2 text-[11px] text-muted-foreground", "data-records-choice-rehome": "", children: [
|
|
5272
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: (0,
|
|
5292
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: (0, import_records20.rehomeSentence)(usage?.[id]?.records ?? 0, removed[id].row.words.trim(), spec, spec.then === "move" ? wordsOf(spec.to) : void 0) }),
|
|
5273
5293
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_design_system23.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-1.5 text-[11px]", onClick: () => putBack(id), children: "Put it back" })
|
|
5274
5294
|
] }, id) : null
|
|
5275
5295
|
),
|
|
@@ -5329,7 +5349,7 @@ function ChoiceSwatch({ words, color, onColor }) {
|
|
|
5329
5349
|
}
|
|
5330
5350
|
|
|
5331
5351
|
// src/NewerKindQuestions.tsx
|
|
5332
|
-
var
|
|
5352
|
+
var import_records21 = require("@ai-matrx/records");
|
|
5333
5353
|
var import_design_system24 = require("@ai-matrx/design-system");
|
|
5334
5354
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5335
5355
|
var STATUS_STARTING_CHOICES = [
|
|
@@ -5350,7 +5370,7 @@ function statusGroupRows(field, rows, keyOfId, changed) {
|
|
|
5350
5370
|
if (words === "") continue;
|
|
5351
5371
|
const ref = r.id ?? words;
|
|
5352
5372
|
const key = r.id ? keyOfId[r.id] : void 0;
|
|
5353
|
-
const held = field && key ? (0,
|
|
5373
|
+
const held = field && key ? (0, import_records21.statusGroupOf)(field, key) : void 0;
|
|
5354
5374
|
out.push({ ref, words, group: changed[ref] ?? held ?? guessStatusGroup(words) });
|
|
5355
5375
|
}
|
|
5356
5376
|
return out;
|
|
@@ -5366,10 +5386,10 @@ function StatusGroupsQuestion({
|
|
|
5366
5386
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "min-w-0 flex-1 truncate text-sm", children: r.words }),
|
|
5367
5387
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_design_system24.Select, { value: r.group, onValueChange: (next) => onGroup(r.ref, next), children: [
|
|
5368
5388
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system24.SelectTrigger, { size: "sm", className: "w-36", "aria-label": `Group for ${r.words}`, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system24.SelectValue, {}) }),
|
|
5369
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system24.SelectContent, { children:
|
|
5389
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system24.SelectContent, { children: import_records21.STATUS_GROUPS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_design_system24.SelectItem, { value: g, children: [
|
|
5370
5390
|
STATUS_GROUP_MARK[g],
|
|
5371
5391
|
" ",
|
|
5372
|
-
|
|
5392
|
+
import_records21.STATUS_GROUP_WORDS[g]
|
|
5373
5393
|
] }, g)) })
|
|
5374
5394
|
] })
|
|
5375
5395
|
] }, r.ref))
|
|
@@ -5407,7 +5427,7 @@ function BarcodeSymbologyQuestion({ value, onChange }) {
|
|
|
5407
5427
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system24.SelectTrigger, { size: "sm", "aria-label": "Code type", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system24.SelectValue, {}) }),
|
|
5408
5428
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_design_system24.SelectContent, { children: [
|
|
5409
5429
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system24.SelectItem, { value: "any", children: "Any code" }),
|
|
5410
|
-
|
|
5430
|
+
import_records21.BARCODE_SYMBOLOGIES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system24.SelectItem, { value: s, children: SYMBOLOGY_WORDS[s] }, s))
|
|
5411
5431
|
] })
|
|
5412
5432
|
] })
|
|
5413
5433
|
] });
|
|
@@ -5727,21 +5747,21 @@ function nextFieldSort(fields) {
|
|
|
5727
5747
|
}
|
|
5728
5748
|
|
|
5729
5749
|
// src/FieldEditor.tsx
|
|
5730
|
-
var
|
|
5750
|
+
var import_records24 = require("@ai-matrx/records");
|
|
5731
5751
|
|
|
5732
5752
|
// src/ButtonSettings.tsx
|
|
5733
5753
|
var import_react40 = require("react");
|
|
5734
5754
|
var import_design_system27 = require("@ai-matrx/design-system");
|
|
5735
5755
|
var import_data_table7 = require("@ai-matrx/design-system/data-table");
|
|
5736
|
-
var
|
|
5756
|
+
var import_records23 = require("@ai-matrx/records");
|
|
5737
5757
|
var import_react41 = require("@ai-matrx/records/react");
|
|
5738
5758
|
|
|
5739
5759
|
// src/AccentSwatches.tsx
|
|
5740
|
-
var
|
|
5760
|
+
var import_records22 = require("@ai-matrx/records");
|
|
5741
5761
|
var import_design_system26 = require("@ai-matrx/design-system");
|
|
5742
5762
|
var import_data_table6 = require("@ai-matrx/design-system/data-table");
|
|
5743
5763
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
5744
|
-
function AccentSwatches({ value, onChange, options =
|
|
5764
|
+
function AccentSwatches({ value, onChange, options = import_records22.PORTAL_ACCENTS, noneLabel = "App colour" }) {
|
|
5745
5765
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-wrap gap-1.5", role: "radiogroup", "aria-label": "Colour", children: [
|
|
5746
5766
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
5747
5767
|
"button",
|
|
@@ -5783,7 +5803,7 @@ var DOES_WORDS = {
|
|
|
5783
5803
|
};
|
|
5784
5804
|
function buttonUrlInWords(url, fields) {
|
|
5785
5805
|
let out = url;
|
|
5786
|
-
for (const id of (0,
|
|
5806
|
+
for (const id of (0, import_records23.buttonUrlPlaceholders)(url)) {
|
|
5787
5807
|
const f = fields.find((x) => x.id === id || x.key === id);
|
|
5788
5808
|
if (f) out = out.split(`{{${id}}}`).join(`{${fieldName(f)}}`);
|
|
5789
5809
|
}
|
|
@@ -5878,7 +5898,7 @@ function ButtonSettingsEditor({
|
|
|
5878
5898
|
}
|
|
5879
5899
|
) : null
|
|
5880
5900
|
] }),
|
|
5881
|
-
value.url && (0,
|
|
5901
|
+
value.url && (0, import_records23.buttonUrlPlaceholders)(value.url).length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "truncate text-[11px] text-muted-foreground", "data-records-button-url-words": "", children: buttonUrlInWords(value.url, fields) }) : null
|
|
5882
5902
|
] }) : null,
|
|
5883
5903
|
value.do === "run_action" ? !tableId ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-xs text-muted-foreground", children: "Row actions belong to a table" }) : actionsRefused ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(RefusalLine, { error: actionsRefused }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-col gap-2", "data-records-button-action": "", children: [
|
|
5884
5904
|
actions === null || actions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
@@ -5984,11 +6004,11 @@ function NewRowAction({
|
|
|
5984
6004
|
}
|
|
5985
6005
|
|
|
5986
6006
|
// src/FieldEditor.tsx
|
|
5987
|
-
var
|
|
6007
|
+
var import_records25 = require("@ai-matrx/records");
|
|
5988
6008
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
5989
6009
|
var RULE_KINDS = FIELD_RULE_KIND_VALUES.map((kind) => ({ kind, label: FIELD_RULE_KIND_LABEL[kind] }));
|
|
5990
|
-
var SENSITIVITIES =
|
|
5991
|
-
var AGENT_VISIBILITY =
|
|
6010
|
+
var SENSITIVITIES = import_records25.FIELD_SENSITIVITIES.map((value) => ({ value, label: FIELD_SENSITIVITY_LABEL[value] }));
|
|
6011
|
+
var AGENT_VISIBILITY = import_records25.CONTEXT_POLICIES.map((value) => ({ value, label: CONTEXT_POLICY_LABEL[value] }));
|
|
5992
6012
|
var ROLLUP_OPERATIONS = ROLLUP_AGG_VALUES.map((value) => ({
|
|
5993
6013
|
value,
|
|
5994
6014
|
label: ROLLUP_AGG_LABEL[value]
|
|
@@ -6001,7 +6021,7 @@ var FORMULA_OPERATIONS = FORMULA_OP_VALUES.map((value) => ({
|
|
|
6001
6021
|
label: FORMULA_OP_LABEL[value],
|
|
6002
6022
|
joins: FORMULA_OP_JOINS[value]
|
|
6003
6023
|
}));
|
|
6004
|
-
var STORE_BEHAVIOUR = new Map(
|
|
6024
|
+
var STORE_BEHAVIOUR = new Map(import_records25.DECLARABLE_FIELD_KINDS.map((row) => [row.kind, row.behavior]));
|
|
6005
6025
|
function holdsAValueOnAStandardTable(kind) {
|
|
6006
6026
|
if (isSystemFieldKind(kind)) return false;
|
|
6007
6027
|
const behaviour = STORE_BEHAVIOUR.get(kind);
|
|
@@ -6101,18 +6121,18 @@ function FieldEditor(props) {
|
|
|
6101
6121
|
const [contextPolicy, setContextPolicy] = (0, import_react42.useState)(String(start?.context_policy ?? "include"));
|
|
6102
6122
|
const [rules, setRules] = (0, import_react42.useState)(start?.rules ?? []);
|
|
6103
6123
|
const [startsWith, setStartsWith] = (0, import_react42.useState)(start?.default ?? null);
|
|
6104
|
-
const [ratingMax, setRatingMax] = (0, import_react42.useState)(() => start ? (0,
|
|
6124
|
+
const [ratingMax, setRatingMax] = (0, import_react42.useState)(() => start ? (0, import_records25.ratingMaxOf)(start) : 5);
|
|
6105
6125
|
const savedRules = (0, import_react42.useMemo)(
|
|
6106
|
-
() => field ? type === "rating" ? (0,
|
|
6126
|
+
() => field ? type === "rating" ? (0, import_records25.rulesWithTopStar)(field.rules ?? [], (0, import_records25.ratingMaxOf)(field)) : field.rules ?? [] : [],
|
|
6107
6127
|
[field, type]
|
|
6108
6128
|
);
|
|
6109
|
-
const editedRules = (0, import_react42.useMemo)(() => type === "rating" ? (0,
|
|
6129
|
+
const editedRules = (0, import_react42.useMemo)(() => type === "rating" ? (0, import_records25.rulesWithTopStar)(rules, ratingMax) : rules, [type, rules, ratingMax]);
|
|
6110
6130
|
const [statusGroups, setStatusGroups] = (0, import_react42.useState)({});
|
|
6111
6131
|
const [statusKeys, setStatusKeys] = (0, import_react42.useState)({});
|
|
6112
6132
|
const [symbology, setSymbology] = (0, import_react42.useState)(String(start?.config?.["symbology"] ?? ""));
|
|
6113
|
-
const buttonStart = (0, import_react42.useMemo)(() => (0,
|
|
6133
|
+
const buttonStart = (0, import_react42.useMemo)(() => (0, import_records24.buttonOf)(start) ?? { label: "" }, [start]);
|
|
6114
6134
|
const [buttonSettings, setButtonSettings] = (0, import_react42.useState)(buttonStart);
|
|
6115
|
-
const prefixStart = (0,
|
|
6135
|
+
const prefixStart = (0, import_records24.autonumberPrefixOf)(start);
|
|
6116
6136
|
const [numberPrefix, setNumberPrefix] = (0, import_react42.useState)(prefixStart);
|
|
6117
6137
|
const dependencyStart = start?.config?.["dependency"] === true;
|
|
6118
6138
|
const [dependency, setDependency] = (0, import_react42.useState)(dependencyStart);
|
|
@@ -6120,7 +6140,7 @@ function FieldEditor(props) {
|
|
|
6120
6140
|
if (!field || type !== "status") return;
|
|
6121
6141
|
let live = true;
|
|
6122
6142
|
void client.fieldOptions({ field_id: field.id }).then((got) => {
|
|
6123
|
-
if (live && got.ok) setStatusKeys(Object.fromEntries((got.data ?? []).map((o) => [String(o.id), (0,
|
|
6143
|
+
if (live && got.ok) setStatusKeys(Object.fromEntries((got.data ?? []).map((o) => [String(o.id), (0, import_records25.optionKey)(o)])));
|
|
6124
6144
|
});
|
|
6125
6145
|
return () => {
|
|
6126
6146
|
live = false;
|
|
@@ -6234,7 +6254,7 @@ function FieldEditor(props) {
|
|
|
6234
6254
|
const noun = onEntity ? "field" : "column";
|
|
6235
6255
|
const nameTaken = columnNameTakenBy(label, others.map(fieldName));
|
|
6236
6256
|
const listsChoices = type === "select" || type === "multi_select" || type === "status";
|
|
6237
|
-
const buttonMissing = type === "button" && buttonSettings.do ? (0,
|
|
6257
|
+
const buttonMissing = type === "button" && buttonSettings.do ? (0, import_records24.buttonNeeds)(buttonSettings) : null;
|
|
6238
6258
|
const missing = buttonMissing ?? (editing ? formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(choiceList) : null) : formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(newChoices) : null) ?? (type === "formula" && formulaWritten ? null : whatIsMissing(
|
|
6239
6259
|
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 }
|
|
6240
6260
|
)));
|
|
@@ -6275,7 +6295,7 @@ function FieldEditor(props) {
|
|
|
6275
6295
|
...statusGroupsChanged ? { status_groups: statusGroupsSent } : {},
|
|
6276
6296
|
// V11 #4/#10: a rating's top star goes as `max`, the word custom.field_update now takes the way
|
|
6277
6297
|
// custom.field_declare does; the store writes the max Rule and sets aside any score above it.
|
|
6278
|
-
...type === "rating" && ratingMax !== (0,
|
|
6298
|
+
...type === "rating" && ratingMax !== (0, import_records25.ratingMaxOf)(field) ? { max: ratingMax } : {},
|
|
6279
6299
|
...type === "barcode" && symbology !== String(field.config?.["symbology"] ?? "") ? { symbology: symbology === "" ? null : symbology } : {},
|
|
6280
6300
|
...type === "button" && JSON.stringify(buttonSettings) !== JSON.stringify(buttonStart) ? { button: buttonSettings } : {},
|
|
6281
6301
|
...field.type === "relation" && dependency !== dependencyStart ? { dependency } : {},
|
|
@@ -7221,13 +7241,13 @@ function buttonPressWords(label, pressed) {
|
|
|
7221
7241
|
var stop = (event) => event.stopPropagation();
|
|
7222
7242
|
function ButtonValue({ field, recordId, inCell }) {
|
|
7223
7243
|
const client = (0, import_react45.useOptionalRecordsClient)();
|
|
7224
|
-
const b = (0,
|
|
7244
|
+
const b = (0, import_records26.buttonOf)(field);
|
|
7225
7245
|
const [busy, setBusy] = (0, import_react44.useState)(false);
|
|
7226
7246
|
const [said2, setSaid] = (0, import_react44.useState)(null);
|
|
7227
7247
|
const [settingUp, setSettingUp] = (0, import_react44.useState)(false);
|
|
7228
7248
|
if (!b) return null;
|
|
7229
7249
|
const color = (0, import_data_table8.isStyleColor)(b.color) ? import_data_table8.CHOICE_CHIP_CLASS[b.color] : import_data_table8.NEUTRAL_CHIP_CLASS;
|
|
7230
|
-
const needs = (0,
|
|
7250
|
+
const needs = (0, import_records26.buttonNeeds)(b);
|
|
7231
7251
|
const tableId = field.entity_definition_id;
|
|
7232
7252
|
const press = async () => {
|
|
7233
7253
|
if (!client || !recordId) return setSaid({ kind: "public" });
|
|
@@ -7307,7 +7327,7 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7307
7327
|
|
|
7308
7328
|
// src/PersonPicker.tsx
|
|
7309
7329
|
var import_react46 = require("react");
|
|
7310
|
-
var
|
|
7330
|
+
var import_records27 = require("@ai-matrx/records");
|
|
7311
7331
|
var import_react47 = require("@ai-matrx/records/react");
|
|
7312
7332
|
var import_design_system30 = require("@ai-matrx/design-system");
|
|
7313
7333
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
@@ -7389,7 +7409,7 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
|
|
|
7389
7409
|
cancelled = true;
|
|
7390
7410
|
};
|
|
7391
7411
|
}, [client, personTable, picked.length, people.length]);
|
|
7392
|
-
const listed = (0,
|
|
7412
|
+
const listed = (0, import_records27.rankTypedMatches)(members ?? [], search, memberName);
|
|
7393
7413
|
if (!membersPort || !client) {
|
|
7394
7414
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: (0, import_design_system30.cn)("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
|
|
7395
7415
|
}
|
|
@@ -7654,7 +7674,7 @@ function formatControl(args) {
|
|
|
7654
7674
|
// src/typedDateHelper.tsx
|
|
7655
7675
|
var import_react50 = require("react");
|
|
7656
7676
|
var import_design_system32 = require("@ai-matrx/design-system");
|
|
7657
|
-
var
|
|
7677
|
+
var import_records28 = require("@ai-matrx/records");
|
|
7658
7678
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7659
7679
|
var WEEK = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
7660
7680
|
var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
@@ -7663,12 +7683,12 @@ function pad(n) {
|
|
|
7663
7683
|
}
|
|
7664
7684
|
function readBox(text, kind) {
|
|
7665
7685
|
if (kind === "time") {
|
|
7666
|
-
const t = (0,
|
|
7686
|
+
const t = (0, import_records28.readTypedTime)(text);
|
|
7667
7687
|
if (!t.ok) return { day: null, time: null };
|
|
7668
7688
|
const [h, m] = t.value.split(":").map(Number);
|
|
7669
7689
|
return { day: null, time: { h, m } };
|
|
7670
7690
|
}
|
|
7671
|
-
const read = (0,
|
|
7691
|
+
const read = (0, import_records28.readTypedDate)(text, { withTime: kind === "datetime" });
|
|
7672
7692
|
if (!read.ok) return { day: null, time: null };
|
|
7673
7693
|
if (kind === "datetime" && read.instant) {
|
|
7674
7694
|
const at = new Date(read.instant);
|
|
@@ -7677,10 +7697,10 @@ function readBox(text, kind) {
|
|
|
7677
7697
|
return { day: read.day, time: null };
|
|
7678
7698
|
}
|
|
7679
7699
|
function wordsFor(kind, day, time) {
|
|
7680
|
-
if (kind === "time") return time ? (0,
|
|
7700
|
+
if (kind === "time") return time ? (0, import_records28.typedTimeText)(time.h, time.m) : "";
|
|
7681
7701
|
if (!day) return "";
|
|
7682
|
-
const dayText = (0,
|
|
7683
|
-
return kind === "datetime" && time ? `${dayText} ${(0,
|
|
7702
|
+
const dayText = (0, import_records28.typedDateText)(day);
|
|
7703
|
+
return kind === "datetime" && time ? `${dayText} ${(0, import_records28.typedTimeText)(time.h, time.m)}` : dayText;
|
|
7684
7704
|
}
|
|
7685
7705
|
var keepFocus = { onMouseDown: (e) => e.preventDefault(), tabIndex: -1 };
|
|
7686
7706
|
function CalendarGlyph() {
|
|
@@ -7802,7 +7822,7 @@ function TypedDateHelper({
|
|
|
7802
7822
|
held.time && held.time.h === t.h && held.time.m === t.m ? "bg-primary text-primary-foreground" : ""
|
|
7803
7823
|
),
|
|
7804
7824
|
onClick: () => pickTime(t),
|
|
7805
|
-
children: (0,
|
|
7825
|
+
children: (0, import_records28.typedTimeText)(t.h, t.m)
|
|
7806
7826
|
},
|
|
7807
7827
|
`${t.h}:${t.m}`
|
|
7808
7828
|
)) })
|
|
@@ -7903,21 +7923,21 @@ function judgeTyped(field, text, choices, nudge) {
|
|
|
7903
7923
|
const format = formatForField(field);
|
|
7904
7924
|
if (trimmed === "") return { value: null };
|
|
7905
7925
|
if (format && format.id === "time") {
|
|
7906
|
-
const read2 = (0,
|
|
7926
|
+
const read2 = (0, import_records29.readTypedTime)(trimmed);
|
|
7907
7927
|
return read2.ok ? { value: read2.value } : { refusal: SHORT_REFUSAL.time, why: `${fieldName(field)} holds a time of day, and ${read2.why}` };
|
|
7908
7928
|
}
|
|
7909
7929
|
if (kind === "select" || kind === "multi_select") {
|
|
7910
7930
|
if (!choices || nudge === null) return null;
|
|
7911
7931
|
const several = field.multi || kind === "multi_select";
|
|
7912
7932
|
const words = several ? trimmed.split(/\s*[,;\n]\s*/).filter(Boolean) : [trimmed];
|
|
7913
|
-
const allowOther = (0,
|
|
7933
|
+
const allowOther = (0, import_records29.allowsOtherValues)(field);
|
|
7914
7934
|
const parts = [];
|
|
7915
7935
|
const add = [];
|
|
7916
7936
|
const ask = [];
|
|
7917
7937
|
const notChoices = [];
|
|
7918
7938
|
let keepOffered = allowOther;
|
|
7919
7939
|
for (const word of words) {
|
|
7920
|
-
const decided = (0,
|
|
7940
|
+
const decided = (0, import_records29.decideTypedChoice)({ words: word, options: choices, allowOther, nudge });
|
|
7921
7941
|
if (decided.decision === "empty") continue;
|
|
7922
7942
|
if (decided.decision === "chosen") parts.push(decided.key);
|
|
7923
7943
|
else {
|
|
@@ -7950,7 +7970,7 @@ function judgeTyped(field, text, choices, nudge) {
|
|
|
7950
7970
|
return usual && digits.length >= 7 && digits.length <= 20 ? { value: trimmed } : { refusal: SHORT_REFUSAL.phone };
|
|
7951
7971
|
}
|
|
7952
7972
|
const showsAsPercent = Boolean(format && (format.id === "percent" || format.id === "progress"));
|
|
7953
|
-
const read = (0,
|
|
7973
|
+
const read = (0, import_records29.coerceTypedAnswer)(field, text, { label: fieldName(field), showsAsPercent });
|
|
7954
7974
|
if ("refusal" in read) {
|
|
7955
7975
|
if (kind === "email" || kind === "url") return { refusal: SHORT_REFUSAL[kind] };
|
|
7956
7976
|
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;
|
|
@@ -7971,12 +7991,12 @@ function openingText(field, value) {
|
|
|
7971
7991
|
if (value === null || value === void 0 || value === "") return "";
|
|
7972
7992
|
const helper = dateHelperKind(field, value);
|
|
7973
7993
|
if (helper === "time") {
|
|
7974
|
-
const read = (0,
|
|
7994
|
+
const read = (0, import_records29.readTypedTime)(String(value));
|
|
7975
7995
|
if (!read.ok) return String(value);
|
|
7976
7996
|
const [h, m] = read.value.split(":").map(Number);
|
|
7977
|
-
return (0,
|
|
7997
|
+
return (0, import_records29.typedTimeText)(h, m);
|
|
7978
7998
|
}
|
|
7979
|
-
if (helper) return (0,
|
|
7999
|
+
if (helper) return (0, import_records29.typedDateText)(value, { withTime: helper === "datetime" });
|
|
7980
8000
|
const format = formatForField(field);
|
|
7981
8001
|
return format ? typedText(format, value) : String(value);
|
|
7982
8002
|
}
|
|
@@ -8065,7 +8085,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
|
|
|
8065
8085
|
" ",
|
|
8066
8086
|
needsChoices ? String(
|
|
8067
8087
|
(Array.isArray(withoutAddition(judged.value).value) ? withoutAddition(judged.value).value : [withoutAddition(judged.value).value]).map((k) => {
|
|
8068
|
-
const option = choices?.find((o) => (0,
|
|
8088
|
+
const option = choices?.find((o) => (0, import_records29.optionKey)(o) === k);
|
|
8069
8089
|
return option ? recordName(option.data, null, String(k)) : String(k);
|
|
8070
8090
|
}).join(", ")
|
|
8071
8091
|
) : (() => {
|
|
@@ -8086,7 +8106,7 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
|
|
|
8086
8106
|
const ownDetails = (0, import_react54.useOptionalRecordsClient)() === null;
|
|
8087
8107
|
if (isTypedDraft(value)) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TypedTextControl, { field, value, onChange, disabled, id: inputId, onCommit, onCancel });
|
|
8088
8108
|
if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(SignaturePad, { id: inputId, value, onChange, disabled });
|
|
8089
|
-
if ((0,
|
|
8109
|
+
if ((0, import_records29.isButtonField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ButtonValue, { field });
|
|
8090
8110
|
const newerControl = newerKindControl({ field, value, onChange, disabled, id: inputId });
|
|
8091
8111
|
if (newerControl !== void 0) return newerControl;
|
|
8092
8112
|
const format = formatForField(field);
|
|
@@ -8242,7 +8262,7 @@ function TypedWordsControl({ field, value, onChange, disabled, id }) {
|
|
|
8242
8262
|
function typedDatePlaceholder(helper) {
|
|
8243
8263
|
const time = "h:mm AM";
|
|
8244
8264
|
if (helper === "time") return time;
|
|
8245
|
-
const pattern = (0,
|
|
8265
|
+
const pattern = (0, import_records29.typedDateText)("2026-11-22").replace("2026", "YYYY").replace("11", "MM").replace("22", "DD");
|
|
8246
8266
|
return helper === "datetime" ? `${pattern} ${time}` : pattern;
|
|
8247
8267
|
}
|
|
8248
8268
|
function CheckboxControl({ field, value, onChange, disabled, id }) {
|
|
@@ -8381,15 +8401,15 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
8381
8401
|
ChoiceAnswer,
|
|
8382
8402
|
{
|
|
8383
8403
|
field,
|
|
8384
|
-
choices: options.map((option) => ({ key: (0,
|
|
8404
|
+
choices: options.map((option) => ({ key: (0, import_records29.optionKey)(option), label: titled(option) })),
|
|
8385
8405
|
value,
|
|
8386
8406
|
onChange,
|
|
8387
8407
|
disabled,
|
|
8388
8408
|
id,
|
|
8389
8409
|
onChosen,
|
|
8390
8410
|
isChosen: (choice, v) => {
|
|
8391
|
-
const option = options.find((o) => (0,
|
|
8392
|
-
return option ? (0,
|
|
8411
|
+
const option = options.find((o) => (0, import_records29.optionKey)(o) === choice.key);
|
|
8412
|
+
return option ? (0, import_records29.isTheChosen)(option, v) : false;
|
|
8393
8413
|
}
|
|
8394
8414
|
}
|
|
8395
8415
|
);
|
|
@@ -8409,7 +8429,7 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
8409
8429
|
onCancel,
|
|
8410
8430
|
initialSearch,
|
|
8411
8431
|
addsChoices,
|
|
8412
|
-
allowOther: (0,
|
|
8432
|
+
allowOther: (0, import_records29.allowsOtherValues)(field),
|
|
8413
8433
|
onChoicesChanged: () => {
|
|
8414
8434
|
if (client) (0, askOnce_exports.forgetAsked)(client, `field_options:${field.id}`);
|
|
8415
8435
|
setReread((n) => n + 1);
|
|
@@ -8422,19 +8442,19 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
8422
8442
|
}
|
|
8423
8443
|
const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
|
|
8424
8444
|
if (field.multi) {
|
|
8425
|
-
const chosen = options.filter((option) => (0,
|
|
8426
|
-
const picked = new Set(chosen.map((option) => (0,
|
|
8445
|
+
const chosen = options.filter((option) => (0, import_records29.choiceValuesOf)(value).some((v) => (0, import_records29.isTheChosen)(option, v)));
|
|
8446
|
+
const picked = new Set(chosen.map((option) => (0, import_records29.optionKey)(option)));
|
|
8427
8447
|
const toggles = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { id: autoOpen ? void 0 : id, className: "flex flex-wrap gap-1", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
8428
8448
|
import_design_system33.Button,
|
|
8429
8449
|
{
|
|
8430
8450
|
type: "button",
|
|
8431
8451
|
size: "sm",
|
|
8432
|
-
variant: picked.has((0,
|
|
8452
|
+
variant: picked.has((0, import_records29.optionKey)(option)) ? "default" : "outline",
|
|
8433
8453
|
disabled,
|
|
8434
8454
|
onClick: () => {
|
|
8435
8455
|
const next = new Set(picked);
|
|
8436
|
-
if (next.has((0,
|
|
8437
|
-
else next.add((0,
|
|
8456
|
+
if (next.has((0, import_records29.optionKey)(option))) next.delete((0, import_records29.optionKey)(option));
|
|
8457
|
+
else next.add((0, import_records29.optionKey)(option));
|
|
8438
8458
|
onChange(next.size === 0 ? null : [...next]);
|
|
8439
8459
|
},
|
|
8440
8460
|
children: titleOf(option)
|
|
@@ -8456,11 +8476,11 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
8456
8476
|
}
|
|
8457
8477
|
);
|
|
8458
8478
|
}
|
|
8459
|
-
const current = options.find((option) => (0,
|
|
8479
|
+
const current = options.find((option) => (0, import_records29.isTheChosen)(option, value));
|
|
8460
8480
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
8461
8481
|
import_design_system33.Select,
|
|
8462
8482
|
{
|
|
8463
|
-
value: current ? (0,
|
|
8483
|
+
value: current ? (0, import_records29.optionKey)(current) : "",
|
|
8464
8484
|
disabled: disabled ?? false,
|
|
8465
8485
|
onValueChange: (next) => onChange(next === "" ? null : next),
|
|
8466
8486
|
...autoOpen ? {
|
|
@@ -8472,7 +8492,7 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
|
|
|
8472
8492
|
} : {},
|
|
8473
8493
|
children: [
|
|
8474
8494
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_design_system33.SelectTrigger, { id, size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_design_system33.SelectValue, { placeholder: "Choose" }) }),
|
|
8475
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_design_system33.SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_design_system33.SelectItem, { value: (0,
|
|
8495
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_design_system33.SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_design_system33.SelectItem, { value: (0, import_records29.optionKey)(option), children: titleOf(option) }, option.id)) })
|
|
8476
8496
|
]
|
|
8477
8497
|
}
|
|
8478
8498
|
);
|
|
@@ -8506,23 +8526,23 @@ function OpenChoicePicker({
|
|
|
8506
8526
|
const [addRefused, setAddRefused] = (0, import_react53.useState)(null);
|
|
8507
8527
|
const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
|
|
8508
8528
|
const held = withoutAddition(value);
|
|
8509
|
-
const current = (0,
|
|
8529
|
+
const current = (0, import_records29.choiceValuesOf)(held.value);
|
|
8510
8530
|
const pickedWords = current.map((v) => {
|
|
8511
|
-
const option = options.find((o) => (0,
|
|
8531
|
+
const option = options.find((o) => (0, import_records29.isTheChosen)(o, v));
|
|
8512
8532
|
return option ? titleOf(option) : String(v);
|
|
8513
8533
|
});
|
|
8514
|
-
const chipOf = (option, word) => option ? choiceChipLookOf(field, (0,
|
|
8534
|
+
const chipOf = (option, word) => option ? choiceChipLookOf(field, (0, import_records29.optionKey)(option), titleOf(option)) : choiceChipLookOf(field, word);
|
|
8515
8535
|
const q = search.trim();
|
|
8516
|
-
const visible = (0,
|
|
8517
|
-
const decided = (0,
|
|
8536
|
+
const visible = (0, import_records29.rankTypedMatches)(options, q, titleOf);
|
|
8537
|
+
const decided = (0, import_records29.decideTypedChoice)({ words: q, options, allowOther, nudge: nudge ?? "ask" });
|
|
8518
8538
|
const choose = (word, addingIt = false) => {
|
|
8519
8539
|
const pending = held.add.filter((w) => w.toLowerCase() !== word.toLowerCase());
|
|
8520
8540
|
let next;
|
|
8521
8541
|
let add2 = [...pending];
|
|
8522
8542
|
if (field.multi) {
|
|
8523
8543
|
const existing = current.map((v) => {
|
|
8524
|
-
const option = options.find((o) => (0,
|
|
8525
|
-
return option ? (0,
|
|
8544
|
+
const option = options.find((o) => (0, import_records29.isTheChosen)(o, v));
|
|
8545
|
+
return option ? (0, import_records29.optionKey)(option) : String(v);
|
|
8526
8546
|
});
|
|
8527
8547
|
const has = existing.some((v) => v.toLowerCase() === word.toLowerCase());
|
|
8528
8548
|
const list = has ? existing.filter((v) => v.toLowerCase() !== word.toLowerCase()) : [...existing, word];
|
|
@@ -8558,7 +8578,7 @@ function OpenChoicePicker({
|
|
|
8558
8578
|
const foot = null;
|
|
8559
8579
|
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;
|
|
8560
8580
|
const listed = visible;
|
|
8561
|
-
const pickedOptions = current.map((v) => options.find((o) => (0,
|
|
8581
|
+
const pickedOptions = current.map((v) => options.find((o) => (0, import_records29.isTheChosen)(o, v)));
|
|
8562
8582
|
const cellChips = pickedWords.map((word, i) => {
|
|
8563
8583
|
const chip = chipOf(pickedOptions[i], word);
|
|
8564
8584
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_design_system33.Badge, { variant: "outline", className: (0, import_design_system33.cn)("text-[11px]", chip.className), "data-records-choice-chip": "", children: word }, word);
|
|
@@ -8570,7 +8590,7 @@ function OpenChoicePicker({
|
|
|
8570
8590
|
label: word,
|
|
8571
8591
|
chip: chipOf(option, word).className,
|
|
8572
8592
|
onRemove: () => {
|
|
8573
|
-
if (field.multi) choose(option ? (0,
|
|
8593
|
+
if (field.multi) choose(option ? (0, import_records29.optionKey)(option) : String(current[i]));
|
|
8574
8594
|
else onChange(null);
|
|
8575
8595
|
}
|
|
8576
8596
|
};
|
|
@@ -8601,11 +8621,11 @@ function OpenChoicePicker({
|
|
|
8601
8621
|
id: option.id,
|
|
8602
8622
|
label: titleOf(option),
|
|
8603
8623
|
chip: chipOf(option, titleOf(option)).className,
|
|
8604
|
-
picked: current.some((v) => (0,
|
|
8624
|
+
picked: current.some((v) => (0, import_records29.isTheChosen)(option, v))
|
|
8605
8625
|
})),
|
|
8606
8626
|
onPick: (optionId) => {
|
|
8607
8627
|
const option = options.find((o) => o.id === optionId);
|
|
8608
|
-
if (option) choose((0,
|
|
8628
|
+
if (option) choose((0, import_records29.optionKey)(option));
|
|
8609
8629
|
},
|
|
8610
8630
|
empty: q === "" ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "No choices yet \u2014 type one to add it." }) : null,
|
|
8611
8631
|
add,
|
|
@@ -8661,7 +8681,7 @@ function ChoiceAnswer({
|
|
|
8661
8681
|
onChosen
|
|
8662
8682
|
}) {
|
|
8663
8683
|
const [search, setSearch] = (0, import_react53.useState)("");
|
|
8664
|
-
const held = field.multi ? (0,
|
|
8684
|
+
const held = field.multi ? (0, import_records29.choiceValuesOf)(value) : value === null || value === void 0 || value === "" ? [] : [value];
|
|
8665
8685
|
const on = (choice) => held.some((v) => isChosen ? isChosen(choice, v) : String(v) === choice.key || String(v) === choice.label);
|
|
8666
8686
|
const press = (choice) => {
|
|
8667
8687
|
if (!field.multi) {
|
|
@@ -8998,7 +9018,7 @@ function RecordPicker({ tableId, value, onChange, disabled }) {
|
|
|
8998
9018
|
|
|
8999
9019
|
// src/DataBindingPicker.tsx
|
|
9000
9020
|
var import_react59 = require("react");
|
|
9001
|
-
var
|
|
9021
|
+
var import_records30 = require("@ai-matrx/records");
|
|
9002
9022
|
var import_react60 = require("@ai-matrx/records/react");
|
|
9003
9023
|
var import_design_system35 = require("@ai-matrx/design-system");
|
|
9004
9024
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
@@ -9032,7 +9052,7 @@ function isCompleteDataBinding(binding) {
|
|
|
9032
9052
|
}
|
|
9033
9053
|
function bindingPlaceholdersFor(field) {
|
|
9034
9054
|
const label = fieldName(field);
|
|
9035
|
-
if ((0,
|
|
9055
|
+
if ((0, import_records30.isEntityReferenceConfig)(field.config)) {
|
|
9036
9056
|
return [
|
|
9037
9057
|
{ token: `{${field.key}.name}`, label: `${label} \xB7 name` },
|
|
9038
9058
|
{ token: `{${field.key}.id}`, label: `${label} \xB7 id` }
|