@ai-matrx/records-ui 0.116.28 → 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/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">[]): PivotQuestion;
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">[]): PivotQuestion;
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-5EFM2G2O.js";
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 measureKey4 } from "@ai-matrx/records";
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 measureKey3
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 = measureKey3(measures[0]);
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] ? measureKey3(measures[1]) : null;
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[measureKey4(question.measure)] : void 0;
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((f) => NUMBER_TYPES.has(String(f.type)));
24995
- const pickMeasure = measureKey4(q.measure);
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 = 2e3;
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) {
@@ -25288,9 +25289,9 @@ function PivotLayout({ view, fields, filter, onChange, remembered }) {
25288
25289
  ] }) }) : null
25289
25290
  ] }) }),
25290
25291
  table.cut ? /* @__PURE__ */ jsxs78("p", { className: "text-xs text-muted-foreground", "data-records-pivot-cut": "", children: [
25291
- "Showing the first ",
25292
+ "First ",
25292
25293
  PIVOT_CELL_LIMIT.toLocaleString(),
25293
- " cells; narrow the view's filter to see the rest."
25294
+ " cells only. Narrow the filter to see the rest."
25294
25295
  ] }) : null
25295
25296
  ] })
25296
25297
  ] });
@@ -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 NUMBER_TYPES3 = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage", "range"]);
25306
+ var NUMBER_TYPES2 = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage", "range"]);
25306
25307
  function isNumberField2(field) {
25307
- if (!NUMBER_TYPES3.has(String(field.type))) return false;
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
  }
@@ -25933,8 +25934,6 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
25933
25934
  cancelled = true;
25934
25935
  };
25935
25936
  }, [client, ruleId, pageSize]);
25936
- const asked2 = stableFilterKey4(filter ?? null);
25937
- const fromView = asked2 !== "{}" && (asked2 === stableFilterKey4(view.where ?? null) || asked2 === stableFilterKey4(view.filters ?? null));
25938
25937
  const tableRows = useMemo52(() => table.data?.rows ?? [], [table.data]);
25939
25938
  const manual = view.order === "manual" && Boolean(viewId) && !ruleId;
25940
25939
  const hand = useHandOrderRows({
@@ -25986,7 +25985,7 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
25986
25985
  // sat over every board and gallery. A view of the whole table says nothing about it; a narrowed
25987
25986
  // one says how, in words a person uses.
25988
25987
  membership: [
25989
- ruleId ? "Showing the records this view's rule picks." : fromView ? "Showing the records this view's filter matches." : asked2 !== "{}" ? "Showing only the records behind the number you clicked." : "",
25988
+ // A person sees the rows; the screen does not narrate why they are the rows.
25990
25989
  manual ? HAND_ORDER_NOTE : ""
25991
25990
  ].filter(Boolean).join(" ")
25992
25991
  };
@@ -42118,7 +42117,6 @@ import { useFields as useFields35, useRecordMutation as useRecordMutation3, useR
42118
42117
  import {
42119
42118
  BasicInput as BasicInput26,
42120
42119
  BasicTextarea as BasicTextarea8,
42121
- Button as Button103,
42122
42120
  Dialog as Dialog23,
42123
42121
  DialogContent as DialogContent23,
42124
42122
  DialogHeader as DialogHeader23,
@@ -42135,6 +42133,7 @@ import {
42135
42133
  } from "@ai-matrx/design-system";
42136
42134
  import { MessageSquareIcon, PlusIcon as PlusIcon2, StickyNoteIcon } from "@ai-matrx/design-system/icons";
42137
42135
  import { readColorPair, readShadowPair, shadowWords } from "@ai-matrx/design-system/field-formats";
42136
+ import { Button as Button103 } from "@ai-matrx/design-system/controls";
42138
42137
 
42139
42138
  // src/EntitySectionCard.tsx
42140
42139
  import { useState as useState124 } from "react";
@@ -42543,7 +42542,7 @@ function ChecksLine({ checks, onFix }) {
42543
42542
  if (checks.length === 0) return null;
42544
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: [
42545
42544
  /* @__PURE__ */ jsx137("span", { className: "text-xs text-warning-ink", children: check.message }),
42546
- check.fix && onFix ? /* @__PURE__ */ jsx137(Button103, { type: "button", size: "sm", variant: "outline", className: "h-6 px-2 text-xs", onClick: () => onFix(check), children: check.fix.label }) : null
42545
+ check.fix && onFix ? /* @__PURE__ */ jsx137(Button103, { type: "button", variant: "outline", onClick: () => onFix(check), children: check.fix.label }) : null
42547
42546
  ] }, i)) });
42548
42547
  }
