@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/dist/index.cjs CHANGED
@@ -9295,8 +9295,8 @@ function colorPairContrast(pair, format, context) {
9295
9295
  }
9296
9296
  return out;
9297
9297
  }
9298
- function ContrastMark({ ratio }) {
9299
- const level = (0, import_field_formats.contrastLevel)(ratio);
9298
+ function ContrastMark({ ratio, min }) {
9299
+ const level = (0, import_field_formats.contrastLevel)(ratio, min);
9300
9300
  const said2 = `${ratio}:1`;
9301
9301
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
9302
9302
  "span",
@@ -9319,12 +9319,12 @@ function ColorPairView({ value, format }) {
9319
9319
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
9320
9320
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Swatch, { color: pair.light }),
9321
9321
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", { className: "font-mono text-xs uppercase", children: pair.light }),
9322
- contrast.light !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ContrastMark, { ratio: contrast.light }) : null
9322
+ contrast.light !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ContrastMark, { ratio: contrast.light, min: pair.min }) : null
9323
9323
  ] }),
9324
9324
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
9325
9325
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Swatch, { color: pair.dark ?? pair.light }),
9326
9326
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", { className: (0, import_design_system2.cn)("font-mono text-xs uppercase", !pair.dark && "text-muted-foreground"), children: pair.dark ?? "Inherits light" }),
9327
- contrast.dark !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ContrastMark, { ratio: contrast.dark }) : null
9327
+ contrast.dark !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ContrastMark, { ratio: contrast.dark, min: pair.min }) : null
9328
9328
  ] })
9329
9329
  ] });
9330
9330
  }
