@ai-matrx/records-ui 0.116.12 → 0.116.13

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/dist/pickers.cjs CHANGED
@@ -4632,8 +4632,8 @@ __export(pickers_exports, {
4632
4632
  module.exports = __toCommonJS(pickers_exports);
4633
4633
 
4634
4634
  // src/TablePickers.tsx
4635
- var import_react74 = require("react");
4636
- var import_react75 = require("@ai-matrx/records/react");
4635
+ var import_react75 = require("react");
4636
+ var import_react76 = require("@ai-matrx/records/react");
4637
4637
  var import_design_system43 = require("@ai-matrx/design-system");
4638
4638
 
4639
4639
  // src/askOnce.ts
@@ -4947,9 +4947,9 @@ function AddChoicesInline({ field, onAdded, disabled = false }) {
4947
4947
  }
4948
4948
 
4949
4949
  // src/editors.tsx
4950
- var import_react70 = require("react");
4950
+ var import_react71 = require("react");
4951
4951
  var import_records28 = require("@ai-matrx/records");
4952
- var import_react71 = require("@ai-matrx/records/react");
4952
+ var import_react72 = require("@ai-matrx/records/react");
4953
4953
  var import_design_system42 = require("@ai-matrx/design-system");
4954
4954
  init_dates();
4955
4955
 
@@ -5590,11 +5590,11 @@ function RelationPicker({ field, value, onChange, disabled, id, className, allow
5590
5590
  }
5591
5591
 
5592
5592
  // src/buttonCell.tsx
5593
- var import_react65 = require("react");
5593
+ var import_react66 = require("react");
5594
5594
  var import_design_system39 = require("@ai-matrx/design-system");
5595
5595
  var import_data_table6 = require("@ai-matrx/design-system/data-table");
5596
5596
  var import_records26 = require("@ai-matrx/records");
5597
- var import_react66 = require("@ai-matrx/records/react");
5597
+ var import_react67 = require("@ai-matrx/records/react");
5598
5598
  init_host();
5599
5599
 
5600
5600
  // src/gridOpen.tsx
@@ -5643,8 +5643,8 @@ function columnNameProblemLine(name, noun = "column") {
5643
5643
  }
5644
5644
 
5645
5645
  // src/FieldEditor.tsx
5646
- var import_react63 = require("react");
5647
- var import_react64 = require("@ai-matrx/records/react");
5646
+ var import_react64 = require("react");
5647
+ var import_react65 = require("@ai-matrx/records/react");
5648
5648
  var import_core9 = require("@ai-matrx/records/core");
5649
5649
  var import_design_system38 = require("@ai-matrx/design-system");
5650
5650
 
@@ -10652,11 +10652,11 @@ init_enumLabels();
10652
10652
  var import_records24 = require("@ai-matrx/records");
10653
10653
 
10654
10654
  // src/ButtonSettings.tsx
10655
- var import_react61 = require("react");
10655
+ var import_react62 = require("react");
10656
10656
  var import_design_system37 = require("@ai-matrx/design-system");
10657
10657
  var import_data_table5 = require("@ai-matrx/design-system/data-table");
10658
10658
  var import_records23 = require("@ai-matrx/records");
10659
- var import_react62 = require("@ai-matrx/records/react");
10659
+ var import_react63 = require("@ai-matrx/records/react");
10660
10660
 
10661
10661
  // src/AccentSwatches.tsx
10662
10662
  var import_records22 = require("@ai-matrx/records");
@@ -10701,6 +10701,7 @@ init_PickOne();
10701
10701
  // src/AddRowSettings.tsx
10702
10702
  var import_design_system36 = require("@ai-matrx/design-system");
10703
10703
  var import_react60 = require("@ai-matrx/records/react");
10704
+ var import_react61 = require("react");
10704
10705
  init_tablePicking();
10705
10706
  init_tablePickerEntries();
10706
10707
  init_PickOne();
@@ -10719,6 +10720,16 @@ function AddRowSettings({ value, onChange, tableId, fields }) {
10719
10720
  const targetFields = (0, import_react60.useFields)(target);
10720
10721
  const typed = (targetFields.data ?? []).filter((f) => f.type !== "formula" && typeof f.config?.["system"] !== "string");
10721
10722
  const sources = [{ value: NOTHING, label: "Nothing" }, { value: THIS_ROW, label: "This row" }, ...fields.map((f) => ({ value: f.key, label: f.label }))];
10723
+ const client = (0, import_react60.useOptionalRecordsClient)();
10724
+ const [templates, setTemplates] = (0, import_react61.useState)([]);
10725
+ (0, import_react61.useEffect)(() => {
10726
+ if (!client || !target) return;
10727
+ let live = true;
10728
+ void client.rowTemplates({ table_id: target }).then((got) => live && setTemplates(got.ok ? got.data : []));
10729
+ return () => {
10730
+ live = false;
10731
+ };
10732
+ }, [client, target]);
10722
10733
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-col gap-2", "data-records-button-add-row": "", children: [
10723
10734
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-col gap-1", children: [
10724
10735
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_design_system36.Label, { className: "text-xs", children: "Adds to" }),
@@ -10728,11 +10739,24 @@ function AddRowSettings({ value, onChange, tableId, fields }) {
10728
10739
  label: "Table the new row goes in",
10729
10740
  value: value.table_id ?? tableId ?? "",
10730
10741
  attrs: { "data-records-button-add-row-table": "" },
10731
- onChange: (id) => onChange({ ...value, table_id: id === tableId ? void 0 : id, prefill: void 0 }),
10742
+ onChange: (id) => onChange({ ...value, table_id: id === tableId ? void 0 : id, prefill: void 0, template_id: void 0 }),
10732
10743
  options: tables.data.filter((t) => !isValueSet(t) && !isKeptTable(t)).map((t) => ({ value: t.id, label: t.id === tableId ? `${t.label_plural ?? t.name} (this table)` : t.label_plural ?? t.name }))
10733
10744
  }
10734
10745
  )
10735
10746
  ] }),
10747
+ templates.length || value.template_id ? /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-col gap-1", children: [
10748
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_design_system36.Label, { className: "text-xs", children: "Starts from" }),
10749
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10750
+ PickOne,
10751
+ {
10752
+ label: "Row template the new row starts from",
10753
+ value: value.template_id ?? NOTHING,
10754
+ attrs: { "data-records-button-add-row-template": "" },
10755
+ onChange: (id) => onChange({ ...value, template_id: id ? id : void 0 }),
10756
+ options: [{ value: NOTHING, label: "A blank row" }, ...templates.map((t) => ({ value: t.template_id, label: t.name }))]
10757
+ }
10758
+ )
10759
+ ] }) : null,
10736
10760
  typed.length ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1", children: typed.map((f) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "contents", children: [
