@ai-matrx/records-ui 0.113.38 → 0.114.0

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
@@ -987,7 +987,9 @@ var NEEDS = {
987
987
  // custom.share_grant — passing your access on is an administrator's right
988
988
  share: "admin",
989
989
  // custom.field_declare / field_update / field_retire / table settings
990
- structure: "admin"
990
+ structure: "admin",
991
+ // custom.field_declare / field_update / field_retire — the same rung; a lock takes it away, nothing else does
992
+ schema: "admin"
991
993
  };
992
994
  var NOT_YET = "Still asking the store what you may do here. Nothing is offered until it has answered.";
993
995
  var NOTHING_AT_ALL = "You have not been given this. Ask somebody who administers it to share it with you.";
@@ -1002,7 +1004,8 @@ function sentenceFor(what, level) {
1002
1004
  organise: "organise this",
1003
1005
  remove: "delete this",
1004
1006
  share: "pass this on to somebody else",
1005
- structure: "change the columns of this table"
1007
+ structure: "change the columns of this table",
1008
+ schema: "change the columns of this table"
1006
1009
  };
1007
1010
  return `You are ${have} here, and it takes ${need} to ${doing[what]}. Ask somebody who is Admin on it to move you up.`;
1008
1011
  }
@@ -1018,6 +1021,7 @@ function whatYouMayDo(level, known = true) {
1018
1021
  remove: may("remove"),
1019
1022
  share: may("share"),
1020
1023
  structure: may("structure"),
1024
+ schema: may("schema"),
1021
1025
  why: (what) => known ? sentenceFor(what, level) : NOT_YET
1022
1026
  };
1023
1027
  }
@@ -1029,15 +1033,16 @@ function whatYouMayDoWithTable(table, level, known) {
1029
1033
  return {
1030
1034
  ...base,
1031
1035
  structure: false,
1032
- why: (what) => what === "structure" ? KERNEL_REASON : base.why(what)
1036
+ schema: false,
1037
+ why: (what) => what === "structure" || what === "schema" ? KERNEL_REASON : base.why(what)
1033
1038
  };
1034
1039
  }
1035
1040
  function tableIsLocked(table) {
1036
1041
  return table?.metadata?.["locked"] === true;
1037
1042
  }
1038
- var DATABASE_LOCKED_REASON = "This database is locked, so its columns and settings are read-only. Unlock it to change them.";
1043
+ var DATABASE_LOCKED_REASON = "This database is locked, so its columns cannot be added, renamed, changed or deleted. Unlock it to change them.";
1039
1044
  function lockedStructure(base) {
1040
- return { ...base, structure: false, why: (what) => what === "structure" ? DATABASE_LOCKED_REASON : base.why(what) };
1045
+ return { ...base, schema: false, why: (what) => what === "schema" ? DATABASE_LOCKED_REASON : base.why(what) };
1041
1046
  }
1042
1047
 
1043
1048
  // src/host.tsx
@@ -4232,46 +4237,10 @@ function SourceArchivedNotice({ fieldId, tableId }) {
4232
4237
  }
4233
4238
 
4234
4239
  // src/Condition.tsx
4235
- var import_react32 = require("react");
4240
+ var import_react31 = require("react");
4236
4241
  var import_design_system21 = require("@ai-matrx/design-system");
4237
4242
  var import_records16 = require("@ai-matrx/records");