@@ -9426,14 +9426,15 @@ function colorPairChecks(value, format, context) {
9426
9426
  const out = [];
9427
9427
  for (const part of ["light", "dark"]) {
9428
9428
  const ratio = contrast[part];
9429
- if (ratio === void 0 || (0, import_field_formats.contrastLevel)(ratio) === "pass") continue;
9429
+ if (ratio === void 0 || (0, import_field_formats.contrastLevel)(ratio, pair.min) === "pass") continue;
9430
9430
  const color = part === "light" ? pair.light : pair.dark ?? pair.light;
9431
+ const need = pair.min ?? import_field_formats.TEXT_CONTRAST;
9431
9432
  out.push({
9432
9433
  part,
9433
9434
  message: `hard to read on ${ground}`,
9434
9435
  fix: {
9435
9436
  label: "Fix with AI",
9436
- ask: `The ${part} color ${color} reads at ${ratio}:1 on ${ground}. Suggest the nearest color that reaches 4.5:1 and keeps its hue.`
9437
+ ask: `The ${part} color ${color} reads at ${ratio}:1 on ${ground}. Suggest the nearest color that reaches ${need}:1 and keeps its hue.`
9437
9438
  }
9438
9439
  });
9439
9440
  }
@@ -44176,16 +44177,81 @@ function ListRow({
44176
44177
  );
44177
44178
  }
44178
44179
 
44180
+ // src/pivot.ts
44181
+ var import_records56 = require("@ai-matrx/records");
44182
+ var PIVOT_OPS = ["count", "sum", "avg", "min", "max"];
44183
+ var isPivotOp = (v) => PIVOT_OPS.includes(v ?? "");
44184
+ var PIVOT_OP_LABEL = { count: "Count", sum: "Sum", avg: "Average", min: "Min", max: "Max" };
44185
+ var PIVOT_CELL_LIMIT = 1e3;
44186
+ var NUMBER_TYPES = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage", "range"]);
44187
+ var isNumberField = (f) => {
44188
+ if (!NUMBER_TYPES.has(String(f.type))) return false;
44189
+ const kind2 = String((f.config ?? {})["kind"] ?? "number");
44190
+ return kind2 !== "date" && kind2 !== "datetime";
44191
+ };
44192
+ function pivotQuestion(view, fields) {
44193
+ const has = (key) => key && fields.some((f) => f.key === key) ? key : null;
44194
+ const rowKey = has(view.groupField);
44195
+ const colKey = has(view.columnField) !== rowKey ? has(view.columnField) : null;
44196
+ const op2 = isPivotOp(view.pivotMeasure) ? view.pivotMeasure : "count";
44197
+ const field2 = view.measure ? fields.find((f) => f.key === view.measure && isNumberField(f)) : void 0;
44198
+ const fellBack = op2 !== "count" && !field2;
44199
+ const measure = op2 !== "count" && field2 ? { op: op2, key: field2.key } : { op: "count" };
44200
+ return { rowKey, colKey, op: fellBack ? "count" : op2, measure, fellBack };
44201
+ }
44202
+ var NONE3 = "\0none";
44203
+ function groupId(value) {
44204
+ return value === null || value === void 0 || value === "" ? NONE3 : String(value);
44205
+ }
44206
+ function byValue(a, b) {
44207
+ if (a.id === NONE3 || b.id === NONE3) return a.id === b.id ? 0 : a.id === NONE3 ? 1 : -1;
44208
+ const x = typeof a.value === "number" ? a.value : null;
44209
+ const y = typeof b.value === "number" ? b.value : null;
44210
+ if (x !== null && y !== null) return x - y;
44211
+ return a.label.localeCompare(b.label, void 0, { numeric: true, sensitivity: "base" });
44212
+ }
44213
+ function pivotTable(q, answers2, label, limit = PIVOT_CELL_LIMIT) {
44214
+ const m = (0, import_records56.measureKey)(q.measure);
44215
+ const read = (r) => r ? { value: typeof r.measures?.[m] === "number" ? r.measures[m] : null, n: r.row_count } : null;
44216
+ const axis = (key, sources) => {
44217
+ if (!key) return [{ id: NONE3, value: null, label: "" }];
44218
+ const seen = /* @__PURE__ */ new Map();
44219
+ for (const rows2 of sources)
44220
+ for (const r of rows2) {
44221
+ const raw = r.groups?.[key];
44222
+ const id = groupId(raw);
44223
+ if (!seen.has(id)) seen.set(id, { id, value: id === NONE3 ? null : raw, label: id === NONE3 ? "\u2014" : label(key, raw) });
44224
+ }
44225
+ return [...seen.values()].sort(byValue);
44226
+ };
44227
+ const rows = axis(q.rowKey, [answers2.rowTotals, answers2.cells]);
44228
+ const cols = axis(q.colKey, [answers2.colTotals, answers2.cells]);
44229
+ const cellAt = /* @__PURE__ */ new Map();
44230
+ for (const r of answers2.cells) cellAt.set(`${groupId(q.rowKey ? r.groups?.[q.rowKey] : null)}${groupId(q.colKey ? r.groups?.[q.colKey] : null)}`, r);
44231
+ const rowAt = new Map(answers2.rowTotals.map((r) => [groupId(q.rowKey ? r.groups?.[q.rowKey] : null), r]));
44232
+ const colAt = new Map(answers2.colTotals.map((r) => [groupId(q.colKey ? r.groups?.[q.colKey] : null), r]));
44233
+ return {
44234
+ rows,
44235
+ cols,
44236
+ // With no row Field every cell is the one row; with no column Field, the one column.
44237
+ cell: (rowId, colId) => read(cellAt.get(`${rowId}${colId}`)),
44238
+ rowTotal: (rowId) => read(rowAt.get(rowId)),
44239
+ colTotal: (colId) => read(colAt.get(colId)),
44240
+ grand: read(answers2.grand[0]),
44241
+ cut: answers2.cells.length >= limit
44242
+ };
44243
+ }
44244
+
44179
44245
  // src/ChartLayout.tsx
44180
44246
  var import_react263 = require("react");
44181
44247
  var import_react264 = require("@ai-matrx/records/react");
44182
- var import_records57 = require("@ai-matrx/records");
44248
+ var import_records58 = require("@ai-matrx/records");
44183
44249
  var import_design_system127 = require("@ai-matrx/design-system");
44184
44250
 
44185
44251
  // src/ChartBlock.tsx
44186
44252
  var import_react262 = require("react");
44187
44253
  var import_recharts = require("recharts");
44188
- var import_records56 = require("@ai-matrx/records");
44254
+ var import_records57 = require("@ai-matrx/records");
44189
44255
  var import_core21 = require("@ai-matrx/records/core");
44190
44256
  var import_design_system126 = require("@ai-matrx/design-system");
44191
44257
  var import_format11 = require("@ai-matrx/kit/format");
@@ -44766,7 +44832,7 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
44766
44832
  const kind2 = shape ? BASE_KIND_OF_SHAPE[shape] : block.kind;
44767
44833
  const tableId = block.table_id ?? subject;
44768
44834
  const measures = block.measures && block.measures.length > 0 ? block.measures : [{ op: "count" }];
44769
- const primary = (0, import_records56.measureKey)(measures[0]);
44835
+ const primary = (0, import_records57.measureKey)(measures[0]);
44770
44836
  const windows = kind2 === "stuck" ? null : block.compare ?? null;
44771
44837
  const compared = !!windows;
44772
44838
  const grain = block.bucket?.by ?? null;
@@ -44776,7 +44842,7 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
44776
44842
  const measureFields = useMeasureFields(primary, source ? void 0 : tableId);
44777
44843
  const measureName = useMeasureWords(primary, tableId);
44778
44844
  const numberFormat = (0, import_react262.useMemo)(() => source ? null : chartFormatFor(primary, measureFields), [source, primary, measureFields]);
44779
- const yKey = drawn === "scatter" && measures[1] ? (0, import_records56.measureKey)(measures[1]) : null;
44845
+ const yKey = drawn === "scatter" && measures[1] ? (0, import_records57.measureKey)(measures[1]) : null;
44780
44846
  const yName = useMeasureWords(yKey ?? primary, tableId);
44781
44847
  const points = (0, import_react262.useMemo)(() => {
44782
44848
  if (kind2 === "stuck") return [];
@@ -45490,13 +45556,12 @@ var import_jsx_runtime151 = require("react/jsx-runtime");
45490
45556
  var KIND_LABEL = { bar: "Bars", line: "Line", area: "Area", donut: "Donut", pie: "Pie", stacked: "Stacked bars", scatter: "Scatter" };
45491
45557
  var BASE_SHAPES = ["bar", "line", "donut"];
45492
45558
  var MEASURE_LABEL2 = { count: "Count", sum: "Sum", avg: "Average" };
45493
- var NUMBER_TYPES = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage"]);
45494
45559
  var DATE_TYPES = /* @__PURE__ */ new Set(["date", "datetime", "timestamp"]);
45495
45560
  var isChartKind = (v) => Object.prototype.hasOwnProperty.call(KIND_LABEL, v ?? "");
45496
45561
  var isChartMeasure = (v) => v === "count" || v === "sum" || v === "avg";
45497
45562
  function defaultChartGroup(fields) {
45498
45563
  return fields.find((f) => {
45499
- const kind2 = (0, import_records57.fieldKindFor)(f);
45564
+ const kind2 = (0, import_records58.fieldKindFor)(f);
45500
45565
  return kind2 === "select" || kind2 === "multi_select";
45501
45566
  })?.key ?? null;
45502
45567
  }
@@ -45548,7 +45613,7 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
45548
45613
  return;
45549
45614
  }
45550
45615
  const wholeRow = overall && overall.ok ? (overall.data ?? [])[0] : void 0;
45551
- const wholeValue = wholeRow ? wholeRow.measures[(0, import_records57.measureKey)(question.measure)] : void 0;
45616
+ const wholeValue = wholeRow ? wholeRow.measures[(0, import_records58.measureKey)(question.measure)] : void 0;
45552
45617
  setState({
45553
45618
  error: null,
45554
45619
  ...question.kind === "donut" ? { total: typeof wholeValue === "number" ? wholeValue : null } : {},
@@ -45568,8 +45633,8 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
45568
45633
  };
45569
45634
  }, [client, view.subject, view.name, qKey, filterKey]);
45570
45635
  const groupable = fields.filter((f) => !["attachment", "file", "formula", "button"].includes(String(f.type)));
45571
- const numeric = fields.filter((f) => NUMBER_TYPES.has(String(f.type)));
45572
- const pickMeasure = (0, import_records57.measureKey)(q.measure);
45636
+ const numeric = fields.filter(isNumberField);
45637
+ const pickMeasure = (0, import_records58.measureKey)(q.measure);
45573
45638
  const dataLabels = view.presentation?.chartLabels === true;
45574
45639
  const legend = view.presentation?.chartLegend !== false;
45575
45640
  const setLook = (patch) => onChange({ presentation: { ...view.presentation, ...patch } });
@@ -45636,69 +45701,6 @@ var import_design_system128 = require("@ai-matrx/design-system");
45636
45701
  var import_skeleton2 = require("@ai-matrx/design-system/skeleton");
45637
45702
  init_host();
45638
45703
  init_names();
45639
-
45640
- // src/pivot.ts
45641
- var import_records58 = require("@ai-matrx/records");
45642
- var PIVOT_OPS = ["count", "sum", "avg", "min", "max"];
45643
- var isPivotOp = (v) => PIVOT_OPS.includes(v ?? "");
45644
- var PIVOT_OP_LABEL = { count: "Count", sum: "Sum", avg: "Average", min: "Min", max: "Max" };
45645
- var PIVOT_CELL_LIMIT = 1e3;
45646
- var NUMBER_TYPES2 = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage"]);
45647
- var isNumberField = (f) => NUMBER_TYPES2.has(String(f.type));
45648
- function pivotQuestion(view, fields) {
45649
- const has = (key) => key && fields.some((f) => f.key === key) ? key : null;
45650
- const rowKey = has(view.groupField);
45651
- const colKey = has(view.columnField) !== rowKey ? has(view.columnField) : null;
45652
- const op2 = isPivotOp(view.pivotMeasure) ? view.pivotMeasure : "count";
45653
- const field2 = view.measure ? fields.find((f) => f.key === view.measure && isNumberField(f)) : void 0;
45654
- const fellBack = op2 !== "count" && !field2;
45655
- const measure = op2 !== "count" && field2 ? { op: op2, key: field2.key } : { op: "count" };
45656
- return { rowKey, colKey, op: fellBack ? "count" : op2, measure, fellBack };
45657
- }
45658
- var NONE3 = "\0none";
45659
- function groupId(value) {
45660
- return value === null || value === void 0 || value === "" ? NONE3 : String(value);
45661
- }
45662
- function byValue(a, b) {
45663
- if (a.id === NONE3 || b.id === NONE3) return a.id === b.id ? 0 : a.id === NONE3 ? 1 : -1;
45664
- const x = typeof a.value === "number" ? a.value : null;
45665
- const y = typeof b.value === "number" ? b.value : null;
45666
- if (x !== null && y !== null) return x - y;
45667
- return a.label.localeCompare(b.label, void 0, { numeric: true, sensitivity: "base" });
45668
- }
45669
- function pivotTable(q, answers2, label, limit = PIVOT_CELL_LIMIT) {
45670
- const m = (0, import_records58.measureKey)(q.measure);
45671
- const read = (r) => r ? { value: typeof r.measures?.[m] === "number" ? r.measures[m] : null, n: r.row_count } : null;
45672
- const axis = (key, sources) => {
45673
- if (!key) return [{ id: NONE3, value: null, label: "" }];
45674
- const seen = /* @__PURE__ */ new Map();
45675
- for (const rows2 of sources)
45676
- for (const r of rows2) {
45677
- const raw = r.groups?.[key];
45678
- const id = groupId(raw);
45679
- if (!seen.has(id)) seen.set(id, { id, value: id === NONE3 ? null : raw, label: id === NONE3 ? "\u2014" : label(key, raw) });
45680
- }
45681
- return [...seen.values()].sort(byValue);
45682
- };
45683
- const rows = axis(q.rowKey, [answers2.rowTotals, answers2.cells]);
45684
- const cols = axis(q.colKey, [answers2.colTotals, answers2.cells]);
45685
- const cellAt = /* @__PURE__ */ new Map();
45686
- for (const r of answers2.cells) cellAt.set(`${groupId(q.rowKey ? r.groups?.[q.rowKey] : null)}${groupId(q.colKey ? r.groups?.[q.colKey] : null)}`, r);
45687
- const rowAt = new Map(answers2.rowTotals.map((r) => [groupId(q.rowKey ? r.groups?.[q.rowKey] : null), r]));
45688
- const colAt = new Map(answers2.colTotals.map((r) => [groupId(q.colKey ? r.groups?.[q.colKey] : null), r]));
45689
- return {
45690
- rows,
45691
- cols,
45692
- // With no row Field every cell is the one row; with no column Field, the one column.
45693
- cell: (rowId, colId) => read(cellAt.get(`${rowId}${colId}`)),
45694
- rowTotal: (rowId) => read(rowAt.get(rowId)),
45695
- colTotal: (colId) => read(colAt.get(colId)),
45696
- grand: read(answers2.grand[0]),
45697
- cut: answers2.cells.length >= limit
45698
- };
45699
- }
45700
-
45701
- // src/PivotLayout.tsx
45702
45704
  init_Refusal();
45703
45705
  var import_jsx_runtime152 = require("react/jsx-runtime");
45704
45706
  var PIVOT_BOX = "min-h-[16rem]";
@@ -45883,9 +45885,9 @@ var import_design_system129 = require("@ai-matrx/design-system");
45883
45885
  init_host();
45884
45886
 
45885
45887
  // src/mapPins.ts
45886
- var NUMBER_TYPES3 = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage", "range"]);
45888
+ var NUMBER_TYPES2 = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage", "range"]);
45887
45889
  function isNumberField2(field2) {
45888
- if (!NUMBER_TYPES3.has(String(field2.type))) return false;
45890
+ if (!NUMBER_TYPES2.has(String(field2.type))) return false;
45889
45891
  const kind2 = String((field2.config ?? {})["kind"] ?? "number");
45890
45892
  return kind2 !== "date" && kind2 !== "datetime";
45891
45893
  }
@@ -63124,6 +63126,7 @@ var import_react361 = require("@ai-matrx/records/react");
63124
63126
  var import_design_system181 = require("@ai-matrx/design-system");
63125
63127
  var import_icons3 = require("@ai-matrx/design-system/icons");
63126
63128
  var import_field_formats12 = require("@ai-matrx/design-system/field-formats");
63129
+ var import_controls14 = require("@ai-matrx/design-system/controls");
63127
63130
  init_names();
63128
63131
  init_plainWords();
63129
63132
 
@@ -63520,7 +63523,7 @@ function ChecksLine({ checks, onFix }) {
63520
63523
  if (checks.length === 0) return null;
63521
63524
  return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "mt-1 flex flex-col items-start gap-1", children: checks.map((check, i) => /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("span", { className: "flex flex-col items-start gap-1", children: [
63522
63525
  /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "text-xs text-warning-ink", children: check.message }),
63523
- check.fix && onFix ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.Button, { type: "button", size: "sm", variant: "outline", className: "h-6 px-2 text-xs", onClick: () => onFix(check), children: check.fix.label }) : null
63526
+ check.fix && onFix ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_controls14.Button, { type: "button", variant: "outline", onClick: () => onFix(check), children: check.fix.label }) : null
63524
63527
  ] }, i)) });