42549
42548
  function ValueCell({
@@ -42552,7 +42551,8 @@ function ValueCell({
42552
42551
  editable,
42553
42552
  save,
42554
42553
  onFix,
42555
- context
42554
+ context,
42555
+ stacked
42556
42556
  }) {
42557
42557
  const { field, format } = column;
42558
42558
  const stored = (row.document ?? {})[field.key];
@@ -42565,11 +42565,12 @@ function ValueCell({
42565
42565
  if (format?.id === "color_pair") {
42566
42566
  const pair = readColorPair(value) ?? null;
42567
42567
  const contrast = pair ? colorPairContrast(pair, format, context) : {};
42568
- 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) => {
42569
42569
  const side = part === "light" ? pair?.light : pair?.dark ?? void 0;
42570
42570
  const ratio = contrast[part];
42571
- 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: [
42572
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,
42573
42574
  editable ? /* @__PURE__ */ jsx137(
42574
42575
  ColorWell,
42575
42576
  {
@@ -42585,7 +42586,7 @@ function ValueCell({
42585
42586
  }
42586
42587
  }
42587
42588
  ) : /* @__PURE__ */ jsx137("code", { className: "font-mono text-xs uppercase", children: side ?? (part === "dark" ? "Inherits light" : "\u2014") }),
42588
- ratio !== void 0 ? /* @__PURE__ */ jsx137(ContrastMark, { ratio }) : null
42589
+ ratio !== void 0 ? /* @__PURE__ */ jsx137(ContrastMark, { ratio, min: pair?.min }) : null
42589
42590
  ] }),
42590
42591
  /* @__PURE__ */ jsx137(ChecksLine, { checks: checks.filter((c) => c.part === part), onFix: fix })
42591
42592
  ] }, part);
@@ -42596,25 +42597,28 @@ function ValueCell({
42596
42597
  const ownDark = typeof value === "string" && value.includes('"dark"');
42597
42598
  const pack = (l) => l.length === 1 ? l[0] : { layers: l };
42598
42599
  const write = (light, dark) => change(JSON.stringify(dark ? { light: pack(light), dark: pack(dark) } : pack(light)));
42599
- 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) => {
42600
42601
  const layers = pair ? pair[part] : null;
42601
42602
  const words2 = !layers ? "Set" : part === "dark" && !ownDark ? "Same as light" : shadowWords(layers);
42602
42603
  const inner = /* @__PURE__ */ jsxs129("span", { className: "flex min-w-0 items-center gap-2", children: [
42603
42604
  layers ? /* @__PURE__ */ jsx137(ShadowSwatch, { layers, theme: part }) : null,
42604
42605
  /* @__PURE__ */ jsx137("span", { className: cn75("truncate text-xs", part === "dark" && !ownDark ? "text-muted-foreground" : "text-foreground"), children: words2 })
42605
42606
  ] });
42606
- return /* @__PURE__ */ jsx137("div", { className: "min-w-0 px-3", children: editable ? /* @__PURE__ */ jsxs129(Popover12, { children: [
42607
- /* @__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 }) }),
42608
- /* @__PURE__ */ jsx137(PopoverContent12, { align: "start", className: "w-80", children: /* @__PURE__ */ jsx137(
42609
- ShadowLayersEditor,
42610
- {
42611
- layers: layers ?? [{ x: 0, y: 4, blur: 12, spread: 0, color: "#0000001f" }],
42612
- id: `${id}-${part}`,
42613
- label: `${fieldName(field)} ${part}`,
42614
- onChange: (next) => part === "light" ? write(next, ownDark && pair ? pair.dark : null) : write(pair ? pair.light : next, next)
42615
- }
42616
- ) })
42617
- ] }) : inner }, part);
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);
42618
42622
  }) });
42619
42623
  }
42620
42624
  const look = fieldLookFor(format?.id);
@@ -42699,20 +42703,15 @@ function groundOf(row, rows, keys) {
42699
42703
  }
42700
42704
  function RowComments({ tableId, row, count, onClosed }) {
42701
42705
  return /* @__PURE__ */ jsxs129(Popover12, { onOpenChange: (open) => !open && onClosed(), children: [
42702
- /* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsxs129(
42703
- "button",
42706
+ /* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx137(
42707
+ Button103,
42704
42708
  {
42705
42709
  type: "button",
42710
+ variant: "quiet",
42711
+ icon: /* @__PURE__ */ jsx137(MessageSquareIcon, {}),
42712
+ badge: count,
42706
42713
  "aria-label": count > 0 ? `${count} open comment${count === 1 ? "" : "s"}` : "Comment",
42707
- "data-records-row-comments": count,
42708
- className: cn75(
42709
- "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",
42710
- count > 0 ? "text-foreground" : "text-muted-foreground"
42711
- ),
42712
- children: [
42713
- /* @__PURE__ */ jsx137(MessageSquareIcon, { className: "h-3.5 w-3.5" }),
42714
- count > 0 ? /* @__PURE__ */ jsx137("span", { className: "text-xs tabular-nums", children: count }) : null
42715
- ]
42714
+ "data-records-row-comments": count
42716
42715
  }
42717
42716
  ) }),