4238
- var import_react33 = require("@ai-matrx/records/react");
4239
-
4240
- // src/personTime.ts
4241
- var import_react31 = require("react");
4242
- var import_table_style2 = require("@ai-matrx/design-system/data-table/table-style");
4243
- var zone = null;
4244
- var listeners = /* @__PURE__ */ new Set();
4245
- function getPersonTimeZone() {
4246
- return zone;
4247
- }
4248
- function usePersonTimeZone() {
4249
- return (0, import_react31.useSyncExternalStore)(
4250
- (cb) => {
4251
- listeners.add(cb);
4252
- return () => listeners.delete(cb);
4253
- },
4254
- () => zone,
4255
- () => null
4256
- );
4257
- }
4258
- function personWallNow(at = /* @__PURE__ */ new Date()) {
4259
- if (!zone) return at;
4260
- const parts = new Intl.DateTimeFormat("en-US", {
4261
- timeZone: zone,
4262
- year: "numeric",
4263
- month: "2-digit",
4264
- day: "2-digit",
4265
- hour: "2-digit",
4266
- minute: "2-digit",
4267
- second: "2-digit",
4268
- hourCycle: "h23"
4269
- }).formatToParts(at);
4270
- const n = (t) => Number(parts.find((p) => p.type === t)?.value ?? 0);
4271
- return new Date(n("year"), n("month") - 1, n("day"), n("hour"), n("minute"), n("second"));
4272
- }
4273
-
4274
- // src/Condition.tsx
4243
+ var import_react32 = require("@ai-matrx/records/react");
4275
4244
  var import_jsx_runtime23 = require("react/jsx-runtime");
