@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.
@@ -1613,7 +1613,7 @@ function ReferenceBuilder({
1613
1613
  }
1614
1614
 
1615
1615
  // src/ChoiceListEditor.tsx
1616
- import { useEffect as useEffect20, useRef as useRef17, useState as useState30 } from "react";
1616
+ import { useEffect as useEffect21, useRef as useRef17, useState as useState31 } from "react";
1617
1617
  import { optionLabel as optionLabel2, recordsUseSentence, rehomeSentence } from "@ai-matrx/records";
1618
1618
  import { useRecordsClient as useRecordsClient9 } from "@ai-matrx/records/react";
1619
1619
  import {
@@ -1671,9 +1671,9 @@ function AddChoicesInline({ field: field2, onAdded, disabled = false }) {
1671
1671
  }
1672
1672
 
1673
1673
  // src/editors.tsx
1674
- import { useCallback as useCallback6, useEffect as useEffect19, useLayoutEffect as useLayoutEffect3, useRef as useRef16, useState as useState29 } from "react";
1674
+ import { useCallback as useCallback6, useEffect as useEffect20, useLayoutEffect as useLayoutEffect3, useRef as useRef16, useState as useState30 } from "react";
1675
1675
  import { isButtonField as isButtonField2, allowsOtherValues, choiceValuesOf, coerceTypedAnswer, newerKindOf as newerKindOf2, decideTypedChoice, isTheChosen, optionKey as optionKey4, rankTypedMatches as rankTypedMatches4, readTypedTime as readTypedTime2, typedDateText as typedDateText2, typedTimeText as typedTimeText2 } from "@ai-matrx/records";
1676
- import { useOptionalRecordsClient as useOptionalRecordsClient11 } from "@ai-matrx/records/react";
1676
+ import { useOptionalRecordsClient as useOptionalRecordsClient12 } from "@ai-matrx/records/react";
1677
1677
  import {
1678
1678
  BasicInput as BasicInput10,
1679
1679
  BasicTextarea as BasicTextarea4,
@@ -2335,11 +2335,11 @@ function RelationPicker({ field: field2, value, onChange, disabled, id, classNam
2335
2335
  }
2336
2336
 
2337
2337
  // src/buttonCell.tsx
2338
- import { useContext as useContext3, useEffect as useEffect17, useRef as useRef13, useState as useState25 } from "react";
2338
+ import { useContext as useContext3, useEffect as useEffect18, useRef as useRef13, useState as useState26 } from "react";
2339
2339
  import { Button as Button15, Dialog as Dialog3, ErrorBox as ErrorBox2, DialogContent as DialogContent3, DialogDescription, DialogHeader as DialogHeader3, DialogTitle as DialogTitle3, Popover as Popover4, PopoverContent as PopoverContent4, PopoverTrigger as PopoverTrigger4, cn as cn18 } from "@ai-matrx/design-system";
2340
2340
  import { CHOICE_CHIP_CLASS, NEUTRAL_CHIP_CLASS, isStyleColor } from "@ai-matrx/design-system/data-table";
2341
2341
  import { buttonNeeds as buttonNeeds2, buttonOf as buttonOf2 } from "@ai-matrx/records";
2342
- import { useOptionalRecordsClient as useOptionalRecordsClient10, useTable as useTable2 } from "@ai-matrx/records/react";
2342
+ import { useOptionalRecordsClient as useOptionalRecordsClient11, useTable as useTable2 } from "@ai-matrx/records/react";
2343
2343
 
2344
2344
  // src/gridOpen.tsx
2345
2345
  import { createContext as createContext2 } from "react";
@@ -2476,7 +2476,7 @@ function columnNameProblemLine(name, noun = "column") {
2476
2476
  }
2477
2477
 
2478
2478
  // src/FieldEditor.tsx
2479
- import { useEffect as useEffect16, useMemo as useMemo10, useRef as useRef12, useState as useState24 } from "react";
2479
+ import { useEffect as useEffect17, useMemo as useMemo10, useRef as useRef12, useState as useState25 } from "react";
2480
2480
  import {
2481
2481
  tableShapeChanged as tableShapeChanged3,
2482
2482
  useEntityFieldMutation,
@@ -7338,11 +7338,11 @@ function nextFieldSort(fields) {
7338
7338
  import { autonumberPrefixOf as autonumberPrefixOf3, buttonNeeds, buttonOf } from "@ai-matrx/records";
7339
7339
 
7340
7340
  // src/ButtonSettings.tsx
7341
- import { useEffect as useEffect15, useState as useState23 } from "react";
7341
+ import { useEffect as useEffect16, useState as useState24 } from "react";
7342
7342
  import { BasicInput as BasicInput7, Button as Button13, Label as Label8 } from "@ai-matrx/design-system";
7343
7343
  import { STYLE_COLORS } from "@ai-matrx/design-system/data-table";
7344
7344
  import { buttonUrlPlaceholders } from "@ai-matrx/records";
7345
- import { useOptionalRecordsClient as useOptionalRecordsClient9 } from "@ai-matrx/records/react";
7345
+ import { useOptionalRecordsClient as useOptionalRecordsClient10 } from "@ai-matrx/records/react";
7346
7346
 
7347
7347
  // src/AccentSwatches.tsx
7348
7348
  import { PORTAL_ACCENTS } from "@ai-matrx/records";
@@ -7383,7 +7383,8 @@ function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel =
7383
7383
 
7384
7384
  // src/AddRowSettings.tsx
7385
7385
  import { Label as Label7 } from "@ai-matrx/design-system";
7386
- import { useFields as useFields2 } from "@ai-matrx/records/react";
7386
+ import { useFields as useFields2, useOptionalRecordsClient as useOptionalRecordsClient9 } from "@ai-matrx/records/react";
7387
+ import { useEffect as useEffect15, useState as useState23 } from "react";
7387
7388
  import { jsx as jsx33, jsxs as jsxs29 } from "react/jsx-runtime";
7388
7389
  var THIS_ROW = "@row";
7389
7390
  var NOTHING = "";
@@ -7399,6 +7400,16 @@ function AddRowSettings({ value, onChange, tableId, fields }) {
7399
7400
  const targetFields = useFields2(target);
7400
7401
  const typed = (targetFields.data ?? []).filter((f) => f.type !== "formula" && typeof f.config?.["system"] !== "string");
7401
7402
  const sources = [{ value: NOTHING, label: "Nothing" }, { value: THIS_ROW, label: "This row" }, ...fields.map((f) => ({ value: f.key, label: f.label }))];
7403
+ const client = useOptionalRecordsClient9();
7404
+ const [templates, setTemplates] = useState23([]);
7405
+ useEffect15(() => {
7406
+ if (!client || !target) return;
7407
+ let live = true;
7408
+ void client.rowTemplates({ table_id: target }).then((got) => live && setTemplates(got.ok ? got.data : []));
7409
+ return () => {
7410
+ live = false;
7411
+ };
7412
+ }, [client, target]);
7402
7413
  return /* @__PURE__ */ jsxs29("div", { className: "flex flex-col gap-2", "data-records-button-add-row": "", children: [
7403
7414
  /* @__PURE__ */ jsxs29("div", { className: "flex flex-col gap-1", children: [
7404
7415
  /* @__PURE__ */ jsx33(Label7, { className: "text-xs", children: "Adds to" }),
@@ -7408,11 +7419,24 @@ function AddRowSettings({ value, onChange, tableId, fields }) {
7408
7419
  label: "Table the new row goes in",
7409
7420
  value: value.table_id ?? tableId ?? "",
7410
7421
  attrs: { "data-records-button-add-row-table": "" },
7411
- onChange: (id) => onChange({ ...value, table_id: id === tableId ? void 0 : id, prefill: void 0 }),
7422
+ onChange: (id) => onChange({ ...value, table_id: id === tableId ? void 0 : id, prefill: void 0, template_id: void 0 }),
7412
7423
  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 }))
7413
7424
  }
7414
7425
  )
7415
7426
  ] }),
7427
+ templates.length || value.template_id ? /* @__PURE__ */ jsxs29("div", { className: "flex flex-col gap-1", children: [
7428
+ /* @__PURE__ */ jsx33(Label7, { className: "text-xs", children: "Starts from" }),
7429
+ /* @__PURE__ */ jsx33(
7430
+ PickOne,
7431
+ {
7432
+ label: "Row template the new row starts from",
7433
+ value: value.template_id ?? NOTHING,
7434
+ attrs: { "data-records-button-add-row-template": "" },
7435
+ onChange: (id) => onChange({ ...value, template_id: id ? id : void 0 }),
7436
+ options: [{ value: NOTHING, label: "A blank row" }, ...templates.map((t) => ({ value: t.template_id, label: t.name }))]
7437
+ }
7438
+ )
7439
+ ] }) : null,
7416
7440
  typed.length ? /* @__PURE__ */ jsx33("div", { className: "grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1", children: typed.map((f) => /* @__PURE__ */ jsxs29("div", { className: "contents", children: [
7417
7441
  /* @__PURE__ */ jsx33("span", { className: "text-sm", children: f.label }),
7418
7442
  /* @__PURE__ */ jsx33(
@@ -7452,11 +7476,11 @@ function ButtonSettingsEditor({
7452
7476
  tableId,
7453
7477
  fields
7454
7478
  }) {
7455
- const client = useOptionalRecordsClient9();
7456
- const [actions, setActions] = useState23(null);
7457
- const [actionsRefused, setActionsRefused] = useState23(null);
7458
- const [automations, setAutomations] = useState23(null);
7459
- useEffect15(() => {
7479
+ const client = useOptionalRecordsClient10();
7480
+ const [actions, setActions] = useState24(null);
7481
+ const [actionsRefused, setActionsRefused] = useState24(null);
7482
+ const [automations, setAutomations] = useState24(null);
7483
+ useEffect16(() => {
7460
7484
  if (!client || !tableId) return;
7461
7485
  let live = true;
7462
7486
  if (value.do === "run_action" && actions === null) {
@@ -7589,12 +7613,12 @@ function NewRowAction({
7589
7613
  columns,
7590
7614
  onMade
7591
7615
  }) {
7592
- const client = useOptionalRecordsClient9();
7616
+ const client = useOptionalRecordsClient10();
7593
7617
  const settable = settableColumns(columns);
7594
- const [fieldId, setFieldId] = useState23("");
7595
- const [setTo, setSetTo] = useState23("");
7596
- const [busy, setBusy] = useState23(false);
7597
- const [refused, setRefused] = useState23(null);
7618
+ const [fieldId, setFieldId] = useState24("");
7619
+ const [setTo, setSetTo] = useState24("");
7620
+ const [busy, setBusy] = useState24(false);
7621
+ const [refused, setRefused] = useState24(null);
7598
7622
  if (settable.length === 0) return /* @__PURE__ */ jsx34("p", { className: "text-xs text-muted-foreground", children: "No column to set" });
7599
7623
  const make = async () => {
7600
7624
  if (!client || fieldId === "") return;
@@ -7770,35 +7794,35 @@ function FieldEditor(props) {
7770
7794
  const copyOf = field2 ? void 0 : props.copyOf;
7771
7795
  const start = field2 ?? copyOf;
7772
7796
  const startAs = start ? void 0 : props.startAs;
7773
- const [label, setLabel] = useState24(field2?.label ?? (copyOf ? `${copyOf.label} (1)` : startAs?.label ?? ""));
7774
- const [type, setType] = useState24(() => startAs ? startAs.type : startingType(start));
7775
- const [required, setRequired] = useState24(start?.required ?? false);
7776
- const [multi, setMulti] = useState24(start?.multi ?? false);
7777
- const [dated, setDated] = useState24(start?.dated ?? false);
7778
- const [sensitivity, setSensitivity] = useState24(String(start?.sensitivity ?? "internal"));
7779
- const [contextPolicy, setContextPolicy] = useState24(String(start?.context_policy ?? "include"));
7780
- const [rules, setRules] = useState24(start?.rules ?? []);
7781
- const [startsWith, setStartsWith] = useState24(start?.default ?? null);
7782
- const [ratingMax, setRatingMax] = useState24(() => start ? ratingMaxOf(start) : 5);
7797
+ const [label, setLabel] = useState25(field2?.label ?? (copyOf ? `${copyOf.label} (1)` : startAs?.label ?? ""));
7798
+ const [type, setType] = useState25(() => startAs ? startAs.type : startingType(start));
7799
+ const [required, setRequired] = useState25(start?.required ?? false);
7800
+ const [multi, setMulti] = useState25(start?.multi ?? false);
7801
+ const [dated, setDated] = useState25(start?.dated ?? false);
7802
+ const [sensitivity, setSensitivity] = useState25(String(start?.sensitivity ?? "internal"));
7803
+ const [contextPolicy, setContextPolicy] = useState25(String(start?.context_policy ?? "include"));
7804
+ const [rules, setRules] = useState25(start?.rules ?? []);
7805
+ const [startsWith, setStartsWith] = useState25(start?.default ?? null);
7806
+ const [ratingMax, setRatingMax] = useState25(() => start ? ratingMaxOf(start) : 5);
7783
7807
  const savedRules = useMemo10(
7784
7808
  () => field2 ? type === "rating" ? rulesWithTopStar(field2.rules ?? [], ratingMaxOf(field2)) : field2.rules ?? [] : [],
7785
7809
  [field2, type]
7786
7810
  );
7787
7811
  const editedRules = useMemo10(() => type === "rating" ? rulesWithTopStar(rules, ratingMax) : rules, [type, rules, ratingMax]);
7788
- const [statusGroups, setStatusGroups] = useState24({});
7789
- const [statusKeys, setStatusKeys] = useState24({});
7790
- const [symbology, setSymbology] = useState24(String(start?.config?.["symbology"] ?? ""));
7812
+ const [statusGroups, setStatusGroups] = useState25({});
7813
+ const [statusKeys, setStatusKeys] = useState25({});
7814
+ const [symbology, setSymbology] = useState25(String(start?.config?.["symbology"] ?? ""));
7791
7815
  const descriptionStart = String(start?.config?.["description"] ?? "");
7792
- const [description, setDescription] = useState24(descriptionStart);
7816
+ const [description, setDescription] = useState25(descriptionStart);
7793
7817
  const buttonStart = useMemo10(() => buttonOf(start) ?? { label: "" }, [start]);
7794
- const [buttonSettings, setButtonSettings] = useState24(buttonStart);
7818
+ const [buttonSettings, setButtonSettings] = useState25(buttonStart);
7795
7819
  const prefixStart = autonumberPrefixOf3(start);
7796
- const [numberPrefix, setNumberPrefix] = useState24(prefixStart);
7820
+ const [numberPrefix, setNumberPrefix] = useState25(prefixStart);
7797
7821
  const dependencyStart = start?.config?.["dependency"] === true;
7798
7822
  const watchStart = useMemo10(() => watchedFieldsOf(start), [start]);
7799
- const [watchFields, setWatchFields] = useState24(watchStart);
7800
- const [dependency, setDependency] = useState24(dependencyStart);
7801
- useEffect16(() => {
7823
+ const [watchFields, setWatchFields] = useState25(watchStart);
7824
+ const [dependency, setDependency] = useState25(dependencyStart);
7825
+ useEffect17(() => {
7802
7826
  if (!field2 || type !== "status") return;
7803
7827
  let live = true;
7804
7828
  void client.fieldOptions({ field_id: field2.id }).then((got) => {
@@ -7808,20 +7832,20 @@ function FieldEditor(props) {
7808
7832
  live = false;
7809
7833
  };
7810
7834
  }, [client, field2, type]);
7811
- useEffect16(() => {
7835
+ useEffect17(() => {
7812
7836
  if (field2 || type !== "status") return;
7813
7837
  setNewChoices(
7814
7838
  (rows) => rows.length > 0 ? rows : STATUS_STARTING_CHOICES.map((c, i) => ({ id: null, words: c.words, row: `status-${i}` }))
7815
7839
  );
7816
7840
  }, [field2, type]);
7817
- useEffect16(() => {
7841
+ useEffect17(() => {
7818
7842
  if (field2 || type !== "select" && type !== "multi_select") return;
7819
7843
  setNewChoices((rows) => rows.length > 0 ? rows : [newChoiceRow([])]);
7820
7844
  }, [field2, type]);
7821
- const [allowOther, setAllowOther] = useState24(start?.config?.["allow_other"] === true);
7822
- const [newChoices, setNewChoices] = useState24([]);
7845
+ const [allowOther, setAllowOther] = useState25(start?.config?.["allow_other"] === true);
7846
+ const [newChoices, setNewChoices] = useState25([]);
7823
7847
  const copyOfId = copyOf?.id ?? null;
7824
- useEffect16(() => {
7848
+ useEffect17(() => {
7825
7849
  if (!copyOf || !copyOfId) return;
7826
7850
  let live = true;
7827
7851
  void client.fieldOptions({ field_id: copyOfId }).then((got) => {
@@ -7833,53 +7857,53 @@ function FieldEditor(props) {
7833
7857
  live = false;
7834
7858
  };
7835
7859
  }, [client, copyOfId]);
7836
- const [choiceList, setChoiceList] = useState24(null);
7837
- const [choiceListStart, setChoiceListStart] = useState24(null);
7838
- const [rehome, setRehome] = useState24({});
7839
- const [rehomed, setRehomed] = useState24(null);
7840
- const [rehomeRefused, setRehomeRefused] = useState24(null);
7841
- const [unit, setUnit] = useState24(start?.unit ?? "$");
7842
- const [withTime, setWithTime] = useState24(String(start?.config?.["kind"] ?? "date") === "datetime");
7843
- const [via, setVia] = useState24(String(start?.config?.["via"] ?? ""));
7844
- const [pick, setPick] = useState24(String(start?.config?.["pick"] ?? ""));
7845
- const [agg, setAgg] = useState24(
7860
+ const [choiceList, setChoiceList] = useState25(null);
7861
+ const [choiceListStart, setChoiceListStart] = useState25(null);
7862
+ const [rehome, setRehome] = useState25({});
7863
+ const [rehomed, setRehomed] = useState25(null);
7864
+ const [rehomeRefused, setRehomeRefused] = useState25(null);
7865
+ const [unit, setUnit] = useState25(start?.unit ?? "$");
7866
+ const [withTime, setWithTime] = useState25(String(start?.config?.["kind"] ?? "date") === "datetime");
7867
+ const [via, setVia] = useState25(String(start?.config?.["via"] ?? ""));
7868
+ const [pick, setPick] = useState25(String(start?.config?.["pick"] ?? ""));
7869
+ const [agg, setAgg] = useState25(
7846
7870
  start?.config?.["agg"] ?? "count"
7847
7871
  );
7848
- const [of, setOf] = useState24(String(start?.config?.["of"] ?? ""));
7872
+ const [of, setOf] = useState25(String(start?.config?.["of"] ?? ""));
7849
7873
  const savedRollupFilter = field2?.config?.["filter"] ?? null;
7850
- const [rollupFilter, setRollupFilter] = useState24(
7874
+ const [rollupFilter, setRollupFilter] = useState25(
7851
7875
  field2 ? savedRollupFilter : copyOf?.config?.["filter"] ?? null
7852
7876
  );
7853
7877
  const rollupFilterChanged = JSON.stringify(rollupFilter) !== JSON.stringify(savedRollupFilter);
7854
- const [relationTarget, setRelationTarget] = useState24(String(start?.relation_target ?? ""));
7855
- const [showOnOther, setShowOnOther] = useState24(true);
7856
- const [nestsSubItems, setNestsSubItems] = useState24(false);
7857
- const [reverseRefused, setReverseRefused] = useState24(null);
7878
+ const [relationTarget, setRelationTarget] = useState25(String(start?.relation_target ?? ""));
7879
+ const [showOnOther, setShowOnOther] = useState25(true);
7880
+ const [nestsSubItems, setNestsSubItems] = useState25(false);
7881
+ const [reverseRefused, setReverseRefused] = useState25(null);
7858
7882
  const otherTable = useTable(!field2 && type === "relation" && relationTarget !== "" ? relationTarget : null);
7859
- const [display, setDisplay] = useState24(start?.display ?? null);
7860
- const [formulaOp, setFormulaOp] = useState24(() => formulaOpOf(start));
7861
- const [formulaFields, setFormulaFields] = useState24(() => formulaFieldIdsOf(start));
7862
- const [formulaSeparator, setFormulaSeparator] = useState24(() => formulaSeparatorOf(start));
7863
- const [allowedTypes, setAllowedTypes] = useState24(() => entityReferenceKindsOf(start));
7883
+ const [display, setDisplay] = useState25(start?.display ?? null);
7884
+ const [formulaOp, setFormulaOp] = useState25(() => formulaOpOf(start));
7885
+ const [formulaFields, setFormulaFields] = useState25(() => formulaFieldIdsOf(start));
7886
+ const [formulaSeparator, setFormulaSeparator] = useState25(() => formulaSeparatorOf(start));
7887
+ const [allowedTypes, setAllowedTypes] = useState25(() => entityReferenceKindsOf(start));
7864
7888
  const startingFormulaText = start ? formulaTextNow(String(start.config?.["formula_text"] ?? ""), start.config?.["expr"] ?? start.expr, fields.data) : "";
7865
- const [formulaText, setFormulaText] = useState24(startingFormulaText);
7889
+ const [formulaText, setFormulaText] = useState25(startingFormulaText);
7866
7890
  const shownFormula = useRef12(startingFormulaText);
7867
- useEffect16(() => {
7891
+ useEffect17(() => {
7868
7892
  if (shownFormula.current === startingFormulaText) return;
7869
7893
  setFormulaText((typed) => typed === shownFormula.current ? startingFormulaText : typed);
7870
7894
  shownFormula.current = startingFormulaText;
7871
7895
  }, [startingFormulaText]);
7872
- const [formulaWritten, setFormulaWritten] = useState24(() => startingFormulaText.trim() !== "" || Boolean(field2) || startAs?.type === "formula");
7873
- const [formulaOk, setFormulaOk] = useState24(null);
7874
- const [askingToRemove, setAskingToRemove] = useState24(false);
7875
- const [attempted, setAttempted] = useState24(false);
7876
- const [showsAs, setShowsAs] = useState24(() => start ? startingChoice(start) : { format: null, retype: null });
7877
- const [backfillError, setBackfillError] = useState24(null);
7878
- const [notLanded, setNotLanded] = useState24(false);
7896
+ const [formulaWritten, setFormulaWritten] = useState25(() => startingFormulaText.trim() !== "" || Boolean(field2) || startAs?.type === "formula");
7897
+ const [formulaOk, setFormulaOk] = useState25(null);
7898
+ const [askingToRemove, setAskingToRemove] = useState25(false);
7899
+ const [attempted, setAttempted] = useState25(false);
7900
+ const [showsAs, setShowsAs] = useState25(() => start ? startingChoice(start) : { format: null, retype: null });
7901
+ const [backfillError, setBackfillError] = useState25(null);
7902
+ const [notLanded, setNotLanded] = useState25(false);
7879
7903
  const liveField = field2 ? fields.data?.find((f) => f.id === field2.id) ?? field2 : void 0;
7880
7904
  const heldAs = liveField ? JSON.stringify([liveField.type, liveField.config?.["kind"] ?? null, liveField.format ?? null, liveField.multi ?? false, liveField.unit ?? null]) : "";
7881
7905
  const seededAs = useRef12(heldAs);
7882
- useEffect16(() => {
7906
+ useEffect17(() => {
7883
7907
  if (!liveField || seededAs.current === heldAs) return;
7884
7908
  seededAs.current = heldAs;
7885
7909
  setType(startingType(liveField));
@@ -7899,7 +7923,7 @@ function FieldEditor(props) {
7899
7923
  const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
7900
7924
  const choice = fieldTypeChoice(type);
7901
7925
  const editing = Boolean(field2);
7902
- useEffect16(() => {
7926
+ useEffect17(() => {
7903
7927
  if (!editing) setStartsWith(null);
7904
7928
  }, [type, editing]);
7905
7929
  const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
@@ -8869,7 +8893,7 @@ function RollupFilterQuestion({
8869
8893
  [farFields.data]
8870
8894
  );
8871
8895
  const lastFar = useRef12(far);
8872
- useEffect16(() => {
8896
+ useEffect17(() => {
8873
8897
  if (lastFar.current !== null && far !== lastFar.current && !editing) onChange(null);
8874
8898
  lastFar.current = far;
8875
8899
  }, [far, editing, onChange]);
@@ -9023,17 +9047,17 @@ function waitingRunsOf(pressed) {
9023
9047
  }
9024
9048
  var stop2 = (event) => event.stopPropagation();
9025
9049
  function ButtonValue({ field: field2, recordId, inCell }) {
9026
- const client = useOptionalRecordsClient10();
9050
+ const client = useOptionalRecordsClient11();
9027
9051
  const b = buttonOf2(field2);
9028
- const [busy, setBusy] = useState25(false);
9029
- const [said2, setSaid] = useState25(null);
9030
- const [settingUp, setSettingUp] = useState25(false);
9031
- const [opening, setOpening] = useState25(false);
9052
+ const [busy, setBusy] = useState26(false);
9053
+ const [said2, setSaid] = useState26(null);
9054
+ const [settingUp, setSettingUp] = useState26(false);
9055
+ const [opening, setOpening] = useState26(false);
9032
9056
  const here = useContext3(OpenRecordHereContext);
9033
9057
  const host = useRecordsUi();
9034
9058
  const addsTo = useTable2(b?.do === "add_row" ? b.table_id ?? field2.entity_definition_id : null);
9035
9059
  const waitingOn = useRef13(0);
9036
- useEffect17(() => () => void (waitingOn.current += 1), []);
9060
+ useEffect18(() => () => void (waitingOn.current += 1), []);
9037
9061
  if (!b) return null;
9038
9062
  const color = isStyleColor(b.color) ? CHOICE_CHIP_CLASS[b.color] : NEUTRAL_CHIP_CLASS;
9039
9063
  const needs = buttonNeeds2(b);
@@ -9202,7 +9226,7 @@ function ButtonValue({ field: field2, recordId, inCell }) {
9202
9226
  }
9203
9227
 
9204
9228
  // src/FloatingRefusal.tsx
9205
- import { useLayoutEffect as useLayoutEffect2, useRef as useRef14, useState as useState26 } from "react";
9229
+ import { useLayoutEffect as useLayoutEffect2, useRef as useRef14, useState as useState27 } from "react";
9206
9230
  import { createPortal } from "react-dom";
9207
9231
  import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs33 } from "react/jsx-runtime";
9208
9232
  var GAP2 = 4;
@@ -9222,8 +9246,8 @@ function placeFor(anchor, note) {
9222
9246
  function FloatingRefusal({ text, why }) {
9223
9247
  const spot = useRef14(null);
9224
9248
  const note = useRef14(null);
9225
- const [style, setStyle] = useState26(null);
9226
- const [floating, setFloating] = useState26(false);
9249
+ const [style, setStyle] = useState27(null);
9250
+ const [floating, setFloating] = useState27(false);
9227
9251
  useLayoutEffect2(() => {
9228
9252
  const here = spot.current;
9229
9253
  if (!here) return;
@@ -9266,7 +9290,7 @@ function FloatingRefusal({ text, why }) {
9266
9290
  }
9267
9291
 
9268
9292
  // src/formatControls.tsx
9269
- import { useEffect as useEffect18, useRef as useRef15, useState as useState27 } from "react";
9293
+ import { useEffect as useEffect19, useRef as useRef15, useState as useState28 } from "react";
9270
9294
  import { BasicInput as BasicInput9, BasicTextarea as BasicTextarea3 } from "@ai-matrx/design-system";
9271
9295
  import { getFieldFormat as getFieldFormat3, parseFieldInput } from "@ai-matrx/design-system/field-formats";
9272
9296
  import { jsx as jsx38, jsxs as jsxs34 } from "react/jsx-runtime";
@@ -9286,9 +9310,9 @@ function keptValue(format, raw) {
9286
9310
  return parsed;
9287
9311
  }
9288
9312
  function NumberInFormat({ format, value, onChange, disabled, id }) {
9289
- const [text, setText] = useState27(() => typedText(format, value));
9313
+ const [text, setText] = useState28(() => typedText(format, value));
9290
9314
  const lastSent = useRef15(void 0);
9291
- useEffect18(() => {
9315
+ useEffect19(() => {
9292
9316
  if (value === lastSent.current) return;
9293
9317
  setText(typedText(format, value));
9294
9318
  }, [value, format]);
@@ -9367,7 +9391,7 @@ function formatControl(args) {
9367
9391
  }
9368
9392
 
9369
9393
  // src/typedDateHelper.tsx
9370
- import { useState as useState28 } from "react";
9394
+ import { useState as useState29 } from "react";
9371
9395
  import { Popover as Popover5, PopoverContent as PopoverContent5, PopoverTrigger as PopoverTrigger5, cn as cn19 } from "@ai-matrx/design-system";
9372
9396
  import { readTypedDate, readTypedTime, typedDateText, typedTimeText } from "@ai-matrx/records";
9373
9397
  import { jsx as jsx39, jsxs as jsxs35 } from "react/jsx-runtime";
@@ -9418,12 +9442,12 @@ function TypedDateHelper({
9418
9442
  onPicked,
9419
9443
  startOpen = false
9420
9444
  }) {
9421
- const [open, setOpen] = useState28(startOpen);
9445
+ const [open, setOpen] = useState29(startOpen);
9422
9446
  const held = readBox(text, kind);
9423
9447
  usePersonTimeZone();
9424
9448
  const today = personWallNow();
9425
9449
  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);
9426
- const [month, setMonth] = useState28(null);
9450
+ const [month, setMonth] = useState29(null);
9427
9451
  const shown2 = month ?? { y: start.getFullYear(), m: start.getMonth() };
9428
9452
  const first = new Date(shown2.y, shown2.m, 1).getDay();
9429
9453
  const days = new Date(shown2.y, shown2.m + 1, 0).getDate();
@@ -9702,7 +9726,7 @@ function draftFromTyping(field2, seed) {
9702
9726
  }
9703
9727
  function ReadsAsNote({ typed, always, children }) {
9704
9728
  const note = useRef16(null);
9705
- const [repeats, setRepeats] = useState29(false);
9729
+ const [repeats, setRepeats] = useState30(false);
9706
9730
  useLayoutEffect3(() => {
9707
9731
  if (always) return;
9708
9732
  const words = (t) => (t ?? "").replace(/^Reads as/, "").replace(/\s+/g, "").toLowerCase();
@@ -9712,12 +9736,12 @@ function ReadsAsNote({ typed, always, children }) {
9712
9736
  return /* @__PURE__ */ jsx40("span", { ref: note, "data-records-typed-reads-as": "", "data-records-cell-note": "", className: "text-[10px] text-muted-foreground", children });
9713
9737
  }
9714
9738
  function TypedTextControl({ field: field2, value, onChange, disabled, id, onCommit, onCancel }) {
9715
- const client = useOptionalRecordsClient11();
9739
+ const client = useOptionalRecordsClient12();
9716
9740
  const kind = String(editorKindFor(field2));
9717
9741
  const needsChoices = kind === "select" || kind === "multi_select";
9718
9742
  const nudge = useChoiceNudge(needsChoices);
9719
- const [choices, setChoices] = useState29(null);
9720
- useEffect19(() => {
9743
+ const [choices, setChoices] = useState30(null);
9744
+ useEffect20(() => {
9721
9745
  if (!needsChoices || !client) return;
9722
9746
  let cancelled = false;
9723
9747
  void (0, askOnce_exports.fieldOptionsOnce)(client, field2.id).then((result) => {
@@ -9727,7 +9751,7 @@ function TypedTextControl({ field: field2, value, onChange, disabled, id, onComm
9727
9751
  cancelled = true;
9728
9752
  };
9729
9753
  }, [client, field2.id, needsChoices]);
9730
- useEffect19(() => {
9754
+ useEffect20(() => {
9731
9755
  if (choices && nudge && value.judged === null) onChange({ ...value, judged: judgeTyped(field2, value.text, choices, nudge) });
9732
9756
  }, [choices, nudge, value, field2, onChange]);
9733
9757
  const judged = value.judged;
@@ -9803,7 +9827,7 @@ function FieldControl({ field: field2, value, onChange, disabled, id, autoOpen,
9803
9827
  const host = useRecordsUi();
9804
9828
  const kind = editorKindFor(field2);
9805
9829
  const inputId = id ?? `field-${field2.key}`;
9806
- const ownDetails = useOptionalRecordsClient11() === null;
9830
+ const ownDetails = useOptionalRecordsClient12() === null;
9807
9831
  if (isTypedDraft(value)) return /* @__PURE__ */ jsx40(TypedTextControl, { field: field2, value, onChange, disabled, id: inputId, onCommit, onCancel });
9808
9832
  if (isSignatureField(field2)) return /* @__PURE__ */ jsx40(SignaturePad, { id: inputId, value, onChange, disabled });
9809
9833
  if (isButtonField2(field2)) return /* @__PURE__ */ jsx40(ButtonValue, { field: field2 });
@@ -9926,11 +9950,11 @@ function FieldControl({ field: field2, value, onChange, disabled, id, autoOpen,
9926
9950
  }
9927
9951
  }
9928
9952
  function TypedWordsControl({ field: field2, value, onChange, disabled, id }) {
9929
- const [text, setText] = useState29(() => openingText(field2, value));
9930
- const [refusal, setRefusal] = useState29(null);
9931
- const [why, setWhy] = useState29(void 0);
9953
+ const [text, setText] = useState30(() => openingText(field2, value));
9954
+ const [refusal, setRefusal] = useState30(null);
9955
+ const [why, setWhy] = useState30(void 0);
9932
9956
  const sent = useRef16(value);
9933
- useEffect19(() => {
9957
+ useEffect20(() => {
9934
9958
  if (value === sent.current) return;
9935
9959
  sent.current = value;
9936
9960
  setText(openingText(field2, value));
@@ -10041,8 +10065,8 @@ function StructuredTextControl({ field: field2, value, onChange, disabled, id, r
10041
10065
  }
10042
10066
  function JsonControl({ field: field2, value, onChange, disabled, id }) {
10043
10067
  const initial = value === null || value === void 0 ? "" : typeof value === "string" ? value : JSON.stringify(value, null, 2);
10044
- const [text, setText] = useState29(initial);
10045
- const [broken, setBroken] = useState29(null);
10068
+ const [text, setText] = useState30(initial);
10069
+ const [broken, setBroken] = useState30(null);
10046
10070
  return /* @__PURE__ */ jsxs36("div", { className: "flex flex-col gap-1", children: [
10047
10071
  /* @__PURE__ */ jsx40(
10048
10072
  BasicTextarea4,
@@ -10103,11 +10127,11 @@ function inTheStoresOrder(options) {
10103
10127
  return [...options].sort((a, b) => position(a) - position(b) || made(a).localeCompare(made(b)));
10104
10128
  }
10105
10129
  function OptionControl({ field: field2, value, onChange, disabled, id, autoOpen, onClose, onCancel, addsChoices, initialSearch, asForm, onChosen }) {
10106
- const client = useOptionalRecordsClient11();
10107
- const [options, setOptions] = useState29(null);
10108
- const [refusal, setRefusal] = useState29(null);
10109
- const [reread, setReread] = useState29(0);
10110
- useEffect19(() => {
10130
+ const client = useOptionalRecordsClient12();
10131
+ const [options, setOptions] = useState30(null);
10132
+ const [refusal, setRefusal] = useState30(null);
10133
+ const [reread, setReread] = useState30(0);
10134
+ useEffect20(() => {
10111
10135
  if (!client) return;
10112
10136
  let cancelled = false;
10113
10137
  void (0, askOnce_exports.fieldOptionsOnce)(client, field2.id).then((result) => {
@@ -10271,18 +10295,18 @@ function OpenChoicePicker({
10271
10295
  allowOther = true,
10272
10296
  onChoicesChanged
10273
10297
  }) {
10274
- const client = useOptionalRecordsClient11();
10298
+ const client = useOptionalRecordsClient12();
10275
10299
  const nudge = useChoiceNudge();
10276
- const [open, setOpenState] = useState29(autoOpen === true);
10300
+ const [open, setOpenState] = useState30(autoOpen === true);
10277
10301
  const onCloseRef = useRef16(onClose);
10278
10302
  onCloseRef.current = onClose;
10279
10303
  const setOpen = useCallback6((next) => {
10280
10304
  setOpenState(next);
10281
10305
  if (!next) onCloseRef.current?.();
10282
10306
  }, []);
10283
- const [search, setSearch] = useState29(initialSearch ?? "");
10284
- const [adding, setAdding] = useState29(false);
10285
- const [addRefused, setAddRefused] = useState29(null);
10307
+ const [search, setSearch] = useState30(initialSearch ?? "");
10308
+ const [adding, setAdding] = useState30(false);
10309
+ const [addRefused, setAddRefused] = useState30(null);
10286
10310
  const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
10287
10311
  const held = withoutAddition(value);
10288
10312
  const current = choiceValuesOf(held.value);
@@ -10439,7 +10463,7 @@ function ChoiceAnswer({
10439
10463
  isChosen,
10440
10464
  onChosen
10441
10465
  }) {
10442
- const [search, setSearch] = useState29("");
10466
+ const [search, setSearch] = useState30("");
10443
10467
  const held = field2.multi ? choiceValuesOf(value) : value === null || value === void 0 || value === "" ? [] : [value];
10444
10468
  const on = (choice) => held.some((v) => isChosen ? isChosen(choice, v) : String(v) === choice.key || String(v) === choice.label);
10445
10469
  const press = (choice) => {
@@ -10585,14 +10609,14 @@ function ChoiceListEditor({
10585
10609
  onRehome
10586
10610
  }) {
10587
10611
  const client = useRecordsClient9();
10588
- const [refused, setRefused] = useState30(null);
10589
- const [usage, setUsage] = useState30(null);
10590
- const [asking, setAsking] = useState30(null);
10591
- const [moveTo, setMoveTo] = useState30("");
10612
+ const [refused, setRefused] = useState31(null);
10613
+ const [usage, setUsage] = useState31(null);
10614
+ const [asking, setAsking] = useState31(null);
10615
+ const [moveTo, setMoveTo] = useState31("");
10592
10616
  const focusRow = useRef17(null);
10593
- const [removed, setRemoved] = useState30({});
10617
+ const [removed, setRemoved] = useState31({});
10594
10618
  const fieldId = field2?.id ?? null;
10595
- useEffect20(() => {
10619
+ useEffect21(() => {
10596
10620
  if (rows !== null || !fieldId || !field2) return;
10597
10621
  let live = true;
10598
10622
  void client.fieldOptions({ field_id: fieldId }).then((got) => {
@@ -10609,7 +10633,7 @@ function ChoiceListEditor({
10609
10633
  live = false;
10610
10634
  };
10611
10635
  }, [client, fieldId, rows, onRows, onStart]);
10612
- useEffect20(() => {
10636
+ useEffect21(() => {
10613
10637
  if (!onRehome || !fieldId) return;
10614
10638
  let live = true;
10615
10639
  void client.fieldChoiceUsage({ field_id: fieldId }).then(
@@ -10749,7 +10773,7 @@ function ChoiceListEditor({
10749
10773
  ] });
10750
10774
  }
10751
10775
  function ChoiceSwatch({ words, color, onColor }) {
10752
- const [open, setOpen] = useState30(false);
10776
+ const [open, setOpen] = useState31(false);
10753
10777
  const pick = (next) => {
10754
10778
  onColor(next);
10755
10779
  setOpen(false);
@@ -10855,12 +10879,12 @@ import { useRef as useRef18 } from "react";
10855
10879
  import { RecordsProvider } from "@ai-matrx/records/react";
10856
10880
 
10857
10881
  // src/PersonNamesBridge.tsx
10858
- import { useEffect as useEffect21 } from "react";
10859
- import { useOptionalRecordsClient as useOptionalRecordsClient12 } from "@ai-matrx/records/react";
10882
+ import { useEffect as useEffect22 } from "react";
10883
+ import { useOptionalRecordsClient as useOptionalRecordsClient13 } from "@ai-matrx/records/react";
10860
10884
  function PersonNamesBridge() {
10861
- const client = useOptionalRecordsClient12();
10885
+ const client = useOptionalRecordsClient13();
10862
10886
  const roster = useMemberRoster();
10863
- useEffect21(() => {
10887
+ useEffect22(() => {
10864
10888
  if (!roster) return;
10865
10889
  setPersonResolver(async (id) => {
10866
10890
  const who = await resolveKeptPerson(client, id, roster);
@@ -10915,7 +10939,7 @@ function sameParts(a, b) {
10915
10939
  }
10916
10940
 
10917
10941
  // src/TablePickers.tsx
10918
- import { useEffect as useEffect22, useMemo as useMemo11, useState as useState31 } from "react";
10942
+ import { useEffect as useEffect23, useMemo as useMemo11, useState as useState32 } from "react";
10919
10943
  import { RecordsProvider as RecordsProvider2, useFields as useFields4, useRecords as useRecords3, useTable as useTable3 } from "@ai-matrx/records/react";
10920
10944
  import { Button as Button18, CreatablePicker } from "@ai-matrx/design-system";
10921
10945
  import { Fragment as Fragment16, jsx as jsx43, jsxs as jsxs39 } from "react/jsx-runtime";
@@ -10950,8 +10974,8 @@ function readTablesAnywhere(dataSource) {
10950
10974
  return read;
10951
10975
  }
10952
10976
  function useTablesAnywhere(dataSource) {
10953
- const [state2, setState] = useState31({ loading: true, error: null, rows: [] });
10954
- useEffect22(() => {
10977
+ const [state2, setState] = useState32({ loading: true, error: null, rows: [] });
10978
+ useEffect23(() => {
10955
10979
  let live = true;
10956
10980
  void readTablesAnywhere(dataSource).then((result) => {
10957
10981
  if (live) setState(result);
@@ -11028,7 +11052,7 @@ function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
11028
11052
  const all = useMemo11(() => fields.data ?? [], [fields.data]);
11029
11053
  const byKey = useMemo11(() => new Map(all.map((f) => [f.key, f])), [all]);
11030
11054
  const keys = Object.keys(value);
11031
- const [adding, setAdding] = useState31(false);
11055
+ const [adding, setAdding] = useState32(false);
11032
11056
  const optionsFor = (current) => all.filter((f) => f.key === current || !(f.key in value)).map((f) => ({ value: f.key, label: fieldName(f) }));
11033
11057
  const rename = (from, to) => {
11034
11058
  if (from === to) return;
@@ -11144,7 +11168,7 @@ function RecordPicker({ tableId, value, onChange, disabled }) {
11144
11168
  }
11145
11169
 
11146
11170
  // src/DataBindingPicker.tsx
11147
- import { useEffect as useEffect23, useMemo as useMemo12 } from "react";
11171
+ import { useEffect as useEffect24, useMemo as useMemo12 } from "react";
11148
11172
  import { isEntityReferenceConfig } from "@ai-matrx/records";
11149
11173
  import { useFields as useFields5, useTable as useTable4 } from "@ai-matrx/records/react";
11150
11174
  import { BasicInput as BasicInput12, Button as Button19, CreatablePicker as CreatablePicker2, cn as cn22 } from "@ai-matrx/design-system";
@@ -11240,7 +11264,7 @@ function BindingDetails({
11240
11264
  const fields = useFields5(tableId);
11241
11265
  const fieldList = useMemo12(() => fields.data ?? [], [fields.data]);
11242
11266
  const shape = binding.semantic_type;
11243
- useEffect23(() => {
11267
+ useEffect24(() => {
11244
11268
  if (disabled || shape === "value" || binding.transform || fields.loading || fieldList.length === 0) return;
11245
11269
  onChange({
11246
11270
  ...binding,
@@ -11462,7 +11486,7 @@ function RecordNameWords({ tableId, recordId }) {
11462
11486
  }
11463
11487
 
11464
11488
  // src/HeldChangeDecision.tsx
11465
- import { useEffect as useEffect24, useState as useState32 } from "react";
11489
+ import { useEffect as useEffect25, useState as useState33 } from "react";
11466
11490
  import { RecordsProvider as RecordsProvider3, useRecordsClient as useRecordsClient10 } from "@ai-matrx/records/react";
11467
11491
  import { Button as Button20 } from "@ai-matrx/design-system";
11468
11492
  import { jsx as jsx46, jsxs as jsxs42 } from "react/jsx-runtime";
@@ -11475,10 +11499,10 @@ function Decision({
11475
11499
  approveLabel
11476
11500
  }) {
11477
11501
  const client = useRecordsClient10();
11478
- const [may, setMay] = useState32(null);
11479
- const [busy, setBusy] = useState32(null);
11480
- const [error, setError] = useState32(null);
11481
- useEffect24(() => {
11502
+ const [may, setMay] = useState33(null);
11503
+ const [busy, setBusy] = useState33(null);
11504
+ const [error, setError] = useState33(null);
11505
+ useEffect25(() => {
11482
11506
  let live = true;
11483
11507
  void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
11484
11508
  if (!live) return;
@@ -11684,4 +11708,4 @@ export {
11684
11708
  RecordNameText,
11685
11709
  HeldChangeDecision
11686
11710
  };
11687
- //# sourceMappingURL=chunk-HL7ZIVVJ.js.map
11711
+ //# sourceMappingURL=chunk-NE72B4OK.js.map