63525
63528
  }
63526
63529
  function ValueCell({
@@ -63529,7 +63532,8 @@ function ValueCell({
63529
63532
  editable,
63530
63533
  save,
63531
63534
  onFix,
63532
- context
63535
+ context,
63536
+ stacked
63533
63537
  }) {
63534
63538
  const { field: field2, format } = column;
63535
63539
  const stored = (row.document ?? {})[field2.key];
@@ -63542,11 +63546,12 @@ function ValueCell({
63542
63546
  if (format?.id === "color_pair") {
63543
63547
  const pair = (0, import_field_formats12.readColorPair)(value) ?? null;
63544
63548
  const contrast = pair ? colorPairContrast(pair, format, context) : {};
63545
- return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
63549
+ return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: stacked ? "flex min-w-0 flex-col gap-1.5" : "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
63546
63550
  const side = part === "light" ? pair?.light : pair?.dark ?? void 0;
63547
63551
  const ratio = contrast[part];
63548
- return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "min-w-0 px-3", children: [
63552
+ return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: stacked ? "min-w-0" : "min-w-0 px-3", children: [
63549
63553
  /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [
63554
+ stacked ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "w-9 shrink-0 text-xs text-muted-foreground", children: part === "light" ? "Light" : "Dark" }) : null,
63550
63555
  editable ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
63551
63556
  ColorWell,
63552
63557
  {
@@ -63562,7 +63567,7 @@ function ValueCell({
63562
63567
  }
63563
63568
  }
63564
63569
  ) : /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("code", { className: "font-mono text-xs uppercase", children: side ?? (part === "dark" ? "Inherits light" : "\u2014") }),
63565
- ratio !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ContrastMark, { ratio }) : null
63570
+ ratio !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ContrastMark, { ratio, min: pair?.min }) : null
63566
63571
  ] }),
63567
63572
  /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ChecksLine, { checks: checks.filter((c) => c.part === part), onFix: fix })
63568
63573
  ] }, part);