4276
4245
  var CONDITION_OPS = [
4277
4246
  { op: "eq", label: "is" },
@@ -4282,7 +4251,7 @@ var CONDITION_OPS = [
4282
4251
  { op: "gte", label: "is at least" },
4283
4252
  { op: "lte", label: "is at most" }
4284
4253
  ];
4285
- var FilterTermsContext = (0, import_react32.createContext)(false);
4254
+ var FilterTermsContext = (0, import_react31.createContext)(false);
4286
4255
  var RELATIVE_DAY_TERMS = [
4287
4256
  { kind: "today", label: "is today" },
4288
4257
  { kind: "tomorrow", label: "is tomorrow" },
@@ -4298,10 +4267,8 @@ var RELATIVE_DAY_TERMS = [
4298
4267
  { kind: "past_days", label: "is in the past \u2026 days", takesDays: true }
4299
4268
  ];
4300
4269
  function relativeDayNode(fieldId, kind, days) {
4301
- const zone2 = getPersonTimeZone();
4302
4270
  const window2 = { relative: kind };
4303
4271
  if (RELATIVE_DAY_TERMS.find((t) => t.kind === kind)?.takesDays) window2["n"] = days ?? 7;
4304
- if (zone2) window2["tz"] = zone2;
4305
4272
  return { op: "within", args: [{ field: fieldId }, { const: window2 }] };
4306
4273
  }
4307
4274
  function relativeDayOf(expr) {
@@ -4333,11 +4300,11 @@ function isChoiceColumn(f) {
4333
4300
  return kind === "select" || kind === "multi_select";
4334
4301
  }
4335
4302
  function ChoiceValue({ field, value, onChange }) {
4336
- const client = (0, import_react33.useOptionalRecordsClient)();
4337
- const [choices, setChoices] = (0, import_react32.useState)(null);
4338
- const [open, setOpen] = (0, import_react32.useState)(false);
4339
- const [search, setSearch] = (0, import_react32.useState)("");
4340
- (0, import_react32.useEffect)(() => {
4303
+ const client = (0, import_react32.useOptionalRecordsClient)();
4304
+ const [choices, setChoices] = (0, import_react31.useState)(null);
4305
+ const [open, setOpen] = (0, import_react31.useState)(false);
4306
+ const [search, setSearch] = (0, import_react31.useState)("");
4307
+ (0, import_react31.useEffect)(() => {
4341
4308
  if (!client) return;
4342
4309
  let cancelled = false;
4343
4310
  void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
@@ -4468,7 +4435,7 @@ function conditionValue(typed) {
4468
4435
  }
4469
4436
  function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
4470
4437
  const node = expr ?? null;
4471
- const filterTerms = (0, import_react32.useContext)(FilterTermsContext);
4438
+ const filterTerms = (0, import_react31.useContext)(FilterTermsContext);
4472
4439
  const relative = relativeDayOf(expr);
4473
4440
  const reader = meOf(expr);
4474
4441
  const op = relative ? `rel:${relative.kind}` : reader ? reader.which : node?.op ?? "";
@@ -4643,7 +4610,7 @@ function ConditionGroup({
4643
4610
  className
4644
4611
  }) {
4645
4612
  const { joiner, args } = clausesOf(expr);
4646
- const [drafting, setDrafting] = (0, import_react32.useState)(null);
4613
+ const [drafting, setDrafting] = (0, import_react31.useState)(null);
4647
4614
  const nested = depth > 0;
4648
4615
  const replaceAt = (index, next) => {
4649
4616
  const nextArgs = args.slice();
@@ -4770,9 +4737,9 @@ function ConditionGroup({
4770
4737
  }
4771
4738
 
4772
4739
  // src/FieldRetype.tsx
4773
- var import_react34 = require("react");
4740
+ var import_react33 = require("react");
4774
4741
  var import_records17 = require("@ai-matrx/records");
4775
- var import_react35 = require("@ai-matrx/records/react");
4742
+ var import_react34 = require("@ai-matrx/records/react");
4776
4743
  var import_design_system22 = require("@ai-matrx/design-system");
4777
4744
  var import_jsx_runtime24 = require("react/jsx-runtime");
4778
4745
  var RETYPE_TARGETS = [
@@ -4809,17 +4776,17 @@ function currentTarget(field) {
4809
4776
  return "text";
4810
4777
  }
4811
4778
  function FieldRetype({ field, tableId, onRetyped }) {
4812
- const client = (0, import_react35.useRecordsClient)();
4779
+ const client = (0, import_react34.useRecordsClient)();
4813
4780
  const notify = useRecordsUi().notify;
4814
- const [to, setTo] = (0, import_react34.useState)(null);
4815
- const [preview, setPreview] = (0, import_react34.useState)(null);
4816
- const [asking, setAsking] = (0, import_react34.useState)(false);
4817
- const [refusal, setRefusal] = (0, import_react34.useState)(null);
4818
- const [busy, setBusy] = (0, import_react34.useState)(false);
4819
- const [said2, setSaid] = (0, import_react34.useState)(null);
4781
+ const [to, setTo] = (0, import_react33.useState)(null);
4782
+ const [preview, setPreview] = (0, import_react33.useState)(null);
4783
+ const [asking, setAsking] = (0, import_react33.useState)(false);
4784
+ const [refusal, setRefusal] = (0, import_react33.useState)(null);
4785
+ const [busy, setBusy] = (0, import_react33.useState)(false);
4786
+ const [said2, setSaid] = (0, import_react33.useState)(null);
4820
4787
  const name = fieldName(field);
4821
4788
  const targets = RETYPE_TARGETS.filter((t) => t.id !== currentTarget(field));
4822
- (0, import_react34.useEffect)(() => {
4789
+ (0, import_react33.useEffect)(() => {
4823
4790
  if (!to) return;
4824
4791
  let cancelled = false;
4825
4792
  setPreview(null);
@@ -4875,7 +4842,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
4875
4842
  undo: async () => {
4876
4843
  const back = await client.migrateUndo({ migration_id: migration });
4877
4844
  if (!back.ok) throw new Error(refusalSentence(back.error));
4878
- (0, import_react35.tableShapeChanged)(tableId);
4845
+ (0, import_react34.tableShapeChanged)(tableId);
4879
4846
  onRetyped?.();
4880
4847
  }
4881
4848
  });
@@ -4886,7 +4853,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
4886
4853
  );
4887
4854
  setTo(null);
4888
4855
  setPreview(null);
4889
- (0, import_react35.tableShapeChanged)(tableId);
4856
+ (0, import_react34.tableShapeChanged)(tableId);
4890
4857
  onRetyped?.();
4891
4858
  };
4892
4859
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col gap-1.5", "data-records-retype": "", children: [
@@ -4918,9 +4885,9 @@ function FieldRetype({ field, tableId, onRetyped }) {
4918
4885
  }
4919
4886
 
4920
4887
  // src/FieldRulePreview.tsx
4921
- var import_react36 = require("react");
4888
+ var import_react35 = require("react");
4922
4889
  var import_records18 = require("@ai-matrx/records");
4923
- var import_react37 = require("@ai-matrx/records/react");
4890
+ var import_react36 = require("@ai-matrx/records/react");
4924
4891
  var import_jsx_runtime25 = require("react/jsx-runtime");
4925
4892
  var PREVIEW_GROUPS2 = 1e3;
4926
4893
  function ruleWords(rules) {
@@ -4938,14 +4905,14 @@ function groupValue(value, numbers) {
4938
4905
  return /^-?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(text) ? Number(text) : value;
4939
4906
  }
4940
4907
  function FieldRulePreview({ field, tableId, rules }) {
4941
- const client = (0, import_react37.useRecordsClient)();
4942
- const [preview, setPreview] = (0, import_react36.useState)(null);
4943
- const [refusal, setRefusal] = (0, import_react36.useState)(null);
4944
- const key = (0, import_react36.useMemo)(() => ruleWords(rules), [rules]);
4945
- const latest = (0, import_react36.useRef)(rules);
4908
+ const client = (0, import_react36.useRecordsClient)();
4909
+ const [preview, setPreview] = (0, import_react35.useState)(null);
4910
+ const [refusal, setRefusal] = (0, import_react35.useState)(null);
4911
+ const key = (0, import_react35.useMemo)(() => ruleWords(rules), [rules]);
4912
+ const latest = (0, import_react35.useRef)(rules);
4946
4913
  latest.current = rules;
4947
4914
  const name = fieldName(field);
4948
- (0, import_react36.useEffect)(() => {
4915
+ (0, import_react35.useEffect)(() => {
4949
4916
  let cancelled = false;
4950
4917
  setPreview(null);
4951
4918
  setRefusal(null);
@@ -5066,9 +5033,9 @@ function choiceLookForNewList(multi, rows) {
5066
5033
  }
5067
5034
 
5068
5035
  // src/ChoiceListEditor.tsx
5069
- var import_react38 = require("react");
5036
+ var import_react37 = require("react");
5070
5037
  var import_records19 = require("@ai-matrx/records");
5071
- var import_react39 = require("@ai-matrx/records/react");
5038
+ var import_react38 = require("@ai-matrx/records/react");
5072
5039
  var import_design_system23 = require("@ai-matrx/design-system");
5073
5040
  var import_data_table5 = require("@ai-matrx/design-system/data-table");
5074
5041
  var import_jsx_runtime26 = require("react/jsx-runtime");
@@ -5113,15 +5080,15 @@ function ChoiceListEditor({
5113
5080
  rehome = {},
5114
5081
  onRehome
5115
5082
  }) {
5116
- const client = (0, import_react39.useRecordsClient)();
5117
- const [refused, setRefused] = (0, import_react38.useState)(null);
5118
- const [usage, setUsage] = (0, import_react38.useState)(null);
5119
- const [asking, setAsking] = (0, import_react38.useState)(null);
5120
- const [moveTo, setMoveTo] = (0, import_react38.useState)("");
5121
- const focusRow = (0, import_react38.useRef)(null);
5122
- const [removed, setRemoved] = (0, import_react38.useState)({});
5083
+ const client = (0, import_react38.useRecordsClient)();
5084
+ const [refused, setRefused] = (0, import_react37.useState)(null);
5085
+ const [usage, setUsage] = (0, import_react37.useState)(null);
5086
+ const [asking, setAsking] = (0, import_react37.useState)(null);
5087
+ const [moveTo, setMoveTo] = (0, import_react37.useState)("");
5088
+ const focusRow = (0, import_react37.useRef)(null);
5089
+ const [removed, setRemoved] = (0, import_react37.useState)({});
5123
5090
  const fieldId = field?.id ?? null;
5124
- (0, import_react38.useEffect)(() => {
5091
+ (0, import_react37.useEffect)(() => {
5125
5092
  if (rows !== null || !fieldId || !field) return;
5126
5093
  let live = true;
5127
5094
  void client.fieldOptions({ field_id: fieldId }).then((got) => {
@@ -5138,7 +5105,7 @@ function ChoiceListEditor({
5138
5105
  live = false;
5139
5106
  };
5140
5107
  }, [client, fieldId, rows, onRows, onStart]);
5141
- (0, import_react38.useEffect)(() => {
5108
+ (0, import_react37.useEffect)(() => {
5142
5109
  if (!onRehome || !fieldId) return;
5143
5110
  let live = true;
5144
5111
  void client.fieldChoiceUsage({ field_id: fieldId }).then(
@@ -5278,7 +5245,7 @@ function ChoiceListEditor({
5278
5245
  ] });
5279
5246
  }
5280
5247
  function ChoiceSwatch({ words, color, onColor }) {
5281
- const [open, setOpen] = (0, import_react38.useState)(false);
5248
+ const [open, setOpen] = (0, import_react37.useState)(false);
5282
5249
  const pick = (next) => {
5283
5250
  onColor(next);
5284
5251
  setOpen(false);
@@ -5719,6 +5686,37 @@ function readersSentence(count, tableName2) {
5719
5686
  return `${rollups} on ${tableName2 ?? "this table"} read through this.`;
5720
5687
  }
5721
5688
 
5689
+ // src/personTime.ts
5690
+ var import_react39 = require("react");
5691
+ var import_table_style2 = require("@ai-matrx/design-system/data-table/table-style");
5692
+ var zone = null;
5693
+ var listeners = /* @__PURE__ */ new Set();
5694
+ function usePersonTimeZone() {
5695
+ return (0, import_react39.useSyncExternalStore)(
5696
+ (cb) => {
5697
+ listeners.add(cb);
5698
+ return () => listeners.delete(cb);
5699
+ },
5700
+ () => zone,
5701
+ () => null
5702
+ );
5703
+ }
5704
+ function personWallNow(at = /* @__PURE__ */ new Date()) {
5705
+ if (!zone) return at;
5706
+ const parts = new Intl.DateTimeFormat("en-US", {
5707
+ timeZone: zone,
5708
+ year: "numeric",
5709
+ month: "2-digit",
5710
+ day: "2-digit",
5711
+ hour: "2-digit",
5712
+ minute: "2-digit",
5713
+ second: "2-digit",
5714
+ hourCycle: "h23"
5715
+ }).formatToParts(at);
5716
+ const n = (t) => Number(parts.find((p) => p.type === t)?.value ?? 0);
5717
+ return new Date(n("year"), n("month") - 1, n("day"), n("hour"), n("minute"), n("second"));
5718
+ }
5719
+
5722
5720
  // src/gridMenus.ts
5723
5721
  function nextFieldSort(fields) {
5724
5722
  let last = 0;
@@ -6083,8 +6081,8 @@ function FieldEditor(props) {
6083
6081
  const entityMutation = (0, import_react43.useEntityFieldMutation)();
6084
6082
  const mutation = onEntity ? { saving: entityMutation.saving, error: entityMutation.error } : { saving: tableMutation.saving, error: tableMutation.error };
6085
6083
  const client = (0, import_react43.useRecordsClient)();
6086
- const mayShape = onEntity ? entityRights.data?.may_declare === true : tableRights2.structure;
6087
- const whyNot = onEntity ? entityRights.data?.reason ?? null : tableRights2.why("structure");
6084
+ const mayShape = onEntity ? entityRights.data?.may_declare === true : tableRights2.schema;
6085
+ const whyNot = onEntity ? entityRights.data?.reason ?? null : tableRights2.why("schema");
6088
6086
  const storeLabel = onEntity ? entityRights.data?.label ?? null : table.data?.name ?? null;
6089
6087
  const tableLabel = props.tableLabel ?? storeLabel;
6090
6088
  const offered = onEntity ? STANDARD_TABLE_FIELD_CHOICES : FIELD_TYPE_CHOICES;