@ai-matrx/records-ui 0.116.84 → 0.116.86

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
@@ -1792,6 +1792,15 @@ var init_kindValues = __esm({
1792
1792
  }
1793
1793
  });
1794
1794
 
1795
+ // src/userIds.ts
1796
+ var PERSON_NOT_IN_ORGANIZATION;
1797
+ var init_userIds = __esm({
1798
+ "src/userIds.ts"() {
1799
+ "use strict";
1800
+ PERSON_NOT_IN_ORGANIZATION = "A person no longer in this organization";
1801
+ }
1802
+ });
1803
+
1795
1804
  // src/recordVersions.ts
1796
1805
  var recordVersions_exports = {};
1797
1806
  var init_recordVersions = __esm({
@@ -1801,6 +1810,261 @@ var init_recordVersions = __esm({
1801
1810
  }
1802
1811
  });
1803
1812
 
1813
+ // src/PersonPicker.tsx
1814
+ function personFromRow(row) {
1815
+ const data = row.document ?? {};
1816
+ const userId = data["user_id"];
1817
+ return {
1818
+ id: row.id,
1819
+ userId: typeof userId === "string" && userId !== "" ? userId : null,
1820
+ name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
1821
+ };
1822
+ }
1823
+ function memberName(member) {
1824
+ const display = (member.name ?? "").trim();
1825
+ if (display !== "") return display;
1826
+ const email = (member.email ?? "").trim();
1827
+ if (email !== "") return email;
1828
+ return "A member with no name set";
1829
+ }
1830
+ async function personRecordForMember(client, personTableId, people, member) {
1831
+ const held = people.find((p) => p.userId === member.userId);
1832
+ if (held) return { ok: true, data: held.id };
1833
+ const written = await client.recordWrite({
1834
+ table_id: personTableId,
1835
+ data: {
1836
+ user_id: member.userId,
1837
+ full_name: memberName(member),
1838
+ ...member.email ? { email: member.email } : {}
1839
+ }
1840
+ });
1841
+ return written;
1842
+ }
1843
+ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
1844
+ const client = (0, import_react41.useOptionalRecordsClient)();
1845
+ const host = useRecordsUi();
1846
+ const [members, setMembers] = (0, import_react40.useState)(null);
1847
+ const [people, setPeople] = (0, import_react40.useState)([]);
1848
+ const [error, setError] = (0, import_react40.useState)(null);
1849
+ const [search, setSearch] = (0, import_react40.useState)(initialSearch ?? "");
1850
+ const [open, setOpenState] = (0, import_react40.useState)(autoOpen === true);
1851
+ const onCloseRef = (0, import_react40.useRef)(onClose);
1852
+ onCloseRef.current = onClose;
1853
+ const setOpen = (0, import_react40.useCallback)((next) => {
1854
+ setOpenState(next);
1855
+ if (!next) onCloseRef.current?.();
1856
+ }, []);
1857
+ const [busy, setBusy] = (0, import_react40.useState)(false);
1858
+ const membersPort = host.members;
1859
+ const personTable = field.relation_target;
1860
+ const picked = (0, import_react40.useMemo)(
1861
+ () => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
1862
+ [value]
1863
+ );
1864
+ const load = (0, import_react40.useCallback)(async () => {
1865
+ if (!membersPort || !client) return;
1866
+ const [roster, records] = await Promise.all([
1867
+ membersPort(),
1868
+ personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
1869
+ ]);
1870
+ setMembers(roster);
1871
+ if (records && !records.ok) {
1872
+ setError(records.error);
1873
+ return;
1874
+ }
1875
+ setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
1876
+ }, [membersPort, client, personTable]);
1877
+ (0, import_react40.useEffect)(() => {
1878
+ if (!open) return;
1879
+ void load();
1880
+ }, [open, load]);
1881
+ (0, import_react40.useEffect)(() => {
1882
+ if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
1883
+ let cancelled = false;
1884
+ void client.list({ table_id: personTable, limit: 500 }).then((result) => {
1885
+ if (cancelled || !result.ok) return;
1886
+ setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
1887
+ });
1888
+ return () => {
1889
+ cancelled = true;
1890
+ };
1891
+ }, [client, personTable, picked.length, people.length]);
1892
+ const listed = (0, import_records11.rankTypedMatches)(members ?? [], search, memberName);
1893
+ if (!membersPort || !client) {
1894
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: (0, import_design_system27.cn)("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
1895
+ }
1896
+ if (!personTable) {
1897
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("p", { className: (0, import_design_system27.cn)("text-xs text-muted-foreground", className), children: [
1898
+ fieldName(field),
1899
+ " is a person field, but it does not say which Table the people are records of yet, so there is nothing to pick from. A table admin sets its target in the field editor."
1900
+ ] });
1901
+ }
1902
+ const displayNameOf = (userId, recordName2) => {
1903
+ const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
1904
+ const own3 = (member?.name ?? "").trim();
1905
+ if (own3 !== "") return own3;
1906
+ const kept2 = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
1907
+ const email = (member?.email ?? "").trim();
1908
+ return kept2 !== "" && kept2 !== email ? kept2 : null;
1909
+ };
1910
+ const nameOfRecord = (recordId) => {
1911
+ const person = people.find((p) => p.id === recordId);
1912
+ if (!person) return "Loading\u2026";
1913
+ const member = (members ?? []).find((m) => m.userId === person.userId);
1914
+ return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
1915
+ };
1916
+ const pick = async (member) => {
1917
+ setBusy(true);
1918
+ setError(null);
1919
+ const resolved = await personRecordForMember(client, personTable, people, member);
1920
+ setBusy(false);
1921
+ if (!resolved.ok) {
1922
+ setError(resolved.error);
1923
+ return;
1924
+ }
1925
+ if (!people.some((p) => p.id === resolved.data)) {
1926
+ setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
1927
+ }
1928
+ if (!field.multi) {
1929
+ onChange(picked[0] === resolved.data ? null : resolved.data);
1930
+ setOpen(false);
1931
+ return;
1932
+ }
1933
+ const next = new Set(picked);
1934
+ if (next.has(resolved.data)) next.delete(resolved.data);
1935
+ else next.add(resolved.data);
1936
+ onChange(next.size === 0 ? null : [...next]);
1937
+ };
1938
+ const drop = (recordId) => {
1939
+ const next = picked.filter((id2) => id2 !== recordId);
1940
+ onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
1941
+ };
1942
+ const visible = listed;
1943
+ const pickedUserIds = new Set(
1944
+ picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
1945
+ );
1946
+ const anchored = autoOpen === true;
1947
+ const cellChips = picked.map((recordId) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
1948
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: (0, import_design_system27.cn)("flex flex-wrap items-center gap-1", className), children: [
1949
+ anchored && !disabled ? null : cellChips,
1950
+ disabled ? null : (
1951
+ // THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
1952
+ // its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
1953
+ // head chips as every other picker, and in a grid cell hangs from the cell.
1954
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1955
+ PickOrAdd,
1956
+ {
1957
+ ...anchored && onCancel ? { onEscape: onCancel } : {},
1958
+ anchored,
1959
+ multi: field.multi,
1960
+ triggerId: id,
1961
+ triggerLabel: `Pick a person for ${fieldName(field)}`,
1962
+ triggerText: picked.length === 0 ? "Pick a person" : "Change",
1963
+ open,
1964
+ onOpenChange: setOpen,
1965
+ search,
1966
+ onSearch: setSearch,
1967
+ chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
1968
+ items: visible.map((member) => ({
1969
+ id: member.userId,
1970
+ label: displayNameOf(member.userId) ?? memberName(member),
1971
+ // A name and an email with nothing between them read as one run-on string (verdict,
1972
+ // 19 September). They are two facts, so they are drawn as two.
1973
+ detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
1974
+ picked: pickedUserIds.has(member.userId),
1975
+ person: true,
1976
+ disabled: busy
1977
+ })),
1978
+ onPick: (userId) => {
1979
+ const member = visible.find((m) => m.userId === userId);
1980
+ if (member && !busy) void pick(member);
1981
+ },
1982
+ notice: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
1983
+ error ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(RefusalLine, { error, className: "p-2" }) : null,
1984
+ members === null ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
1985
+ ] }),
1986
+ empty: members !== null ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: members.length === 0 ? "This organization has no other members yet, so there is nobody to assign." : "Nobody in this organization matches." }) : null,
1987
+ children: anchored ? cellChips : null
1988
+ }
1989
+ )
1990
+ )
1991
+ ] });
1992
+ }
1993
+ var import_react40, import_records11, import_react41, import_design_system27, import_jsx_runtime31;
1994
+ var init_PersonPicker = __esm({
1995
+ "src/PersonPicker.tsx"() {
1996
+ "use strict";
1997
+ "use client";
1998
+ import_react40 = require("react");
1999
+ import_records11 = require("@ai-matrx/records");
2000
+ import_react41 = require("@ai-matrx/records/react");
2001
+ import_design_system27 = require("@ai-matrx/design-system");
2002
+ init_PickOrAdd();
2003
+ init_personChip();
2004
+ init_host();
2005
+ init_host();
2006
+ init_names();
2007
+ init_Refusal();
2008
+ import_jsx_runtime31 = require("react/jsx-runtime");
2009
+ }
2010
+ });
2011
+
2012
+ // src/memberNames.ts
2013
+ function memberWords(member) {
2014
+ const name = member?.name?.trim();
2015
+ if (name) return name;
2016
+ const email = member?.email?.trim();
2017
+ return email ? email : null;
2018
+ }
2019
+ function useMemberRoster() {
2020
+ const host = useRecordsUi();
2021
+ const members = host.members;
2022
+ const [roster, setRoster] = (0, import_react42.useState)(null);
2023
+ (0, import_react42.useEffect)(() => {
2024
+ if (!members) {
2025
+ setRoster(/* @__PURE__ */ new Map());
2026
+ return;
2027
+ }
2028
+ let cancelled = false;
2029
+ void members().then((list) => !cancelled && setRoster(new Map(list.map((m) => [m.userId.toLowerCase(), m])))).catch(() => !cancelled && setRoster(/* @__PURE__ */ new Map()));
2030
+ return () => {
2031
+ cancelled = true;
2032
+ };
2033
+ }, [members]);
2034
+ return roster;
2035
+ }
2036
+ async function resolveKeptPerson(client, id, roster) {
2037
+ if (client) {
2038
+ try {
2039
+ const read = await client.recordRead({ record_id: id });
2040
+ if (read.ok) {
2041
+ const person = personFromRow({ id, document: read.data.document });
2042
+ const member = person.userId ? roster.get(person.userId.toLowerCase()) : void 0;
2043
+ const named = memberWords(member) ?? (person.name !== "" ? person.name : null);
2044
+ const doc = read.data.document ?? {};
2045
+ const email = (typeof doc["email"] === "string" && doc["email"].trim() !== "" ? doc["email"].trim() : null) ?? member?.email?.trim() ?? null;
2046
+ if (person.userId || named) return { id, recordId: id, name: named ?? PERSON_NOT_IN_ORGANIZATION, userId: person.userId, email };
2047
+ }
2048
+ } catch {
2049
+ }
2050
+ }
2051
+ const direct = roster.get(id.toLowerCase());
2052
+ return { id, recordId: null, name: memberWords(direct) ?? PERSON_NOT_IN_ORGANIZATION, userId: direct ? id : null, email: direct?.email?.trim() || null };
2053
+ }
2054
+ var import_react42, import_react43, import_uuid3;
2055
+ var init_memberNames = __esm({
2056
+ "src/memberNames.ts"() {
2057
+ "use strict";
2058
+ "use client";
2059
+ import_react42 = require("react");
2060
+ import_react43 = require("@ai-matrx/records/react");
2061
+ init_host();
2062
+ init_PersonPicker();
2063
+ import_uuid3 = require("@ai-matrx/kit/uuid");
2064
+ init_userIds();
2065
+ }
2066
+ });
2067
+
1804
2068
  // src/tableShape.ts
