@ai-matrx/records-ui 0.113.3 → 0.113.4

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.js CHANGED
@@ -671,6 +671,7 @@ function personWallNow(at = /* @__PURE__ */ new Date()) {
671
671
  }
672
672
 
673
673
  // src/choiceLooks.ts
674
+ import { newerKindOf } from "@ai-matrx/records";
674
675
  import {
675
676
  CHOICE_CHIP_CLASS,
676
677
  NEUTRAL_CHIP_CLASS,
@@ -709,6 +710,20 @@ function choiceLooksOf(field2) {
709
710
  function choiceWord(value) {
710
711
  return String(value ?? "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
711
712
  }
713
+ var STATUS_GROUP_COLOR = { todo: "gray", in_progress: "blue", done: "green" };
714
+ function statusGroupColor(field2, value) {
715
+ if (newerKindOf(field2) !== "status" || value === null || value === void 0 || value === "") return void 0;
716
+ const word = choiceWord(value);
717
+ if (word === "") return void 0;
718
+ const groups = (field2.config ?? {})["status_groups"];
719
+ if (groups && typeof groups === "object") {
720
+ for (const [key, group] of Object.entries(groups)) {
721
+ if (choiceWord(key) !== word) continue;
722
+ return group === "in_progress" ? STATUS_GROUP_COLOR.in_progress : group === "done" ? STATUS_GROUP_COLOR.done : STATUS_GROUP_COLOR.todo;
723
+ }
724
+ }
725
+ return STATUS_GROUP_COLOR.todo;
726
+ }
712
727
  function storedChoiceColor(field2, value) {
713
728
  if (value === null || value === void 0 || value === "") return void 0;
714
729
  const word = choiceWord(value);
@@ -717,7 +732,7 @@ function storedChoiceColor(field2, value) {
717
732
  if (!look.color) continue;
718
733
  if (choiceWord(look.value) === word || look.label && choiceWord(look.label) === word) return look.color;
719
734
  }
720
- return void 0;
735
+ return statusGroupColor(field2, value);
721
736
  }
722
737
  function storedChoiceColorLookup(fields, fallback) {
723
738
  const byKey = new Map(fields.map((f) => [f.key, f]));
@@ -745,7 +760,7 @@ import {
745
760
  KERNEL_TABLES,
746
761
  PARITY_FIELD_TYPES as PARITY_FIELD_TYPES2,
747
762
  fieldKindFor,
748
- newerKindOf
763
+ newerKindOf as newerKindOf2
749
764
  } from "@ai-matrx/records";
750
765
  import { humanizeIdentifier as humanizeIdentifier2 } from "@ai-matrx/kit/text-case";
751
766
 
@@ -892,7 +907,7 @@ function editorKindFor(field2) {
892
907
  }
893
908
  function pickableTypeOf(field2) {
894
909
  if (isSignatureField(field2)) return "signature";
895
- const newer = newerKindOf(field2);
910
+ const newer = newerKindOf2(field2);
896
911
  if (newer) return newer;
897
912
  const look = displayFormatOf(field2)?.id;
898
913
  if (look === "rating" && field2.type === "range") return "rating";
@@ -3785,7 +3800,7 @@ import {
3785
3800
  COLOR_ROTATION
3786
3801
  } from "@ai-matrx/design-system/data-table";
3787
3802
  import { getFieldFormat } from "@ai-matrx/design-system/field-formats";
3788
- import { newerKindOf as newerKindOf2, ratingMaxOf } from "@ai-matrx/records";
3803
+ import { newerKindOf as newerKindOf3, ratingMaxOf } from "@ai-matrx/records";
3789
3804
 
3790
3805
  // src/dates.ts
3791
3806
  import { formatFieldValue } from "@ai-matrx/design-system/field-formats";
@@ -4063,7 +4078,7 @@ function shownAsOf(field2) {
4063
4078
  }
4064
4079
  function formatForField(field2) {
4065
4080
  const shownAs = shownAsOf(field2);
4066
- if (newerKindOf2(field2) === "rating" && (!shownAs || shownAs.id === "rating")) {
4081
+ if (newerKindOf3(field2) === "rating" && (!shownAs || shownAs.id === "rating")) {
4067
4082
  return { id: "rating", options: { ...shownAs?.options ?? {}, ratingMax: ratingMaxOf(field2) } };
4068
4083
  }
4069
4084
  if (shownAs) return shownAs;
@@ -4186,7 +4201,7 @@ function resolveTableStyle(decorations, fields, viewStyle) {
4186
4201
 
4187
4202
  // src/editors.tsx
4188
4203
  import { useCallback as useCallback7, useEffect as useEffect14, useLayoutEffect as useLayoutEffect2, useRef as useRef14, useState as useState19 } from "react";
4189
- import { allowsOtherValues, choiceValuesOf, coerceTypedAnswer, newerKindOf as newerKindOf4, decideTypedChoice, isTheChosen, optionKey as optionKey2, rankTypedMatches as rankTypedMatches3, readTypedTime as readTypedTime2, typedDateText as typedDateText2, typedTimeText as typedTimeText2 } from "@ai-matrx/records";
4204
+ import { allowsOtherValues, choiceValuesOf, coerceTypedAnswer, newerKindOf as newerKindOf5, decideTypedChoice, isTheChosen, optionKey as optionKey2, rankTypedMatches as rankTypedMatches3, readTypedTime as readTypedTime2, typedDateText as typedDateText2, typedTimeText as typedTimeText2 } from "@ai-matrx/records";
4190
4205
  import { useOptionalRecordsClient as useOptionalRecordsClient7 } from "@ai-matrx/records/react";
4191
4206
  import {
4192
4207
  BasicInput as BasicInput6,
@@ -4218,7 +4233,7 @@ import {
4218
4233
  durationText,
4219
4234
  isAddressValue,
4220
4235
  isPersonStamp,
4221
- newerKindOf as newerKindOf3,
4236
+ newerKindOf as newerKindOf4,
4222
4237
  personStampText,
4223
4238
  readTypedDuration,
4224
4239
  safeLinkHref,
@@ -4228,7 +4243,7 @@ import { BasicInput as BasicInput3, cn as cn9 } from "@ai-matrx/design-system";
4228
4243
  import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
4229
4244
  var own = (event) => event.stopPropagation();
4230
4245
  function newerKindValue(field2, value, opts = {}) {
4231
- switch (newerKindOf3(field2)) {
4246
+ switch (newerKindOf4(field2)) {
4232
4247
  case "duration": {
4233
4248
  const words2 = durationText(value);
4234
4249
  return words2 === null ? void 0 : /* @__PURE__ */ jsx13("span", { className: "tabular-nums", "data-records-duration": "", children: words2 });
@@ -4291,7 +4306,7 @@ function AddressLink({ value }) {
4291
4306
  }
4292
4307
  var STATUS_GROUP_MARK = { todo: "\u25CB", in_progress: "\u25D0", done: "\u25CF" };
4293
4308
  function statusMarkOf(field2, value, document2) {
4294
- if (newerKindOf3(field2) !== "status" || typeof value !== "string") return null;
4309
+ if (newerKindOf4(field2) !== "status" || typeof value !== "string") return null;
4295
4310
  const chosen = document2?.["_choices"]?.[field2.key];
4296
4311
  const key = chosen && typeof chosen === "object" && typeof chosen.key === "string" ? chosen.key : value;
4297
4312
  const group = statusGroupOf(field2, key);
@@ -4388,7 +4403,7 @@ function SafeMarkdown({ text: text2, clipped }) {
4388
4403
  );
4389
4404
  }
4390
4405
  function newerKindControl(props) {
4391
- switch (newerKindOf3(props.field)) {
4406
+ switch (newerKindOf4(props.field)) {
4392
4407
  case "duration":
4393
4408
  return /* @__PURE__ */ jsx13(DurationControl, { ...props });
4394
4409
  case "address":
@@ -5832,7 +5847,7 @@ function FieldLabel({ field: field2, htmlFor, children }) {
5832
5847
  return /* @__PURE__ */ jsxs20("div", { className: "flex items-baseline gap-1.5", children: [
5833
5848
  /* @__PURE__ */ jsx22(Label2, { htmlFor, className: "text-xs font-medium", children: fieldName(field2) }),
5834
5849
  field2.required ? /* @__PURE__ */ jsx22("span", { className: "text-xs text-destructive", children: "required" }) : null,
5835
- field2.unit && newerKindOf4(field2) !== "duration" ? /* @__PURE__ */ jsx22("span", { className: "text-xs text-muted-foreground", children: field2.unit }) : null,
5850
+ field2.unit && newerKindOf5(field2) !== "duration" ? /* @__PURE__ */ jsx22("span", { className: "text-xs text-muted-foreground", children: field2.unit }) : null,
5836
5851
  children
5837
5852
  ] });
5838
5853
  }
@@ -18607,9 +18622,15 @@ var TYPE_ICON = {
18607
18622
  rollup: FORMULA,
18608
18623
  json: [["path", { d: "M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" }], ["path", { d: "M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" }]]
18609
18624
  };
18625
+ var CLOCK = [["circle", { cx: 12, cy: 12, r: 10 }], ["path", { d: "M12 6v6l4 2" }]];
18626
+ var PERSON_PLUS = [["path", { d: "M2 21a8 8 0 0 1 13.292-6" }], ["circle", { cx: 10, cy: 8, r: 5 }], ["path", { d: "M19 16v6" }], ["path", { d: "M22 19h-6" }]];
18627
+ var PERSON_PEN = [["path", { d: "M11.5 15H7a4 4 0 0 0-4 4v2" }], ["path", { d: "M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z" }], ["circle", { cx: 10, cy: 7, r: 4 }]];
18628
+ var STAMP_ICON = { created_time: CLOCK, modified_time: CLOCK, created_by: PERSON_PLUS, modified_by: PERSON_PEN };
18610
18629
  function withTypeMark(field2, header) {
18611
- const kind = editorKindFor(field2);
18612
- const parts = TYPE_ICON[kind] ?? TYPE_ICON.text;
18630
+ const picked = pickableTypeOf(field2);
18631
+ const stamp = picked !== void 0 && picked in STAMP_ICON ? picked : void 0;
18632
+ const kind = stamp ?? editorKindFor(field2);
18633
+ const parts = (stamp ? STAMP_ICON[stamp] : TYPE_ICON[editorKindFor(field2)]) ?? TYPE_ICON.text;
18613
18634
  return /* @__PURE__ */ jsxs55("span", { className: "inline-flex min-w-0 items-center gap-1.5", "data-records-type-mark": kind, children: [
18614
18635
  /* @__PURE__ */ jsx60(
18615
18636
  "svg",
@@ -30076,12 +30097,12 @@ function ShareForSomebodyElse({
30076
30097
  // src/RecordBody.tsx
30077
30098
  import { useEffect as useEffect69, useRef as useRef42, useState as useState80 } from "react";
30078
30099
  import { Button as Button61, cn as cn49 } from "@ai-matrx/design-system";
30079
- import { newerKindOf as newerKindOf5 } from "@ai-matrx/records";
30100
+ import { newerKindOf as newerKindOf6 } from "@ai-matrx/records";
30080
30101
  import { tableShapeChanged as tableShapeChanged11, useFieldMutation as useFieldMutation5, useFields as useFields14, useRecord as useRecord2, useRecordsClient as useRecordsClient58, useTable as useTable14 } from "@ai-matrx/records/react";
30081
30102
  import { Fragment as Fragment37, jsx as jsx99, jsxs as jsxs90 } from "react/jsx-runtime";
30082
30103
  var BODY_NAMES = /^(notes?|page|body|content|page content|details|description)$/i;
30083
30104
  function bodyFieldOf(fields) {
30084
- const rich2 = fields.filter((field2) => newerKindOf5(field2) === "rich_text");
30105
+ const rich2 = fields.filter((field2) => newerKindOf6(field2) === "rich_text");
30085
30106
  return rich2.find((field2) => BODY_NAMES.test((field2.label ?? field2.key).trim()) || BODY_NAMES.test(field2.key.replace(/_/g, " "))) ?? rich2[0];
30086
30107
  }
30087
30108
  var BODY_COLUMN_NAME = "Notes";
@@ -30488,7 +30509,7 @@ function usePlatformTable(spec) {
30488
30509
  // src/ViewSwitcher.tsx
30489
30510
  import { useEffect as useEffect78, useMemo as useMemo56, useState as useState90 } from "react";
30490
30511
  import { mayDrag as mayDrag4, useFields as useFields18, useRecordPage as useRecordPage2, useRecordsClient as useRecordsClient65, useTable as useTable18 } from "@ai-matrx/records/react";
30491
- import { newerKindOf as newerKindOf6, stableFilterKey as stableFilterKey4 } from "@ai-matrx/records";
30512
+ import { newerKindOf as newerKindOf7, stableFilterKey as stableFilterKey4 } from "@ai-matrx/records";
30492
30513
  import { Button as Button68, Select as Select16, SelectContent as SelectContent16, SelectItem as SelectItem16, SelectTrigger as SelectTrigger16, SelectValue as SelectValue16, cn as cn56 } from "@ai-matrx/design-system";
30493
30514
  import {
30494
30515
  CHOICE_CHIP_CLASS as CHOICE_CHIP_CLASS4,
@@ -34812,7 +34833,7 @@ function cardHiddenOf(presentation) {
34812
34833
  }
34813
34834
  var STATUS_WORDS = /^(status|stage|state|progress|phase)$/i;
34814
34835
  function boardDefaultGroupField(eligible) {
34815
- return eligible.find((f) => newerKindOf6(f) === "status") ?? eligible.find((f) => STATUS_WORDS.test(fieldName(f).trim()) || STATUS_WORDS.test(f.key)) ?? eligible[0] ?? null;
34836
+ return eligible.find((f) => newerKindOf7(f) === "status") ?? eligible.find((f) => STATUS_WORDS.test(fieldName(f).trim()) || STATUS_WORDS.test(f.key)) ?? eligible[0] ?? null;
34816
34837
  }
34817
34838
 
34818
34839
  // src/ArchivedView.tsx