@@ -63573,25 +63578,28 @@ function ValueCell({
63573
63578
  const ownDark = typeof value === "string" && value.includes('"dark"');
63574
63579
  const pack = (l) => l.length === 1 ? l[0] : { layers: l };
63575
63580
  const write = (light, dark) => change(JSON.stringify(dark ? { light: pack(light), dark: pack(dark) } : pack(light)));
63576
- return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
63581
+ return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: stacked ? "flex min-w-0 flex-col gap-1.5" : "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
63577
63582
  const layers = pair ? pair[part] : null;
63578
63583
  const words2 = !layers ? "Set" : part === "dark" && !ownDark ? "Same as light" : (0, import_field_formats12.shadowWords)(layers);
63579
63584
  const inner2 = /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("span", { className: "flex min-w-0 items-center gap-2", children: [
63580
63585
  layers ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ShadowSwatch, { layers, theme: part }) : null,
63581
63586
  /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: (0, import_design_system181.cn)("truncate text-xs", part === "dark" && !ownDark ? "text-muted-foreground" : "text-foreground"), children: words2 })
63582
63587
  ] });
63583
- return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "min-w-0 px-3", children: editable ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Popover, { children: [
63584
- /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("button", { type: "button", "aria-label": `${fieldName(field2)} ${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: inner2 }) }),
63585
- /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverContent, { align: "start", className: "w-80", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
63586
- ShadowLayersEditor,
63587
- {
63588
- layers: layers ?? [{ x: 0, y: 4, blur: 12, spread: 0, color: "#0000001f" }],
63589
- id: `${id}-${part}`,
63590
- label: `${fieldName(field2)} ${part}`,
63591
- onChange: (next) => part === "light" ? write(next, ownDark && pair ? pair.dark : null) : write(pair ? pair.light : next, next)
63592
- }
63593
- ) })
63594
- ] }) : inner2 }, part);
63588
+ return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: stacked ? "flex min-w-0 items-center gap-2" : "min-w-0 px-3", children: [
63589
+ stacked ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "w-9 shrink-0 text-xs text-muted-foreground", children: part === "light" ? "Light" : "Dark" }) : null,
63590
+ editable ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Popover, { children: [
63591
+ /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("button", { type: "button", "aria-label": `${fieldName(field2)} ${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: inner2 }) }),
63592
+ /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverContent, { align: "start", className: "w-80", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
63593
+ ShadowLayersEditor,
63594
+ {
63595
+ layers: layers ?? [{ x: 0, y: 4, blur: 12, spread: 0, color: "#0000001f" }],
63596
+ id: `${id}-${part}`,
63597
+ label: `${fieldName(field2)} ${part}`,
63598
+ onChange: (next) => part === "light" ? write(next, ownDark && pair ? pair.dark : null) : write(pair ? pair.light : next, next)
63599
+ }
63600
+ ) })
63601
+ ] }) : inner2
63602
+ ] }, part);
63595
63603
  }) });