42718
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" }) })
@@ -42725,16 +42724,14 @@ function NoteButton({ row, noteField, editable, save }) {
42725
42724
  const has = text.trim() !== "";
42726
42725
  return /* @__PURE__ */ jsxs129(Popover12, { children: [
42727
42726
  /* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx137(
42728
- "button",
42727
+ Button103,
42729
42728
  {
42730
42729
  type: "button",
42730
+ variant: "quiet",
42731
+ icon: /* @__PURE__ */ jsx137(StickyNoteIcon, {}),
42732
+ pressed: has,
42731
42733
  "aria-label": has ? `${fieldName(noteField)}: ${text}` : `Add ${fieldName(noteField).toLowerCase()}`,
42732
- title: has ? text : fieldName(noteField),
42733
- className: cn75(
42734
- "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",
42735
- has ? "text-foreground" : "text-muted-foreground"
42736
- ),
42737
- children: /* @__PURE__ */ jsx137(StickyNoteIcon, { className: "h-4 w-4" })
42734
+ title: has ? text : fieldName(noteField)
42738
42735
  }
42739
42736
  ) }),
42740
42737
  /* @__PURE__ */ jsx137(PopoverContent12, { align: "end", className: "w-72", children: /* @__PURE__ */ jsx137(
@@ -42848,8 +42845,8 @@ function AddDialog({
42848
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) })
42849
42846
  ] }) : null,
42850
42847
  /* @__PURE__ */ jsxs129("div", { className: "flex justify-end gap-2 pt-1", children: [
42851
- /* @__PURE__ */ jsx137(Button103, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: "Cancel" }),
42852
- /* @__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" })
42853
42850
  ] })
42854
42851
  ]
42855
42852
  }
@@ -42928,27 +42925,15 @@ function TableSectionCard(props) {
42928
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: [
42929
42926
  /* @__PURE__ */ jsxs129("header", { className: "flex items-start justify-between gap-4 px-5 pt-5 pb-3 sm:px-6", children: [
42930
42927
  /* @__PURE__ */ jsxs129("div", { className: "min-w-0", children: [
42931
- /* @__PURE__ */ jsx137("h2", { className: "truncate font-serif text-2xl tracking-tight text-foreground", children: title || "\xA0" }),
42928
+ /* @__PURE__ */ jsx137("h2", { className: "type-heading truncate text-foreground", children: title || "\xA0" }),
42932
42929
  props.description ? /* @__PURE__ */ jsx137("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: props.description }) : null
42933
42930
  ] }),
42934
- mayWrite && nameField ? /* @__PURE__ */ jsxs129(Button103, { type: "button", variant: "outline", size: "sm", onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED2), children: [
42935
- /* @__PURE__ */ jsx137(PlusIcon2, { className: "h-3.5 w-3.5" }),
42936
- "Add"
42937
- ] }) : 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
42938
42932
  ] }),
42939
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: [
42940
42934
  cols.group ? /* @__PURE__ */ jsxs129("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
42941
42935
  /* @__PURE__ */ jsx137("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
42942
- mayWrite ? /* @__PURE__ */ jsx137(
42943
- "button",
42944
- {
42945
- type: "button",
42946
- "aria-label": `Add to ${group.key || "no group"}`,
42947
- 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",
42948
- onClick: () => setAdding(group.key),
42949
- children: /* @__PURE__ */ jsx137(PlusIcon2, { className: "h-4 w-4" })
42950
- }
42951
- ) : 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
42952
42937
  ] }) : null,
42953
42938
  /* @__PURE__ */ jsxs129("div", { role: "table", "aria-label": group.key || title, className: narrow ? "" : "min-w-[36rem]", children: [
42954
42939
  /* @__PURE__ */ jsxs129("div", { role: "row", style: gridStyle, className: cn75("grid border-b border-border text-xs text-muted-foreground", narrow && "hidden"), children: [
@@ -42988,7 +42973,7 @@ function TableSectionCard(props) {
42988
42973
  style: c.part ? { gridColumn: "span 2" } : void 0,
42989
42974
  className: narrow ? "min-w-0" : cn75("min-w-0 py-1", c.part ? "" : "px-3"),
42990
42975
  children: [
42991
- 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,
42992
42977
  /* @__PURE__ */ jsx137(
42993
42978
  ValueCell,
42994
42979
  {
@@ -42997,7 +42982,8 @@ function TableSectionCard(props) {
42997
42982
  editable,
42998
42983
  save: rowSave,
42999
42984
  onFix,
43000
- 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
43001
42987
  }
43002
42988
  )
43003
42989
  ]