@proveanything/smartlinks-utils-ui 0.12.21 → 0.12.23

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.
@@ -154,6 +154,13 @@ interface ResolvedRecord<TData = unknown> {
154
154
  * against.
155
155
  */
156
156
  facetRule?: FacetRule | null;
157
+ /**
158
+ * Lifecycle status (`active` / `archived` / `draft` / host custom) of
159
+ * the resolved record, when `source === 'self'` or `'inherited'`.
160
+ * Surfaced so the editor footer's lifecycle menu can render against
161
+ * pinned-anchor (singleton) records the rail does not list directly.
162
+ */
163
+ lifecycleStatus?: string;
157
164
  }
158
165
 
159
166
  interface EditorContext<TData = unknown> {
@@ -2219,6 +2226,7 @@ declare function useResolvedRecord<T = unknown>(args: UseResolvedRecordArgs): {
2219
2226
  matchedAt?: _proveanything_smartlinks.MatchedAt;
2220
2227
  matchedRule?: _proveanything_smartlinks.FacetRule;
2221
2228
  facetRule?: _proveanything_smartlinks.FacetRule | null;
2229
+ lifecycleStatus?: string;
2222
2230
  };
2223
2231
 
2224
2232
  interface UseCollectionItemsArgs {
@@ -16,6 +16,7 @@ import { createPortal } from 'react-dom';
16
16
  var RECORD_LIST_QK = ["records-admin", "list"];
17
17
  var COLLECTION_ITEMS_QK = ["records-admin", "collection-items"];
18
18
  var SCOPE_COUNTS_QK = ["records-admin", "scope-counts"];
19
+ var RESOLVED_RECORD_QK = ["records-admin", "resolved"];
19
20
  var matchesCtx = (queryKey, prefix, ctx) => {
20
21
  if (queryKey.length < prefix.length + 3) return false;
21
22
  for (let i = 0; i < prefix.length; i += 1) {
@@ -178,6 +179,13 @@ function patchRecordStatusInCaches(queryClient, ctx, recordId, status) {
178
179
  return touched ? { ...prev, records } : prev;
179
180
  });
180
181
  }
182
+ const resolved = queryClient.getQueriesData({
183
+ queryKey: RESOLVED_RECORD_QK
184
+ });
185
+ for (const [key, cache] of resolved) {
186
+ if (!cache || cache.recordId !== recordId) continue;
187
+ queryClient.setQueryData(key, { ...cache, lifecycleStatus: status });
188
+ }
181
189
  }
182
190
  function markScopeCountsStale(queryClient, ctx) {
183
191
  const all = queryClient.getQueriesData({
@@ -547,7 +555,8 @@ var resolveRecord = async (args) => {
547
555
  recordId: winner.id,
548
556
  parentValue: args.withParent && parent ? parent.data : void 0,
549
557
  matchedAt: winner.matchedAt,
550
- matchedRule: winner.matchedRule
558
+ matchedRule: winner.matchedRule,
559
+ lifecycleStatus: winner.status
551
560
  };
552
561
  }
553
562
  return {
@@ -557,7 +566,8 @@ var resolveRecord = async (args) => {
557
566
  recordId: winner.id,
558
567
  parentValue: args.withParent ? winner.data : void 0,
559
568
  matchedAt: winner.matchedAt,
560
- matchedRule: winner.matchedRule
569
+ matchedRule: winner.matchedRule,
570
+ lifecycleStatus: winner.status
561
571
  };
562
572
  };
563
573
 
@@ -621,7 +631,8 @@ function useResolvedRecord(args) {
621
631
  source: "self",
622
632
  sourceRef: rec.ref ?? void 0,
623
633
  recordId: rec.id,
624
- facetRule: recFacetRule
634
+ facetRule: recFacetRule,
635
+ lifecycleStatus: rec.status
625
636
  };
626
637
  }
627
638
  const target = {
@@ -8840,6 +8851,8 @@ function PreviewReopenPill({
8840
8851
  side = "right",
8841
8852
  vAlign = "center"
8842
8853
  }) {
8854
+ const EDGE_INSET = 0;
8855
+ const TUCK_OFFSET = -12;
8843
8856
  const [pos, setPos] = useState(null);
8844
8857
  const rafRef = useRef(null);
8845
8858
  const getViewportCenterY = () => {
@@ -8853,25 +8866,26 @@ function PreviewReopenPill({
8853
8866
  const TOP_INSET = 0;
8854
8867
  const fallbackTop = () => vAlign === "top" ? TOP_INSET : vAlign === "bottom" ? Math.max(0, window.innerHeight - TOP_INSET) : getViewportCenterY();
8855
8868
  if (!el) {
8856
- setPos({ top: fallbackTop(), right: 8, left: 8 });
8869
+ setPos({ top: fallbackTop(), right: EDGE_INSET, left: EDGE_INSET });
8857
8870
  return;
8858
8871
  }
8872
+ const applyMeasurement = () => {
8873
+ const rect = el.getBoundingClientRect();
8874
+ if (rect.width === 0 && rect.height === 0) {
8875
+ return;
8876
+ }
8877
+ const top = vAlign === "top" ? rect.top + TOP_INSET : vAlign === "bottom" ? rect.bottom - TOP_INSET : getViewportCenterY();
8878
+ setPos({
8879
+ top,
8880
+ right: EDGE_INSET,
8881
+ left: EDGE_INSET
8882
+ });
8883
+ };
8859
8884
  const measure = () => {
8860
8885
  if (rafRef.current != null) cancelAnimationFrame(rafRef.current);
8861
- rafRef.current = requestAnimationFrame(() => {
8862
- const rect = el.getBoundingClientRect();
8863
- if (rect.width === 0 && rect.height === 0) {
8864
- return;
8865
- }
8866
- const top = vAlign === "top" ? rect.top + TOP_INSET : vAlign === "bottom" ? rect.bottom - TOP_INSET : getViewportCenterY();
8867
- setPos({
8868
- top,
8869
- right: 0,
8870
- left: 0
8871
- });
8872
- });
8886
+ rafRef.current = requestAnimationFrame(applyMeasurement);
8873
8887
  };
8874
- measure();
8888
+ applyMeasurement();
8875
8889
  const ro = new ResizeObserver(measure);
8876
8890
  ro.observe(el);
8877
8891
  ro.observe(document.body);
@@ -8887,12 +8901,12 @@ function PreviewReopenPill({
8887
8901
  window.visualViewport?.removeEventListener("scroll", measure);
8888
8902
  if (rafRef.current != null) cancelAnimationFrame(rafRef.current);
8889
8903
  };
8890
- }, [anchorRef, vAlign]);
8904
+ }, [anchorRef, vAlign, EDGE_INSET]);
8891
8905
  if (typeof document === "undefined") return null;
8892
8906
  const effectivePos = pos ?? {
8893
8907
  top: typeof window !== "undefined" ? vAlign === "top" ? 14 : vAlign === "bottom" ? window.innerHeight - 14 : getViewportCenterY() : 200,
8894
- right: 8,
8895
- left: 8
8908
+ right: EDGE_INSET,
8909
+ left: EDGE_INSET
8896
8910
  };
8897
8911
  const translateY = vAlign === "center" ? "-50%" : "0";
8898
8912
  return createPortal(
@@ -8907,10 +8921,12 @@ function PreviewReopenPill({
8907
8921
  style: {
8908
8922
  position: "fixed",
8909
8923
  top: effectivePos.top,
8910
- ...side === "right" ? { right: effectivePos.right } : { left: effectivePos.left },
8911
- // Pull half the pill width out into the gutter so it visually
8912
- // anchors *to* the editor edge rather than sitting inside it.
8913
- transform: side === "right" ? `translate(50%, ${translateY})` : `translate(-50%, ${translateY})`
8924
+ ...side === "right" ? { right: effectivePos.right + TUCK_OFFSET } : { left: effectivePos.left + TUCK_OFFSET },
8925
+ // Use a fixed tuck amount instead of percentage-based horizontal
8926
+ // translation. Percentage shifts depend on the pill's live width,
8927
+ // which differs across remount/close paths and caused the rail +
8928
+ // drawer variants to hide too much before a refresh.
8929
+ transform: `translateY(${translateY})`
8914
8930
  },
8915
8931
  children
8916
8932
  }
@@ -10227,7 +10243,18 @@ function RecordsAdminShellInner(props) {
10227
10243
  ]
10228
10244
  }
10229
10245
  ) : null;
10230
- const selectedSummary = isCollection && selectedItemId && !isDraftId3(selectedItemId) ? collectionItems.items.find((r) => r.id === selectedItemId || r.itemId === selectedItemId) : selectedRecordId && selectedRecordId !== DRAFT_ID3 ? recordList.items.find((r) => r.id === selectedRecordId) ?? globalScopedList.items.find((r) => r.id === selectedRecordId) ?? ruleScopedList.items.find((r) => r.id === selectedRecordId) ?? collectionItems.items.find((r) => r.id === selectedRecordId) : void 0;
10246
+ let selectedSummary = isCollection && selectedItemId && !isDraftId3(selectedItemId) ? collectionItems.items.find((r) => r.id === selectedItemId || r.itemId === selectedItemId) : selectedRecordId && selectedRecordId !== DRAFT_ID3 ? recordList.items.find((r) => r.id === selectedRecordId) ?? globalScopedList.items.find((r) => r.id === selectedRecordId) ?? ruleScopedList.items.find((r) => r.id === selectedRecordId) ?? collectionItems.items.find((r) => r.id === selectedRecordId) : void 0;
10247
+ if (!selectedSummary && !isCollection && resolved.source === "self" && resolved.recordId && editingTargetScope) {
10248
+ selectedSummary = {
10249
+ id: resolved.recordId,
10250
+ ref: resolved.sourceRef ?? editingTargetScope.raw,
10251
+ scope: editingTargetScope,
10252
+ data: resolved.data,
10253
+ status: "configured",
10254
+ label: "",
10255
+ lifecycleStatus: resolved.lifecycleStatus
10256
+ };
10257
+ }
10231
10258
  const editorLifecycleControl = selectedSummary?.id ? /* @__PURE__ */ jsx(
10232
10259
  LifecycleStatusControl,
10233
10260
  {