63596
63604
  }
63597
63605
  const look = fieldLookFor(format?.id);
@@ -63676,20 +63684,15 @@ function groundOf(row, rows, keys) {
63676
63684
  }
63677
63685
  function RowComments({ tableId, row, count, onClosed }) {
63678
63686
  return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Popover, { onOpenChange: (open) => !open && onClosed(), children: [
63679
- /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(
63680
- "button",
63687
+ /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
63688
+ import_controls14.Button,
63681
63689
  {
63682
63690
  type: "button",
63691
+ variant: "quiet",
63692
+ icon: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.MessageSquareIcon, {}),
63693
+ badge: count,
63683
63694
  "aria-label": count > 0 ? `${count} open comment${count === 1 ? "" : "s"}` : "Comment",
63684
- "data-records-row-comments": count,
63685
- className: (0, import_design_system181.cn)(
63686
- "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",
63687
- count > 0 ? "text-foreground" : "text-muted-foreground"
63688
- ),
63689
- children: [
63690
- /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.MessageSquareIcon, { className: "h-3.5 w-3.5" }),
63691
- count > 0 ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "text-xs tabular-nums", children: count }) : null
63692
- ]
63695
+ "data-records-row-comments": count
63693
63696
  }
63694
63697
  ) }),
63695
63698
  /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverContent, { align: "end", className: "w-96 p-0", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(CommentThread, { tableId, recordId: row.id, className: "max-h-[70dvh] overflow-y-auto p-3" }) })
