@proveanything/smartlinks-utils-ui 1.13.16 → 1.13.19

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.
@@ -1,4 +1,4 @@
1
- export { AssetPicker, useAppRegistry, useAssets } from '../../chunk-5NKKNCFT.js';
1
+ export { AssetPicker, useAppRegistry, useAssets } from '../../chunk-2LIV5MSN.js';
2
2
  import '../../chunk-OLYC54YT.js';
3
3
  import '../../chunk-5UQQYXCX.js';
4
4
  import '../../chunk-L7FQ52F5.js';
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { FacetRule } from '@proveanything/smartlinks/dist/types/appObjects';
3
- export { FacetRule, FacetRuleClause } from '@proveanything/smartlinks/dist/types/appObjects';
2
+ import { FacetRule } from '@proveanything/smartlinks';
3
+ export { FacetRule, FacetRuleClause } from '@proveanything/smartlinks';
4
4
  import { F as FacetOption } from '../../types-BLqki3Zy.js';
5
5
 
6
6
  interface FacetRuleEditorProps {
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { FacetRule, MatchedAt, AppRecord, RecordTarget, MatchResult, ResolveAllEntry } from '@proveanything/smartlinks/dist/types/appObjects';
2
+ import * as _proveanything_smartlinks from '@proveanything/smartlinks';
3
+ import { FacetRule, MatchedAt, AppRecord, RecordTarget, MatchResult, ResolveAllEntry } from '@proveanything/smartlinks';
3
4
  import * as React$1 from 'react';
4
5
  import { ReactNode, ComponentType } from 'react';
5
6
  import { LucideIcon } from 'lucide-react';
6
7
  import * as _tanstack_query_core from '@tanstack/query-core';
7
- import * as _proveanything_smartlinks from '@proveanything/smartlinks';
8
8
  import { InfiniteData } from '@tanstack/react-query';
9
9
  export { E as ErrorBoundary, a as ErrorBoundaryProps } from '../../ErrorBoundary-J9iKgF_H.js';
10
10
 
@@ -9565,6 +9565,32 @@ function RecordsAdminShellInner(props) {
9565
9565
  } = selection;
9566
9566
  const [isReconcilingRecordSelection, setIsReconcilingRecordSelection] = useState(false);
9567
9567
  const { dismissed, dismiss, undismiss } = useIntroDismissed(SL, collectionId, appId, recordType);
9568
+ const primeResolvedFromRow = useCallback((row) => {
9569
+ if (!row?.id) return;
9570
+ if (row.data === void 0) return;
9571
+ const cacheKey = resolvedRecordQueryKey({
9572
+ collectionId,
9573
+ appId,
9574
+ recordType,
9575
+ productId: row.scope?.productId,
9576
+ variantId: row.scope?.variantId,
9577
+ batchId: row.scope?.batchId,
9578
+ facetId: row.scope?.facetId,
9579
+ facetValue: row.scope?.facetValue,
9580
+ proofId: row.scope?.proofId,
9581
+ recordId: row.id,
9582
+ withParent: true
9583
+ });
9584
+ if (queryClient.getQueryData(cacheKey) !== void 0) return;
9585
+ queryClient.setQueryData(cacheKey, {
9586
+ data: row.data,
9587
+ source: "self",
9588
+ sourceRef: row.ref || void 0,
9589
+ recordId: row.id,
9590
+ facetRule: row.facetRule ?? null,
9591
+ lifecycleStatus: row.lifecycleStatus
9592
+ });
9593
+ }, [queryClient, collectionId, appId, recordType]);
9568
9594
  const mintRuleWizardDraftKey = useCallback(
9569
9595
  () => `rule-wizard:${typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`}`,
9570
9596
  []
@@ -9706,10 +9732,12 @@ function RecordsAdminShellInner(props) {
9706
9732
  if (cardinality === "singleton") {
9707
9733
  const conflict = findConflictForRecord(first.id, singletonConflicts);
9708
9734
  if (conflict?.active.id) {
9735
+ primeResolvedFromRow(recordList.items.find((it) => it.id === conflict.active.id) ?? null);
9709
9736
  setSelectedRecordId(conflict.active.id);
9710
9737
  return;
9711
9738
  }
9712
9739
  }
9740
+ primeResolvedFromRow(first);
9713
9741
  setSelectedRecordId(first.id);
9714
9742
  }, [activeScope, selectedRecordId, recordList.items, cardinality, ruleWizardStep, draftKind, isReconcilingRecordSelection, singletonConflicts]);
9715
9743
  const editingScopes = useEditingScope({
@@ -11064,6 +11092,7 @@ function RecordsAdminShellInner(props) {
11064
11092
  setSelectedBatchId(void 0);
11065
11093
  setDrillTab("product");
11066
11094
  } else {
11095
+ primeResolvedFromRow(item);
11067
11096
  setSelectedRecordId(item.id ?? null);
11068
11097
  setDraftKind(null);
11069
11098
  if (ruleWizardStep !== null) {
@@ -11465,6 +11494,12 @@ function RecordsAdminShellInner(props) {
11465
11494
  },
11466
11495
  onArchiveDuplicates: enableArchiveDuplicates ? async () => {
11467
11496
  const ids = singletonConflicts.flatMap((c) => c.duplicates.map((d) => d.id)).filter((id) => !!id);
11497
+ const survivorIfStrandedArchive = (() => {
11498
+ if (!selectedRecordId || selectedRecordId === DRAFT_ID3) return void 0;
11499
+ if (!ids.includes(selectedRecordId)) return void 0;
11500
+ const c = singletonConflicts.find((c2) => c2.duplicates.some((d) => d.id === selectedRecordId));
11501
+ return c?.active.id;
11502
+ })();
11468
11503
  for (const id of ids) {
11469
11504
  try {
11470
11505
  const updated = await SL.app.records.update(collectionId, appId, id, { status: archivedStatusValue }, true);
@@ -11482,9 +11517,18 @@ function RecordsAdminShellInner(props) {
11482
11517
  }
11483
11518
  }
11484
11519
  markScopeCountsStale(queryClient, ctx);
11520
+ if (survivorIfStrandedArchive) {
11521
+ setSelectedRecordId(survivorIfStrandedArchive);
11522
+ }
11485
11523
  } : void 0,
11486
11524
  onDeleteDuplicates: enableDeleteDuplicates ? async () => {
11487
11525
  const ids = singletonConflicts.flatMap((c) => c.duplicates.map((d) => d.id)).filter((id) => !!id);
11526
+ const survivorIfStrandedDelete = (() => {
11527
+ if (!selectedRecordId || selectedRecordId === DRAFT_ID3) return void 0;
11528
+ if (!ids.includes(selectedRecordId)) return void 0;
11529
+ const c = singletonConflicts.find((c2) => c2.duplicates.some((d) => d.id === selectedRecordId));
11530
+ return c?.active.id;
11531
+ })();
11488
11532
  for (const id of ids) {
11489
11533
  try {
11490
11534
  await SL.app.records.remove(collectionId, appId, id, true);
@@ -11500,6 +11544,11 @@ function RecordsAdminShellInner(props) {
11500
11544
  }
11501
11545
  }
11502
11546
  markScopeCountsStale(queryClient, ctx);
11547
+ if (survivorIfStrandedDelete) {
11548
+ setSelectedRecordId(survivorIfStrandedDelete);
11549
+ } else if (selectedRecordId && ids.includes(selectedRecordId)) {
11550
+ setSelectedRecordId(null);
11551
+ }
11503
11552
  } : void 0,
11504
11553
  i18n: {
11505
11554
  title: i18n.conflictBannerTitle,
@@ -12275,7 +12324,13 @@ function useRecordEditor(args) {
12275
12324
  source: "self",
12276
12325
  sourceRef: scope.raw,
12277
12326
  recordId: resolved.recordId,
12278
- parentValue: previousCache?.parentValue ?? resolved.parentValue
12327
+ parentValue: previousCache?.parentValue ?? resolved.parentValue,
12328
+ // Preserve the record's `facetRule` across the optimistic flip so
12329
+ // rule-targeted rows don't briefly look like unanchored globals
12330
+ // (which would cascade into the editor seeding an empty rule and
12331
+ // the next save creating a duplicate global).
12332
+ facetRule: facetRule ?? previousCache?.facetRule ?? null,
12333
+ lifecycleStatus: previousCache?.lifecycleStatus
12279
12334
  });
12280
12335
  try {
12281
12336
  if (resolved.recordId && resolved.source === "self") {