@ai-matrx/records-ui 0.101.14 → 0.101.15
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +27 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +27 -15
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog — @ai-matrx/records-ui
|
|
2
2
|
|
|
3
|
+
## 0.101.15
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/records-ui/v0.101.14..npm/records-ui/v0.101.15 -- apps/shared/records-ui`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
3
9
|
## 0.101.14
|
|
4
10
|
|
|
5
11
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
package/dist/index.cjs
CHANGED
|
@@ -7696,6 +7696,7 @@ function containsPattern(text) {
|
|
|
7696
7696
|
var BLANK_VALUE = "__empty__";
|
|
7697
7697
|
var field = (f) => ({ field: f.id });
|
|
7698
7698
|
var constant = (value) => ({ const: value });
|
|
7699
|
+
var withinWindow = (f, window2) => ({ op: "within", args: [field(f), constant(window2)] });
|
|
7699
7700
|
var op = (name, ...args) => ({ op: name, args });
|
|
7700
7701
|
function clauseFor(f, value, now = /* @__PURE__ */ new Date()) {
|
|
7701
7702
|
const name = fieldName(f);
|
|
@@ -7725,12 +7726,12 @@ function clauseFor(f, value, now = /* @__PURE__ */ new Date()) {
|
|
|
7725
7726
|
const kind = String(editorKindFor(f));
|
|
7726
7727
|
if (kind === "datetime" || kind === "date") {
|
|
7727
7728
|
if (words2.length === 0) return { rule: value.negated ? present : not(present) };
|
|
7728
|
-
if (words2.length > 1 || blank || value.negated) {
|
|
7729
|
-
return `${name} is asked one ticked day at a time. Use the date range for more.`;
|
|
7730
|
-
}
|
|
7731
|
-
const day = words2[0];
|
|
7732
7729
|
const holdsDays = String((f.config ?? {})["kind"] ?? "") === "date";
|
|
7733
|
-
return { flat: { [f.key]: dayWindow(
|
|
7730
|
+
if (words2.length === 1 && !blank && !value.negated) return { flat: { [f.key]: dayWindow(words2[0], holdsDays) } };
|
|
7731
|
+
const leaves = words2.map((day) => withinWindow(f, dayWindow(day, holdsDays)));
|
|
7732
|
+
const anyDay = leaves.length === 1 ? leaves[0] : op("or", ...leaves);
|
|
7733
|
+
if (!value.negated) return { rule: blank ? op("or", not(present), anyDay) : anyDay };
|
|
7734
|
+
return { rule: blank ? op("and", present, not(anyDay)) : not(anyDay) };
|
|
7734
7735
|
}
|
|
7735
7736
|
const asStored = (w) => holdsNumbers(f) || kind === "rating" ? Number.isFinite(Number(w)) ? Number(w) : w : kind === "checkbox" && (w === "true" || w === "false") ? w === "true" : w;
|
|
7736
7737
|
const stored = words2.map(asStored);
|
|
@@ -7813,7 +7814,7 @@ function storeQuestion(fields, base, columnFilters, now = /* @__PURE__ */ new Da
|
|
|
7813
7814
|
const value = flat[key];
|
|
7814
7815
|
if (!f) continue;
|
|
7815
7816
|
if (value !== null && typeof value === "object") {
|
|
7816
|
-
|
|
7817
|
+
rules.push(withinWindow(f, value));
|
|
7817
7818
|
continue;
|
|
7818
7819
|
}
|
|
7819
7820
|
rules.push(value === null ? op("not", op("present", field(f))) : op("eq", field(f), constant(value)));
|
|
@@ -13878,26 +13879,26 @@ function useMergedGridControls(args) {
|
|
|
13878
13879
|
);
|
|
13879
13880
|
const choiceKeys = (0, import_react77.useMemo)(() => enabled ? fields.filter(isChoiceField).map((f) => f.key) : [], [enabled, fields]);
|
|
13880
13881
|
const choiceOptions = useChoiceOptions(fields, choiceKeys);
|
|
13881
|
-
const
|
|
13882
|
-
const countQuestionKey = JSON.stringify([choiceKeys, query.columnFilters, args.filter ?? null]);
|
|
13882
|
+
const searchWords = (args.search ?? "").trim();
|
|
13883
|
+
const countQuestionKey = JSON.stringify([choiceKeys, query.columnFilters, args.filter ?? null, searchWords]);
|
|
13883
13884
|
const rowsKey = rows.map((row) => `${row.id}:${row.version ?? ""}`).join(",");
|
|
13884
13885
|
const fieldsRef = (0, import_react77.useRef)(fields);
|
|
13885
13886
|
fieldsRef.current = fields;
|
|
13886
13887
|
const [choiceCounts, setChoiceCounts] = (0, import_react77.useState)({});
|
|
13887
13888
|
(0, import_react77.useEffect)(() => {
|
|
13888
|
-
if (!enabled ||
|
|
13889
|
+
if (!enabled || choiceKeys.length === 0) {
|
|
13889
13890
|
setChoiceCounts({});
|
|
13890
13891
|
return;
|
|
13891
13892
|
}
|
|
13892
13893
|
let cancelled = false;
|
|
13893
|
-
const [keys, filters, base] = JSON.parse(countQuestionKey);
|
|
13894
|
+
const [keys, filters, base, searched] = JSON.parse(countQuestionKey);
|
|
13894
13895
|
for (const key of keys) {
|
|
13895
13896
|
const { [key]: _own, ...others } = filters;
|
|
13896
13897
|
const asked3 = storeQuestion(fieldsRef.current, base ?? void 0, others);
|
|
13897
13898
|
void askOnce(
|
|
13898
13899
|
client,
|
|
13899
|
-
`value_counts:${tableId}:${key}:${JSON.stringify(asked3.filter ?? null)}`,
|
|
13900
|
-
() => client.recordAggregate({ table_id: tableId, groupBy: [key], measures: [{ op: "count" }], ...asked3.filter ? { filter: asked3.filter } : {}, limit: 500 }),
|
|
13900
|
+
`value_counts:${tableId}:${key}:${searched}:${JSON.stringify(asked3.filter ?? null)}`,
|
|
13901
|
+
() => client.recordAggregate({ table_id: tableId, groupBy: [key], measures: [{ op: "count" }], ...asked3.filter ? { filter: asked3.filter } : {}, ...searched ? { search: searched } : {}, limit: 500 }),
|
|
13901
13902
|
VALUE_COUNTS_FRESH_MS
|
|
13902
13903
|
).then((answer) => {
|
|
13903
13904
|
if (cancelled || !answer.ok) return;
|
|
@@ -13913,7 +13914,7 @@ function useMergedGridControls(args) {
|
|
|
13913
13914
|
return () => {
|
|
13914
13915
|
cancelled = true;
|
|
13915
13916
|
};
|
|
13916
|
-
}, [enabled,
|
|
13917
|
+
}, [enabled, countQuestionKey, client, tableId, rowsKey]);
|
|
13917
13918
|
const filterFor = (0, import_react77.useCallback)(
|
|
13918
13919
|
(key) => {
|
|
13919
13920
|
if (!enabled) return void 0;
|
|
@@ -19225,7 +19226,8 @@ async function askColumnValues(inputs, args) {
|
|
|
19225
19226
|
const field2 = inputs.fields.find((f) => f.key === args.columnId);
|
|
19226
19227
|
const kind = valueListKind(field2);
|
|
19227
19228
|
if (kind === "none") return noValueList(args.columnId);
|
|
19228
|
-
if (kind === "loaded"
|
|
19229
|
+
if (kind === "loaded") return null;
|
|
19230
|
+
const searched = args.search.trim();
|
|
19229
19231
|
const { [args.columnId]: _own, ...others } = inputs.columnFilters;
|
|
19230
19232
|
const asked3 = storeQuestion(inputs.fields, inputs.filter, others);
|
|
19231
19233
|
const limit = Math.min(Math.max(args.limit, 1), MOST_VALUES);
|
|
@@ -19234,6 +19236,7 @@ async function askColumnValues(inputs, args) {
|
|
|
19234
19236
|
...kind === "days" ? { bucket: { key: field2.key, by: "day" } } : { groupBy: [field2.key] },
|
|
19235
19237
|
measures: [{ op: "count" }],
|
|
19236
19238
|
...asked3.filter ? { filter: asked3.filter } : {},
|
|
19239
|
+
...searched ? { search: searched } : {},
|
|
19237
19240
|
limit: MOST_VALUES
|
|
19238
19241
|
});
|
|
19239
19242
|
if (!answer.ok) throw new Error(refusalSentence(answer.error));
|
|
@@ -19245,7 +19248,8 @@ async function askColumnValues(inputs, args) {
|
|
|
19245
19248
|
const unique = await inputs.client.recordAggregate({
|
|
19246
19249
|
table_id: inputs.tableId,
|
|
19247
19250
|
measures: [{ op: "unique", key: field2.key }],
|
|
19248
|
-
...asked3.filter ? { filter: asked3.filter } : {}
|
|
19251
|
+
...asked3.filter ? { filter: asked3.filter } : {},
|
|
19252
|
+
...searched ? { search: searched } : {}
|
|
19249
19253
|
});
|
|
19250
19254
|
if (unique.ok) {
|
|
19251
19255
|
const n = Number(unique.data?.[0]?.measures?.[`unique_${field2.key}`]);
|
|
@@ -21656,6 +21660,7 @@ function GridBody({
|
|
|
21656
21660
|
writeLook,
|
|
21657
21661
|
query,
|
|
21658
21662
|
...filter ? { filter } : {},
|
|
21663
|
+
search: searchTerm,
|
|
21659
21664
|
setQuery,
|
|
21660
21665
|
duplicate: (row) => void duplicate(row),
|
|
21661
21666
|
askDelete: setDeleting,
|
|
@@ -27138,8 +27143,15 @@ function bodyFieldOf(fields) {
|
|
|
27138
27143
|
var BODY_COLUMN_NAME = "Notes";
|
|
27139
27144
|
var BODY_SAVE_PAUSE_MS = 900;
|
|
27140
27145
|
function RecordBody({ tableId, recordId, className }) {
|
|
27146
|
+
const host = useRecordsUi();
|
|
27141
27147
|
const fields = (0, import_react150.useFields)(tableId);
|
|
27148
|
+
const hostRecord = (0, import_react150.useRecord)(recordId, true, { tableId });
|
|
27149
|
+
const hostMay = useRecordRights(recordId);
|
|
27142
27150
|
const field2 = bodyFieldOf(fields.data ?? []);
|
|
27151
|
+
const hostBody = host.renderRecordBody && hostRecord.data ? host.renderRecordBody({ tableId, recordId, record: hostRecord.data, readOnly: !hostMay.write }) : null;
|
|
27152
|
+
if (hostBody !== null && hostBody !== void 0) {
|
|
27153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("section", { className: (0, import_design_system80.cn)("flex min-w-0 flex-col gap-1.5", className), "data-record-body": "host", children: hostBody });
|
|
27154
|
+
}
|
|
27143
27155
|
if (fields.loading && !fields.data) return null;
|
|
27144
27156
|
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("section", { className: (0, import_design_system80.cn)("flex min-w-0 flex-col gap-1.5", className), "data-record-body": field2?.key ?? "", children: field2 ? /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BodyEditor, { tableId, recordId, field: field2 }, `${recordId}:${field2.key}`) : /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(AddBody, { tableId }) });
|
|
27145
27157
|
}
|