@@ -63702,16 +63705,14 @@ function NoteButton({ row, noteField, editable, save }) {
63702
63705
  const has = text.trim() !== "";
63703
63706
  return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Popover, { children: [
63704
63707
  /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
63705
- "button",
63708
+ import_controls14.Button,
63706
63709
  {
63707
63710
  type: "button",
63711
+ variant: "quiet",
63712
+ icon: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.StickyNoteIcon, {}),
63713
+ pressed: has,
63708
63714
  "aria-label": has ? `${fieldName(noteField)}: ${text}` : `Add ${fieldName(noteField).toLowerCase()}`,
63709
- title: has ? text : fieldName(noteField),
63710
- className: (0, import_design_system181.cn)(
63711
- "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",
63712
- has ? "text-foreground" : "text-muted-foreground"
63713
- ),
63714
- children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.StickyNoteIcon, { className: "h-4 w-4" })
63715
+ title: has ? text : fieldName(noteField)
63715
63716
  }
63716
63717
  ) }),
63717
63718
  /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverContent, { align: "end", className: "w-72", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
@@ -63825,8 +63826,8 @@ function AddDialog({
63825
63826
  /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.BasicTextarea, { 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) })
63826
63827
  ] }) : null,
63827
63828
  /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "flex justify-end gap-2 pt-1", children: [
63828
- /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: "Cancel" }),
63829
- /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.Button, { type: "submit", disabled: !ready, children: "Add" })
63829
+ /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_controls14.Button, { type: "button", variant: "quiet", onClick: () => onOpenChange(false), children: "Cancel" }),
63830
+ /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_controls14.Button, { type: "submit", variant: "primary", disabled: !ready, children: "Add" })
63830
63831
  ] })
