@ai-matrx/records-ui 0.113.31 → 0.113.33

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/pickers.cjs CHANGED
@@ -2408,9 +2408,9 @@ function EntityReferenceKindPicker({ value, onChange, locked = false, className
2408
2408
  }
2409
2409
 
2410
2410
  // src/SourceArchivedNotice.tsx
2411
- var import_react30 = require("react");
2411
+ var import_react29 = require("react");
2412
2412
  var import_design_system20 = require("@ai-matrx/design-system");
2413
- var import_react31 = require("@ai-matrx/records/react");
2413
+ var import_react30 = require("@ai-matrx/records/react");
2414
2414
 
2415
2415
  // src/values.tsx
2416
2416
  var import_data_table4 = require("@ai-matrx/design-system/data-table");
@@ -2418,19 +2418,99 @@ var import_field_formats4 = require("@ai-matrx/design-system/field-formats");
2418
2418
  var import_design_system19 = require("@ai-matrx/design-system");
2419
2419
 
2420
2420
  // src/embeddedLook.tsx
2421
- var import_react21 = require("react");
2421
+ var import_react16 = require("react");
2422
2422
 
2423
- // src/labels.tsx
2424
- var import_react18 = require("react");
2425
- var import_react19 = require("@ai-matrx/records/react");
2423
+ // src/presentation.ts
2424
+ var import_table_style = require("@ai-matrx/design-system/data-table/table-style");
2425
+ var import_data_table2 = require("@ai-matrx/design-system/data-table");
2426
+ var import_field_formats2 = require("@ai-matrx/design-system/field-formats");
2426
2427
  var import_records9 = require("@ai-matrx/records");
2428
+ var DRAWN_KINDS = /* @__PURE__ */ new Set(["select", "multi_select", "relation", "member", "person", "attachment", "file", "entity_reference", "checkbox", "boolean", "signature", "json"]);
2429
+ function shownAsOf(field) {
2430
+ if (DRAWN_KINDS.has(String(editorKindFor(field)))) return void 0;
2431
+ const raw = field.display_format;
2432
+ if (!raw || typeof raw !== "object") return void 0;
2433
+ const id = raw.id;
2434
+ if (typeof id !== "string" || id === "formula" || !(0, import_field_formats2.getFieldFormat)(id)) return void 0;
2435
+ const options = raw.options;
2436
+ return options && typeof options === "object" && Object.keys(options).length > 0 ? { id, options } : { id };
2437
+ }
2438
+ function formatForField(field) {
2439
+ const shownAs = shownAsOf(field);
2440
+ if ((0, import_records9.newerKindOf)(field) === "rating" && (!shownAs || shownAs.id === "rating")) {
2441
+ return { id: "rating", options: { ...shownAs?.options ?? {}, ratingMax: (0, import_records9.ratingMaxOf)(field) } };
2442
+ }
2443
+ if (shownAs) return shownAs;
2444
+ const stamp = dateFormatFor(field);
2445
+ if (stamp && editorKindFor(field) !== "datetime") return stamp;
2446
+ switch (editorKindFor(field)) {
2447
+ case "currency":
2448
+ return {
2449
+ id: "currency",
2450
+ options: { currency: currencyCodeFor(field.unit) }
2451
+ };
2452
+ case "percent":
2453
+ return { id: "percent" };
2454
+ case "datetime":
2455
+ return String(field.config?.["kind"] ?? "") === "date" ? { id: "date" } : { id: "datetime" };
2456
+ case "email":
2457
+ return { id: "email" };
2458
+ case "url":
2459
+ return { id: "url" };
2460
+ case "phone":
2461
+ return { id: "phone" };
2462
+ case "number":
2463
+ return { id: "number" };
2464
+ default:
2465
+ return void 0;
2466
+ }
2467
+ }
2468
+ var SYMBOL_TO_CODE = {
2469
+ $: "USD",
2470
+ "\xA3": "GBP",
2471
+ "\u20AC": "EUR",
2472
+ "\xA5": "JPY",
2473
+ "\u20B9": "INR",
2474
+ "\u20BD": "RUB",
2475
+ "\u20A9": "KRW",
2476
+ "R$": "BRL",
2477
+ "C$": "CAD",
2478
+ "A$": "AUD"
2479
+ };
2480
+ function currencyCodeFor(unit) {
2481
+ const raw = (unit ?? "").trim();
2482
+ if (raw === "") return "USD";
2483
+ return SYMBOL_TO_CODE[raw] ?? raw.toUpperCase();
2484
+ }
2485
+
2486
+ // src/embeddedLook.tsx
2487
+ var EmbeddedLookContext = (0, import_react16.createContext)(null);
2488
+ var EmbeddedLookProvider = EmbeddedLookContext.Provider;
2489
+ function useEmbeddedLook() {
2490
+ return (0, import_react16.useContext)(EmbeddedLookContext);
2491
+ }
2492
+ var EMBEDDED_TABLE_CLASS = [
2493
+ "[&_tbody_td]:h-10",
2494
+ "[&_tbody_td]:align-middle!",
2495
+ "[&_tbody_td]:border-r",
2496
+ "[&_tbody_td]:border-border",
2497
+ "[&_tbody_td:last-child]:border-r-0",
2498
+ "[&_thead_th]:border-r",
2499
+ "[&_thead_th]:border-border",
2500
+ "[&_thead_th:last-child]:border-r-0"
2501
+ ].join(" ");
2502
+
2503
+ // src/labels.tsx
2504
+ var import_react19 = require("react");
2505
+ var import_react20 = require("@ai-matrx/records/react");
2427
2506
  var import_records10 = require("@ai-matrx/records");
2507
+ var import_records11 = require("@ai-matrx/records");
2428
2508
  var import_uuid2 = require("@ai-matrx/kit/uuid");
2429
2509
 
2430
2510
  // src/signature.tsx
2431
- var import_react16 = require("react");
2511
+ var import_react17 = require("react");
2432
2512
  var import_design_system11 = require("@ai-matrx/design-system");
2433
- var import_react17 = require("@ai-matrx/records/react");
2513
+ var import_react18 = require("@ai-matrx/records/react");
2434
2514
  var import_jsx_runtime12 = require("react/jsx-runtime");
2435
2515
  var DRAWN = /^data:image\/(png|jpeg);base64,[A-Za-z0-9+/=]{64,}$/;
2436
2516
  function drawnSignatureOf(value) {
@@ -2505,10 +2585,10 @@ function SignatureDrawing({
2505
2585
  value,
2506
2586
  inCell
2507
2587
  }) {
2508
- const client = (0, import_react17.useOptionalRecordsClient)();
2588
+ const client = (0, import_react18.useOptionalRecordsClient)();
2509
2589
  const host = useRecordsUi();
2510
- const [drawing, setDrawing] = (0, import_react16.useState)(null);
2511
- (0, import_react16.useEffect)(() => {
2590
+ const [drawing, setDrawing] = (0, import_react17.useState)(null);
2591
+ (0, import_react17.useEffect)(() => {
2512
2592
  let cancelled = false;
2513
2593
  setDrawing(null);
2514
2594
  if (!client) return;
@@ -2555,12 +2635,12 @@ function SignaturePad({
2555
2635
  }) {
2556
2636
  const kept = drawnSignatureOf(value);
2557
2637
  const named = !kept && typeof value === "string" && value !== "" ? value : null;
2558
- const [showPad, setShowPad] = (0, import_react16.useState)(() => !kept && !named);
2559
- const canvasRef = (0, import_react16.useRef)(null);
2560
- const drawing = (0, import_react16.useRef)(false);
2561
- const [dirty, setDirty] = (0, import_react16.useState)(false);
2562
- const [tooBig, setTooBig] = (0, import_react16.useState)(false);
2563
- (0, import_react16.useEffect)(() => {
2638
+ const [showPad, setShowPad] = (0, import_react17.useState)(() => !kept && !named);
2639
+ const canvasRef = (0, import_react17.useRef)(null);
2640
+ const drawing = (0, import_react17.useRef)(false);
2641
+ const [dirty, setDirty] = (0, import_react17.useState)(false);
2642
+ const [tooBig, setTooBig] = (0, import_react17.useState)(false);
2643
+ (0, import_react17.useEffect)(() => {
2564
2644
  if (!showPad) return;
2565
2645
  const canvas = canvasRef.current;
2566
2646
  if (!canvas) return;
@@ -2699,7 +2779,7 @@ function encodeAt(canvas, type, maxWidth, quality) {
2699
2779
 
2700
2780
  // src/labels.tsx
2701
2781
  var import_jsx_runtime13 = require("react/jsx-runtime");
2702
- var LabelContext = (0, import_react18.createContext)({
2782
+ var LabelContext = (0, import_react19.createContext)({
2703
2783
  // With no provider the resolver is ABSENT, not silently empty: a caller gets
2704
2784
  // null and says "Loading…" forever, which is visible. The mount always
2705
2785
  // provides one, so this is only ever a bare unit test.
@@ -2727,16 +2807,16 @@ function pointsAtRecords(field) {
2727
2807
  return field.type === "list" || field.type === "relation";
2728
2808
  }
2729
2809
  function RecordLabelProvider({ children }) {
2730
- const client = (0, import_react19.useRecordsClient)();
2731
- const [names, setNames] = (0, import_react18.useState)({});
2732
- const [archivedRefs, setArchivedRefs] = (0, import_react18.useState)({});
2733
- const [iconsOf, setIconsOf] = (0, import_react18.useState)({});
2734
- const [settled, setSettled] = (0, import_react18.useState)({});
2735
- const [waitingLines, setWaitingLines] = (0, import_react18.useState)({});
2736
- const asked2 = (0, import_react18.useRef)(/* @__PURE__ */ new Set());
2737
- const chased = (0, import_react18.useRef)(/* @__PURE__ */ new Set());
2738
- const timers = (0, import_react18.useRef)(/* @__PURE__ */ new Map());
2739
- const startWaitClock = (0, import_react18.useCallback)((field, target) => {
2810
+ const client = (0, import_react20.useRecordsClient)();
2811
+ const [names, setNames] = (0, import_react19.useState)({});
2812
+ const [archivedRefs, setArchivedRefs] = (0, import_react19.useState)({});
2813
+ const [iconsOf, setIconsOf] = (0, import_react19.useState)({});
2814
+ const [settled, setSettled] = (0, import_react19.useState)({});
2815
+ const [waitingLines, setWaitingLines] = (0, import_react19.useState)({});
2816
+ const asked2 = (0, import_react19.useRef)(/* @__PURE__ */ new Set());
2817
+ const chased = (0, import_react19.useRef)(/* @__PURE__ */ new Set());
2818
+ const timers = (0, import_react19.useRef)(/* @__PURE__ */ new Map());
2819
+ const startWaitClock = (0, import_react19.useCallback)((field, target) => {
2740
2820
  if (timers.current.has(field.id)) return;
2741
2821
  timers.current.set(
2742
2822
  field.id,
@@ -2748,7 +2828,7 @@ function RecordLabelProvider({ children }) {
2748
2828
  }, SAY_WHAT_YOU_ARE_WAITING_FOR_AFTER_MS)
2749
2829
  );
2750
2830
  }, []);
2751
- const stopWaitClock = (0, import_react18.useCallback)((fieldId) => {
2831
+ const stopWaitClock = (0, import_react19.useCallback)((fieldId) => {
2752
2832
  const timer = timers.current.get(fieldId);
2753
2833
  if (timer) {
2754
2834
  clearTimeout(timer);
@@ -2761,14 +2841,14 @@ function RecordLabelProvider({ children }) {
2761
2841
  return next;
2762
2842
  });
2763
2843
  }, []);
2764
- (0, import_react18.useEffect)(
2844
+ (0, import_react19.useEffect)(
2765
2845
  () => () => {
2766
2846
  for (const timer of timers.current.values()) clearTimeout(timer);
2767
2847
  timers.current.clear();
2768
2848
  },
2769
2849
  []
2770
2850
  );
2771
- const want = (0, import_react18.useCallback)(
2851
+ const want = (0, import_react19.useCallback)(
2772
2852
  (field) => {
2773
2853
  if (!pointsAtRecords(field)) return;
2774
2854
  if (asked2.current.has(field.id)) return;
@@ -2783,7 +2863,7 @@ function RecordLabelProvider({ children }) {
2783
2863
  for (const option of result.data ?? []) {
2784
2864
  const words = recordName(option.data, null, "Unnamed choice");
2785
2865
  next[option.id] = words;
2786
- const key = (0, import_records10.optionKey)(option);
2866
+ const key = (0, import_records11.optionKey)(option);
2787
2867
  if (key) next[choiceKeyName(field.id, key)] = words;
2788
2868
  }
2789
2869
  return next;
@@ -2803,9 +2883,9 @@ function RecordLabelProvider({ children }) {
2803
2883
  },
2804
2884
  [client, startWaitClock, stopWaitClock]
2805
2885
  );
2806
- const queued = (0, import_react18.useRef)(/* @__PURE__ */ new Map());
2807
- const flushing = (0, import_react18.useRef)(null);
2808
- const flush = (0, import_react18.useCallback)(() => {
2886
+ const queued = (0, import_react19.useRef)(/* @__PURE__ */ new Map());
2887
+ const flushing = (0, import_react19.useRef)(null);
2888
+ const flush = (0, import_react19.useCallback)(() => {
2809
2889
  flushing.current = null;
2810
2890
  const batch = [...queued.current.values()];
2811
2891
  queued.current.clear();
@@ -2835,7 +2915,7 @@ function RecordLabelProvider({ children }) {
2835
2915
  for (const { field } of batch) stopWaitClock(field.id);
2836
2916
  })();
2837
2917
  }, [client, stopWaitClock]);
2838
- const chase = (0, import_react18.useCallback)(
2918
+ const chase = (0, import_react19.useCallback)(
2839
2919
  (field, id) => {
2840
2920
  const key = `${field.id}:${id}`;
2841
2921
  if (chased.current.has(key)) return;
@@ -2848,14 +2928,14 @@ function RecordLabelProvider({ children }) {
2848
2928
  },
2849
2929
  [flush, startWaitClock]
2850
2930
  );
2851
- (0, import_react18.useEffect)(
2931
+ (0, import_react19.useEffect)(
2852
2932
  () => () => {
2853
2933
  if (flushing.current !== null) clearTimeout(flushing.current);
2854
2934
  },
2855
2935
  []
2856
2936
  );
2857
- const rereadFor = (0, import_react18.useRef)(/* @__PURE__ */ new Set());
2858
- const lookupWords = (0, import_react18.useCallback)(
2937
+ const rereadFor = (0, import_react19.useRef)(/* @__PURE__ */ new Set());
2938
+ const lookupWords = (0, import_react19.useCallback)(
2859
2939
  (field, id) => {
2860
2940
  if (field.type === "list" && !isId(id)) {
2861
2941
  const named = names[choiceKeyName(field.id, id)];
@@ -2875,7 +2955,7 @@ function RecordLabelProvider({ children }) {
2875
2955
  },
2876
2956
  [names, settled, chase, want]
2877
2957
  );
2878
- const lookup = (0, import_react18.useMemo)(
2958
+ const lookup = (0, import_react19.useMemo)(
2879
2959
  () => {
2880
2960
  const answer = ((field, id) => lookupWords(field, id));
2881
2961
  answer.archived = (field, id) => archivedRefs[`${field.id}:${id}`] === true;
@@ -2884,128 +2964,18 @@ function RecordLabelProvider({ children }) {
2884
2964
  },
2885
2965
  [lookupWords, archivedRefs, iconsOf]
2886
2966
  );
2887
- const waiting = (0, import_react18.useCallback)((field) => waitingLines[field.id] ?? null, [waitingLines]);
2888
- const value = (0, import_react18.useMemo)(() => ({ lookup, want, waiting }), [lookup, want, waiting]);
2967
+ const waiting = (0, import_react19.useCallback)((field) => waitingLines[field.id] ?? null, [waitingLines]);
2968
+ const value = (0, import_react19.useMemo)(() => ({ lookup, want, waiting }), [lookup, want, waiting]);
2889
2969
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LabelContext.Provider, { value, children });
2890
2970
  }
2891
2971
  function useRecordLabels(fields) {
2892
- const { lookup, want } = (0, import_react18.useContext)(LabelContext);
2893
- (0, import_react18.useEffect)(() => {
2972
+ const { lookup, want } = (0, import_react19.useContext)(LabelContext);
2973
+ (0, import_react19.useEffect)(() => {
2894
2974
  for (const field of fields ?? []) want(field);
2895
2975
  }, [fields, want]);
2896
2976
  return lookup;
2897
2977
  }
2898
2978
 
2899
- // src/personTime.ts
2900
- var import_react20 = require("react");
2901
- var zone = null;
2902
- var listeners = /* @__PURE__ */ new Set();
2903
- function usePersonTimeZone() {
2904
- return (0, import_react20.useSyncExternalStore)(
2905
- (cb) => {
2906
- listeners.add(cb);
2907
- return () => listeners.delete(cb);
2908
- },
2909
- () => zone,
2910
- () => null
2911
- );
2912
- }
2913
- function personWallNow(at = /* @__PURE__ */ new Date()) {
2914
- if (!zone) return at;
2915
- const parts = new Intl.DateTimeFormat("en-US", {
2916
- timeZone: zone,
2917
- year: "numeric",
2918
- month: "2-digit",
2919
- day: "2-digit",
2920
- hour: "2-digit",
2921
- minute: "2-digit",
2922
- second: "2-digit",
2923
- hourCycle: "h23"
2924
- }).formatToParts(at);
2925
- const n = (t) => Number(parts.find((p) => p.type === t)?.value ?? 0);
2926
- return new Date(n("year"), n("month") - 1, n("day"), n("hour"), n("minute"), n("second"));
2927
- }
2928
-
2929
- // src/presentation.ts
2930
- var import_table_style = require("@ai-matrx/design-system/data-table/table-style");
2931
- var import_data_table2 = require("@ai-matrx/design-system/data-table");
2932
- var import_field_formats2 = require("@ai-matrx/design-system/field-formats");
2933
- var import_records11 = require("@ai-matrx/records");
2934
- var DRAWN_KINDS = /* @__PURE__ */ new Set(["select", "multi_select", "relation", "member", "person", "attachment", "file", "entity_reference", "checkbox", "boolean", "signature", "json"]);
2935
- function shownAsOf(field) {
2936
- if (DRAWN_KINDS.has(String(editorKindFor(field)))) return void 0;
2937
- const raw = field.display_format;
2938
- if (!raw || typeof raw !== "object") return void 0;
2939
- const id = raw.id;
2940
- if (typeof id !== "string" || id === "formula" || !(0, import_field_formats2.getFieldFormat)(id)) return void 0;
2941
- const options = raw.options;
2942
- return options && typeof options === "object" && Object.keys(options).length > 0 ? { id, options } : { id };
2943
- }
2944
- function formatForField(field) {
2945
- const shownAs = shownAsOf(field);
2946
- if ((0, import_records11.newerKindOf)(field) === "rating" && (!shownAs || shownAs.id === "rating")) {
2947
- return { id: "rating", options: { ...shownAs?.options ?? {}, ratingMax: (0, import_records11.ratingMaxOf)(field) } };
2948
- }
2949
- if (shownAs) return shownAs;
2950
- const stamp = dateFormatFor(field);
2951
- if (stamp && editorKindFor(field) !== "datetime") return stamp;
2952
- switch (editorKindFor(field)) {
2953
- case "currency":
2954
- return {
2955
- id: "currency",
2956
- options: { currency: currencyCodeFor(field.unit) }
2957
- };
2958
- case "percent":
2959
- return { id: "percent" };
2960
- case "datetime":
2961
- return String(field.config?.["kind"] ?? "") === "date" ? { id: "date" } : { id: "datetime" };
2962
- case "email":
2963
- return { id: "email" };
2964
- case "url":
2965
- return { id: "url" };
2966
- case "phone":
2967
- return { id: "phone" };
2968
- case "number":
2969
- return { id: "number" };
2970
- default:
2971
- return void 0;
2972
- }
2973
- }
2974
- var SYMBOL_TO_CODE = {
2975
- $: "USD",
2976
- "\xA3": "GBP",
2977
- "\u20AC": "EUR",
2978
- "\xA5": "JPY",
2979
- "\u20B9": "INR",
2980
- "\u20BD": "RUB",
2981
- "\u20A9": "KRW",
2982
- "R$": "BRL",
2983
- "C$": "CAD",
2984
- "A$": "AUD"
2985
- };
2986
- function currencyCodeFor(unit) {
2987
- const raw = (unit ?? "").trim();
2988
- if (raw === "") return "USD";
2989
- return SYMBOL_TO_CODE[raw] ?? raw.toUpperCase();
2990
- }
2991
-
2992
- // src/embeddedLook.tsx
2993
- var EmbeddedLookContext = (0, import_react21.createContext)(null);
2994
- var EmbeddedLookProvider = EmbeddedLookContext.Provider;
2995
- function useEmbeddedLook() {
2996
- return (0, import_react21.useContext)(EmbeddedLookContext);
2997
- }
2998
- var EMBEDDED_TABLE_CLASS = [
2999
- "[&_tbody_td]:h-10",
3000
- "[&_tbody_td]:align-middle!",
3001
- "[&_tbody_td]:border-r",
3002
- "[&_tbody_td]:border-border",
3003
- "[&_tbody_td:last-child]:border-r-0",
3004
- "[&_thead_th]:border-r",
3005
- "[&_thead_th]:border-border",
3006
- "[&_thead_th:last-child]:border-r-0"
3007
- ].join(" ");
3008
-
3009
2979
  // src/enumLabels.ts
3010
2980
  function exhaustiveValuesOf() {
3011
2981
  return function(values) {
@@ -3082,13 +3052,13 @@ var ABSENCE_WORD_LABEL = {
3082
3052
  };
3083
3053
 
3084
3054
  // src/EntityReferenceControl.tsx
3085
- var import_react23 = require("react");
3055
+ var import_react22 = require("react");
3086
3056
  var import_records12 = require("@ai-matrx/records");
3087
- var import_react24 = require("@ai-matrx/records/react");
3057
+ var import_react23 = require("@ai-matrx/records/react");
3088
3058
  var import_design_system13 = require("@ai-matrx/design-system");
3089
3059
 
3090
3060
  // src/PickOne.tsx
3091
- var import_react22 = require("react");
3061
+ var import_react21 = require("react");
3092
3062
  var import_design_system12 = require("@ai-matrx/design-system");
3093
3063
  var import_jsx_runtime14 = require("react/jsx-runtime");
3094
3064
  var PICK_ONE_SEARCH_AFTER = 7;
@@ -3106,8 +3076,8 @@ function PickOne({
3106
3076
  disabled,
3107
3077
  attrs
3108
3078
  }) {
3109
- const [open, setOpen] = (0, import_react22.useState)(false);
3110
- const [search, setSearch] = (0, import_react22.useState)("");
3079
+ const [open, setOpen] = (0, import_react21.useState)(false);
3080
+ const [search, setSearch] = (0, import_react21.useState)("");
3111
3081
  const current = options.find((o) => o.value === value);
3112
3082
  if (options.length > PICK_ONE_SEARCH_AFTER) {
3113
3083
  const q = search.trim().toLowerCase();
@@ -3189,19 +3159,19 @@ function allowedKindsOf(field) {
3189
3159
  return kinds.map((k) => String(k).trim().toLowerCase()).filter(Boolean);
3190
3160
  }
3191
3161
  function EntityReferenceControl(props) {
3192
- const client = (0, import_react24.useOptionalRecordsClient)();
3162
+ const client = (0, import_react23.useOptionalRecordsClient)();
3193
3163
  return client ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(WithWords, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Chips, { ...props, words: null, picker: null });
3194
3164
  }
3195
3165
  function WithWords(props) {
3196
- const refs = (0, import_react23.useMemo)(() => (0, import_records12.entityRefsOf)(props.value), [props.value]);
3197
- const [known, setKnown] = (0, import_react23.useState)([]);
3166
+ const refs = (0, import_react22.useMemo)(() => (0, import_records12.entityRefsOf)(props.value), [props.value]);
3167
+ const [known, setKnown] = (0, import_react22.useState)([]);
3198
3168
  const withKnown = refs.map((r) => r.label === null ? known.find((k) => k.token === r.token && k.id === r.id) ?? r : r);
3199
- const unlabelled = (0, import_react23.useMemo)(
3169
+ const unlabelled = (0, import_react22.useMemo)(
3200
3170
  () => withKnown.filter((r) => r.label === null).map((r) => ({ token: r.token, id: r.id })),
3201
3171
  // eslint-disable-next-line react-hooks/exhaustive-deps
3202
3172
  [JSON.stringify(withKnown)]
3203
3173
  );
3204
- const words = (0, import_react24.useEntityReferenceWords)(unlabelled);
3174
+ const words = (0, import_react23.useEntityReferenceWords)(unlabelled);
3205
3175
  const picker = props.disabled ? null : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3206
3176
  EntityReferencePicker,
3207
3177
  {
@@ -3223,13 +3193,13 @@ function EntityReferencePicker({
3223
3193
  onPick
3224
3194
  }) {
3225
3195
  const allowed = allowedKindsOf(field);
3226
- const kinds = (0, import_react24.useEntityReferenceKinds)();
3196
+ const kinds = (0, import_react23.useEntityReferenceKinds)();
3227
3197
  const labelOfKind = (token) => kinds.data?.find((k) => k.token === token)?.label ?? token.replace(/_/g, " ");
3228
- const [open, setOpen] = (0, import_react23.useState)(false);
3229
- const [search, setSearch] = (0, import_react23.useState)("");
3230
- const [only, setOnly] = (0, import_react23.useState)(null);
3198
+ const [open, setOpen] = (0, import_react22.useState)(false);
3199
+ const [search, setSearch] = (0, import_react22.useState)("");
3200
+ const [only, setOnly] = (0, import_react22.useState)(null);
3231
3201
  const tokens = only ? [only] : allowed;
3232
- const found = (0, import_react24.useEntityReferenceSearch)(tokens, search, open);
3202
+ const found = (0, import_react23.useEntityReferenceSearch)(tokens, search, open);
3233
3203
  const multi = Boolean(field.multi);
3234
3204
  const items = (found.data ?? []).map((r) => ({
3235
3205
  id: `${r.token}:${r.id}`,
@@ -3300,7 +3270,7 @@ function Chips({
3300
3270
  words,
3301
3271
  picker
3302
3272
  }) {
3303
- const refs = (0, import_react23.useMemo)(() => (0, import_records12.entityRefsOf)(value), [value]);
3273
+ const refs = (0, import_react22.useMemo)(() => (0, import_records12.entityRefsOf)(value), [value]);
3304
3274
  const labelOf = (token, refId, own3) => {
3305
3275
  if (own3) return own3;
3306
3276
  const read = words?.data?.find((w) => w.token === token && w.id === refId)?.label;
@@ -3339,7 +3309,7 @@ function Chips({
3339
3309
  var import_core5 = require("@ai-matrx/records/core");
3340
3310
 
3341
3311
  // src/WholeValue.tsx
3342
- var import_react25 = require("react");
3312
+ var import_react24 = require("react");
3343
3313
  var import_core4 = require("@ai-matrx/records/core");
3344
3314
  var import_design_system14 = require("@ai-matrx/design-system");
3345
3315
  var import_jsx_runtime16 = require("react/jsx-runtime");
@@ -3364,7 +3334,7 @@ function WholeValueCell({ words, pointer }) {
3364
3334
  var import_field_formats5 = require("@ai-matrx/design-system/field-formats");
3365
3335
 
3366
3336
  // src/formattedValue.tsx
3367
- var import_react26 = require("react");
3337
+ var import_react25 = require("react");
3368
3338
  var import_data_table3 = require("@ai-matrx/design-system/data-table");
3369
3339
  var import_field_formats3 = require("@ai-matrx/design-system/field-formats");
3370
3340
  var import_design_system15 = require("@ai-matrx/design-system");
@@ -3386,7 +3356,7 @@ function RatingStars({
3386
3356
  label,
3387
3357
  selectFirst
3388
3358
  }) {
3389
- const armed = (0, import_react26.useRef)(true);
3359
+ const armed = (0, import_react25.useRef)(true);
3390
3360
  const score = numberOf(value) ?? 0;
3391
3361
  const shown2 = Math.round(score);
3392
3362
  const said2 = `${shown2} out of ${max}`;
@@ -3518,12 +3488,12 @@ function linkChipText(raw) {
3518
3488
  }
3519
3489
 
3520
3490
  // src/gridAttachments.tsx
3521
- var import_react28 = require("react");
3522
- var import_react29 = require("@ai-matrx/records/react");
3491
+ var import_react27 = require("react");
3492
+ var import_react28 = require("@ai-matrx/records/react");
3523
3493
  var import_design_system17 = require("@ai-matrx/design-system");
3524
3494
 
3525
3495
  // src/FilePicker.tsx
3526
- var import_react27 = require("react");
3496
+ var import_react26 = require("react");
3527
3497
  var import_design_system16 = require("@ai-matrx/design-system");
3528
3498
  var import_jsx_runtime18 = require("react/jsx-runtime");
3529
3499
  function FilePicker({
@@ -3537,17 +3507,17 @@ function FilePicker({
3537
3507
  chosenName,
3538
3508
  className
3539
3509
  }) {
3540
- const inputId = (0, import_react27.useId)();
3541
- const input = (0, import_react27.useRef)(null);
3542
- const [over, setOver] = (0, import_react27.useState)(false);
3543
- const take = (0, import_react27.useCallback)(
3510
+ const inputId = (0, import_react26.useId)();
3511
+ const input = (0, import_react26.useRef)(null);
3512
+ const [over, setOver] = (0, import_react26.useState)(false);
3513
+ const take = (0, import_react26.useCallback)(
3544
3514
  (file) => {
3545
3515
  if (!file || disabled) return;
3546
3516
  onFile(file);
3547
3517
  },
3548
3518
  [disabled, onFile]
3549
3519
  );
3550
- const onDrop = (0, import_react27.useCallback)(
3520
+ const onDrop = (0, import_react26.useCallback)(
3551
3521
  (e) => {
3552
3522
  e.preventDefault();
3553
3523
  setOver(false);
@@ -3640,10 +3610,10 @@ function rememberHostFileIds(ids) {
3640
3610
  var FILE_CHIP_UNREAD = "File";
3641
3611
  var FILE_CHIP_NO_PAGE = "This screen has no way to open files yet.";
3642
3612
  function AttachmentChip({ id, onRemove }) {
3643
- const client = (0, import_react29.useOptionalRecordsClient)();
3613
+ const client = (0, import_react28.useOptionalRecordsClient)();
3644
3614
  const host = useRecordsUi();
3645
- const [read, setRead] = (0, import_react28.useState)(null);
3646
- (0, import_react28.useEffect)(() => {
3615
+ const [read, setRead] = (0, import_react27.useState)(null);
3616
+ (0, import_react27.useEffect)(() => {
3647
3617
  let cancelled = false;
3648
3618
  if (!client) {
3649
3619
  setRead({ name: null, fileId: null, why: null });
@@ -3718,9 +3688,9 @@ function AttachmentControl({
3718
3688
  onClose
3719
3689
  }) {
3720
3690
  const host = useRecordsUi();
3721
- const [busy, setBusy] = (0, import_react28.useState)(false);
3722
- const [why, setWhy] = (0, import_react28.useState)(null);
3723
- const latest = (0, import_react28.useRef)(value);
3691
+ const [busy, setBusy] = (0, import_react27.useState)(false);
3692
+ const [why, setWhy] = (0, import_react27.useState)(null);
3693
+ const latest = (0, import_react27.useRef)(value);
3724
3694
  latest.current = value;
3725
3695
  const multiple = Boolean(field.multi);
3726
3696
  const pick = async () => {
@@ -3741,8 +3711,8 @@ function AttachmentControl({
3741
3711
  setBusy(false);
3742
3712
  onClose?.();
3743
3713
  };
3744
- const opened = (0, import_react28.useRef)(false);
3745
- (0, import_react28.useEffect)(() => {
3714
+ const opened = (0, import_react27.useRef)(false);
3715
+ (0, import_react27.useEffect)(() => {
3746
3716
  if (!autoOpen || opened.current || !host.pickFiles) return;
3747
3717
  opened.current = true;
3748
3718
  void pick();
@@ -4208,16 +4178,16 @@ function bringBackLabel(state) {
4208
4178
  return state.label ? `Bring back ${state.label}` : "Bring it back";
4209
4179
  }
4210
4180
  function SourceArchivedNotice({ fieldId, tableId }) {
4211
- const client = (0, import_react31.useRecordsClient)();
4212
- const [state, setState] = (0, import_react30.useState)(null);
4213
- const [busy, setBusy] = (0, import_react30.useState)(false);
4214
- const [refused, setRefused] = (0, import_react30.useState)(null);
4215
- const read = (0, import_react30.useCallback)(async () => {
4181
+ const client = (0, import_react30.useRecordsClient)();
4182
+ const [state, setState] = (0, import_react29.useState)(null);
4183
+ const [busy, setBusy] = (0, import_react29.useState)(false);
4184
+ const [refused, setRefused] = (0, import_react29.useState)(null);
4185
+ const read = (0, import_react29.useCallback)(async () => {
4216
4186
  const answer = await client.fieldSourceArchived({ field_id: fieldId });
4217
4187
  if (answer.ok) setState(answer.data);
4218
4188
  else setRefused(answer.error);
4219
4189
  }, [client, fieldId]);
4220
- (0, import_react30.useEffect)(() => {
4190
+ (0, import_react29.useEffect)(() => {
4221
4191
  void read();
4222
4192
  }, [read]);
4223
4193
  if (refused && !state) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(RefusalNotice, { error: refused });
@@ -4232,8 +4202,8 @@ function SourceArchivedNotice({ fieldId, tableId }) {
4232
4202
  setRefused(done.error);
4233
4203
  return;
4234
4204
  }
4235
- if (state.table_id) (0, import_react31.tableShapeChanged)(state.table_id);
4236
- (0, import_react31.tableShapeChanged)(tableId);
4205
+ if (state.table_id) (0, import_react30.tableShapeChanged)(state.table_id);
4206
+ (0, import_react30.tableShapeChanged)(tableId);
4237
4207
  await read();
4238
4208
  };
4239
4209
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
@@ -4255,10 +4225,10 @@ function SourceArchivedNotice({ fieldId, tableId }) {
4255
4225
  }
4256
4226
 
4257
4227
  // src/Condition.tsx
4258
- var import_react32 = require("react");
4228
+ var import_react31 = require("react");
4259
4229
  var import_design_system21 = require("@ai-matrx/design-system");
4260
4230
  var import_records16 = require("@ai-matrx/records");
4261
- var import_react33 = require("@ai-matrx/records/react");
4231
+ var import_react32 = require("@ai-matrx/records/react");
4262
4232
  var import_jsx_runtime23 = require("react/jsx-runtime");
4263
4233
  var CONDITION_OPS = [
4264
4234
  { op: "eq", label: "is" },
@@ -4278,11 +4248,11 @@ function isChoiceColumn(f) {
4278
4248
  return kind === "select" || kind === "multi_select";
4279
4249
  }
4280
4250
  function ChoiceValue({ field, value, onChange }) {
4281
- const client = (0, import_react33.useOptionalRecordsClient)();
4282
- const [choices, setChoices] = (0, import_react32.useState)(null);
4283
- const [open, setOpen] = (0, import_react32.useState)(false);
4284
- const [search, setSearch] = (0, import_react32.useState)("");
4285
- (0, import_react32.useEffect)(() => {
4251
+ const client = (0, import_react32.useOptionalRecordsClient)();
4252
+ const [choices, setChoices] = (0, import_react31.useState)(null);
4253
+ const [open, setOpen] = (0, import_react31.useState)(false);
4254
+ const [search, setSearch] = (0, import_react31.useState)("");
4255
+ (0, import_react31.useEffect)(() => {
4286
4256
  if (!client) return;
4287
4257
  let cancelled = false;
4288
4258
  void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
@@ -4549,7 +4519,7 @@ function ConditionGroup({
4549
4519
  className
4550
4520
  }) {
4551
4521
  const { joiner, args } = clausesOf(expr);
4552
- const [drafting, setDrafting] = (0, import_react32.useState)(null);
4522
+ const [drafting, setDrafting] = (0, import_react31.useState)(null);
4553
4523
  const nested = depth > 0;
4554
4524
  const replaceAt = (index, next) => {
4555
4525
  const nextArgs = args.slice();
@@ -4676,9 +4646,9 @@ function ConditionGroup({
4676
4646
  }
4677
4647
 
4678
4648
  // src/FieldRetype.tsx
4679
- var import_react34 = require("react");
4649
+ var import_react33 = require("react");
4680
4650
  var import_records17 = require("@ai-matrx/records");
4681
- var import_react35 = require("@ai-matrx/records/react");
4651
+ var import_react34 = require("@ai-matrx/records/react");
4682
4652
  var import_design_system22 = require("@ai-matrx/design-system");
4683
4653
  var import_jsx_runtime24 = require("react/jsx-runtime");
4684
4654
  var RETYPE_TARGETS = [
@@ -4715,17 +4685,17 @@ function currentTarget(field) {
4715
4685
  return "text";
4716
4686
  }
4717
4687
  function FieldRetype({ field, tableId, onRetyped }) {
4718
- const client = (0, import_react35.useRecordsClient)();
4688
+ const client = (0, import_react34.useRecordsClient)();
4719
4689
  const notify = useRecordsUi().notify;
4720
- const [to, setTo] = (0, import_react34.useState)(null);
4721
- const [preview, setPreview] = (0, import_react34.useState)(null);
4722
- const [asking, setAsking] = (0, import_react34.useState)(false);
4723
- const [refusal, setRefusal] = (0, import_react34.useState)(null);
4724
- const [busy, setBusy] = (0, import_react34.useState)(false);
4725
- const [said2, setSaid] = (0, import_react34.useState)(null);
4690
+ const [to, setTo] = (0, import_react33.useState)(null);
4691
+ const [preview, setPreview] = (0, import_react33.useState)(null);
4692
+ const [asking, setAsking] = (0, import_react33.useState)(false);
4693
+ const [refusal, setRefusal] = (0, import_react33.useState)(null);
4694
+ const [busy, setBusy] = (0, import_react33.useState)(false);
4695
+ const [said2, setSaid] = (0, import_react33.useState)(null);
4726
4696
  const name = fieldName(field);
4727
4697
  const targets = RETYPE_TARGETS.filter((t) => t.id !== currentTarget(field));
4728
- (0, import_react34.useEffect)(() => {
4698
+ (0, import_react33.useEffect)(() => {
4729
4699
  if (!to) return;
4730
4700
  let cancelled = false;
4731
4701
  setPreview(null);
@@ -4781,7 +4751,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
4781
4751
  undo: async () => {
4782
4752
  const back = await client.migrateUndo({ migration_id: migration });
4783
4753
  if (!back.ok) throw new Error(refusalSentence(back.error));
4784
- (0, import_react35.tableShapeChanged)(tableId);
4754
+ (0, import_react34.tableShapeChanged)(tableId);
4785
4755
  onRetyped?.();
4786
4756
  }
4787
4757
  });
@@ -4792,7 +4762,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
4792
4762
  );
4793
4763
  setTo(null);
4794
4764
  setPreview(null);
4795
- (0, import_react35.tableShapeChanged)(tableId);
4765
+ (0, import_react34.tableShapeChanged)(tableId);
4796
4766
  onRetyped?.();
4797
4767
  };
4798
4768
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col gap-1.5", "data-records-retype": "", children: [
@@ -4824,9 +4794,9 @@ function FieldRetype({ field, tableId, onRetyped }) {
4824
4794
  }
4825
4795
 
4826
4796
  // src/FieldRulePreview.tsx
4827
- var import_react36 = require("react");
4797
+ var import_react35 = require("react");
4828
4798
  var import_records18 = require("@ai-matrx/records");
4829
- var import_react37 = require("@ai-matrx/records/react");
4799
+ var import_react36 = require("@ai-matrx/records/react");
4830
4800
  var import_jsx_runtime25 = require("react/jsx-runtime");
4831
4801
  var PREVIEW_GROUPS2 = 1e3;
4832
4802
  function ruleWords(rules) {
@@ -4844,14 +4814,14 @@ function groupValue(value, numbers) {
4844
4814
  return /^-?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(text) ? Number(text) : value;
4845
4815
  }
4846
4816
  function FieldRulePreview({ field, tableId, rules }) {
4847
- const client = (0, import_react37.useRecordsClient)();
4848
- const [preview, setPreview] = (0, import_react36.useState)(null);
4849
- const [refusal, setRefusal] = (0, import_react36.useState)(null);
4850
- const key = (0, import_react36.useMemo)(() => ruleWords(rules), [rules]);
4851
- const latest = (0, import_react36.useRef)(rules);
4817
+ const client = (0, import_react36.useRecordsClient)();
4818
+ const [preview, setPreview] = (0, import_react35.useState)(null);
4819
+ const [refusal, setRefusal] = (0, import_react35.useState)(null);
4820
+ const key = (0, import_react35.useMemo)(() => ruleWords(rules), [rules]);
4821
+ const latest = (0, import_react35.useRef)(rules);
4852
4822
  latest.current = rules;
4853
4823
  const name = fieldName(field);
4854
- (0, import_react36.useEffect)(() => {
4824
+ (0, import_react35.useEffect)(() => {
4855
4825
  let cancelled = false;
4856
4826
  setPreview(null);
4857
4827
  setRefusal(null);
@@ -4972,9 +4942,9 @@ function choiceLookForNewList(multi, rows) {
4972
4942
  }
4973
4943
 
4974
4944
  // src/ChoiceListEditor.tsx
4975
- var import_react38 = require("react");
4945
+ var import_react37 = require("react");
4976
4946
  var import_records19 = require("@ai-matrx/records");
4977
- var import_react39 = require("@ai-matrx/records/react");
4947
+ var import_react38 = require("@ai-matrx/records/react");
4978
4948
  var import_design_system23 = require("@ai-matrx/design-system");
4979
4949
  var import_data_table5 = require("@ai-matrx/design-system/data-table");
4980
4950
  var import_jsx_runtime26 = require("react/jsx-runtime");
@@ -5019,15 +4989,15 @@ function ChoiceListEditor({
5019
4989
  rehome = {},
5020
4990
  onRehome
5021
4991
  }) {
5022
- const client = (0, import_react39.useRecordsClient)();
5023
- const [refused, setRefused] = (0, import_react38.useState)(null);
5024
- const [usage, setUsage] = (0, import_react38.useState)(null);
5025
- const [asking, setAsking] = (0, import_react38.useState)(null);
5026
- const [moveTo, setMoveTo] = (0, import_react38.useState)("");
5027
- const focusRow = (0, import_react38.useRef)(null);
5028
- const [removed, setRemoved] = (0, import_react38.useState)({});
4992
+ const client = (0, import_react38.useRecordsClient)();
4993
+ const [refused, setRefused] = (0, import_react37.useState)(null);
4994
+ const [usage, setUsage] = (0, import_react37.useState)(null);
4995
+ const [asking, setAsking] = (0, import_react37.useState)(null);
4996
+ const [moveTo, setMoveTo] = (0, import_react37.useState)("");
4997
+ const focusRow = (0, import_react37.useRef)(null);
4998
+ const [removed, setRemoved] = (0, import_react37.useState)({});
5029
4999
  const fieldId = field?.id ?? null;
5030
- (0, import_react38.useEffect)(() => {
5000
+ (0, import_react37.useEffect)(() => {
5031
5001
  if (rows !== null || !fieldId || !field) return;
5032
5002
  let live = true;
5033
5003
  void client.fieldOptions({ field_id: fieldId }).then((got) => {
@@ -5044,7 +5014,7 @@ function ChoiceListEditor({
5044
5014
  live = false;
5045
5015
  };
5046
5016
  }, [client, fieldId, rows, onRows, onStart]);
5047
- (0, import_react38.useEffect)(() => {
5017
+ (0, import_react37.useEffect)(() => {
5048
5018
  if (!onRehome || !fieldId) return;
5049
5019
  let live = true;
5050
5020
  void client.fieldChoiceUsage({ field_id: fieldId }).then(
@@ -5184,7 +5154,7 @@ function ChoiceListEditor({
5184
5154
  ] });
5185
5155
  }
5186
5156
  function ChoiceSwatch({ words, color, onColor }) {
5187
- const [open, setOpen] = (0, import_react38.useState)(false);
5157
+ const [open, setOpen] = (0, import_react37.useState)(false);
5188
5158
  const pick = (next) => {
5189
5159
  onColor(next);
5190
5160
  setOpen(false);
@@ -5625,6 +5595,36 @@ function readersSentence(count, tableName2) {
5625
5595
  return `${rollups} on ${tableName2 ?? "this table"} read through this.`;
5626
5596
  }
5627
5597
 
5598
+ // src/personTime.ts
5599
+ var import_react39 = require("react");
5600
+ var zone = null;
5601
+ var listeners = /* @__PURE__ */ new Set();
5602
+ function usePersonTimeZone() {
5603
+ return (0, import_react39.useSyncExternalStore)(
5604
+ (cb) => {
5605
+ listeners.add(cb);
5606
+ return () => listeners.delete(cb);
5607
+ },
5608
+ () => zone,
5609
+ () => null
5610
+ );
5611
+ }
5612
+ function personWallNow(at = /* @__PURE__ */ new Date()) {
5613
+ if (!zone) return at;
5614
+ const parts = new Intl.DateTimeFormat("en-US", {
5615
+ timeZone: zone,
5616
+ year: "numeric",
5617
+ month: "2-digit",
5618
+ day: "2-digit",
5619
+ hour: "2-digit",
5620
+ minute: "2-digit",
5621
+ second: "2-digit",
5622
+ hourCycle: "h23"
5623
+ }).formatToParts(at);
5624
+ const n = (t) => Number(parts.find((p) => p.type === t)?.value ?? 0);
5625
+ return new Date(n("year"), n("month") - 1, n("day"), n("hour"), n("minute"), n("second"));
5626
+ }
5627
+
5628
5628
  // src/gridMenus.ts
5629
5629
  function nextFieldSort(fields) {
5630
5630
  let last = 0;