@ai-matrx/records-ui 0.116.29 → 0.116.30
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 +16 -1
- package/dist/{chunk-5EFM2G2O.js → chunk-2SI7LSP3.js} +9 -7
- package/dist/chunk-2SI7LSP3.js.map +1 -0
- package/dist/index.cjs +125 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +118 -130
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +7 -6
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-5EFM2G2O.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -5561,7 +5561,9 @@ interface PivotView {
|
|
|
5561
5561
|
* draws the rest), the same Field is never both rows and columns, and a measure that needs a number
|
|
5562
5562
|
* Field it does not have falls back to a count and `fellBack` says so.
|
|
5563
5563
|
*/
|
|
5564
|
-
declare function pivotQuestion(view: PivotView, fields: readonly Pick<CoercibleField, "key" | "type">
|
|
5564
|
+
declare function pivotQuestion(view: PivotView, fields: readonly (Pick<CoercibleField, "key" | "type"> & {
|
|
5565
|
+
config?: unknown;
|
|
5566
|
+
})[]): PivotQuestion;
|
|
5565
5567
|
interface PivotAxisItem {
|
|
5566
5568
|
id: string;
|
|
5567
5569
|
/** The stored value, as the drill-through filters by it (`null` = no value). */
|
|
@@ -7811,9 +7813,10 @@ declare function colorPairContrast(pair: ColorPair, format: FieldFormatConfig, c
|
|
|
7811
7813
|
light?: number;
|
|
7812
7814
|
dark?: number;
|
|
7813
7815
|
};
|
|
7814
|
-
/** "17:1" with a tick, or a warning mark under 4.5:1. */
|
|
7815
|
-
declare function ContrastMark({ ratio }: {
|
|
7816
|
+
/** "17:1" with a tick, or a warning mark under the color's minimum (its `min`, else text's 4.5:1). */
|
|
7817
|
+
declare function ContrastMark({ ratio, min }: {
|
|
7816
7818
|
ratio: number;
|
|
7819
|
+
min?: number | undefined;
|
|
7817
7820
|
}): react.JSX.Element;
|
|
7818
7821
|
/** One side of a pair: a color well and its hex, typed or picked. */
|
|
7819
7822
|
declare function ColorWell({ id, label, value, placeholder, onChange, disabled, }: {
|
package/dist/index.d.ts
CHANGED
|
@@ -5561,7 +5561,9 @@ interface PivotView {
|
|
|
5561
5561
|
* draws the rest), the same Field is never both rows and columns, and a measure that needs a number
|
|
5562
5562
|
* Field it does not have falls back to a count and `fellBack` says so.
|
|
5563
5563
|
*/
|
|
5564
|
-
declare function pivotQuestion(view: PivotView, fields: readonly Pick<CoercibleField, "key" | "type">
|
|
5564
|
+
declare function pivotQuestion(view: PivotView, fields: readonly (Pick<CoercibleField, "key" | "type"> & {
|
|
5565
|
+
config?: unknown;
|
|
5566
|
+
})[]): PivotQuestion;
|
|
5565
5567
|
interface PivotAxisItem {
|
|
5566
5568
|
id: string;
|
|
5567
5569
|
/** The stored value, as the drill-through filters by it (`null` = no value). */
|
|
@@ -7811,9 +7813,10 @@ declare function colorPairContrast(pair: ColorPair, format: FieldFormatConfig, c
|
|
|
7811
7813
|
light?: number;
|
|
7812
7814
|
dark?: number;
|
|
7813
7815
|
};
|
|
7814
|
-
/** "17:1" with a tick, or a warning mark under 4.5:1. */
|
|
7815
|
-
declare function ContrastMark({ ratio }: {
|
|
7816
|
+
/** "17:1" with a tick, or a warning mark under the color's minimum (its `min`, else text's 4.5:1). */
|
|
7817
|
+
declare function ContrastMark({ ratio, min }: {
|
|
7816
7818
|
ratio: number;
|
|
7819
|
+
min?: number | undefined;
|
|
7817
7820
|
}): react.JSX.Element;
|
|
7818
7821
|
/** One side of a pair: a color well and its hex, typed or picked. */
|
|
7819
7822
|
declare function ColorWell({ id, label, value, placeholder, onChange, disabled, }: {
|
package/dist/index.js
CHANGED
|
@@ -182,7 +182,7 @@ import {
|
|
|
182
182
|
withoutAddition,
|
|
183
183
|
withoutLeadingBlank,
|
|
184
184
|
workedOutErrorFor
|
|
185
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-2SI7LSP3.js";
|
|
186
186
|
import {
|
|
187
187
|
CHART_PLOT_PX,
|
|
188
188
|
EMBEDDED_ROW_PX,
|
|
@@ -23578,10 +23578,75 @@ function ListRow({
|
|
|
23578
23578
|
);
|
|
23579
23579
|
}
|
|
23580
23580
|
|
|
23581
|
+
// src/pivot.ts
|
|
23582
|
+
import { measureKey as measureKey3 } from "@ai-matrx/records";
|
|
23583
|
+
var PIVOT_OPS = ["count", "sum", "avg", "min", "max"];
|
|
23584
|
+
var isPivotOp = (v) => PIVOT_OPS.includes(v ?? "");
|
|
23585
|
+
var PIVOT_OP_LABEL = { count: "Count", sum: "Sum", avg: "Average", min: "Min", max: "Max" };
|
|
23586
|
+
var PIVOT_CELL_LIMIT = 1e3;
|
|
23587
|
+
var NUMBER_TYPES = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage", "range"]);
|
|
23588
|
+
var isNumberField = (f) => {
|
|
23589
|
+
if (!NUMBER_TYPES.has(String(f.type))) return false;
|
|
23590
|
+
const kind2 = String((f.config ?? {})["kind"] ?? "number");
|
|
23591
|
+
return kind2 !== "date" && kind2 !== "datetime";
|
|
23592
|
+
};
|
|
23593
|
+
function pivotQuestion(view, fields) {
|
|
23594
|
+
const has = (key) => key && fields.some((f) => f.key === key) ? key : null;
|
|
23595
|
+
const rowKey = has(view.groupField);
|
|
23596
|
+
const colKey = has(view.columnField) !== rowKey ? has(view.columnField) : null;
|
|
23597
|
+
const op = isPivotOp(view.pivotMeasure) ? view.pivotMeasure : "count";
|
|
23598
|
+
const field = view.measure ? fields.find((f) => f.key === view.measure && isNumberField(f)) : void 0;
|
|
23599
|
+
const fellBack = op !== "count" && !field;
|
|
23600
|
+
const measure = op !== "count" && field ? { op, key: field.key } : { op: "count" };
|
|
23601
|
+
return { rowKey, colKey, op: fellBack ? "count" : op, measure, fellBack };
|
|
23602
|
+
}
|
|
23603
|
+
var NONE3 = "\0none";
|
|
23604
|
+
function groupId(value) {
|
|
23605
|
+
return value === null || value === void 0 || value === "" ? NONE3 : String(value);
|
|
23606
|
+
}
|
|
23607
|
+
function byValue(a, b) {
|
|
23608
|
+
if (a.id === NONE3 || b.id === NONE3) return a.id === b.id ? 0 : a.id === NONE3 ? 1 : -1;
|
|
23609
|
+
const x = typeof a.value === "number" ? a.value : null;
|
|
23610
|
+
const y = typeof b.value === "number" ? b.value : null;
|
|
23611
|
+
if (x !== null && y !== null) return x - y;
|
|
23612
|
+
return a.label.localeCompare(b.label, void 0, { numeric: true, sensitivity: "base" });
|
|
23613
|
+
}
|
|
23614
|
+
function pivotTable(q, answers, label, limit = PIVOT_CELL_LIMIT) {
|
|
23615
|
+
const m = measureKey3(q.measure);
|
|
23616
|
+
const read = (r) => r ? { value: typeof r.measures?.[m] === "number" ? r.measures[m] : null, n: r.row_count } : null;
|
|
23617
|
+
const axis = (key, sources) => {
|
|
23618
|
+
if (!key) return [{ id: NONE3, value: null, label: "" }];
|
|
23619
|
+
const seen = /* @__PURE__ */ new Map();
|
|
23620
|
+
for (const rows2 of sources)
|
|
23621
|
+
for (const r of rows2) {
|
|
23622
|
+
const raw = r.groups?.[key];
|
|
23623
|
+
const id = groupId(raw);
|
|
23624
|
+
if (!seen.has(id)) seen.set(id, { id, value: id === NONE3 ? null : raw, label: id === NONE3 ? "\u2014" : label(key, raw) });
|
|
23625
|
+
}
|
|
23626
|
+
return [...seen.values()].sort(byValue);
|
|
23627
|
+
};
|
|
23628
|
+
const rows = axis(q.rowKey, [answers.rowTotals, answers.cells]);
|
|
23629
|
+
const cols = axis(q.colKey, [answers.colTotals, answers.cells]);
|
|
23630
|
+
const cellAt = /* @__PURE__ */ new Map();
|
|
23631
|
+
for (const r of answers.cells) cellAt.set(`${groupId(q.rowKey ? r.groups?.[q.rowKey] : null)}${groupId(q.colKey ? r.groups?.[q.colKey] : null)}`, r);
|
|
23632
|
+
const rowAt = new Map(answers.rowTotals.map((r) => [groupId(q.rowKey ? r.groups?.[q.rowKey] : null), r]));
|
|
23633
|
+
const colAt = new Map(answers.colTotals.map((r) => [groupId(q.colKey ? r.groups?.[q.colKey] : null), r]));
|
|
23634
|
+
return {
|
|
23635
|
+
rows,
|
|
23636
|
+
cols,
|
|
23637
|
+
// With no row Field every cell is the one row; with no column Field, the one column.
|
|
23638
|
+
cell: (rowId, colId) => read(cellAt.get(`${rowId}${colId}`)),
|
|
23639
|
+
rowTotal: (rowId) => read(rowAt.get(rowId)),
|
|
23640
|
+
colTotal: (colId) => read(colAt.get(colId)),
|
|
23641
|
+
grand: read(answers.grand[0]),
|
|
23642
|
+
cut: answers.cells.length >= limit
|
|
23643
|
+
};
|
|
23644
|
+
}
|
|
23645
|
+
|
|
23581
23646
|
// src/ChartLayout.tsx
|
|
23582
23647
|
import { useEffect as useEffect67, useMemo as useMemo48, useState as useState76 } from "react";
|
|
23583
23648
|
import { useRecordsClient as useRecordsClient60 } from "@ai-matrx/records/react";
|
|
23584
|
-
import { fieldKindFor, measureKey as
|
|
23649
|
+
import { fieldKindFor, measureKey as measureKey5 } from "@ai-matrx/records";
|
|
23585
23650
|
import { Select as Select8, SelectContent as SelectContent6, SelectItem as SelectItem6, SelectTrigger as SelectTrigger6, SelectValue as SelectValue6 } from "@ai-matrx/design-system";
|
|
23586
23651
|
|
|
23587
23652
|
// src/ChartBlock.tsx
|
|
@@ -23607,7 +23672,7 @@ import {
|
|
|
23607
23672
|
YAxis
|
|
23608
23673
|
} from "recharts";
|
|
23609
23674
|
import {
|
|
23610
|
-
measureKey as
|
|
23675
|
+
measureKey as measureKey4
|
|
23611
23676
|
} from "@ai-matrx/records";
|
|
23612
23677
|
import { mapPgError as mapPgError2 } from "@ai-matrx/records/core";
|
|
23613
23678
|
import { cn as cn36 } from "@ai-matrx/design-system";
|
|
@@ -24191,7 +24256,7 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
|
|
|
24191
24256
|
const kind2 = shape ? BASE_KIND_OF_SHAPE[shape] : block.kind;
|
|
24192
24257
|
const tableId = block.table_id ?? subject;
|
|
24193
24258
|
const measures = block.measures && block.measures.length > 0 ? block.measures : [{ op: "count" }];
|
|
24194
|
-
const primary =
|
|
24259
|
+
const primary = measureKey4(measures[0]);
|
|
24195
24260
|
const windows = kind2 === "stuck" ? null : block.compare ?? null;
|
|
24196
24261
|
const compared = !!windows;
|
|
24197
24262
|
const grain = block.bucket?.by ?? null;
|
|
@@ -24201,7 +24266,7 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
|
|
|
24201
24266
|
const measureFields = useMeasureFields(primary, source ? void 0 : tableId);
|
|
24202
24267
|
const measureName = useMeasureWords(primary, tableId);
|
|
24203
24268
|
const numberFormat = useMemo47(() => source ? null : chartFormatFor(primary, measureFields), [source, primary, measureFields]);
|
|
24204
|
-
const yKey = drawn === "scatter" && measures[1] ?
|
|
24269
|
+
const yKey = drawn === "scatter" && measures[1] ? measureKey4(measures[1]) : null;
|
|
24205
24270
|
const yName = useMeasureWords(yKey ?? primary, tableId);
|
|
24206
24271
|
const points = useMemo47(() => {
|
|
24207
24272
|
if (kind2 === "stuck") return [];
|
|
@@ -24913,7 +24978,6 @@ import { Fragment as Fragment35, jsx as jsx84, jsxs as jsxs77 } from "react/jsx-
|
|
|
24913
24978
|
var KIND_LABEL = { bar: "Bars", line: "Line", area: "Area", donut: "Donut", pie: "Pie", stacked: "Stacked bars", scatter: "Scatter" };
|
|
24914
24979
|
var BASE_SHAPES = ["bar", "line", "donut"];
|
|
24915
24980
|
var MEASURE_LABEL2 = { count: "Count", sum: "Sum", avg: "Average" };
|
|
24916
|
-
var NUMBER_TYPES = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage"]);
|
|
24917
24981
|
var DATE_TYPES = /* @__PURE__ */ new Set(["date", "datetime", "timestamp"]);
|
|
24918
24982
|
var isChartKind = (v) => Object.prototype.hasOwnProperty.call(KIND_LABEL, v ?? "");
|
|
24919
24983
|
var isChartMeasure = (v) => v === "count" || v === "sum" || v === "avg";
|
|
@@ -24971,7 +25035,7 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
|
|
|
24971
25035
|
return;
|
|
24972
25036
|
}
|
|
24973
25037
|
const wholeRow = overall && overall.ok ? (overall.data ?? [])[0] : void 0;
|
|
24974
|
-
const wholeValue = wholeRow ? wholeRow.measures[
|
|
25038
|
+
const wholeValue = wholeRow ? wholeRow.measures[measureKey5(question.measure)] : void 0;
|
|
24975
25039
|
setState({
|
|
24976
25040
|
error: null,
|
|
24977
25041
|
...question.kind === "donut" ? { total: typeof wholeValue === "number" ? wholeValue : null } : {},
|
|
@@ -24991,8 +25055,8 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
|
|
|
24991
25055
|
};
|
|
24992
25056
|
}, [client, view.subject, view.name, qKey, filterKey]);
|
|
24993
25057
|
const groupable = fields.filter((f) => !["attachment", "file", "formula", "button"].includes(String(f.type)));
|
|
24994
|
-
const numeric = fields.filter(
|
|
24995
|
-
const pickMeasure =
|
|
25058
|
+
const numeric = fields.filter(isNumberField);
|
|
25059
|
+
const pickMeasure = measureKey5(q.measure);
|
|
24996
25060
|
const dataLabels = view.presentation?.chartLabels === true;
|
|
24997
25061
|
const legend = view.presentation?.chartLegend !== false;
|
|
24998
25062
|
const setLook = (patch) => onChange({ presentation: { ...view.presentation, ...patch } });
|
|
@@ -25057,69 +25121,6 @@ import { useRecordsClient as useRecordsClient61 } from "@ai-matrx/records/react"
|
|
|
25057
25121
|
import { measureKey as measureKey6 } from "@ai-matrx/records";
|
|
25058
25122
|
import { Select as Select9, SelectContent as SelectContent7, SelectItem as SelectItem7, SelectTrigger as SelectTrigger7, SelectValue as SelectValue7, cn as cn37 } from "@ai-matrx/design-system";
|
|
25059
25123
|
import { Skeleton as Skeleton17 } from "@ai-matrx/design-system/skeleton";
|
|
25060
|
-
|
|
25061
|
-
// src/pivot.ts
|
|
25062
|
-
import { measureKey as measureKey5 } from "@ai-matrx/records";
|
|
25063
|
-
var PIVOT_OPS = ["count", "sum", "avg", "min", "max"];
|
|
25064
|
-
var isPivotOp = (v) => PIVOT_OPS.includes(v ?? "");
|
|
25065
|
-
var PIVOT_OP_LABEL = { count: "Count", sum: "Sum", avg: "Average", min: "Min", max: "Max" };
|
|
25066
|
-
var PIVOT_CELL_LIMIT = 1e3;
|
|
25067
|
-
var NUMBER_TYPES2 = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage"]);
|
|
25068
|
-
var isNumberField = (f) => NUMBER_TYPES2.has(String(f.type));
|
|
25069
|
-
function pivotQuestion(view, fields) {
|
|
25070
|
-
const has = (key) => key && fields.some((f) => f.key === key) ? key : null;
|
|
25071
|
-
const rowKey = has(view.groupField);
|
|
25072
|
-
const colKey = has(view.columnField) !== rowKey ? has(view.columnField) : null;
|
|
25073
|
-
const op = isPivotOp(view.pivotMeasure) ? view.pivotMeasure : "count";
|
|
25074
|
-
const field = view.measure ? fields.find((f) => f.key === view.measure && isNumberField(f)) : void 0;
|
|
25075
|
-
const fellBack = op !== "count" && !field;
|
|
25076
|
-
const measure = op !== "count" && field ? { op, key: field.key } : { op: "count" };
|
|
25077
|
-
return { rowKey, colKey, op: fellBack ? "count" : op, measure, fellBack };
|
|
25078
|
-
}
|
|
25079
|
-
var NONE3 = "\0none";
|
|
25080
|
-
function groupId(value) {
|
|
25081
|
-
return value === null || value === void 0 || value === "" ? NONE3 : String(value);
|
|
25082
|
-
}
|
|
25083
|
-
function byValue(a, b) {
|
|
25084
|
-
if (a.id === NONE3 || b.id === NONE3) return a.id === b.id ? 0 : a.id === NONE3 ? 1 : -1;
|
|
25085
|
-
const x = typeof a.value === "number" ? a.value : null;
|
|
25086
|
-
const y = typeof b.value === "number" ? b.value : null;
|
|
25087
|
-
if (x !== null && y !== null) return x - y;
|
|
25088
|
-
return a.label.localeCompare(b.label, void 0, { numeric: true, sensitivity: "base" });
|
|
25089
|
-
}
|
|
25090
|
-
function pivotTable(q, answers, label, limit = PIVOT_CELL_LIMIT) {
|
|
25091
|
-
const m = measureKey5(q.measure);
|
|
25092
|
-
const read = (r) => r ? { value: typeof r.measures?.[m] === "number" ? r.measures[m] : null, n: r.row_count } : null;
|
|
25093
|
-
const axis = (key, sources) => {
|
|
25094
|
-
if (!key) return [{ id: NONE3, value: null, label: "" }];
|
|
25095
|
-
const seen = /* @__PURE__ */ new Map();
|
|
25096
|
-
for (const rows2 of sources)
|
|
25097
|
-
for (const r of rows2) {
|
|
25098
|
-
const raw = r.groups?.[key];
|
|
25099
|
-
const id = groupId(raw);
|
|
25100
|
-
if (!seen.has(id)) seen.set(id, { id, value: id === NONE3 ? null : raw, label: id === NONE3 ? "\u2014" : label(key, raw) });
|
|
25101
|
-
}
|
|
25102
|
-
return [...seen.values()].sort(byValue);
|
|
25103
|
-
};
|
|
25104
|
-
const rows = axis(q.rowKey, [answers.rowTotals, answers.cells]);
|
|
25105
|
-
const cols = axis(q.colKey, [answers.colTotals, answers.cells]);
|
|
25106
|
-
const cellAt = /* @__PURE__ */ new Map();
|
|
25107
|
-
for (const r of answers.cells) cellAt.set(`${groupId(q.rowKey ? r.groups?.[q.rowKey] : null)}${groupId(q.colKey ? r.groups?.[q.colKey] : null)}`, r);
|
|
25108
|
-
const rowAt = new Map(answers.rowTotals.map((r) => [groupId(q.rowKey ? r.groups?.[q.rowKey] : null), r]));
|
|
25109
|
-
const colAt = new Map(answers.colTotals.map((r) => [groupId(q.colKey ? r.groups?.[q.colKey] : null), r]));
|
|
25110
|
-
return {
|
|
25111
|
-
rows,
|
|
25112
|
-
cols,
|
|
25113
|
-
// With no row Field every cell is the one row; with no column Field, the one column.
|
|
25114
|
-
cell: (rowId, colId) => read(cellAt.get(`${rowId}${colId}`)),
|
|
25115
|
-
rowTotal: (rowId) => read(rowAt.get(rowId)),
|
|
25116
|
-
colTotal: (colId) => read(colAt.get(colId)),
|
|
25117
|
-
grand: read(answers.grand[0]),
|
|
25118
|
-
cut: answers.cells.length >= limit
|
|
25119
|
-
};
|
|
25120
|
-
}
|
|
25121
|
-
|
|
25122
|
-
// src/PivotLayout.tsx
|
|
25123
25124
|
import { Fragment as Fragment36, jsx as jsx85, jsxs as jsxs78 } from "react/jsx-runtime";
|
|
25124
25125
|
var PIVOT_BOX = "min-h-[16rem]";
|
|
25125
25126
|
function defaultPivotRows(fields) {
|
|
@@ -25302,9 +25303,9 @@ import { useFieldMutation as useFieldMutation6, useRecordMutation as useRecordMu
|
|
|
25302
25303
|
import { Button as Button61, Select as Select10, SelectContent as SelectContent8, SelectItem as SelectItem8, SelectTrigger as SelectTrigger8, SelectValue as SelectValue8, cn as cn38 } from "@ai-matrx/design-system";
|
|
25303
25304
|
|
|
25304
25305
|
// src/mapPins.ts
|
|
25305
|
-
var
|
|
25306
|
+
var NUMBER_TYPES2 = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage", "range"]);
|
|
25306
25307
|
function isNumberField2(field) {
|
|
25307
|
-
if (!
|
|
25308
|
+
if (!NUMBER_TYPES2.has(String(field.type))) return false;
|
|
25308
25309
|
const kind2 = String((field.config ?? {})["kind"] ?? "number");
|
|
25309
25310
|
return kind2 !== "date" && kind2 !== "datetime";
|
|
25310
25311
|
}
|
|
@@ -42116,7 +42117,6 @@ import { useFields as useFields35, useRecordMutation as useRecordMutation3, useR
|
|
|
42116
42117
|
import {
|
|
42117
42118
|
BasicInput as BasicInput26,
|
|
42118
42119
|
BasicTextarea as BasicTextarea8,
|
|
42119
|
-
Button as Button103,
|
|
42120
42120
|
Dialog as Dialog23,
|
|
42121
42121
|
DialogContent as DialogContent23,
|
|
42122
42122
|
DialogHeader as DialogHeader23,
|
|
@@ -42133,6 +42133,7 @@ import {
|
|
|
42133
42133
|
} from "@ai-matrx/design-system";
|
|
42134
42134
|
import { MessageSquareIcon, PlusIcon as PlusIcon2, StickyNoteIcon } from "@ai-matrx/design-system/icons";
|
|
42135
42135
|
import { readColorPair, readShadowPair, shadowWords } from "@ai-matrx/design-system/field-formats";
|
|
42136
|
+
import { Button as Button103 } from "@ai-matrx/design-system/controls";
|
|
42136
42137
|
|
|
42137
42138
|
// src/EntitySectionCard.tsx
|
|
42138
42139
|
import { useState as useState124 } from "react";
|
|
@@ -42541,7 +42542,7 @@ function ChecksLine({ checks, onFix }) {
|
|
|
42541
42542
|
if (checks.length === 0) return null;
|
|
42542
42543
|
return /* @__PURE__ */ jsx137("span", { className: "mt-1 flex flex-col items-start gap-1", children: checks.map((check, i) => /* @__PURE__ */ jsxs129("span", { className: "flex flex-col items-start gap-1", children: [
|
|
42543
42544
|
/* @__PURE__ */ jsx137("span", { className: "text-xs text-warning-ink", children: check.message }),
|
|
42544
|
-
check.fix && onFix ? /* @__PURE__ */ jsx137(Button103, { type: "button",
|
|
42545
|
+
check.fix && onFix ? /* @__PURE__ */ jsx137(Button103, { type: "button", variant: "outline", onClick: () => onFix(check), children: check.fix.label }) : null
|
|
42545
42546
|
] }, i)) });
|
|
42546
42547
|
}
|
|
42547
42548
|
function ValueCell({
|
|
@@ -42550,7 +42551,8 @@ function ValueCell({
|
|
|
42550
42551
|
editable,
|
|
42551
42552
|
save,
|
|
42552
42553
|
onFix,
|
|
42553
|
-
context
|
|
42554
|
+
context,
|
|
42555
|
+
stacked
|
|
42554
42556
|
}) {
|
|
42555
42557
|
const { field, format } = column;
|
|
42556
42558
|
const stored = (row.document ?? {})[field.key];
|
|
@@ -42563,11 +42565,12 @@ function ValueCell({
|
|
|
42563
42565
|
if (format?.id === "color_pair") {
|
|
42564
42566
|
const pair = readColorPair(value) ?? null;
|
|
42565
42567
|
const contrast = pair ? colorPairContrast(pair, format, context) : {};
|
|
42566
|
-
return /* @__PURE__ */ jsx137("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
|
|
42568
|
+
return /* @__PURE__ */ jsx137("div", { className: stacked ? "flex min-w-0 flex-col gap-1.5" : "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
|
|
42567
42569
|
const side = part === "light" ? pair?.light : pair?.dark ?? void 0;
|
|
42568
42570
|
const ratio = contrast[part];
|
|
42569
|
-
return /* @__PURE__ */ jsxs129("div", { className: "min-w-0 px-3", children: [
|
|
42571
|
+
return /* @__PURE__ */ jsxs129("div", { className: stacked ? "min-w-0" : "min-w-0 px-3", children: [
|
|
42570
42572
|
/* @__PURE__ */ jsxs129("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
42573
|
+
stacked ? /* @__PURE__ */ jsx137("span", { className: "w-9 shrink-0 text-xs text-muted-foreground", children: part === "light" ? "Light" : "Dark" }) : null,
|
|
42571
42574
|
editable ? /* @__PURE__ */ jsx137(
|
|
42572
42575
|
ColorWell,
|
|
42573
42576
|
{
|
|
@@ -42583,7 +42586,7 @@ function ValueCell({
|
|
|
42583
42586
|
}
|
|
42584
42587
|
}
|
|
42585
42588
|
) : /* @__PURE__ */ jsx137("code", { className: "font-mono text-xs uppercase", children: side ?? (part === "dark" ? "Inherits light" : "\u2014") }),
|
|
42586
|
-
ratio !== void 0 ? /* @__PURE__ */ jsx137(ContrastMark, { ratio }) : null
|
|
42589
|
+
ratio !== void 0 ? /* @__PURE__ */ jsx137(ContrastMark, { ratio, min: pair?.min }) : null
|
|
42587
42590
|
] }),
|
|
42588
42591
|
/* @__PURE__ */ jsx137(ChecksLine, { checks: checks.filter((c) => c.part === part), onFix: fix })
|
|
42589
42592
|
] }, part);
|
|
@@ -42594,25 +42597,28 @@ function ValueCell({
|
|
|
42594
42597
|
const ownDark = typeof value === "string" && value.includes('"dark"');
|
|
42595
42598
|
const pack = (l) => l.length === 1 ? l[0] : { layers: l };
|
|
42596
42599
|
const write = (light, dark) => change(JSON.stringify(dark ? { light: pack(light), dark: pack(dark) } : pack(light)));
|
|
42597
|
-
return /* @__PURE__ */ jsx137("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
|
|
42600
|
+
return /* @__PURE__ */ jsx137("div", { className: stacked ? "flex min-w-0 flex-col gap-1.5" : "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
|
|
42598
42601
|
const layers = pair ? pair[part] : null;
|
|
42599
42602
|
const words2 = !layers ? "Set" : part === "dark" && !ownDark ? "Same as light" : shadowWords(layers);
|
|
42600
42603
|
const inner = /* @__PURE__ */ jsxs129("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
42601
42604
|
layers ? /* @__PURE__ */ jsx137(ShadowSwatch, { layers, theme: part }) : null,
|
|
42602
42605
|
/* @__PURE__ */ jsx137("span", { className: cn75("truncate text-xs", part === "dark" && !ownDark ? "text-muted-foreground" : "text-foreground"), children: words2 })
|
|
42603
42606
|
] });
|
|
42604
|
-
return /* @__PURE__ */
|
|
42605
|
-
|
|
42606
|
-
/* @__PURE__ */
|
|
42607
|
-
|
|
42608
|
-
{
|
|
42609
|
-
|
|
42610
|
-
|
|
42611
|
-
|
|
42612
|
-
|
|
42613
|
-
|
|
42614
|
-
|
|
42615
|
-
|
|
42607
|
+
return /* @__PURE__ */ jsxs129("div", { className: stacked ? "flex min-w-0 items-center gap-2" : "min-w-0 px-3", children: [
|
|
42608
|
+
stacked ? /* @__PURE__ */ jsx137("span", { className: "w-9 shrink-0 text-xs text-muted-foreground", children: part === "light" ? "Light" : "Dark" }) : null,
|
|
42609
|
+
editable ? /* @__PURE__ */ jsxs129(Popover12, { children: [
|
|
42610
|
+
/* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx137("button", { type: "button", "aria-label": `${fieldName(field)} ${part}`, className: "block w-full min-w-0 rounded-md px-1 py-0.5 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: inner }) }),
|
|
42611
|
+
/* @__PURE__ */ jsx137(PopoverContent12, { align: "start", className: "w-80", children: /* @__PURE__ */ jsx137(
|
|
42612
|
+
ShadowLayersEditor,
|
|
42613
|
+
{
|
|
42614
|
+
layers: layers ?? [{ x: 0, y: 4, blur: 12, spread: 0, color: "#0000001f" }],
|
|
42615
|
+
id: `${id}-${part}`,
|
|
42616
|
+
label: `${fieldName(field)} ${part}`,
|
|
42617
|
+
onChange: (next) => part === "light" ? write(next, ownDark && pair ? pair.dark : null) : write(pair ? pair.light : next, next)
|
|
42618
|
+
}
|
|
42619
|
+
) })
|
|
42620
|
+
] }) : inner
|
|
42621
|
+
] }, part);
|
|
42616
42622
|
}) });
|
|
42617
42623
|
}
|
|
42618
42624
|
const look = fieldLookFor(format?.id);
|
|
@@ -42697,20 +42703,15 @@ function groundOf(row, rows, keys) {
|
|
|
42697
42703
|
}
|
|
42698
42704
|
function RowComments({ tableId, row, count, onClosed }) {
|
|
42699
42705
|
return /* @__PURE__ */ jsxs129(Popover12, { onOpenChange: (open) => !open && onClosed(), children: [
|
|
42700
|
-
/* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */
|
|
42701
|
-
|
|
42706
|
+
/* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx137(
|
|
42707
|
+
Button103,
|
|
42702
42708
|
{
|
|
42703
42709
|
type: "button",
|
|
42710
|
+
variant: "quiet",
|
|
42711
|
+
icon: /* @__PURE__ */ jsx137(MessageSquareIcon, {}),
|
|
42712
|
+
badge: count,
|
|
42704
42713
|
"aria-label": count > 0 ? `${count} open comment${count === 1 ? "" : "s"}` : "Comment",
|
|
42705
|
-
"data-records-row-comments": count
|
|
42706
|
-
className: cn75(
|
|
42707
|
-
"inline-flex h-7 min-w-7 items-center justify-center gap-0.5 rounded-md px-1 hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
42708
|
-
count > 0 ? "text-foreground" : "text-muted-foreground"
|
|
42709
|
-
),
|
|
42710
|
-
children: [
|
|
42711
|
-
/* @__PURE__ */ jsx137(MessageSquareIcon, { className: "h-3.5 w-3.5" }),
|
|
42712
|
-
count > 0 ? /* @__PURE__ */ jsx137("span", { className: "text-xs tabular-nums", children: count }) : null
|
|
42713
|
-
]
|
|
42714
|
+
"data-records-row-comments": count
|
|
42714
42715
|
}
|
|
42715
42716
|
) }),
|
|
42716
42717
|
/* @__PURE__ */ jsx137(PopoverContent12, { align: "end", className: "w-96 p-0", children: /* @__PURE__ */ jsx137(CommentThread, { tableId, recordId: row.id, className: "max-h-[70dvh] overflow-y-auto p-3" }) })
|
|
@@ -42723,16 +42724,14 @@ function NoteButton({ row, noteField, editable, save }) {
|
|
|
42723
42724
|
const has = text.trim() !== "";
|
|
42724
42725
|
return /* @__PURE__ */ jsxs129(Popover12, { children: [
|
|
42725
42726
|
/* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx137(
|
|
42726
|
-
|
|
42727
|
+
Button103,
|
|
42727
42728
|
{
|
|
42728
42729
|
type: "button",
|
|
42730
|
+
variant: "quiet",
|
|
42731
|
+
icon: /* @__PURE__ */ jsx137(StickyNoteIcon, {}),
|
|
42732
|
+
pressed: has,
|
|
42729
42733
|
"aria-label": has ? `${fieldName(noteField)}: ${text}` : `Add ${fieldName(noteField).toLowerCase()}`,
|
|
42730
|
-
title: has ? text : fieldName(noteField)
|
|
42731
|
-
className: cn75(
|
|
42732
|
-
"inline-flex h-7 w-7 items-center justify-center rounded-md hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
42733
|
-
has ? "text-foreground" : "text-muted-foreground"
|
|
42734
|
-
),
|
|
42735
|
-
children: /* @__PURE__ */ jsx137(StickyNoteIcon, { className: "h-4 w-4" })
|
|
42734
|
+
title: has ? text : fieldName(noteField)
|
|
42736
42735
|
}
|
|
42737
42736
|
) }),
|
|
42738
42737
|
/* @__PURE__ */ jsx137(PopoverContent12, { align: "end", className: "w-72", children: /* @__PURE__ */ jsx137(
|
|
@@ -42846,8 +42845,8 @@ function AddDialog({
|
|
|
42846
42845
|
/* @__PURE__ */ jsx137(BasicTextarea8, { id: "section-add-note", rows: 2, placeholder: name.trim() ? `When should ${name.trim()} be used?` : "When should it be used?", value: note, onChange: (e) => setNote(e.target.value) })
|
|
42847
42846
|
] }) : null,
|
|
42848
42847
|
/* @__PURE__ */ jsxs129("div", { className: "flex justify-end gap-2 pt-1", children: [
|
|
42849
|
-
/* @__PURE__ */ jsx137(Button103, { type: "button", variant: "
|
|
42850
|
-
/* @__PURE__ */ jsx137(Button103, { type: "submit", disabled: !ready, children: "Add" })
|
|
42848
|
+
/* @__PURE__ */ jsx137(Button103, { type: "button", variant: "quiet", onClick: () => onOpenChange(false), children: "Cancel" }),
|
|
42849
|
+
/* @__PURE__ */ jsx137(Button103, { type: "submit", variant: "primary", disabled: !ready, children: "Add" })
|
|
42851
42850
|
] })
|
|
42852
42851
|
]
|
|
42853
42852
|
}
|
|
@@ -42926,27 +42925,15 @@ function TableSectionCard(props) {
|
|
|
42926
42925
|
return /* @__PURE__ */ jsxs129("section", { ref: sectionRef, "data-records-section-card": "", "data-narrow": narrow ? "" : void 0, className: cn75("rounded-2xl border border-border bg-card text-card-foreground", className), children: [
|
|
42927
42926
|
/* @__PURE__ */ jsxs129("header", { className: "flex items-start justify-between gap-4 px-5 pt-5 pb-3 sm:px-6", children: [
|
|
42928
42927
|
/* @__PURE__ */ jsxs129("div", { className: "min-w-0", children: [
|
|
42929
|
-
/* @__PURE__ */ jsx137("h2", { className: "
|
|
42928
|
+
/* @__PURE__ */ jsx137("h2", { className: "type-heading truncate text-foreground", children: title || "\xA0" }),
|
|
42930
42929
|
props.description ? /* @__PURE__ */ jsx137("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: props.description }) : null
|
|
42931
42930
|
] }),
|
|
42932
|
-
mayWrite && nameField ? /* @__PURE__ */
|
|
42933
|
-
/* @__PURE__ */ jsx137(PlusIcon2, { className: "h-3.5 w-3.5" }),
|
|
42934
|
-
"Add"
|
|
42935
|
-
] }) : null
|
|
42931
|
+
mayWrite && nameField ? /* @__PURE__ */ jsx137(Button103, { type: "button", variant: "outline", icon: /* @__PURE__ */ jsx137(PlusIcon2, {}), onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED2), children: "Add" }) : null
|
|
42936
42932
|
] }),
|
|
42937
42933
|
refused ? /* @__PURE__ */ jsx137("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: refusalSentence(refused) }) : !fieldsRead.data || page.loading && rows.length === 0 ? /* @__PURE__ */ jsx137("div", { className: "flex flex-col gap-1.5 px-5 pb-5 sm:px-6", "aria-busy": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx137("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : rows.length === 0 ? /* @__PURE__ */ jsx137("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." }) : /* @__PURE__ */ jsx137("div", { className: cn75("-mb-px", !narrow && "overflow-x-auto"), children: groups.map((group) => /* @__PURE__ */ jsxs129("div", { "data-records-section-group": group.key, className: "", children: [
|
|
42938
42934
|
cols.group ? /* @__PURE__ */ jsxs129("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
|
|
42939
42935
|
/* @__PURE__ */ jsx137("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
|
|
42940
|
-
mayWrite ? /* @__PURE__ */ jsx137(
|
|
42941
|
-
"button",
|
|
42942
|
-
{
|
|
42943
|
-
type: "button",
|
|
42944
|
-
"aria-label": `Add to ${group.key || "no group"}`,
|
|
42945
|
-
className: "inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
42946
|
-
onClick: () => setAdding(group.key),
|
|
42947
|
-
children: /* @__PURE__ */ jsx137(PlusIcon2, { className: "h-4 w-4" })
|
|
42948
|
-
}
|
|
42949
|
-
) : null
|
|
42936
|
+
mayWrite ? /* @__PURE__ */ jsx137(Button103, { type: "button", variant: "quiet", icon: /* @__PURE__ */ jsx137(PlusIcon2, {}), "aria-label": `Add to ${group.key || "no group"}`, onClick: () => setAdding(group.key) }) : null
|
|
42950
42937
|
] }) : null,
|
|
42951
42938
|
/* @__PURE__ */ jsxs129("div", { role: "table", "aria-label": group.key || title, className: narrow ? "" : "min-w-[36rem]", children: [
|
|
42952
42939
|
/* @__PURE__ */ jsxs129("div", { role: "row", style: gridStyle, className: cn75("grid border-b border-border text-xs text-muted-foreground", narrow && "hidden"), children: [
|
|
@@ -42986,7 +42973,7 @@ function TableSectionCard(props) {
|
|
|
42986
42973
|
style: c.part ? { gridColumn: "span 2" } : void 0,
|
|
42987
42974
|
className: narrow ? "min-w-0" : cn75("min-w-0 py-1", c.part ? "" : "px-3"),
|
|
42988
42975
|
children: [
|
|
42989
|
-
narrow ? /* @__PURE__ */ jsx137("span", { className: "mb-0.5 block text-xs text-muted-foreground", children: cellLabel(c) }) : null,
|
|
42976
|
+
narrow && !c.part ? /* @__PURE__ */ jsx137("span", { className: "mb-0.5 block text-xs text-muted-foreground", children: cellLabel(c) }) : null,
|
|
42990
42977
|
/* @__PURE__ */ jsx137(
|
|
42991
42978
|
ValueCell,
|
|
42992
42979
|
{
|
|
@@ -42995,7 +42982,8 @@ function TableSectionCard(props) {
|
|
|
42995
42982
|
editable,
|
|
42996
42983
|
save: rowSave,
|
|
42997
42984
|
onFix,
|
|
42998
|
-
context: c.field.key === readsOnColorKey ? groundOf(row, rows, { name: cols.name, readsOn: cols.readsOn, color: c.field.key }) : void 0
|
|
42985
|
+
context: c.field.key === readsOnColorKey ? groundOf(row, rows, { name: cols.name, readsOn: cols.readsOn, color: c.field.key }) : void 0,
|
|
42986
|
+
stacked: narrow
|
|
42999
42987
|
}
|
|
43000
42988
|
)
|
|
43001
42989
|
]
|