63831
63832
  ]
63832
63833
  }
@@ -63905,27 +63906,15 @@ function TableSectionCard(props) {
63905
63906
  return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("section", { ref: sectionRef, "data-records-section-card": "", "data-narrow": narrow ? "" : void 0, className: (0, import_design_system181.cn)("rounded-2xl border border-border bg-card text-card-foreground", className), children: [
63906
63907
  /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("header", { className: "flex items-start justify-between gap-4 px-5 pt-5 pb-3 sm:px-6", children: [
63907
63908
  /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "min-w-0", children: [
63908
- /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("h2", { className: "truncate font-serif text-2xl tracking-tight text-foreground", children: title || "\xA0" }),
63909
+ /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("h2", { className: "type-heading truncate text-foreground", children: title || "\xA0" }),
63909
63910
  props.description ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: props.description }) : null
63910
63911
  ] }),
63911
- mayWrite && nameField ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Button, { type: "button", variant: "outline", size: "sm", onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED2), children: [
63912
- /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.PlusIcon, { className: "h-3.5 w-3.5" }),
63913
- "Add"
63914
- ] }) : null
63912
+ mayWrite && nameField ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_controls14.Button, { type: "button", variant: "outline", icon: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.PlusIcon, {}), onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED2), children: "Add" }) : null
63915
63913
  ] }),
