@ai-matrx/records-ui 0.116.60 → 0.116.62

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/index.cjs CHANGED
@@ -14776,6 +14776,15 @@ function WithWords(props) {
14776
14776
  {
14777
14777
  field: props.field,
14778
14778
  refs: withKnown,
14779
+ autoOpen: props.autoOpen,
14780
+ onClose: props.onClose,
14781
+ onCancel: props.onCancel,
14782
+ initialSearch: props.initialSearch,
14783
+ onTakeOff: (ref) => {
14784
+ const rest = withKnown.filter((x) => !(x.token === ref.token && x.id === ref.id));
14785
+ props.onChange((0, import_records13.entityRefsToWrite)(rest, Boolean(props.field.multi)));
14786
+ },
14787
+ labelOf: (r) => r.label ?? words2?.data?.find((w) => w.token === r.token && w.id === r.id)?.label ?? WITHHELD_ENTITY_LABEL,
14779
14788
  onPick: (picked) => {
14780
14789
  setKnown((k) => [...k.filter((x) => !(x.token === picked.token && x.id === picked.id)), picked]);
14781
14790
  const multi = Boolean(props.field.multi);
@@ -14784,18 +14793,32 @@ function WithWords(props) {
14784
14793
  }
14785
14794
  }
14786
14795
  );
14796
+ if (props.autoOpen && !props.disabled) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { id: props.id, className: (0, import_design_system24.cn)("flex min-w-0 max-w-full flex-wrap items-center gap-1", props.className), children: picker });
14787
14797
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Chips, { ...props, value: withKnown, words: words2, picker });
14788
14798
  }
