@ai-matrx/records-ui 0.41.0 → 0.42.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/index.js CHANGED
@@ -5308,7 +5308,7 @@ function offerableFields(all, want) {
5308
5308
  return kind === "datetime" || kind === "date";
5309
5309
  });
5310
5310
  }
5311
- function useIsPipeline(tableId, groupField) {
5311
+ function useStageField(tableId) {
5312
5312
  const client = useRecordsClient13();
5313
5313
  const [stage, setStage] = useState19({
5314
5314
  asked: false,
@@ -5325,8 +5325,17 @@ function useIsPipeline(tableId, groupField) {
5325
5325
  cancelled = true;
5326
5326
  };
5327
5327
  }, [client, tableId]);
5328
- if (!stage.asked) return null;
5329
- return stage.key != null && stage.key === groupField;
5328
+ return stage;
5329
+ }
5330
+ function boardColumnChoice(fields, chosenKey, stage) {
5331
+ const has = (key) => key != null && fields.some((f) => f.key === key) ? key : null;
5332
+ const chosen = has(chosenKey);
5333
+ if (chosen) {
5334
+ return { groupKey: chosen, isPipeline: stage.asked ? stage.key === chosen : null, stillAsking: false };
5335
+ }
5336
+ if (!stage.asked) return { groupKey: null, isPipeline: null, stillAsking: true };
5337
+ const fromTable = has(stage.key);
5338
+ return { groupKey: fromTable, isPipeline: fromTable != null, stillAsking: false };
5330
5339
  }
5331
5340
  function Board({
5332
5341
  view,
@@ -5338,7 +5347,7 @@ function Board({
5338
5347
  }) {
5339
5348
  const fields = useFields10(view.subject);
5340
5349
  const records = useViewRecords(view, pageSize);
5341
- const isPipeline = useIsPipeline(view.subject, view.groupField);
5350
+ const stage = useStageField(view.subject);
5342
5351
  if (fields.error) return /* @__PURE__ */ jsx21(RefusalNotice, { error: fields.error });
5343
5352
  if (records.error) return /* @__PURE__ */ jsx21(RefusalNotice, { error: records.error });
5344
5353
  if (fields.loading || records.loading) return /* @__PURE__ */ jsx21(Skeleton6, { className: "h-40 w-full" });
@@ -5346,7 +5355,9 @@ function Board({
5346
5355
  const byKey = (key) => all.find((f) => f.key === key);
5347
5356
  const titleField = byKey(view.groupField) ? all.find((f) => f.key !== view.groupField) ?? all[0] : all[0];
5348
5357
  if (view.layout === "kanban") {
5349
- const groupField = byKey(view.groupField);
5358
+ const choice = boardColumnChoice(all, view.groupField, stage);
5359
+ const groupField = byKey(choice.groupKey);
5360
+ const isPipeline = choice.isPipeline;
5350
5361
  const picker = /* @__PURE__ */ jsx21(
5351
5362
  FieldPicker,
5352
5363
  {
@@ -5358,6 +5369,7 @@ function Board({
5358
5369
  onPick: (key) => onChange({ groupField: key })
5359
5370
  }
5360
5371
  );
5372
+ if (choice.stillAsking) return /* @__PURE__ */ jsx21(Skeleton6, { className: "h-40 w-full" });
5361
5373
  if (!groupField) return /* @__PURE__ */ jsx21(Needs, { layout: "kanban", picker });
5362
5374
  return /* @__PURE__ */ jsxs18("div", { className: "flex min-h-0 flex-col gap-2", children: [
5363
5375
  picker,