63916
63914
  refused ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("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__ */ (0, import_jsx_runtime207.jsx)("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__ */ (0, import_jsx_runtime207.jsx)("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." }) : /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: (0, import_design_system181.cn)("-mb-px", !narrow && "overflow-x-auto"), children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { "data-records-section-group": group.key, className: "", children: [
63917
63915
  cols.group ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
63918
63916
  /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
63919
- mayWrite ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
63920
- "button",
63921
- {
63922
- type: "button",
63923
- "aria-label": `Add to ${group.key || "no group"}`,
63924
- 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",
63925
- onClick: () => setAdding(group.key),
63926
- children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.PlusIcon, { className: "h-4 w-4" })
63927
- }
63928
- ) : null
63917
+ mayWrite ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_controls14.Button, { type: "button", variant: "quiet", icon: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.PlusIcon, {}), "aria-label": `Add to ${group.key || "no group"}`, onClick: () => setAdding(group.key) }) : null
63929
63918
  ] }) : null,
63930
63919
  /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { role: "table", "aria-label": group.key || title, className: narrow ? "" : "min-w-[36rem]", children: [
63931
63920
  /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { role: "row", style: gridStyle, className: (0, import_design_system181.cn)("grid border-b border-border text-xs text-muted-foreground", narrow && "hidden"), children: [
@@ -63965,7 +63954,7 @@ function TableSectionCard(props) {
63965
63954
  style: c.part ? { gridColumn: "span 2" } : void 0,
63966
63955
  className: narrow ? "min-w-0" : (0, import_design_system181.cn)("min-w-0 py-1", c.part ? "" : "px-3"),
63967
63956
  children: [
63968
- narrow ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "mb-0.5 block text-xs text-muted-foreground", children: cellLabel(c) }) : null,
63957
+ narrow && !c.part ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "mb-0.5 block text-xs text-muted-foreground", children: cellLabel(c) }) : null,
63969
63958
  /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
63970
63959
  ValueCell,
63971
63960
  {
@@ -63974,7 +63963,8 @@ function TableSectionCard(props) {
63974
63963
  editable,
63975
63964
  save: rowSave,
63976
63965
  onFix,
63977
- context: c.field.key === readsOnColorKey ? groundOf(row, rows, { name: cols.name, readsOn: cols.readsOn, color: c.field.key }) : void 0
63966
+ context: c.field.key === readsOnColorKey ? groundOf(row, rows, { name: cols.name, readsOn: cols.readsOn, color: c.field.key }) : void 0,
63967
+ stacked: narrow
63978
63968
  }
63979
63969
  )
63980
63970
  ]