10737
10761
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "text-sm", children: f.label }),
10738
10762
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
@@ -10775,11 +10799,11 @@ function ButtonSettingsEditor({
10775
10799
  tableId,
10776
10800
  fields
10777
10801
  }) {
10778
- const client = (0, import_react62.useOptionalRecordsClient)();
10779
- const [actions, setActions] = (0, import_react61.useState)(null);
10780
- const [actionsRefused, setActionsRefused] = (0, import_react61.useState)(null);
10781
- const [automations, setAutomations] = (0, import_react61.useState)(null);
10782
- (0, import_react61.useEffect)(() => {
10802
+ const client = (0, import_react63.useOptionalRecordsClient)();
10803
+ const [actions, setActions] = (0, import_react62.useState)(null);
10804
+ const [actionsRefused, setActionsRefused] = (0, import_react62.useState)(null);
10805
+ const [automations, setAutomations] = (0, import_react62.useState)(null);
10806
+ (0, import_react62.useEffect)(() => {
10783
10807
  if (!client || !tableId) return;
10784
10808
  let live = true;
10785
10809
  if (value.do === "run_action" && actions === null) {
@@ -10912,12 +10936,12 @@ function NewRowAction({
10912
10936
  columns,
10913
10937
  onMade
10914
10938
  }) {
10915
- const client = (0, import_react62.useOptionalRecordsClient)();
10939
+ const client = (0, import_react63.useOptionalRecordsClient)();
10916
10940
  const settable = settableColumns(columns);
10917
- const [fieldId, setFieldId] = (0, import_react61.useState)("");
10918
- const [setTo, setSetTo] = (0, import_react61.useState)("");
10919
- const [busy, setBusy] = (0, import_react61.useState)(false);
10920
- const [refused, setRefused] = (0, import_react61.useState)(null);
10941
+ const [fieldId, setFieldId] = (0, import_react62.useState)("");
10942
+ const [setTo, setSetTo] = (0, import_react62.useState)("");
10943
+ const [busy, setBusy] = (0, import_react62.useState)(false);
10944
+ const [refused, setRefused] = (0, import_react62.useState)(null);
10921
10945
  if (settable.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "text-xs text-muted-foreground", children: "No column to set" });
10922
10946
  const make = async () => {
10923
10947
  if (!client || fieldId === "") return;
@@ -11070,16 +11094,16 @@ function FieldEditor(props) {
11070
11094
  const entityToken = props.entityToken ?? null;
11071
11095
  const onEntity = entityToken !== null;
11072
11096
  const tableId = props.tableId ?? "";
11073
- const table = (0, import_react64.useTable)(onEntity ? null : tableId);
11074
- const tableFields = (0, import_react64.useFields)(onEntity ? null : tableId);
11075
- const entityFields = (0, import_react64.useEntityFields)(entityToken);
11097
+ const table = (0, import_react65.useTable)(onEntity ? null : tableId);
11098
+ const tableFields = (0, import_react65.useFields)(onEntity ? null : tableId);
11099
+ const entityFields = (0, import_react65.useEntityFields)(entityToken);
11076
11100
  const fields = onEntity ? entityFields : tableFields;
11077
11101
  const tableRights2 = useTableRights(onEntity ? null : table.data);
11078
- const entityRights = (0, import_react64.useEntityFieldRights)(entityToken);
11079
- const tableMutation = (0, import_react64.useFieldMutation)();
11080
- const entityMutation = (0, import_react64.useEntityFieldMutation)();
11102
+ const entityRights = (0, import_react65.useEntityFieldRights)(entityToken);
11103
+ const tableMutation = (0, import_react65.useFieldMutation)();
11104
+ const entityMutation = (0, import_react65.useEntityFieldMutation)();
11081
11105
  const mutation = onEntity ? { saving: entityMutation.saving, error: entityMutation.error } : { saving: tableMutation.saving, error: tableMutation.error };
11082
- const client = (0, import_react64.useRecordsClient)();
11106
+ const client = (0, import_react65.useRecordsClient)();
11083
11107
  const mayShape = onEntity ? entityRights.data?.may_declare === true : tableRights2.structure;
11084
11108
  const whyNot = onEntity ? entityRights.data?.reason ?? null : tableRights2.why("structure");
11085
11109
  const storeLabel = onEntity ? entityRights.data?.label ?? null : table.data?.name ?? null;
@@ -11089,35 +11113,35 @@ function FieldEditor(props) {
11089
11113
  const copyOf = field ? void 0 : props.copyOf;
11090
11114
  const start = field ?? copyOf;
11091
11115
  const startAs = start ? void 0 : props.startAs;
11092
- const [label, setLabel] = (0, import_react63.useState)(field?.label ?? (copyOf ? `${copyOf.label} (1)` : startAs?.label ?? ""));
11093
- const [type, setType] = (0, import_react63.useState)(() => startAs ? startAs.type : startingType(start));
11094
- const [required, setRequired] = (0, import_react63.useState)(start?.required ?? false);
11095
- const [multi, setMulti] = (0, import_react63.useState)(start?.multi ?? false);
11096
- const [dated, setDated] = (0, import_react63.useState)(start?.dated ?? false);
11097
- const [sensitivity, setSensitivity] = (0, import_react63.useState)(String(start?.sensitivity ?? "internal"));
11098
- const [contextPolicy, setContextPolicy] = (0, import_react63.useState)(String(start?.context_policy ?? "include"));
11099
- const [rules, setRules] = (0, import_react63.useState)(start?.rules ?? []);
11100
- const [startsWith, setStartsWith] = (0, import_react63.useState)(start?.default ?? null);
11101
- const [ratingMax, setRatingMax] = (0, import_react63.useState)(() => start ? (0, import_records25.ratingMaxOf)(start) : 5);
11102
- const savedRules = (0, import_react63.useMemo)(
11116
+ const [label, setLabel] = (0, import_react64.useState)(field?.label ?? (copyOf ? `${copyOf.label} (1)` : startAs?.label ?? ""));
11117
+ const [type, setType] = (0, import_react64.useState)(() => startAs ? startAs.type : startingType(start));
11118
+ const [required, setRequired] = (0, import_react64.useState)(start?.required ?? false);
11119
+ const [multi, setMulti] = (0, import_react64.useState)(start?.multi ?? false);
11120
+ const [dated, setDated] = (0, import_react64.useState)(start?.dated ?? false);
11121
+ const [sensitivity, setSensitivity] = (0, import_react64.useState)(String(start?.sensitivity ?? "internal"));
11122
+ const [contextPolicy, setContextPolicy] = (0, import_react64.useState)(String(start?.context_policy ?? "include"));
11123
+ const [rules, setRules] = (0, import_react64.useState)(start?.rules ?? []);
11124
+ const [startsWith, setStartsWith] = (0, import_react64.useState)(start?.default ?? null);
11125
+ const [ratingMax, setRatingMax] = (0, import_react64.useState)(() => start ? (0, import_records25.ratingMaxOf)(start) : 5);
11126
+ const savedRules = (0, import_react64.useMemo)(
11103
11127
  () => field ? type === "rating" ? (0, import_records25.rulesWithTopStar)(field.rules ?? [], (0, import_records25.ratingMaxOf)(field)) : field.rules ?? [] : [],
11104
11128
  [field, type]
11105
11129
  );
11106
- const editedRules = (0, import_react63.useMemo)(() => type === "rating" ? (0, import_records25.rulesWithTopStar)(rules, ratingMax) : rules, [type, rules, ratingMax]);
11107
- const [statusGroups, setStatusGroups] = (0, import_react63.useState)({});
11108
- const [statusKeys, setStatusKeys] = (0, import_react63.useState)({});
11109
- const [symbology, setSymbology] = (0, import_react63.useState)(String(start?.config?.["symbology"] ?? ""));
11130
+ const editedRules = (0, import_react64.useMemo)(() => type === "rating" ? (0, import_records25.rulesWithTopStar)(rules, ratingMax) : rules, [type, rules, ratingMax]);
11131
+ const [statusGroups, setStatusGroups] = (0, import_react64.useState)({});
11132
+ const [statusKeys, setStatusKeys] = (0, import_react64.useState)({});
11133
+ const [symbology, setSymbology] = (0, import_react64.useState)(String(start?.config?.["symbology"] ?? ""));
11110
11134
  const descriptionStart = String(start?.config?.["description"] ?? "");
11111
- const [description, setDescription] = (0, import_react63.useState)(descriptionStart);
11112
- const buttonStart = (0, import_react63.useMemo)(() => (0, import_records24.buttonOf)(start) ?? { label: "" }, [start]);
11113
- const [buttonSettings, setButtonSettings] = (0, import_react63.useState)(buttonStart);
11135
+ const [description, setDescription] = (0, import_react64.useState)(descriptionStart);
11136
+ const buttonStart = (0, import_react64.useMemo)(() => (0, import_records24.buttonOf)(start) ?? { label: "" }, [start]);
11137
+ const [buttonSettings, setButtonSettings] = (0, import_react64.useState)(buttonStart);
11114
11138
  const prefixStart = (0, import_records24.autonumberPrefixOf)(start);
11115
- const [numberPrefix, setNumberPrefix] = (0, import_react63.useState)(prefixStart);
11139
+ const [numberPrefix, setNumberPrefix] = (0, import_react64.useState)(prefixStart);
11116
11140
  const dependencyStart = start?.config?.["dependency"] === true;
11117
- const watchStart = (0, import_react63.useMemo)(() => watchedFieldsOf(start), [start]);
11118
- const [watchFields, setWatchFields] = (0, import_react63.useState)(watchStart);
11119
- const [dependency, setDependency] = (0, import_react63.useState)(dependencyStart);
11120
- (0, import_react63.useEffect)(() => {
11141
+ const watchStart = (0, import_react64.useMemo)(() => watchedFieldsOf(start), [start]);
11142
+ const [watchFields, setWatchFields] = (0, import_react64.useState)(watchStart);
11143
+ const [dependency, setDependency] = (0, import_react64.useState)(dependencyStart);
11144
+ (0, import_react64.useEffect)(() => {
11121
11145
  if (!field || type !== "status") return;
11122
11146
  let live = true;
11123
11147
  void client.fieldOptions({ field_id: field.id }).then((got) => {
@@ -11127,20 +11151,20 @@ function FieldEditor(props) {
11127
11151
  live = false;
11128
11152
  };
11129
11153
  }, [client, field, type]);
11130
- (0, import_react63.useEffect)(() => {
11154
+ (0, import_react64.useEffect)(() => {
11131
11155
  if (field || type !== "status") return;
11132
11156
  setNewChoices(
11133
11157
  (rows) => rows.length > 0 ? rows : STATUS_STARTING_CHOICES.map((c, i) => ({ id: null, words: c.words, row: `status-${i}` }))
11134
11158
  );
11135
11159
  }, [field, type]);
11136
- (0, import_react63.useEffect)(() => {
11160
+ (0, import_react64.useEffect)(() => {
11137
11161
  if (field || type !== "select" && type !== "multi_select") return;
11138
11162
  setNewChoices((rows) => rows.length > 0 ? rows : [newChoiceRow([])]);
11139
11163
  }, [field, type]);
11140
- const [allowOther, setAllowOther] = (0, import_react63.useState)(start?.config?.["allow_other"] === true);
11141
- const [newChoices, setNewChoices] = (0, import_react63.useState)([]);
11164
+ const [allowOther, setAllowOther] = (0, import_react64.useState)(start?.config?.["allow_other"] === true);
11165
+ const [newChoices, setNewChoices] = (0, import_react64.useState)([]);
11142
11166
  const copyOfId = copyOf?.id ?? null;
11143
- (0, import_react63.useEffect)(() => {
11167
+ (0, import_react64.useEffect)(() => {
11144
11168
  if (!copyOf || !copyOfId) return;
11145
11169
  let live = true;
11146
11170
  void client.fieldOptions({ field_id: copyOfId }).then((got) => {
@@ -11152,53 +11176,53 @@ function FieldEditor(props) {
11152
11176
  live = false;
11153
11177
  };
11154
11178
  }, [client, copyOfId]);
11155
- const [choiceList, setChoiceList] = (0, import_react63.useState)(null);
11156
- const [choiceListStart, setChoiceListStart] = (0, import_react63.useState)(null);
11157
- const [rehome, setRehome] = (0, import_react63.useState)({});
11158
- const [rehomed, setRehomed] = (0, import_react63.useState)(null);
11159
- const [rehomeRefused, setRehomeRefused] = (0, import_react63.useState)(null);
11160
- const [unit, setUnit] = (0, import_react63.useState)(start?.unit ?? "$");
11161
- const [withTime, setWithTime] = (0, import_react63.useState)(String(start?.config?.["kind"] ?? "date") === "datetime");
11162
- const [via, setVia] = (0, import_react63.useState)(String(start?.config?.["via"] ?? ""));
11163
- const [pick, setPick] = (0, import_react63.useState)(String(start?.config?.["pick"] ?? ""));
11164
- const [agg, setAgg] = (0, import_react63.useState)(
11179
+ const [choiceList, setChoiceList] = (0, import_react64.useState)(null);
11180
+ const [choiceListStart, setChoiceListStart] = (0, import_react64.useState)(null);
11181
+ const [rehome, setRehome] = (0, import_react64.useState)({});
11182
+ const [rehomed, setRehomed] = (0, import_react64.useState)(null);
11183
+ const [rehomeRefused, setRehomeRefused] = (0, import_react64.useState)(null);
11184
+ const [unit, setUnit] = (0, import_react64.useState)(start?.unit ?? "$");
11185
+ const [withTime, setWithTime] = (0, import_react64.useState)(String(start?.config?.["kind"] ?? "date") === "datetime");
11186
+ const [via, setVia] = (0, import_react64.useState)(String(start?.config?.["via"] ?? ""));
11187
+ const [pick, setPick] = (0, import_react64.useState)(String(start?.config?.["pick"] ?? ""));
11188
+ const [agg, setAgg] = (0, import_react64.useState)(
11165
11189
  start?.config?.["agg"] ?? "count"
11166
11190
  );
11167
- const [of, setOf] = (0, import_react63.useState)(String(start?.config?.["of"] ?? ""));
11191
+ const [of, setOf] = (0, import_react64.useState)(String(start?.config?.["of"] ?? ""));
11168
11192
  const savedRollupFilter = field?.config?.["filter"] ?? null;
11169
- const [rollupFilter, setRollupFilter] = (0, import_react63.useState)(
11193
+ const [rollupFilter, setRollupFilter] = (0, import_react64.useState)(
11170
11194
  field ? savedRollupFilter : copyOf?.config?.["filter"] ?? null
11171
11195
  );
11172
11196
  const rollupFilterChanged = JSON.stringify(rollupFilter) !== JSON.stringify(savedRollupFilter);
11173
- const [relationTarget, setRelationTarget] = (0, import_react63.useState)(String(start?.relation_target ?? ""));
11174
- const [showOnOther, setShowOnOther] = (0, import_react63.useState)(true);
11175
- const [nestsSubItems, setNestsSubItems] = (0, import_react63.useState)(false);
11176
- const [reverseRefused, setReverseRefused] = (0, import_react63.useState)(null);
11177
- const otherTable = (0, import_react64.useTable)(!field && type === "relation" && relationTarget !== "" ? relationTarget : null);
11178
- const [display, setDisplay] = (0, import_react63.useState)(start?.display ?? null);
11179
- const [formulaOp, setFormulaOp] = (0, import_react63.useState)(() => formulaOpOf(start));
11180
- const [formulaFields, setFormulaFields] = (0, import_react63.useState)(() => formulaFieldIdsOf(start));
11181
- const [formulaSeparator, setFormulaSeparator] = (0, import_react63.useState)(() => formulaSeparatorOf(start));
11182
- const [allowedTypes, setAllowedTypes] = (0, import_react63.useState)(() => entityReferenceKindsOf(start));
11197
+ const [relationTarget, setRelationTarget] = (0, import_react64.useState)(String(start?.relation_target ?? ""));
11198
+ const [showOnOther, setShowOnOther] = (0, import_react64.useState)(true);
11199
+ const [nestsSubItems, setNestsSubItems] = (0, import_react64.useState)(false);
11200
+ const [reverseRefused, setReverseRefused] = (0, import_react64.useState)(null);
11201
+ const otherTable = (0, import_react65.useTable)(!field && type === "relation" && relationTarget !== "" ? relationTarget : null);
11202
+ const [display, setDisplay] = (0, import_react64.useState)(start?.display ?? null);
11203
+ const [formulaOp, setFormulaOp] = (0, import_react64.useState)(() => formulaOpOf(start));
11204
+ const [formulaFields, setFormulaFields] = (0, import_react64.useState)(() => formulaFieldIdsOf(start));
11205
+ const [formulaSeparator, setFormulaSeparator] = (0, import_react64.useState)(() => formulaSeparatorOf(start));
11206
+ const [allowedTypes, setAllowedTypes] = (0, import_react64.useState)(() => entityReferenceKindsOf(start));
11183
11207
  const startingFormulaText = start ? formulaTextNow(String(start.config?.["formula_text"] ?? ""), start.config?.["expr"] ?? start.expr, fields.data) : "";
11184
- const [formulaText, setFormulaText] = (0, import_react63.useState)(startingFormulaText);
11185
- const shownFormula = (0, import_react63.useRef)(startingFormulaText);
11186
- (0, import_react63.useEffect)(() => {
11208
+ const [formulaText, setFormulaText] = (0, import_react64.useState)(startingFormulaText);
11209
+ const shownFormula = (0, import_react64.useRef)(startingFormulaText);
11210
+ (0, import_react64.useEffect)(() => {
11187
11211
  if (shownFormula.current === startingFormulaText) return;
11188
11212
  setFormulaText((typed) => typed === shownFormula.current ? startingFormulaText : typed);
11189
11213
  shownFormula.current = startingFormulaText;
11190
11214
  }, [startingFormulaText]);
11191
- const [formulaWritten, setFormulaWritten] = (0, import_react63.useState)(() => startingFormulaText.trim() !== "" || Boolean(field) || startAs?.type === "formula");
11192
- const [formulaOk, setFormulaOk] = (0, import_react63.useState)(null);
11193
- const [askingToRemove, setAskingToRemove] = (0, import_react63.useState)(false);
11194
- const [attempted, setAttempted] = (0, import_react63.useState)(false);
11195
- const [showsAs, setShowsAs] = (0, import_react63.useState)(() => start ? startingChoice(start) : { format: null, retype: null });
11196
- const [backfillError, setBackfillError] = (0, import_react63.useState)(null);
11197
- const [notLanded, setNotLanded] = (0, import_react63.useState)(false);
11215
+ const [formulaWritten, setFormulaWritten] = (0, import_react64.useState)(() => startingFormulaText.trim() !== "" || Boolean(field) || startAs?.type === "formula");
11216
+ const [formulaOk, setFormulaOk] = (0, import_react64.useState)(null);
11217
+ const [askingToRemove, setAskingToRemove] = (0, import_react64.useState)(false);
11218
+ const [attempted, setAttempted] = (0, import_react64.useState)(false);
11219
+ const [showsAs, setShowsAs] = (0, import_react64.useState)(() => start ? startingChoice(start) : { format: null, retype: null });
11220
+ const [backfillError, setBackfillError] = (0, import_react64.useState)(null);
11221
+ const [notLanded, setNotLanded] = (0, import_react64.useState)(false);
11198
11222
  const liveField = field ? fields.data?.find((f) => f.id === field.id) ?? field : void 0;
11199
11223
  const heldAs = liveField ? JSON.stringify([liveField.type, liveField.config?.["kind"] ?? null, liveField.format ?? null, liveField.multi ?? false, liveField.unit ?? null]) : "";
11200
- const seededAs = (0, import_react63.useRef)(heldAs);
11201
- (0, import_react63.useEffect)(() => {
11224
+ const seededAs = (0, import_react64.useRef)(heldAs);
11225
+ (0, import_react64.useEffect)(() => {
11202
11226
  if (!liveField || seededAs.current === heldAs) return;
11203
11227
  seededAs.current = heldAs;
11204
11228
  setType(startingType(liveField));
@@ -11207,24 +11231,24 @@ function FieldEditor(props) {
11207
11231
  setUnit(liveField.unit ?? "$");
11208
11232
  setWithTime(String(liveField.config?.["kind"] ?? "date") === "datetime");
11209
11233
  }, [heldAs]);
11210
- const others = (0, import_react63.useMemo)(
11234
+ const others = (0, import_react64.useMemo)(
11211
11235
  () => (fields.data ?? []).filter((f) => f.id !== field?.id),
11212
11236
  [fields.data, field?.id]
11213
11237
  );
11214
- const relations = (0, import_react63.useMemo)(() => others.filter((f) => sourceKindOf(f) !== null), [others]);
11215
- const reverse = (0, import_react64.useReverseColumns)(onEntity ? null : tableId);
11216
- const backLinks = (0, import_react63.useMemo)(() => (reverse.data ?? []).map(backLinkAsSource), [reverse.data]);
11217
- const totalSources = (0, import_react63.useMemo)(() => [...relations, ...backLinks], [relations, backLinks]);
11238
+ const relations = (0, import_react64.useMemo)(() => others.filter((f) => sourceKindOf(f) !== null), [others]);
11239
+ const reverse = (0, import_react65.useReverseColumns)(onEntity ? null : tableId);
11240
+ const backLinks = (0, import_react64.useMemo)(() => (reverse.data ?? []).map(backLinkAsSource), [reverse.data]);
11241
+ const totalSources = (0, import_react64.useMemo)(() => [...relations, ...backLinks], [relations, backLinks]);
11218
11242
  const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
11219
11243
  const choice = fieldTypeChoice(type);
11220
11244
  const editing = Boolean(field);
11221
- (0, import_react63.useEffect)(() => {
11245
+ (0, import_react64.useEffect)(() => {
11222
11246
  if (!editing) setStartsWith(null);
11223
11247
  }, [type, editing]);
11224
11248
  const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
11225
- const farFieldsOfLink = (0, import_react64.useFields)(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
11226
- const farTable = (0, import_react64.useTable)(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
11227
- const linkReaders = (0, import_react63.useMemo)(
11249
+ const farFieldsOfLink = (0, import_react65.useFields)(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
11250
+ const farTable = (0, import_react65.useTable)(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
11251
+ const linkReaders = (0, import_react64.useMemo)(
11228
11252
  () => field ? readingThroughLink(field, farFieldsOfLink.data ?? []) : [],
11229
11253
  [field, farFieldsOfLink.data]
11230
11254
  );
@@ -11321,7 +11345,7 @@ function FieldEditor(props) {
11321
11345
  setRehomeRefused(done.error);
11322
11346
  return;
11323
11347
  }
11324
- (0, import_react64.tableShapeChanged)(tableId);
11348
+ (0, import_react65.tableShapeChanged)(tableId);
11325
11349
  for (const c of done.data.undo.cells_back) (0, import_core9.announceRecordChanged)(c.record_id);
11326
11350
  const n = done.data.rehomed.reduce((sum, r) => sum + r.records, 0);
11327
11351
  setRehome({});
@@ -11397,7 +11421,7 @@ function FieldEditor(props) {
11397
11421
  if (newDefault !== null && newColumnDefaultGoes(type) === "right-after") {
11398
11422
  const defaulted = await client.fieldUpdate({ field_id: written, patch: { default: newDefault } });
11399
11423
  if (!defaulted.ok) {
11400
- (0, import_react64.tableShapeChanged)(tableId);
11424
+ (0, import_react65.tableShapeChanged)(tableId);
11401
11425
  setBackfillError(defaulted.error);
11402
11426
  return;
11403
11427
  }
@@ -11423,7 +11447,7 @@ function FieldEditor(props) {
11423
11447
  setReverseRefused(made.error);
11424
11448
  return;
11425
11449
  }
11426
- (0, import_react64.tableShapeChanged)(relationTarget);
11450
+ (0, import_react65.tableShapeChanged)(relationTarget);
11427
11451
  }
11428
11452
  setReverseRefused(null);
11429
11453
  onSaved?.();
@@ -11837,7 +11861,7 @@ function FieldEditor(props) {
11837
11861
  setRehomeRefused(back.error);
11838
11862
  return;
11839
11863
  }
11840
- (0, import_react64.tableShapeChanged)(tableId);
11864
+ (0, import_react65.tableShapeChanged)(tableId);
11841
11865
  for (const c of undo.cells_back) (0, import_core9.announceRecordChanged)(c.record_id);
11842
11866
  setChoiceList(null);
11843
11867
  setChoiceListStart(null);
@@ -12182,13 +12206,13 @@ function RollupFilterQuestion({
12182
12206
  onChange
12183
12207
  }) {
12184
12208
  const far = relation?.relation_target ?? null;
12185
- const farFields = (0, import_react64.useFields)(far);
12186
- const conditionFields = (0, import_react63.useMemo)(
12209
+ const farFields = (0, import_react65.useFields)(far);
12210
+ const conditionFields = (0, import_react64.useMemo)(
12187
12211
  () => (farFields.data ?? []).filter((f) => f.type !== "formula").map((f) => ({ id: f.id, key: f.key, label: fieldName(f), field: f })),
12188
12212
  [farFields.data]
12189
12213
  );
12190
- const lastFar = (0, import_react63.useRef)(far);
12191
- (0, import_react63.useEffect)(() => {
12214
+ const lastFar = (0, import_react64.useRef)(far);
12215
+ (0, import_react64.useEffect)(() => {
12192
12216
  if (lastFar.current !== null && far !== lastFar.current && !editing) onChange(null);
12193
12217
  lastFar.current = far;
12194
12218
  }, [far, editing, onChange]);
@@ -12221,9 +12245,9 @@ function ValueOnTheOtherSide({
12221
12245
  compact
12222
12246
  }) {
12223
12247
  const target = relation?.relation_target ?? null;
12224
- const columns = (0, import_react64.useFields)(target);
12248
+ const columns = (0, import_react65.useFields)(target);
12225
12249
  const declared = (columns.data ?? []).filter((f) => f.type !== "formula");
12226
- const sample = (0, import_react64.useRecords)(declared.length === 0 && !columns.loading ? target : null, { pageSize: 1 });
12250
+ const sample = (0, import_react65.useRecords)(declared.length === 0 && !columns.loading ? target : null, { pageSize: 1 });
12227
12251
  const carried = sample.data?.rows[0]?.document ?? null;
12228
12252
  const offered = declared.length > 0 ? declared.map((f) => ({ key: f.key, name: fieldName(f) })) : Object.keys(carried ?? {}).map((key) => ({ key, name: (0, import_text_case7.humanizeIdentifier)(key) }));
12229
12253
  const stillAsking = columns.loading || declared.length === 0 && sample.loading;
@@ -12344,17 +12368,17 @@ function waitingRunsOf(pressed) {
12344
12368
  }
12345
12369
  var stop2 = (event) => event.stopPropagation();
12346
12370
  function ButtonValue({ field, recordId, inCell }) {
12347
- const client = (0, import_react66.useOptionalRecordsClient)();
12371
+ const client = (0, import_react67.useOptionalRecordsClient)();
12348
12372
  const b = (0, import_records26.buttonOf)(field);
12349
- const [busy, setBusy] = (0, import_react65.useState)(false);
12350
- const [said2, setSaid] = (0, import_react65.useState)(null);
12351
- const [settingUp, setSettingUp] = (0, import_react65.useState)(false);
12352
- const [opening, setOpening] = (0, import_react65.useState)(false);
12353
- const here = (0, import_react65.useContext)(OpenRecordHereContext);
12373
+ const [busy, setBusy] = (0, import_react66.useState)(false);
12374
+ const [said2, setSaid] = (0, import_react66.useState)(null);
12375
+ const [settingUp, setSettingUp] = (0, import_react66.useState)(false);
12376
+ const [opening, setOpening] = (0, import_react66.useState)(false);
12377
+ const here = (0, import_react66.useContext)(OpenRecordHereContext);
12354
12378
  const host = useRecordsUi();
12355
- const addsTo = (0, import_react66.useTable)(b?.do === "add_row" ? b.table_id ?? field.entity_definition_id : null);
12356
- const waitingOn = (0, import_react65.useRef)(0);
12357
- (0, import_react65.useEffect)(() => () => void (waitingOn.current += 1), []);
12379
+ const addsTo = (0, import_react67.useTable)(b?.do === "add_row" ? b.table_id ?? field.entity_definition_id : null);
12380
+ const waitingOn = (0, import_react66.useRef)(0);
12381
+ (0, import_react66.useEffect)(() => () => void (waitingOn.current += 1), []);
12358
12382
  if (!b) return null;
12359
12383
  const color = (0, import_data_table6.isStyleColor)(b.color) ? import_data_table6.CHOICE_CHIP_CLASS[b.color] : import_data_table6.NEUTRAL_CHIP_CLASS;
12360
12384
  const needs = (0, import_records26.buttonNeeds)(b);
@@ -12528,7 +12552,7 @@ init_PickOrAdd();
12528
12552
  init_Refusal();
12529
12553
 
12530
12554
  // src/FloatingRefusal.tsx
12531
- var import_react67 = require("react");
12555
+ var import_react68 = require("react");
12532
12556
  var import_react_dom = require("react-dom");
12533
12557
  var import_jsx_runtime45 = require("react/jsx-runtime");
12534
12558
  var GAP = 4;
@@ -12546,11 +12570,11 @@ function placeFor(anchor, note) {
12546
12570
  return { position: "fixed", top: a.top + (a.height - height) / 2, left: Math.max(a.left, a.right - width - 8) };
12547
12571
  }
12548
12572
  function FloatingRefusal({ text, why }) {
12549
- const spot = (0, import_react67.useRef)(null);
12550
- const note = (0, import_react67.useRef)(null);
12551
- const [style, setStyle] = (0, import_react67.useState)(null);
12552
- const [floating, setFloating] = (0, import_react67.useState)(false);
12553
- (0, import_react67.useLayoutEffect)(() => {
12573
+ const spot = (0, import_react68.useRef)(null);
12574
+ const note = (0, import_react68.useRef)(null);
12575
+ const [style, setStyle] = (0, import_react68.useState)(null);
12576
+ const [floating, setFloating] = (0, import_react68.useState)(false);
12577
+ (0, import_react68.useLayoutEffect)(() => {
12554
12578
  const here = spot.current;
12555
12579
  if (!here) return;
12556
12580
  const anchor = here.closest("[data-matrx-cell-editor]");
@@ -12595,7 +12619,7 @@ function FloatingRefusal({ text, why }) {
12595
12619
  init_refusals();
12596
12620
 
12597
12621
  // src/formatControls.tsx
12598
- var import_react68 = require("react");
12622
+ var import_react69 = require("react");
12599
12623
  var import_design_system40 = require("@ai-matrx/design-system");
12600
12624
  var import_field_formats9 = require("@ai-matrx/design-system/field-formats");
12601
12625
  var import_jsx_runtime46 = require("react/jsx-runtime");
@@ -12615,9 +12639,9 @@ function keptValue(format, raw) {
12615
12639
  return parsed;
12616
12640
  }
12617
12641
  function NumberInFormat({ format, value, onChange, disabled, id }) {
12618
- const [text, setText] = (0, import_react68.useState)(() => typedText(format, value));
12619
- const lastSent = (0, import_react68.useRef)(void 0);
12620
- (0, import_react68.useEffect)(() => {
12642
+ const [text, setText] = (0, import_react69.useState)(() => typedText(format, value));
12643
+ const lastSent = (0, import_react69.useRef)(void 0);
12644
+ (0, import_react69.useEffect)(() => {
12621
12645
  if (value === lastSent.current) return;
12622
12646
  setText(typedText(format, value));
12623
12647
  }, [value, format]);
@@ -12696,7 +12720,7 @@ function formatControl(args) {
12696
12720
  }
12697
12721
 
12698
12722
  // src/typedDateHelper.tsx
12699
- var import_react69 = require("react");
12723
+ var import_react70 = require("react");
12700
12724
  var import_design_system41 = require("@ai-matrx/design-system");
12701
12725
  var import_records27 = require("@ai-matrx/records");
12702
12726
  var import_jsx_runtime47 = require("react/jsx-runtime");
@@ -12747,12 +12771,12 @@ function TypedDateHelper({
12747
12771
  onPicked,
12748
12772
  startOpen = false
12749
12773
  }) {
12750
- const [open, setOpen] = (0, import_react69.useState)(startOpen);
12774
+ const [open, setOpen] = (0, import_react70.useState)(startOpen);
12751
12775
  const held = readBox(text, kind);
12752
12776
  usePersonTimeZone();
12753
12777
  const today = personWallNow();
12754
12778
  const start = held.day ? new Date(Number(held.day.slice(0, 4)), Number(held.day.slice(5, 7)) - 1, 1) : new Date(today.getFullYear(), today.getMonth(), 1);
12755
- const [month, setMonth] = (0, import_react69.useState)(null);
12779
+ const [month, setMonth] = (0, import_react70.useState)(null);
12756
12780
  const shown2 = month ?? { y: start.getFullYear(), m: start.getMonth() };
12757
12781
  const first = new Date(shown2.y, shown2.m, 1).getDay();
12758
12782
  const days = new Date(shown2.y, shown2.m + 1, 0).getDate();
@@ -12995,9 +13019,9 @@ function openingText(field, value) {
12995
13019
  return format ? typedText(format, value) : String(value);
12996
13020
  }
12997
13021
  function ReadsAsNote({ typed, always, children }) {
12998
- const note = (0, import_react70.useRef)(null);
12999
- const [repeats, setRepeats] = (0, import_react70.useState)(false);
13000
- (0, import_react70.useLayoutEffect)(() => {
13022
+ const note = (0, import_react71.useRef)(null);
13023
+ const [repeats, setRepeats] = (0, import_react71.useState)(false);
13024
+ (0, import_react71.useLayoutEffect)(() => {
13001
13025
  if (always) return;
13002
13026
  const words = (t) => (t ?? "").replace(/^Reads as/, "").replace(/\s+/g, "").toLowerCase();
13003
13027
  setRepeats(words(note.current?.textContent) === words(typed));
@@ -13006,12 +13030,12 @@ function ReadsAsNote({ typed, always, children }) {
13006
13030
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { ref: note, "data-records-typed-reads-as": "", "data-records-cell-note": "", className: "text-[10px] text-muted-foreground", children });
13007
13031
  }
13008
13032
  function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCancel }) {
13009
- const client = (0, import_react71.useOptionalRecordsClient)();
13033
+ const client = (0, import_react72.useOptionalRecordsClient)();
13010
13034
  const kind = String(editorKindFor(field));
13011
13035
  const needsChoices = kind === "select" || kind === "multi_select";
13012
13036
  const nudge = useChoiceNudge(needsChoices);
13013
- const [choices, setChoices] = (0, import_react70.useState)(null);
13014
- (0, import_react70.useEffect)(() => {
13037
+ const [choices, setChoices] = (0, import_react71.useState)(null);
13038
+ (0, import_react71.useEffect)(() => {
13015
13039
  if (!needsChoices || !client) return;
13016
13040
  let cancelled = false;
13017
13041
  void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((result) => {
@@ -13021,7 +13045,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
13021
13045
  cancelled = true;
13022
13046
  };
13023
13047
  }, [client, field.id, needsChoices]);
13024
- (0, import_react70.useEffect)(() => {
13048
+ (0, import_react71.useEffect)(() => {
13025
13049
  if (choices && nudge && value.judged === null) onChange({ ...value, judged: judgeTyped(field, value.text, choices, nudge) });
13026
13050
  }, [choices, nudge, value, field, onChange]);
13027
13051
  const judged = value.judged;
@@ -13097,7 +13121,7 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
13097
13121
  const host = useRecordsUi();
13098
13122
  const kind = editorKindFor(field);
13099
13123
  const inputId = id ?? `field-${field.key}`;
13100
- const ownDetails = (0, import_react71.useOptionalRecordsClient)() === null;
13124
+ const ownDetails = (0, import_react72.useOptionalRecordsClient)() === null;
13101
13125
  if (isTypedDraft(value)) return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TypedTextControl, { field, value, onChange, disabled, id: inputId, onCommit, onCancel });
13102
13126
  if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SignaturePad, { id: inputId, value, onChange, disabled });
13103
13127
  if ((0, import_records28.isButtonField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ButtonValue, { field });
@@ -13220,11 +13244,11 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
13220
13244
  }
13221
13245
  }
13222
13246
  function TypedWordsControl({ field, value, onChange, disabled, id }) {
13223
- const [text, setText] = (0, import_react70.useState)(() => openingText(field, value));
13224
- const [refusal, setRefusal] = (0, import_react70.useState)(null);
13225
- const [why, setWhy] = (0, import_react70.useState)(void 0);
13226
- const sent = (0, import_react70.useRef)(value);
13227
- (0, import_react70.useEffect)(() => {
13247
+ const [text, setText] = (0, import_react71.useState)(() => openingText(field, value));
13248
+ const [refusal, setRefusal] = (0, import_react71.useState)(null);
13249
+ const [why, setWhy] = (0, import_react71.useState)(void 0);
13250
+ const sent = (0, import_react71.useRef)(value);
13251
+ (0, import_react71.useEffect)(() => {
13228
13252
  if (value === sent.current) return;
13229
13253
  sent.current = value;
13230
13254
  setText(openingText(field, value));
@@ -13335,8 +13359,8 @@ function StructuredTextControl({ field, value, onChange, disabled, id, rows }) {
13335
13359
  }
13336
13360
  function JsonControl({ field, value, onChange, disabled, id }) {
13337
13361
  const initial = value === null || value === void 0 ? "" : typeof value === "string" ? value : JSON.stringify(value, null, 2);
13338
- const [text, setText] = (0, import_react70.useState)(initial);
13339
- const [broken, setBroken] = (0, import_react70.useState)(null);
13362
+ const [text, setText] = (0, import_react71.useState)(initial);
13363
+ const [broken, setBroken] = (0, import_react71.useState)(null);
13340
13364
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex flex-col gap-1", children: [
13341
13365
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
13342
13366
  import_design_system42.BasicTextarea,
@@ -13397,11 +13421,11 @@ function inTheStoresOrder(options) {
13397
13421
  return [...options].sort((a, b) => position(a) - position(b) || made(a).localeCompare(made(b)));
13398
13422
  }
13399
13423
  function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose, onCancel, addsChoices, initialSearch, asForm, onChosen }) {
13400
- const client = (0, import_react71.useOptionalRecordsClient)();
13401
- const [options, setOptions] = (0, import_react70.useState)(null);
13402
- const [refusal, setRefusal] = (0, import_react70.useState)(null);
13403
- const [reread, setReread] = (0, import_react70.useState)(0);
13404
- (0, import_react70.useEffect)(() => {
13424
+ const client = (0, import_react72.useOptionalRecordsClient)();
13425
+ const [options, setOptions] = (0, import_react71.useState)(null);
13426
+ const [refusal, setRefusal] = (0, import_react71.useState)(null);
13427
+ const [reread, setReread] = (0, import_react71.useState)(0);
13428
+ (0, import_react71.useEffect)(() => {
13405
13429
  if (!client) return;
13406
13430
  let cancelled = false;
13407
13431
  void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((result) => {
@@ -13565,18 +13589,18 @@ function OpenChoicePicker({
13565
13589
  allowOther = true,
13566
13590
  onChoicesChanged
13567
13591
  }) {
13568
- const client = (0, import_react71.useOptionalRecordsClient)();
13592
+ const client = (0, import_react72.useOptionalRecordsClient)();
13569
13593
  const nudge = useChoiceNudge();
13570
- const [open, setOpenState] = (0, import_react70.useState)(autoOpen === true);
13571
- const onCloseRef = (0, import_react70.useRef)(onClose);
13594
+ const [open, setOpenState] = (0, import_react71.useState)(autoOpen === true);
13595
+ const onCloseRef = (0, import_react71.useRef)(onClose);
13572
13596
  onCloseRef.current = onClose;
13573
- const setOpen = (0, import_react70.useCallback)((next) => {
13597
+ const setOpen = (0, import_react71.useCallback)((next) => {
13574
13598
  setOpenState(next);
13575
13599
  if (!next) onCloseRef.current?.();
13576
13600
  }, []);
13577
- const [search, setSearch] = (0, import_react70.useState)(initialSearch ?? "");
13578
- const [adding, setAdding] = (0, import_react70.useState)(false);
13579
- const [addRefused, setAddRefused] = (0, import_react70.useState)(null);
13601
+ const [search, setSearch] = (0, import_react71.useState)(initialSearch ?? "");
13602
+ const [adding, setAdding] = (0, import_react71.useState)(false);
13603
+ const [addRefused, setAddRefused] = (0, import_react71.useState)(null);
13580
13604
  const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
13581
13605
  const held = withoutAddition(value);
13582
13606
  const current = (0, import_records28.choiceValuesOf)(held.value);
@@ -13733,7 +13757,7 @@ function ChoiceAnswer({
13733
13757
  isChosen,
13734
13758
  onChosen
13735
13759
  }) {
13736
- const [search, setSearch] = (0, import_react70.useState)("");
13760
+ const [search, setSearch] = (0, import_react71.useState)("");
13737
13761
  const held = field.multi ? (0, import_records28.choiceValuesOf)(value) : value === null || value === void 0 || value === "" ? [] : [value];
13738
13762
  const on = (choice) => held.some((v) => isChosen ? isChosen(choice, v) : String(v) === choice.key || String(v) === choice.label);
13739
13763
  const press = (choice) => {
@@ -13839,7 +13863,7 @@ function ChoiceAnswer({
13839
13863
  init_names();
13840
13864
 
13841
13865
  // src/RecordsMount.tsx
13842
- var import_react72 = require("react");
13866
+ var import_react73 = require("react");
13843
13867
 
13844
13868
  // src/dataSource.ts
13845
13869
  var import_global_slot2 = require("@ai-matrx/kit/global-slot");
@@ -13849,7 +13873,7 @@ function personActor(userId) {
13849
13873
  var dataSources = (0, import_global_slot2.globalSlot)("ai-matrx.records-ui.data-sources", () => /* @__PURE__ */ new WeakMap());
13850
13874
 
13851
13875
  // src/RecordsMount.tsx
13852
- var import_react73 = require("@ai-matrx/records/react");
13876
+ var import_react74 = require("@ai-matrx/records/react");
13853
13877
  var import_jsx_runtime49 = require("react/jsx-runtime");
13854
13878
 
13855
13879
  // src/TablePickers.tsx
@@ -13889,8 +13913,8 @@ function readTablesAnywhere(dataSource) {
13889
13913
  return read;
13890
13914
  }
13891
13915
  function useTablesAnywhere(dataSource) {
13892
- const [state2, setState] = (0, import_react74.useState)({ loading: true, error: null, rows: [] });
13893
- (0, import_react74.useEffect)(() => {
13916
+ const [state2, setState] = (0, import_react75.useState)({ loading: true, error: null, rows: [] });
13917
+ (0, import_react75.useEffect)(() => {
13894
13918
  let live = true;
13895
13919
  void readTablesAnywhere(dataSource).then((result) => {
13896
13920
  if (live) setState(result);
@@ -13960,14 +13984,14 @@ function TableScope({ dataSource, userId, tableId, children, fallback = null, un
13960
13984
  const organizationId = list.rows.find((t) => t.table_id === tableId)?.organization_id ?? null;
13961
13985
  if (tableId && !organizationId && !list.loading) return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_jsx_runtime50.Fragment, { children: unavailable ?? fallback });
13962
13986
  if (!tableId || !organizationId) return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_jsx_runtime50.Fragment, { children: fallback });
13963
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react75.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children });
13987
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react76.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children });
13964
13988
  }
13965
13989
  function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
13966
- const fields = (0, import_react75.useFields)(tableId);
13967
- const all = (0, import_react74.useMemo)(() => fields.data ?? [], [fields.data]);
13968
- const byKey = (0, import_react74.useMemo)(() => new Map(all.map((f) => [f.key, f])), [all]);
13990
+ const fields = (0, import_react76.useFields)(tableId);
13991
+ const all = (0, import_react75.useMemo)(() => fields.data ?? [], [fields.data]);
13992
+ const byKey = (0, import_react75.useMemo)(() => new Map(all.map((f) => [f.key, f])), [all]);
13969
13993
  const keys = Object.keys(value);
13970
- const [adding, setAdding] = (0, import_react74.useState)(false);
13994
+ const [adding, setAdding] = (0, import_react75.useState)(false);
13971
13995
  const optionsFor = (current) => all.filter((f) => f.key === current || !(f.key in value)).map((f) => ({ value: f.key, label: fieldName(f) }));
13972
13996
  const rename = (from, to) => {
13973
13997
  if (from === to) return;
@@ -14055,8 +14079,8 @@ function ColumnValueRow({
14055
14079
  ] });
14056
14080
  }
14057
14081
  function RecordPicker({ tableId, value, onChange, disabled }) {
14058
- const table = (0, import_react75.useTable)(tableId);
14059
- const records = (0, import_react75.useRecords)(tableId, { pageSize: 200 });
14082
+ const table = (0, import_react76.useTable)(tableId);
14083
+ const records = (0, import_react76.useRecords)(tableId, { pageSize: 200 });
14060
14084
  const rows = records.data?.rows ?? [];
14061
14085
  const options = rows.map((row) => ({
14062
14086
  value: row.id,
@@ -14083,9 +14107,9 @@ function RecordPicker({ tableId, value, onChange, disabled }) {
14083
14107
  }
14084
14108
 
14085
14109
  // src/DataBindingPicker.tsx
14086
- var import_react76 = require("react");
14110
+ var import_react77 = require("react");
14087
14111
  var import_records29 = require("@ai-matrx/records");
14088
- var import_react77 = require("@ai-matrx/records/react");
14112
+ var import_react78 = require("@ai-matrx/records/react");
14089
14113
  var import_design_system44 = require("@ai-matrx/design-system");
14090
14114
  init_names();
14091
14115
  var import_jsx_runtime51 = require("react/jsx-runtime");
@@ -14176,11 +14200,11 @@ function BindingDetails({
14176
14200
  disabled,
14177
14201
  defaultRowLimit
14178
14202
  }) {
14179
- const table = (0, import_react77.useTable)(tableId);
14180
- const fields = (0, import_react77.useFields)(tableId);
14181
- const fieldList = (0, import_react76.useMemo)(() => fields.data ?? [], [fields.data]);
14203
+ const table = (0, import_react78.useTable)(tableId);
14204
+ const fields = (0, import_react78.useFields)(tableId);
14205
+ const fieldList = (0, import_react77.useMemo)(() => fields.data ?? [], [fields.data]);
14182
14206
  const shape = binding.semantic_type;
14183
- (0, import_react76.useEffect)(() => {
14207
+ (0, import_react77.useEffect)(() => {
14184
14208
  if (disabled || shape === "value" || binding.transform || fields.loading || fieldList.length === 0) return;
14185
14209
  onChange({
14186
14210
  ...binding,
@@ -14325,7 +14349,7 @@ function BindingDetails({
14325
14349
  }
14326
14350
 
14327
14351
  // src/PickedSummaries.tsx
14328
- var import_react78 = require("@ai-matrx/records/react");
14352
+ var import_react79 = require("@ai-matrx/records/react");
14329
14353
  init_names();
14330
14354
  var import_jsx_runtime52 = require("react/jsx-runtime");
14331
14355
  function TableNameText({ dataSource, tableId }) {
@@ -14355,7 +14379,7 @@ function ColumnValuesText({
14355
14379
  );
14356
14380
  }
14357
14381
  function ColumnValuesWords({ tableId, value }) {
14358
- const fields = (0, import_react78.useFields)(tableId);
14382
+ const fields = (0, import_react79.useFields)(tableId);
14359
14383
  const labels = useRecordLabels(fields.data ?? void 0);
14360
14384
  if (fields.loading) return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: "\u2026" });
14361
14385
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: "Couldn't load this table's columns" });
@@ -14394,8 +14418,8 @@ function RecordNameText({
14394
14418
  );
14395
14419
  }
14396
14420
  function RecordNameWords({ tableId, recordId }) {
14397
- const table = (0, import_react78.useTable)(tableId);
14398
- const record = (0, import_react78.useRecord)(recordId);
14421
+ const table = (0, import_react79.useTable)(tableId);
14422
+ const record = (0, import_react79.useRecord)(recordId);
14399
14423
  if (record.loading || table.loading) return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: "\u2026" });
14400
14424
  if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: "Couldn't load this record" });
14401
14425
  if (!record.data) return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: "A record you cannot open" });
@@ -14403,24 +14427,24 @@ function RecordNameWords({ tableId, recordId }) {
14403
14427
  }
14404
14428
 
14405
14429
  // src/HeldChangeDecision.tsx
14406
- var import_react79 = require("react");
14407
- var import_react80 = require("@ai-matrx/records/react");
14430
+ var import_react80 = require("react");
14431
+ var import_react81 = require("@ai-matrx/records/react");
14408
14432
  var import_design_system45 = require("@ai-matrx/design-system");
14409
14433
  init_Refusal();
14410
14434
  var import_jsx_runtime53 = require("react/jsx-runtime");
14411
14435
  function HeldChangeDecision({ dataSource, userId, organizationId, approvalId, onDecided, approveLabel }) {
14412
- return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react80.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Decision, { approvalId, onDecided, approveLabel: approveLabel ?? "Approve" }) });
14436
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react81.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Decision, { approvalId, onDecided, approveLabel: approveLabel ?? "Approve" }) });
14413
14437
  }
14414
14438
  function Decision({
14415
14439
  approvalId,
14416
14440
  onDecided,
14417
14441
  approveLabel
14418
14442
  }) {
14419
- const client = (0, import_react80.useRecordsClient)();
14420
- const [may, setMay] = (0, import_react79.useState)(null);
14421
- const [busy, setBusy] = (0, import_react79.useState)(null);
14422
- const [error, setError] = (0, import_react79.useState)(null);
14423
- (0, import_react79.useEffect)(() => {
14443
+ const client = (0, import_react81.useRecordsClient)();
14444
+ const [may, setMay] = (0, import_react80.useState)(null);
14445
+ const [busy, setBusy] = (0, import_react80.useState)(null);
14446
+ const [error, setError] = (0, import_react80.useState)(null);
14447
+ (0, import_react80.useEffect)(() => {
14424
14448
  let live = true;
14425
14449
  void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
14426
14450
  if (!live) return;