1805
2069
  function cellWords(raw) {
1806
2070
  return (0, import_source2.mapInlineCodeSpans)(raw, (_range, span) => (0, import_source2.codeSpanText)(span)).replace(/<br\s*\/?>/gi, "\n").replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]+)\]\(([^)]*)\)/g, "$1").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/__([^_]+)__/g, "$1").replace(/(^|[^\w*])\*([^*\n]+)\*(?=[^\w*]|$)/g, "$1$2").replace(/(^|[^\w_])_([^_\n]+)_(?=[^\w_]|$)/g, "$1$2").replace(/~~([^~]+)~~/g, "$1").replace(/\\\|/g, "|").trim();
@@ -8957,9 +9221,7 @@ function formulaSourceArchived(field, document2) {
8957
9221
  // src/values.tsx
8958
9222
  var import_records17 = require("@ai-matrx/records");
8959
9223
  var import_uuid4 = require("@ai-matrx/kit/uuid");
8960
-
8961
- // src/userIds.ts
8962
- var PERSON_NOT_IN_ORGANIZATION = "A person no longer in this organization";
9224
+ init_userIds();
8963
9225
 
8964
9226
  // src/personNames.ts
8965
9227
  var import_react39 = require("react");
@@ -8998,247 +9260,6 @@ function knownPerson(id) {
8998
9260
  return null;
8999
9261
  }
9000
9262
 
9001
- // src/memberNames.ts
9002
- var import_react42 = require("react");
9003
- var import_react43 = require("@ai-matrx/records/react");
9004
- init_host();
9005
-
9006
- // src/PersonPicker.tsx
9007
- var import_react40 = require("react");
9008
- var import_records11 = require("@ai-matrx/records");
9009
- var import_react41 = require("@ai-matrx/records/react");
9010
- var import_design_system27 = require("@ai-matrx/design-system");
9011
- init_PickOrAdd();
9012
- init_personChip();
9013
- init_host();
9014
- init_host();
9015
- init_names();
9016
- init_Refusal();
9017
- var import_jsx_runtime31 = require("react/jsx-runtime");
9018
- function personFromRow(row) {
9019
- const data = row.document ?? {};
9020
- const userId = data["user_id"];
9021
- return {
9022
- id: row.id,
9023
- userId: typeof userId === "string" && userId !== "" ? userId : null,
9024
- name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
9025
- };
9026
- }
9027
- function memberName(member) {
9028
- const display = (member.name ?? "").trim();
9029
- if (display !== "") return display;
9030
- const email = (member.email ?? "").trim();
9031
- if (email !== "") return email;
9032
- return "A member with no name set";
9033
- }
9034
- async function personRecordForMember(client, personTableId, people, member) {
9035
- const held = people.find((p) => p.userId === member.userId);
9036
- if (held) return { ok: true, data: held.id };
9037
- const written = await client.recordWrite({
9038
- table_id: personTableId,
9039
- data: {
9040
- user_id: member.userId,
9041
- full_name: memberName(member),
9042
- ...member.email ? { email: member.email } : {}
9043
- }
9044
- });
9045
- return written;
9046
- }
9047
- function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
9048
- const client = (0, import_react41.useOptionalRecordsClient)();
9049
- const host = useRecordsUi();
9050
- const [members, setMembers] = (0, import_react40.useState)(null);
9051
- const [people, setPeople] = (0, import_react40.useState)([]);
9052
- const [error, setError] = (0, import_react40.useState)(null);
9053
- const [search, setSearch] = (0, import_react40.useState)(initialSearch ?? "");
9054
- const [open, setOpenState] = (0, import_react40.useState)(autoOpen === true);
9055
- const onCloseRef = (0, import_react40.useRef)(onClose);
9056
- onCloseRef.current = onClose;
9057
- const setOpen = (0, import_react40.useCallback)((next) => {
9058
- setOpenState(next);
9059
- if (!next) onCloseRef.current?.();
9060
- }, []);
9061
- const [busy, setBusy] = (0, import_react40.useState)(false);
9062
- const membersPort = host.members;
9063
- const personTable = field.relation_target;
9064
- const picked = (0, import_react40.useMemo)(
9065
- () => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
9066
- [value]
9067
- );
9068
- const load = (0, import_react40.useCallback)(async () => {
9069
- if (!membersPort || !client) return;
9070
- const [roster, records] = await Promise.all([
9071
- membersPort(),
9072
- personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
9073
- ]);
9074
- setMembers(roster);
9075
- if (records && !records.ok) {
9076
- setError(records.error);
9077
- return;
9078
- }
9079
- setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
9080
- }, [membersPort, client, personTable]);
9081
- (0, import_react40.useEffect)(() => {
9082
- if (!open) return;
9083
- void load();
9084
- }, [open, load]);
9085
- (0, import_react40.useEffect)(() => {
9086
- if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
9087
- let cancelled = false;
9088
- void client.list({ table_id: personTable, limit: 500 }).then((result) => {
9089
- if (cancelled || !result.ok) return;
9090
- setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
9091
- });
9092
- return () => {
9093
- cancelled = true;
9094
- };
9095
- }, [client, personTable, picked.length, people.length]);
9096
- const listed = (0, import_records11.rankTypedMatches)(members ?? [], search, memberName);
9097
- if (!membersPort || !client) {
9098
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: (0, import_design_system27.cn)("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
9099
- }
9100
- if (!personTable) {
9101
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("p", { className: (0, import_design_system27.cn)("text-xs text-muted-foreground", className), children: [
9102
- fieldName(field),
9103
- " is a person field, but it does not say which Table the people are records of yet, so there is nothing to pick from. A table admin sets its target in the field editor."
9104
- ] });
9105
- }
9106
- const displayNameOf = (userId, recordName2) => {
9107
- const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
9108
- const own3 = (member?.name ?? "").trim();
9109
- if (own3 !== "") return own3;
9110
- const kept2 = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
9111
- const email = (member?.email ?? "").trim();
9112
- return kept2 !== "" && kept2 !== email ? kept2 : null;
9113
- };
9114
- const nameOfRecord = (recordId) => {
9115
- const person = people.find((p) => p.id === recordId);
9116
- if (!person) return "Loading\u2026";
9117
- const member = (members ?? []).find((m) => m.userId === person.userId);
9118
- return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
9119
- };
9120
- const pick = async (member) => {
9121
- setBusy(true);
9122
- setError(null);
9123
- const resolved = await personRecordForMember(client, personTable, people, member);
9124
- setBusy(false);
9125
- if (!resolved.ok) {
9126
- setError(resolved.error);
9127
- return;
9128
- }
9129
- if (!people.some((p) => p.id === resolved.data)) {
9130
- setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
9131
- }
9132
- if (!field.multi) {
9133
- onChange(picked[0] === resolved.data ? null : resolved.data);
9134
- setOpen(false);
9135
- return;
9136
- }
9137
- const next = new Set(picked);
9138
- if (next.has(resolved.data)) next.delete(resolved.data);
9139
- else next.add(resolved.data);
9140
- onChange(next.size === 0 ? null : [...next]);
9141
- };
9142
- const drop = (recordId) => {
9143
- const next = picked.filter((id2) => id2 !== recordId);
9144
- onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
9145
- };
9146
- const visible = listed;
9147
- const pickedUserIds = new Set(
9148
- picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
9149
- );
9150
- const anchored = autoOpen === true;
9151
- const cellChips = picked.map((recordId) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
9152
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: (0, import_design_system27.cn)("flex flex-wrap items-center gap-1", className), children: [
9153
- anchored && !disabled ? null : cellChips,
9154
- disabled ? null : (
9155
- // THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
9156
- // its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
9157
- // head chips as every other picker, and in a grid cell hangs from the cell.
9158
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
9159
- PickOrAdd,
9160
- {
9161
- ...anchored && onCancel ? { onEscape: onCancel } : {},
9162
- anchored,
9163
- multi: field.multi,
9164
- triggerId: id,
9165
- triggerLabel: `Pick a person for ${fieldName(field)}`,
9166
- triggerText: picked.length === 0 ? "Pick a person" : "Change",
9167
- open,
9168
- onOpenChange: setOpen,
9169
- search,
9170
- onSearch: setSearch,
9171
- chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
9172
- items: visible.map((member) => ({
9173
- id: member.userId,
9174
- label: displayNameOf(member.userId) ?? memberName(member),
9175
- // A name and an email with nothing between them read as one run-on string (verdict,
9176
- // 19 September). They are two facts, so they are drawn as two.
9177
- detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
9178
- picked: pickedUserIds.has(member.userId),
9179
- person: true,
9180
- disabled: busy
9181
- })),
9182
- onPick: (userId) => {
9183
- const member = visible.find((m) => m.userId === userId);
9184
- if (member && !busy) void pick(member);
9185
- },
9186
- notice: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
9187
- error ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(RefusalLine, { error, className: "p-2" }) : null,
9188
- members === null ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
9189
- ] }),
9190
- empty: members !== null ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: members.length === 0 ? "This organization has no other members yet, so there is nobody to assign." : "Nobody in this organization matches." }) : null,
9191
- children: anchored ? cellChips : null
9192
- }
9193
- )
9194
- )
9195
- ] });
9196
- }
9197
-
9198
- // src/memberNames.ts
9199
- var import_uuid3 = require("@ai-matrx/kit/uuid");
9200
- function memberWords(member) {
9201
- const name = member?.name?.trim();
9202
- if (name) return name;
9203
- const email = member?.email?.trim();
9204
- return email ? email : null;
9205
- }
9206
- function useMemberRoster() {
9207
- const host = useRecordsUi();
9208
- const members = host.members;
9209
- const [roster, setRoster] = (0, import_react42.useState)(null);
9210
- (0, import_react42.useEffect)(() => {
9211
- if (!members) {
9212
- setRoster(/* @__PURE__ */ new Map());
9213
- return;
9214
- }
9215
- let cancelled = false;
9216
- void members().then((list) => !cancelled && setRoster(new Map(list.map((m) => [m.userId.toLowerCase(), m])))).catch(() => !cancelled && setRoster(/* @__PURE__ */ new Map()));
9217
- return () => {
9218
- cancelled = true;
9219
- };
9220
- }, [members]);
9221
- return roster;
9222
- }
9223
- async function resolveKeptPerson(client, id, roster) {
9224
- if (client) {
9225
- try {
9226
- const read = await client.recordRead({ record_id: id });
9227
- if (read.ok) {
9228
- const person = personFromRow({ id, document: read.data.document });
9229
- const member = person.userId ? roster.get(person.userId.toLowerCase()) : void 0;
9230
- const named = memberWords(member) ?? (person.name !== "" ? person.name : null);
9231
- const doc = read.data.document ?? {};
9232
- const email = (typeof doc["email"] === "string" && doc["email"].trim() !== "" ? doc["email"].trim() : null) ?? member?.email?.trim() ?? null;
9233
- if (person.userId || named) return { id, recordId: id, name: named ?? PERSON_NOT_IN_ORGANIZATION, userId: person.userId, email };
9234
- }
9235
- } catch {
9236
- }
9237
- }
9238
- const direct = roster.get(id.toLowerCase());
9239
- return { id, recordId: null, name: memberWords(direct) ?? PERSON_NOT_IN_ORGANIZATION, userId: direct ? id : null, email: direct?.email?.trim() || null };
9240
- }
9241
-
9242
9263
  // src/values.tsx