14789
14799
  function EntityReferencePicker({
14790
14800
  field: field2,
14791
14801
  refs,
14792
- onPick
14802
+ onPick,
14803
+ autoOpen,
14804
+ onClose,
14805
+ onCancel,
14806
+ initialSearch,
14807
+ onTakeOff,
14808
+ labelOf
14793
14809
  }) {
14794
14810
  const allowed = allowedKindsOf(field2);
14795
14811
  const kinds = (0, import_react46.useEntityReferenceKinds)();
14796
14812
  const labelOfKind = (token2) => kinds.data?.find((k) => k.token === token2)?.label ?? token2.replace(/_/g, " ");
14797
- const [open, setOpen] = (0, import_react45.useState)(false);
14798
- const [search, setSearch] = (0, import_react45.useState)("");
14813
+ const [open, setOpenState] = (0, import_react45.useState)(autoOpen === true);
14814
+ const onCloseRef = (0, import_react45.useRef)(onClose);
14815
+ onCloseRef.current = onClose;
14816
+ const setOpen = (0, import_react45.useCallback)((next) => {
14817
+ setOpenState(next);
14818
+ if (!next) onCloseRef.current?.();
14819
+ }, []);
14820
+ const anchored = autoOpen === true;
14821
+ const [search, setSearch] = (0, import_react45.useState)(initialSearch ?? "");
14799
14822
  const [only, setOnly] = (0, import_react45.useState)(null);
14800
14823
  const tokens = only ? [only] : allowed;
14801
14824
  const found = (0, import_react46.useEntityReferenceSearch)(tokens, search, open);
@@ -14838,6 +14861,10 @@ function EntityReferencePicker({
14838
14861
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
14839
14862
  PickOrAdd,
14840
14863
  {
14864
+ anchored,
14865
+ ...anchored && onCancel ? { onEscape: onCancel } : {},
14866
+ multi,
14867
+ ...anchored ? { chips: refs.map((r) => ({ id: `${r.token}:${r.id}`, label: labelOf(r), onRemove: () => onTakeOff(r) })) } : {},
14841
14868
  triggerLabel: `Pick for ${field2.label}`,
14842
14869
  triggerText: refs.length > 0 && !multi ? "Change" : "Pick",
14843
14870
  open,
@@ -17528,6 +17555,7 @@ var import_records28 = require("@ai-matrx/records");
17528
17555
  var import_react83 = require("@ai-matrx/records/react");
17529
17556
  init_Refusal();
17530
17557
  init_names();
17558
+ init_plainWords();
17531
17559
  init_refusals();
17532
17560
  var import_jsx_runtime56 = require("react/jsx-runtime");
17533
17561
  var PREVIEW_GROUPS = 1e3;
@@ -17561,7 +17589,14 @@ function FieldRulePreview({ field: field2, tableId, rules }) {
17561
17589
  void client.recordAggregate({ table_id: tableId, groupBy: [field2.key], measures: [{ op: "count" }], limit: PREVIEW_GROUPS }).then((answer) => {
17562
17590
  if (cancelled) return;
17563
17591
  if (!answer.ok) {
17564
- setRefusal(answer.error);
17592
+ setRefusal(
17593
+ answer.error.code === "unreachable" ? (0, refusals_exports.refusal)(
17594
+ "unreachable",
17595
+ `${name}'s values could not be counted.`,
17596
+ "The check still applies when you save.",
17597
+ refusalForAPerson(answer.error).forEngineers
17598
+ ) : answer.error
17599
+ );
17565
17600
  return;
17566
17601
  }
17567
17602
  const numbers = holdsNumbers3(field2);
@@ -20764,7 +20799,7 @@ function FieldControl({ field: field2, value, onChange, disabled, id, autoOpen,
20764
20799
  case "member":
20765
20800
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(PersonPicker, { field: field2, value, onChange, disabled, id: inputId, autoOpen, onClose, onCancel, initialSearch });
20766
20801
  case "entity_reference":
20767
- return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(EntityReferenceControl, { field: field2, value, onChange, disabled, id: inputId });
20802
+ return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(EntityReferenceControl, { field: field2, value, onChange, disabled, id: inputId, autoOpen, onClose, onCancel, initialSearch });
20768
20803
  case "attachment":
20769
20804
  if (hostTakesFiles(host)) {
20770
20805
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(AttachmentControl, { field: field2, value, onChange, disabled, id: inputId, autoOpen, onClose });
@@ -22719,6 +22754,7 @@ function opensAsAList(field2, takesFiles = false) {
22719
22754
  const kind2 = editorKindFor(field2);
22720
22755
  if (kind2 === "member") return true;
22721
22756
  if (kind2 === "relation") return true;
22757
+ if (kind2 === "entity_reference") return true;
22722
22758
  if (kind2 === "attachment") return takesFiles;
22723
22759
  if (kind2 === "select" || kind2 === "multi_select") return CHOICE_EDITOR_ADDS_WHAT_IS_TYPED;
22724
22760
  return false;
@@ -33343,6 +33379,7 @@ function GridBody({
33343
33379
  );
33344
33380
  const merged = host.grid === "merged";
33345
33381
  const phone = (0, import_design_system94.useIsMobile)();
33382
+ const macLook = (0, import_data_table14.useMatrxDataTableHost)().defaultLook === "mac";
33346
33383
  const toolbarFold2 = useTableToolbarFold();
33347
33384
  const sheetExtras = useTableToolbarSheetExtras();
33348
33385
  const rights = useTableRights(table.data);
@@ -35375,7 +35412,7 @@ function GridBody({
35375
35412
  tableClassName: (0, import_design_system94.cn)(
35376
35413
  !look.wrap && lines === 1 && "[&_tbody_td]:max-w-[28rem] [&_tbody_td]:overflow-hidden [&_tbody_td]:text-ellipsis [&_tbody_td]:whitespace-nowrap! [&_tbody_td_*:not(textarea)]:whitespace-nowrap!",
35377
35414
  // (A textarea is only ever an OPEN long-text editor, whose words must wrap — records walk D10.)
35378
- embedded && EMBEDDED_TABLE_CLASS,
35415
+ embedded && !macLook && EMBEDDED_TABLE_CLASS,
35379
35416
  embedded && !calculationChosen && EMBEDDED_PLAIN_FOOTER_CLASS
35380
35417
  ),
35381
35418
  footerRows,