@ai-matrx/records-ui 0.116.47 → 0.116.48

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.js CHANGED
@@ -15090,7 +15090,8 @@ import { useCallback as useCallback23, useEffect as useEffect38, useState as use
15090
15090
  import {
15091
15091
  isShownTo,
15092
15092
  levelHasShownTo,
15093
- SHOWN_TO_LABEL
15093
+ SHOWN_TO_LABEL,
15094
+ SHOWN_TO_WHO_MAY_CHANGE
15094
15095
  } from "@ai-matrx/records";
15095
15096
  import { useRecordsClient as useRecordsClient38, useTable as useTable10 } from "@ai-matrx/records/react";
15096
15097
  import {
@@ -15114,7 +15115,7 @@ var ROW_CONTROL_WORDS = {
15114
15115
  applying: "Applying\u2026",
15115
15116
  whoMayChangeTable: "Only the table's maker or an admin can change these.",
15116
15117
  shownTo: "Shown to",
15117
- whoMayChangeRow: "Only who added this row, or an admin, can change this."
15118
+ whoMayChangeRow: SHOWN_TO_WHO_MAY_CHANGE
15118
15119
  };
15119
15120
  function appliedLine(done) {
15120
15121
  const rows = `${done.changed} ${done.changed === 1 ? "row" : "rows"} changed`;
@@ -26643,7 +26644,7 @@ function Board({
26643
26644
  ...addCard ? { onNew: () => void addCard() } : {},
26644
26645
  ...newRowLabel ? { newLabel: newRowLabel } : {},
26645
26646
  tableId: view.subject,
26646
- titleKey,
26647
+ titleKey: titleField?.key ?? titleKey,
26647
26648
  onChanged: () => {
26648
26649
  records.reload();
26649
26650
  onMoved?.();
@@ -36286,6 +36287,24 @@ function doorField(f) {
36286
36287
  config: f.system ? { system: f.system } : {}
36287
36288
  };
36288
36289
  }
36290
+ function choiceKey(value) {
36291
+ return value.replace(/[^A-Za-z0-9]+/g, "").toLowerCase();
36292
+ }
36293
+ function withChoiceWords(document2, labels) {
36294
+ if (!labels) return document2;
36295
+ let out = null;
36296
+ for (const [key, words2] of Object.entries(labels)) {
36297
+ const value = document2[key];
36298
+ const word = (v) => typeof v === "string" ? words2[choiceKey(v)] ?? v : v;
36299
+ const next = Array.isArray(value) ? value.map(word) : word(value);
36300
+ const changed2 = Array.isArray(next) ? next.some((n, i) => n !== value[i]) : next !== value;
36301
+ if (changed2) {
36302
+ out ??= { ...document2 };
36303
+ out[key] = next;
36304
+ }
36305
+ }
36306
+ return out ?? document2;
36307
+ }
36289
36308
  function useDoorRows(door, elementId, recordId) {
36290
36309
  const client = useRecordsClient82();
36291
36310
  const [state, setState] = useState103({
@@ -36309,7 +36328,7 @@ function useDoorRows(door, elementId, recordId) {
36309
36328
  }, [client, door, elementId, recordId, tick]);
36310
36329
  return useMemo64(
36311
36330
  () => ({
36312
- rows: (state.data?.rows ?? []).map((r) => ({ id: r.id, document: r.document })),
36331
+ rows: (state.data?.rows ?? []).map((r) => ({ id: r.id, document: withChoiceWords(r.document, state.data?.labels) })),
36313
36332
  fields: (state.data?.fields ?? []).map(doorField),
36314
36333
  total: state.data ? state.data.count : null,
36315
36334
  loading: state.loading,
@@ -36518,8 +36537,8 @@ function BlockBody(inner) {
36518
36537
  case "applet":
36519
36538
  return /* @__PURE__ */ jsx114(AppletBlockView, { block });
36520
36539
  case "chart": {
36540
+ if (props.through) return /* @__PURE__ */ jsx114(ChartThroughNote, { title: block.title ?? props.chart?.title ?? null });
36521
36541
  if (!props.chart) return null;
36522
- if (props.through) return null;
36523
36542
  const index = props.run?.blocks.findIndex((b) => b.id === props.chart?.id) ?? -1;
36524
36543
  const result = index >= 0 ? props.run.blocks[index] : null;
36525
36544
  return result ? /* @__PURE__ */ jsx114(ChartBlock, { block: result, subject: props.subject }) : /* @__PURE__ */ jsx114(RecordsSkeleton, { layout: "chart" });
@@ -36764,8 +36783,30 @@ function ReviewBlockView({ block, viewerUserId, extra }) {
36764
36783
  function NumberBlockView({ block, viewerUserId, extra }) {
36765
36784
  const read = useElementRows(block, viewerUserId, extra, false);
36766
36785
  if (read.error) return /* @__PURE__ */ jsx114(RefusalLine, { error: read.error });
36767
- if (read.waiting || read.total === null) return /* @__PURE__ */ jsx114(Skeleton36, { className: "h-12 w-24" });
36768
- return /* @__PURE__ */ jsx114("p", { className: "text-3xl font-semibold tabular-nums", "data-records-page-number": block.id, children: formatCount6(read.total) });
36786
+ const title = block.title ? /* @__PURE__ */ jsx114("p", { className: "truncate text-xs text-muted-foreground", "data-records-page-number-title": block.id, children: block.title }) : null;
36787
+ if (read.waiting || read.total === null) {
36788
+ return /* @__PURE__ */ jsxs107(Fragment50, { children: [
36789
+ title,
36790
+ /* @__PURE__ */ jsx114(Skeleton36, { className: "h-12 w-24" })
36791
+ ] });
36792
+ }
36793
+ return /* @__PURE__ */ jsxs107(Fragment50, { children: [
36794
+ title,
36795
+ /* @__PURE__ */ jsx114("p", { className: "text-3xl font-semibold tabular-nums", "data-records-page-number": block.id, children: formatCount6(read.total) })
36796
+ ] });
36797
+ }
36798
+ function ChartThroughNote({ title }) {
36799
+ return /* @__PURE__ */ jsxs107("div", { className: "flex flex-col gap-2", "data-records-page-chart-note": "through", children: [
36800
+ title ? /* @__PURE__ */ jsx114("p", { className: "truncate text-xs text-muted-foreground", children: title }) : null,
36801
+ /* @__PURE__ */ jsx114(
36802
+ "p",
36803
+ {
36804
+ className: "flex items-center justify-center rounded-md border border-dashed p-3 text-center text-xs text-muted-foreground",
36805
+ style: { height: CHART_PLOT_PX },
36806
+ children: "Charts draw for members of this organization."
36807
+ }
36808
+ )
36809
+ ] });
36769
36810
  }
36770
36811
  function LayoutBlockView({ block, viewerUserId, extra }) {
36771
36812
  const door = useInterfaceDoor();