9243
9264
  var import_outbound_react6 = require("@ai-matrx/kit/outbound-react");
9244
9265
 
@@ -10163,6 +10184,8 @@ function conditionInWords(expr, fields) {
10163
10184
  has_none: "has none of",
10164
10185
  is_exactly: "is exactly"
10165
10186
  };
10187
+ const flat = flatFilterInWords(expr, fields);
10188
+ if (flat !== null) return flat;
10166
10189
  const walk = (node) => {
10167
10190
  if (node === null || node === void 0) return "nothing";
10168
10191
  const n = node;
@@ -10200,9 +10223,66 @@ function conditionInWords(expr, fields) {
10200
10223
  if (op === "and" || op === "or") return args.map(walk).join(` ${word} `);
10201
10224
  if (args.length === 2) return `${walk(args[0])} ${word} ${walk(args[1])}`;
10202
10225
  if (args.length === 1) return `${walk(args[0])} ${word}`;
10203
- return op;
10226
+ return op || UNREADABLE_CONDITION;
10227
+ };
10228
+ return walk(expr) || UNREADABLE_CONDITION;
10229
+ }
10230
+ var UNREADABLE_CONDITION = "a condition this screen cannot read";
10231
+ var RULE_NODE_KEYS = ["op", "const", "field", "args"];
10232
+ function flatFilterInWords(expr, fields) {
10233
+ if (expr === null || expr === void 0 || typeof expr !== "object" || Array.isArray(expr)) return null;
10234
+ const map = expr;
10235
+ if (RULE_NODE_KEYS.some((k) => k in map)) return null;
10236
+ const keys = Object.keys(map);
10237
+ if (keys.length === 0) return "every record";
10238
+ const name = (key) => {
10239
+ const f = fields.find((x) => x.key === key || x.id === key);
10240
+ if (f) return f.label || f.key;
10241
+ const words = key.replace(/[._]+/g, " ").trim();
10242
+ return words ? words.charAt(0).toUpperCase() + words.slice(1) : "a column";
10243
+ };
10244
+ const one = (v) => v === null || v === void 0 ? "nothing" : typeof v === "string" ? JSON.stringify(v) : String(v);
10245
+ const list = (v, joiner) => (Array.isArray(v) ? v : [v]).map(one).join(` ${joiner} `);
10246
+ const listSaid = {
10247
+ contains: ["contains", "or"],
10248
+ not_contains: ["does not contain", "or"],
10249
+ has_any: ["has any of", "or"],
10250
+ has_all: ["has all of", "and"],
10251
+ has_none: ["has none of", "or"],
10252
+ is_exactly: ["is exactly", "and"]
10253
+ };
10254
+ const clause = (key, v) => {
10255
+ const who = name(key);
10256
+ if (v === null) return `${who} is empty`;
10257
+ if (Array.isArray(v)) return v.length === 0 ? `${who} is empty` : `${who} is ${list(v, "or")}`;
10258
+ if (typeof v !== "object") return `${who} is ${one(v)}`;
10259
+ const o = v;
10260
+ const parts = [];
10261
+ for (const [word, arg] of Object.entries(o)) {
10262
+ if (word === "link") continue;
10263
+ if (word === "not" || word === "is_not") {
10264
+ parts.push(Array.isArray(arg) ? `is none of ${list(arg, "or")}` : `is not ${one(arg)}`);
10265
+ } else if (word === "from" || word === "to") {
10266
+ if (word === "to" && "from" in o) continue;
10267
+ parts.push(
10268
+ word === "from" && "to" in o ? `is from ${one(arg)} to ${one(o["to"])}` : word === "from" ? `is from ${one(arg)} on` : `is up to ${one(arg)}`
10269
+ );
10270
+ } else if (word === "relative") {
10271
+ parts.push(`is ${String(arg).replace(/_/g, " ")}`);
10272
+ } else if (word === "is_empty" || word === "is_not_empty") {
10273
+ const empty = word === "is_empty" === (arg !== false);
10274
+ parts.push(empty ? "is empty" : "is not empty");
10275
+ } else if (listSaid[word]) {
10276
+ const [said2, joiner] = listSaid[word];
10277
+ parts.push(`${said2} ${list(arg, joiner)}`);
10278
+ } else {
10279
+ parts.push(`${word.replace(/_/g, " ")} ${one(typeof arg === "object" ? JSON.stringify(arg) : arg)}`);
10280
+ }
10281
+ }
10282
+ const link = o["link"] === "every" ? "every linked " : o["link"] === "none" ? "no linked " : "";
10283
+ return `${link}${who} ${parts.length > 0 ? parts.join(" and ") : "is set"}`;
10204
10284
  };
10205
- return walk(expr);
10285
+ return keys.map((k) => clause(k, map[k])).join(" and ");
10206
10286
  }
10207
10287
  function conditionValue(typed) {
10208
10288
  const trimmed = typed.trim();
@@ -10557,11 +10637,13 @@ init_names();
10557
10637
  init_Refusal();
10558
10638
  init_host();
10559
10639
  init_plainWords();
10640
+ init_memberNames();
10560
10641
 
10561
10642
  // src/personRetype.ts
10562
10643
  init_recordVersions();
10563
10644
  init_plainWords();
10564
10645
  var import_uuid5 = require("@ai-matrx/kit/uuid");
10646
+ init_memberNames();
10565
10647
  var PAGE = 500;
10566
10648
  var CEILING = 2e4;
10567
10649
  function idsIn(value) {
@@ -13706,6 +13788,7 @@ function ButtonValue({ field, recordId, inCell, beforeSave }) {
13706
13788
  // src/editors.tsx
13707
13789
  init_host();
13708
13790
  init_PickOrAdd();
13791
+ init_PersonPicker();
13709
13792
  init_Refusal();
13710
13793
 
13711
13794
  // src/FloatingRefusal.tsx