@proveanything/smartlinks-utils-ui 0.8.3 → 0.9.1

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.
@@ -19,8 +19,15 @@ import { InfiniteData } from '@tanstack/react-query';
19
19
  * - `rule` — synthetic UI scope: records that target via a `facetRule`
20
20
  * (AND-of-OR over facets) rather than being pinned to a
21
21
  * specific node in the chain. Their refs start with `rule:`.
22
+ * - `all` — synthetic UI scope: opt-in flat-list view of every record
23
+ * in the collection (global + ruled + pinned). Skips the
24
+ * framework's scope-as-axis grouping entirely so hosts can
25
+ * drive the rail with their own `rail.groupBy` (e.g.
26
+ * open / upcoming / closed for time-bound records like
27
+ * votes or competitions). Off by default — add `'all'` to
28
+ * the host's `scopes` array to enable.
22
29
  */
23
- type ScopeKind = 'collection' | 'product' | 'facet' | 'variant' | 'batch' | 'rule';
30
+ type ScopeKind = 'collection' | 'product' | 'facet' | 'variant' | 'batch' | 'rule' | 'all';
24
31
  /** Parsed `ref` string — see `data/refs.ts`. Format: `kind:id` or chain. */
25
32
  interface ParsedRef {
26
33
  /** Most-specific scope this ref points at. */
@@ -407,6 +414,16 @@ interface RecordsAdminI18n {
407
414
  subtitleEmpty: string;
408
415
  subtitleConfigured: string;
409
416
  subtitleInherited: string;
417
+ /**
418
+ * Hover tooltip on the "Rules" scope tab. The label itself stays short
419
+ * for navigation density; this longer string surfaces the audience /
420
+ * targeting vocabulary that explains the feature without needing docs.
421
+ * Apps can override per-domain (e.g. "Show this FAQ to a targeted
422
+ * audience").
423
+ */
424
+ rulesTabTooltip: string;
425
+ /** Empty-state body shown inside the Rules tab when no rules exist yet. */
426
+ rulesEmptyBody: string;
410
427
  }
411
428
  declare const DEFAULT_I18N: RecordsAdminI18n;
412
429
 
@@ -675,285 +692,194 @@ interface RecordsAdminShellProps<TData = unknown> {
675
692
  */
676
693
  contextScopeMode?: 'strict' | 'expand';
677
694
  renderEditor: (ctx: EditorContext<TData>) => ReactNode;
678
- /**
679
- * Render the preview surface. Receives the editor's current value so the
680
- * preview tracks unsaved edits. When `previewScope` differs from the
681
- * editing scope (because the user picked something in `<PreviewScopePicker>`),
682
- * `previewScope` reflects the chosen target — apps can use it to load
683
- * resolved/collected/merged data for that scope instead of `resolved`.
684
- */
685
- renderPreview?: (ctx: {
686
- resolved: TData | null;
687
- previewScope: ParsedRef;
688
- }) => ReactNode;
689
- /**
690
- * How the preview surface attaches to the editor pane.
691
- * - `inline` (default): rendered below the form (current behaviour).
692
- * - `side`: resizable right pane next to the editor.
693
- * - `tab`: Editor / Preview siblings inside the right pane.
694
- * - `drawer`: slide-out from the right, toggled by a button.
695
- */
696
- previewMode?: 'inline' | 'side' | 'tab' | 'drawer';
697
- /**
698
- * When true, render a `<PreviewScopePicker>` in the preview chrome so admins
699
- * can preview as a different product/variant/batch than they're editing.
700
- * Default false.
701
- */
702
- previewScopePicker?: boolean;
703
- /**
704
- * Editor tab strip behaviour. See {@link RecordsAdminEditorTabsMode}.
705
- * Default `'off'` — the redundant single-tab strip is hidden when the
706
- * product has no variants/batches.
707
- */
708
- editorTabs?: RecordsAdminEditorTabsMode;
709
- /**
710
- * How to handle unsaved edits when the user navigates to a different
711
- * record/scope/tab.
712
- * - `prompt` (default): show a confirm dialog (Discard / Cancel / Save).
713
- * - `autosave`: silently save before navigating away.
714
- * - `keep`: hold edits in memory keyed by ref; coming back restores them.
715
- */
716
- dirtyStrategy?: 'prompt' | 'autosave' | 'keep';
717
- /**
718
- * Pre-delete hook. Return `false` to abort. Lets apps run app-specific
719
- * confirms (e.g. "this batch has 12k linked proofs"). When omitted the
720
- * inline two-step confirm is the only safeguard.
721
- */
722
- onBeforeDelete?: (scope: ParsedRef) => boolean | Promise<boolean>;
723
- /**
724
- * Disable the browser-level `beforeunload` prompt. Default false.
725
- * Set true when the host platform handles unload guarding itself.
726
- */
727
- disableBeforeUnload?: boolean;
728
- intro?: {
729
- title: string;
730
- body: ReactNode;
731
- /**
732
- * Where to surface the "show again" affordance after the user dismisses
733
- * the intro banner.
734
- *
735
- * - `'header'` *(default)* — small ghost icon-button (`?`) inline inside
736
- * the `ShellHeader`, right-aligned next to `headerActions`. Zero
737
- * vertical footprint. Auto-falls back to `'footer'` when no header
738
- * card is rendered (host hasn't enabled it).
739
- * - `'footer'` — render the `?` button in the quiet utility row that
740
- * sits above the rail/editor split.
741
- * - `'inline'` — legacy behaviour: full-width strip with a "How it
742
- * works" pill on the right.
743
- * - `'hidden'` — once dismissed, do not offer a way to bring it back
744
- * from this surface. The host can still re-enable via state reset.
745
- */
746
- reopenAffordance?: 'header' | 'footer' | 'inline' | 'hidden';
747
- /** Override the default "How it works" label / tooltip. */
748
- reopenLabel?: string;
749
- };
750
695
  csvSchema?: CsvSchema<TData>;
751
696
  classify?: (record: RecordSummary<TData>) => RecordStatus;
752
697
  defaultData?: () => TData;
753
698
  /**
754
- * Optional derivation for the label that represents an in-flight draft
755
- * in the unsaved-changes tray. Receives the editor's current value and
756
- * its scope; return a short, human-readable title (or `undefined` to
757
- * defer to the built-in heuristic). Useful when your record shape nests
758
- * the title under a custom key the heuristic doesn't know about.
759
- */
760
- deriveDraftLabel?: (value: TData, scope: ParsedRef) => string | undefined;
761
- /**
762
- * Which layouts the rail offers. Default `['list']`. When more than one is
763
- * supplied, a switcher appears above the list and the choice persists
764
- * per-app/recordType.
765
- */
766
- presentations?: RecordPresentation[];
767
- /** Initial presentation when nothing is persisted. Default first of `presentations`. */
768
- defaultPresentation?: RecordPresentation;
769
- /**
770
- * Optional custom row renderer for the rail. Applied to both `list` and
771
- * `compact` densities. Cards/galleries are not supported in the rail —
772
- * they belong on the right pane (see `renderItemList` / `itemView`).
699
+ * Header card configuration. The card is off by default; set `show: true`
700
+ * (or pass any of `title` / `subtitle` / `icon` / `actions` / `stats`) to
701
+ * opt in.
773
702
  */
774
- renderListRow?: (record: RecordSummary<TData>, ctx: RecordSlotContext) => ReactNode;
703
+ header?: HeaderConfig;
775
704
  /**
776
- * Optional custom empty-state renderer for the rail. If omitted the shell
777
- * uses the default `<EmptyState>` with `i18n.emptyTitle` / `i18n.emptyBody`.
705
+ * Dismissable intro / "How it works" card shown above the rail+editor split.
706
+ * Only renders when supplied. The reopen affordance defaults to a small
707
+ * icon-button inside the header (auto-falls back to the utility row when
708
+ * no header is rendered).
778
709
  */
779
- renderEmpty?: (ctx: {
780
- scope: ParsedRef | null;
781
- }) => ReactNode;
710
+ intro?: IntroConfig;
711
+ rail?: RailConfig<TData>;
712
+ editor?: EditorConfig<TData>;
713
+ items?: ItemsConfig<TData>;
714
+ unsaved?: UnsavedConfig<TData>;
715
+ clipboard?: ClipboardConfig<TData>;
716
+ actions?: ActionsConfig;
782
717
  /**
783
- * Whether each scope holds at most one record (`singleton`, default) or
784
- * many (`collection`, e.g. FAQs / recipes / SOPs). In collection mode the
785
- * shell treats scopes as folders containing items: when a scope is selected
786
- * with no item open, the right pane shows the multi-item view (default
787
- * table, or `renderItemList` / `itemView` overrides). Clicking an item
788
- * opens it in the editor with Back / prev / next nav, and the rail flips
789
- * to siblings (see `collectionRailMode`).
718
+ * Mirror the shell's runtime state into URL params. Off by default. The
719
+ * shell only owns `item`, `scope`, `view` host platform params are
720
+ * untouched.
790
721
  */
791
- cardinality?: RecordCardinality;
792
- /** Display name for an item in collection mode (defaults to `'item'`). */
793
- itemNoun?: string;
794
- /**
795
- * Generate a host-local handle for a brand-new collection item draft when
796
- * "+ New" is clicked. The shell prefixes non-draft values so they remain
797
- * recognisably unsaved (`draft:…`) until the first save returns a real
798
- * record UUID. Use this when the host wants stable local draft identities
799
- * for analytics/UI bookkeeping — not to predeclare the eventual server id.
800
- */
801
- generateItemId?: () => string;
802
- /**
803
- * Which built-in item views the right pane offers when a scope is selected
804
- * and no item is open. Default `['table']`. When more than one is supplied,
805
- * a switcher appears above the item view and the choice persists per
806
- * `appId` + `recordType`.
807
- *
808
- * Ignored when `renderItemList` is supplied (the host owns the entire view).
809
- */
810
- itemViews?: ItemView[];
811
- /** Initial item view when nothing is persisted. Default first of `itemViews`. */
812
- defaultItemView?: ItemView;
813
- /**
814
- * Declarative columns for the built-in default `table` view. The shell
815
- * renders a styled table — most apps with a few well-defined fields
816
- * (FAQ question + last-updated, recipe name + cuisine + servings) want
817
- * this rather than a custom renderer.
818
- */
819
- itemColumns?: ItemColumn<TData>[];
820
- /**
821
- * Full custom item-view renderer. When supplied, replaces the built-in
822
- * table / cards / gallery entirely — `itemViews`, `itemColumns`, and
823
- * `renderItemCard` are ignored.
824
- */
825
- renderItemList?: (items: RecordSummary<TData>[], ctx: ItemViewContext) => ReactNode;
826
- /**
827
- * Custom card renderer for the `cards` and `gallery` item views. Falls
828
- * back to a styled built-in card when omitted.
829
- */
830
- renderItemCard?: (record: RecordSummary<TData>, ctx: ItemSlotContext) => ReactNode;
831
- /**
832
- * Visual density of the built-in `cards` / `gallery` item views.
833
- * - `'sm'` — tight: ~180px (cards) / ~240px (gallery) min column width.
834
- * - `'md'` *(default)* — comfortable: ~240px / ~320px.
835
- * - `'lg'` — spacious: ~320px / ~420px, suits hero-style imagery.
836
- *
837
- * Hosts that need exact pixel control can override the underlying
838
- * `--ra-item-card-min` / `--ra-item-gallery-min` CSS custom properties
839
- * on `.ra-shell` instead.
840
- */
841
- itemCardSize?: 'sm' | 'md' | 'lg';
842
- /**
843
- * Custom empty state when a scope has no items yet. Falls back to a
844
- * styled built-in empty state with a "+ New {noun}" CTA.
845
- */
846
- renderItemEmpty?: (ctx: ItemViewContext) => ReactNode;
847
- /**
848
- * What the rail shows once an item is open (collection cardinality only).
849
- * Default `'siblings'` — the rail flips to the items in the current scope
850
- * with a pinned `← All scopes` link. Set to `'scopes'` to keep the rail
851
- * on scope navigation (admin must use Back / prev / next instead).
852
- */
853
- collectionRailMode?: CollectionRailMode;
854
- /** Display title shown in the header card. Falls back to `label`, then `recordType`. */
855
- title?: string;
856
- /** Single-line muted subtitle under the header title. */
857
- subtitle?: string;
858
- /**
859
- * Render the branded header card above the rail. Off by default — most apps
860
- * don't need it (the surrounding host typically already shows a title). Set
861
- * `true` to opt in, or simply pass any of the header-customising props
862
- * (`title`, `subtitle`, `headerIcon`, `headerActions`, `showStats`,
863
- * `statsItems`) and the header will auto-show.
864
- */
865
- showHeader?: boolean;
866
- /** Icon shown in the header card. Falls back to `icons.header.byRecordType[recordType]`
867
- * or `icons.header.default`. Pass a Lucide icon component or any ReactNode. */
868
- headerIcon?: ReactNode;
869
- /** Right-aligned header content — typically a primary "+ New" button + secondary controls. */
870
- headerActions?: ReactNode;
871
- /** Show a counts strip in the header (e.g. Shared · Products). Off by default —
872
- * most apps don't need it. When `true`, the shell renders built-in counts unless
873
- * `statsItems` is also provided. */
874
- showStats?: boolean;
875
- /** Show the contextual icon to the left of the header title. Default true.
876
- * Set to `false` if the recordType icon (database, etc.) feels off-brand. */
877
- showHeaderIcon?: boolean;
878
- /** Fully custom stats strip content. When provided, replaces the built-in
879
- * Shared/Products counts. Each item renders as a value + uppercase label. */
880
- statsItems?: Array<{
722
+ deepLink?: DeepLinkOptions;
723
+ /** Override the default Lucide icons used by the shell. Deep-merged onto
724
+ * `DEFAULT_ICONS`. */
725
+ icons?: Partial<RecordsAdminIcons>;
726
+ i18n?: Partial<RecordsAdminI18n>;
727
+ onTelemetry?: (event: TelemetryEvent) => void;
728
+ className?: string;
729
+ }
730
+ interface HeaderStatsConfig {
731
+ /** Show a counts strip in the header. */
732
+ show?: boolean;
733
+ /** Fully custom stats items. When provided, replaces built-in counts. */
734
+ items?: Array<{
881
735
  label: string;
882
736
  value: string | number;
883
737
  }>;
884
738
  /** Optional title rendered above the stats strip (e.g. "At a glance"). */
885
- statsTitle?: string;
886
- /** Optional icon rendered next to `statsTitle`. Pass a Lucide icon element
887
- * or any ReactNode. */
888
- statsIcon?: ReactNode;
889
- /**
890
- * External help / documentation link for this admin surface. When set, the
891
- * shell renders a small icon-button in the header (right side) that opens
892
- * the URL in a new tab. Use this to point at an app-specific help doc in
893
- * your shared docs site.
894
- */
739
+ title?: string;
740
+ /** Optional icon rendered next to the stats title. */
741
+ icon?: ReactNode;
742
+ }
743
+ interface HeaderConfig {
744
+ /** Render the branded header card above the rail. Auto-true when any other
745
+ * header field is set. */
746
+ show?: boolean;
747
+ /** Display title shown in the header card. Falls back to `label`, then
748
+ * `recordType`. */
749
+ title?: string;
750
+ /** Single-line muted subtitle under the title. */
751
+ subtitle?: string;
752
+ /** Icon shown to the left of the header title. Falls back to
753
+ * `icons.header.byRecordType[recordType]` or `icons.header.default`. */
754
+ icon?: ReactNode;
755
+ /** Show the contextual icon. Default true. */
756
+ showIcon?: boolean;
757
+ /** Right-aligned header content — typically a primary "+ New" button. */
758
+ actions?: ReactNode;
759
+ /** External help / documentation link rendered as a small icon-button. */
895
760
  helpUrl?: string;
896
- /** Tooltip / aria-label for the help link. Defaults to "Help & documentation". */
761
+ /** Tooltip / aria-label for the help link. Defaults to
762
+ * "Help & documentation". */
897
763
  helpLabel?: string;
898
- /** Override the default Lucide icons used by the shell (scope tabs, statuses,
899
- * empty states, action menus, etc.). Deep-merged onto `DEFAULT_ICONS`. */
900
- icons?: Partial<RecordsAdminIcons>;
901
- /** When supplied, the records list is rendered as accordion-style groups.
902
- * Return `null` to put a record in the default "Other" bucket. */
764
+ /** Counts strip configuration. */
765
+ stats?: HeaderStatsConfig;
766
+ }
767
+ interface IntroConfig {
768
+ title: string;
769
+ body: ReactNode;
770
+ /**
771
+ * Where to surface the "show again" affordance after dismissal.
772
+ * Defaults to `'header'` (auto-falls back to `'footer'` when no header
773
+ * card is rendered).
774
+ */
775
+ reopenAffordance?: 'header' | 'footer' | 'inline' | 'hidden';
776
+ /** Override the default "How it works" label / tooltip. */
777
+ reopenLabel?: string;
778
+ }
779
+ interface RailConfig<TData = unknown> {
780
+ /** Which layouts the rail offers. Default `['list']`. */
781
+ presentations?: RecordPresentation[];
782
+ /** Initial presentation when nothing is persisted. */
783
+ defaultPresentation?: RecordPresentation;
784
+ /** Custom row renderer for `list` / `compact` densities. */
785
+ renderListRow?: (record: RecordSummary<TData>, ctx: RecordSlotContext) => ReactNode;
786
+ /**
787
+ * Custom empty-state renderer for the records rail. Receives the active
788
+ * scope (kind only). Falls back to the styled built-in empty state.
789
+ */
790
+ renderEmpty?: (ctx: {
791
+ scope: ScopeKind;
792
+ }) => ReactNode;
793
+ /** Group rail records into accordion-style buckets. Return `null` to put
794
+ * a record in the default "Other" bucket. */
903
795
  groupBy?: (record: RecordSummary) => {
904
796
  key: string;
905
797
  label: string;
906
798
  icon?: ReactNode;
907
799
  } | null;
908
- /** Custom empty-state renderer for the records rail. Falls back to the styled
909
- * built-in empty state (icon + title + body + optional CTAs). */
910
- renderEmptyState?: (ctx: {
911
- scope: ScopeKind;
912
- }) => ReactNode;
913
800
  /** Visual density. Default `comfortable`. */
914
801
  density?: 'comfortable' | 'compact';
915
- i18n?: Partial<RecordsAdminI18n>;
916
- onTelemetry?: (event: TelemetryEvent) => void;
917
- className?: string;
802
+ }
803
+ interface EditorPreviewConfig<TData = unknown> {
918
804
  /**
919
- * Override the resting label for footer / banner actions. When a key is
920
- * omitted the shell falls back to the i18n default ("Save", "Discard",
921
- * "Delete"). Loading / disabled states (e.g. "Saving…") remain owned by
922
- * the shell — only the resting label is customisable here.
923
- *
924
- * Hosts that need translated labels should pass already-translated
925
- * strings; the shell stays locale-agnostic.
805
+ * Render the preview surface. Receives the editor's current value so the
806
+ * preview tracks unsaved edits, plus the chosen `previewScope` (which can
807
+ * differ from the editing scope when `<PreviewScopePicker>` is used).
926
808
  */
927
- actionLabels?: Partial<Record<RecordsAdminActionKey, string>>;
809
+ render?: (ctx: {
810
+ resolved: TData | null;
811
+ previewScope: ParsedRef;
812
+ }) => ReactNode;
928
813
  /**
929
- * Optional icon component rendered before each action label (sized
930
- * `h-4 w-4`). Omit a key to preserve current look — the editor footer
931
- * renders Save/Discard without icons by default. Delete retains its
932
- * built-in `Trash2` unless overridden here.
814
+ * How the preview surface attaches to the editor pane.
815
+ * - `inline` (default): rendered below the form.
816
+ * - `side`: resizable right pane next to the editor.
817
+ * - `tab`: Editor / Preview siblings inside the right pane.
818
+ * - `drawer`: slide-out from the right, toggled by a button.
933
819
  */
934
- actionIcons?: Partial<Record<RecordsAdminActionKey, RecordsAdminActionIcon>>;
820
+ mode?: 'inline' | 'side' | 'tab' | 'drawer';
821
+ /** Render a `<PreviewScopePicker>` so admins can preview as a different
822
+ * product/variant/batch than they're editing. Default false. */
823
+ scopePicker?: boolean;
824
+ }
825
+ interface EditorConfig<TData = unknown> {
826
+ /** Editor tab strip behaviour. See {@link RecordsAdminEditorTabsMode}. */
827
+ tabs?: RecordsAdminEditorTabsMode;
828
+ /** Preview pane configuration. */
829
+ preview?: EditorPreviewConfig<TData>;
830
+ }
831
+ interface ItemsConfig<TData = unknown> {
935
832
  /**
936
- * Enable in-shell Copy / Paste between scopes for the current `recordType`.
937
- * Default `true`. The clipboard is scoped per `(appId, recordType)` and
938
- * persists in `sessionStorage` so it survives host route changes.
833
+ * Whether each scope holds at most one record (`singleton`, default) or
834
+ * many (`collection`).
939
835
  */
940
- enableClipboard?: boolean;
836
+ cardinality?: RecordCardinality;
837
+ /** Display name for an item in collection mode. Default `'item'`. */
838
+ noun?: string;
839
+ /** Generate a host-local handle for a brand-new draft. */
840
+ generateId?: () => string;
841
+ /** Which built-in item views the right pane offers. Default `['table']`. */
842
+ views?: ItemView[];
843
+ /** Initial item view when nothing is persisted. */
844
+ defaultView?: ItemView;
845
+ /** Declarative columns for the built-in `table` view. */
846
+ columns?: ItemColumn<TData>[];
847
+ /** Card renderer for `cards` / `gallery` views. */
848
+ renderCard?: (record: RecordSummary<TData>, ctx: ItemSlotContext) => ReactNode;
849
+ /** Full custom item-view renderer. Replaces built-in views entirely. */
850
+ renderList?: (items: RecordSummary<TData>[], ctx: ItemViewContext) => ReactNode;
851
+ /** Custom empty-state when a scope has no items yet. */
852
+ renderEmpty?: (ctx: ItemViewContext) => ReactNode;
853
+ /** Visual density of `cards` / `gallery` views. Default `'md'`. */
854
+ cardSize?: 'sm' | 'md' | 'lg';
855
+ /** What the rail shows once an item is open. Default `'siblings'`. */
856
+ railMode?: CollectionRailMode;
857
+ }
858
+ interface UnsavedConfig<TData = unknown> {
941
859
  /**
942
- * Optional transform on Copy. Receives the resolved value at the source
943
- * scope and returns what should be stored in the clipboard. Use this to
944
- * strip per-scope-only fields (e.g. country of origin) that shouldn't
945
- * propagate. Defaults to a deep clone of the resolved value.
860
+ * How to handle unsaved edits when navigating away.
861
+ * - `keep` (default): hold edits per editor mount; surface via the
862
+ * inline UnsavedBanner.
863
+ * - `prompt`: show a confirm dialog on navigation.
864
+ * - `autosave`: silently save before navigating.
946
865
  */
866
+ strategy?: 'prompt' | 'autosave' | 'keep';
867
+ /** Disable the browser-level `beforeunload` prompt. Default false. */
868
+ disableBeforeUnload?: boolean;
869
+ /** Pre-delete hook. Return `false` to abort. */
870
+ onBeforeDelete?: (scope: ParsedRef) => boolean | Promise<boolean>;
871
+ /** Derive a label for an in-flight draft in the unsaved-changes tray. */
872
+ deriveDraftLabel?: (value: TData, scope: ParsedRef) => string | undefined;
873
+ }
874
+ interface ClipboardConfig<TData = unknown> {
875
+ /** Enable in-shell Copy / Paste. Default `true`. */
876
+ enabled?: boolean;
877
+ /** Optional transform on Copy. Defaults to a deep clone. */
947
878
  onCopy?: (source: {
948
879
  value: TData;
949
880
  scope: ParsedRef;
950
881
  }) => TData;
951
- /**
952
- * Optional transform on Paste. Receives the clipboard payload and the
953
- * destination scope/current value. Return the value to apply, or `null`
954
- * to abort the paste. Defaults to replacing the destination's value with
955
- * the clipboard's.
956
- */
882
+ /** Optional transform on Paste. Return `null` to abort. */
957
883
  onPaste?: (clipboard: {
958
884
  value: TData;
959
885
  sourceScope: ParsedRef;
@@ -961,21 +887,12 @@ interface RecordsAdminShellProps<TData = unknown> {
961
887
  scope: ParsedRef;
962
888
  currentValue: TData | null;
963
889
  }) => TData | null;
964
- /**
965
- * Mirror the shell's runtime state (current scope, open item, right-pane
966
- * view) into URL parameters so links open to the right place and the
967
- * browser back/forward buttons feel native.
968
- *
969
- * Off by default. The shell only owns the params it knows about
970
- * (`item`, `scope`, `view`); platform context like `appId` /
971
- * `collectionId` lives in the host's URL and stays untouched.
972
- *
973
- * Pass an `adapter` to integrate with a host router (React Router,
974
- * SmartLinks `persistentQueryParams`, etc.) — without one the shell
975
- * uses a default `window.location` + `window.history` adapter that
976
- * also handles hash routing.
977
- */
978
- deepLink?: DeepLinkOptions;
890
+ }
891
+ interface ActionsConfig {
892
+ /** Override resting labels for `save` / `discard` / `delete` (etc.). */
893
+ labels?: Partial<Record<RecordsAdminActionKey, string>>;
894
+ /** Optional icon component rendered before each action label. */
895
+ icons?: Partial<Record<RecordsAdminActionKey, RecordsAdminActionIcon>>;
979
896
  }
980
897
  /**
981
898
  * Controls the small tab strip that appears above the editor body inside the
@@ -1031,10 +948,17 @@ interface Props$g {
1031
948
  loading?: boolean;
1032
949
  /** Optional per-scope counts displayed as tiny badges. */
1033
950
  counts?: Partial<Record<ScopeKind, number>>;
951
+ /**
952
+ * Optional per-scope hover tooltip (rendered as native `title`). Used by
953
+ * the shell to surface marketing-friendly explanations on tabs whose
954
+ * one-word label benefits from a longer gloss — primarily "Rules"
955
+ * ("Use rules to scope records to a targeted audience…").
956
+ */
957
+ tooltips?: Partial<Record<ScopeKind, string>>;
1034
958
  /** Override icons used per scope. Falls back to DEFAULT_ICONS.scope. */
1035
959
  icons?: RecordsAdminIcons['scope'];
1036
960
  }
1037
- declare const ScopeTabs: ({ scopes, active, onChange, loading, counts, icons, }: Props$g) => react_jsx_runtime.JSX.Element;
961
+ declare const ScopeTabs: ({ scopes, active, onChange, loading, counts, tooltips, icons, }: Props$g) => react_jsx_runtime.JSX.Element;
1038
962
 
1039
963
  interface Props$f {
1040
964
  source?: RecordSource;
@@ -1088,6 +1012,8 @@ interface Props$c {
1088
1012
  * Anchor-based highlight fallback for tabs whose rail rows are not backed
1089
1013
  * by AppRecords (Products, Facets). Compared against `RecordSummary.ref`
1090
1014
  * which for those tabs is a synthesised display-only anchor string.
1015
+ * NOTE: framework-owned. Built via `anchorKey(scope)` — does NOT come from
1016
+ * the host's `record.ref` field (which the framework deliberately ignores).
1091
1017
  */
1092
1018
  selectedAnchorKey?: string;
1093
1019
  onSelect: (item: RecordSummary) => void;
@@ -1114,6 +1040,18 @@ interface Props$c {
1114
1040
  label: string;
1115
1041
  icon?: ReactNode;
1116
1042
  } | null;
1043
+ /**
1044
+ * Optional per-group action slot rendered to the right of the group
1045
+ * header label/count. Used by the shell to surface a "Edit rule for all"
1046
+ * affordance on Rules-tab groups (each group is one shared rule). The
1047
+ * callback receives the group's key + the records in that group so the
1048
+ * caller can target them. Returning `null` hides the slot.
1049
+ */
1050
+ renderGroupActions?: (group: {
1051
+ key: string;
1052
+ label: string;
1053
+ items: RecordSummary[];
1054
+ }) => ReactNode;
1117
1055
  /**
1118
1056
  * Optional clipboard wiring per row. When provided the shell's Copy /
1119
1057
  * Paste affordance appears in each row's context menu. Returning `null`
@@ -1129,11 +1067,11 @@ interface Props$c {
1129
1067
  /** Resolved i18n strings — used by default row/card renderers. */
1130
1068
  i18n?: RecordsAdminI18n;
1131
1069
  }
1132
- declare const RecordList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1133
- declare const ProductList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1134
- declare const FacetList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1135
- declare const VariantList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1136
- declare const BatchList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1070
+ declare const RecordList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1071
+ declare const ProductList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1072
+ declare const FacetList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1073
+ declare const VariantList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1074
+ declare const BatchList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1137
1075
 
1138
1076
  interface DefaultRecordRowProps {
1139
1077
  record: RecordSummary;
@@ -1197,6 +1135,13 @@ interface Props$a<T> {
1197
1135
  * leave it `undefined` and nothing renders.
1198
1136
  */
1199
1137
  targeting?: ReactNode;
1138
+ /**
1139
+ * Optional small control rendered in the header's right cluster (next to
1140
+ * the bulk-actions menu). Used for the per-record `TargetingPopover` so
1141
+ * admins can flip between Global / a preset rule / a custom rule from
1142
+ * the editor header without scrolling to the Targeting section.
1143
+ */
1144
+ targetingControl?: ReactNode;
1200
1145
  bulkActions?: React.ComponentProps<typeof BulkActionsMenu>;
1201
1146
  /** Extra slot rendered in the footer between the danger actions and Save. */
1202
1147
  footerExtra?: ReactNode;
@@ -1235,7 +1180,7 @@ interface Props$a<T> {
1235
1180
  /** Host-provided icons rendered before save / discard / delete labels. */
1236
1181
  actionIcons?: Partial<Record<RecordsAdminActionKey, RecordsAdminActionIcon>>;
1237
1182
  }
1238
- declare function RecordEditor<T>({ ctx, i18n, children, preview, targeting, bulkActions, footerExtra, onBeforeDelete, headerLabel, headerSubtitle, headerMeta, clipboard, actionLabels, actionIcons, }: Props$a<T>): react_jsx_runtime.JSX.Element;
1183
+ declare function RecordEditor<T>({ ctx, i18n, children, preview, targeting, targetingControl, bulkActions, footerExtra, onBeforeDelete, headerLabel, headerSubtitle, headerMeta, clipboard, actionLabels, actionIcons, }: Props$a<T>): react_jsx_runtime.JSX.Element;
1239
1184
 
1240
1185
  interface InheritanceCtx {
1241
1186
  parentValue?: Record<string, unknown> | null;
@@ -1677,6 +1622,14 @@ interface UseCollectionItemsArgs {
1677
1622
  * are skipped, since they belong on the Rules tab).
1678
1623
  */
1679
1624
  facetRule?: FacetRule | null;
1625
+ /**
1626
+ * When true, return every item-cardinality record across the whole
1627
+ * collection — anchor-pinned, ruled, and global. Used by the 'all' top-
1628
+ * level scope which intentionally bypasses scope-as-axis grouping so
1629
+ * hosts can drive the rail with their own `groupBy` (e.g. lifecycle).
1630
+ * `scope` and `facetRule` are ignored when this is set.
1631
+ */
1632
+ includeAll?: boolean;
1680
1633
  /** Per-page size requested from the SDK (default 100). */
1681
1634
  pageSize?: number;
1682
1635
  /**
@@ -1834,6 +1787,32 @@ declare const useScopeProbe: ({ SL, collectionId, admin, enabled }: UseScopeProb
1834
1787
  error: Error | null;
1835
1788
  };
1836
1789
 
1790
+ interface UseScopeCountsArgs {
1791
+ ctx: RecordsCtx;
1792
+ /** Disable the query (e.g. before SL/collection is ready). */
1793
+ enabled?: boolean;
1794
+ /**
1795
+ * Hard cap on records scanned for counts. Above this we return a
1796
+ * lower-bound count and set `truncated: true`. Default 500.
1797
+ */
1798
+ maxRecords?: number;
1799
+ /** Page size used for the underlying SDK list calls. Default 100. */
1800
+ pageSize?: number;
1801
+ }
1802
+ interface ScopeCounts extends Partial<Record<ScopeKind, number>> {
1803
+ }
1804
+ interface UseScopeCountsResult {
1805
+ counts: ScopeCounts;
1806
+ total: number;
1807
+ isLoading: boolean;
1808
+ error: Error | null;
1809
+ /** True when we hit `maxRecords` and stopped paginating. */
1810
+ truncated: boolean;
1811
+ }
1812
+ declare const useScopeCounts: (args: UseScopeCountsArgs) => UseScopeCountsResult;
1813
+ /** React Query key factory for cache invalidation from save/delete sites. */
1814
+ declare const scopeCountsQueryKey: (collectionId: string, appId: string, recordType?: string) => (string | null)[];
1815
+
1837
1816
  declare const useIntroDismissed: (SL: SmartLinksSDK, collectionId: string, appId: string, recordType?: string) => {
1838
1817
  dismissed: boolean;
1839
1818
  dismiss: () => Promise<void>;
@@ -2334,6 +2313,31 @@ interface ResolveArgs {
2334
2313
  }
2335
2314
  declare const resolveRecord: <T>(args: ResolveArgs) => Promise<ResolvedRecord<T>>;
2336
2315
 
2316
+ interface NormalisedRule {
2317
+ all: Array<{
2318
+ facetKey: string;
2319
+ anyOf: string[];
2320
+ }>;
2321
+ }
2322
+ /**
2323
+ * Canonicalise a FacetRule so semantically identical rules produce identical
2324
+ * strings. Returns `null` for empty/missing rules so callers can distinguish
2325
+ * "no rule" from "the rule that matches everything".
2326
+ */
2327
+ declare const normaliseRule: (rule: FacetRule | null | undefined) => NormalisedRule | null;
2328
+ /**
2329
+ * Stable content-addressed hash of a FacetRule. `null`/empty rules return
2330
+ * `null` so the caller can route them to a separate "no rule" bucket.
2331
+ */
2332
+ declare const ruleHash: (rule: FacetRule | null | undefined) => string | null;
2333
+ /**
2334
+ * Human-readable single-line summary of a rule, used for group headers.
2335
+ * Compact ("country=DE,FR · tier=premium") so it fits a rail-width header.
2336
+ */
2337
+ declare const summariseRule: (rule: FacetRule | null | undefined) => string;
2338
+ /** Comparator: are two rules semantically identical? */
2339
+ declare const rulesEqual: (a: FacetRule | null | undefined, b: FacetRule | null | undefined) => boolean;
2340
+
2337
2341
  interface ImportReport {
2338
2342
  total: number;
2339
2343
  saved: number;
@@ -2349,4 +2353,4 @@ declare const exportCsv: <T>(records: RecordSummary<T>[], schema: CsvSchema<T>)
2349
2353
  declare const importCsv: <T>(file: File, schema: CsvSchema<T>, ctx: RecordsCtx) => Promise<ImportReport>;
2350
2354
  declare const downloadBlob: (blob: Blob, filename: string) => void;
2351
2355
 
2352
- export { ALL_ITEM_VIEWS, ALL_PRESENTATIONS, BatchList, BulkActionsMenu, type ClipboardEntry, type CollectedRecord, type CollectedSort, type CollectionRailMode, type CsvSchema, type CsvSchemaColumn, DEFAULT_DEEP_LINK_PARAM_NAMES, DEFAULT_I18N, DEFAULT_ICONS, type DeepLinkAdapter, type DeepLinkChangeKind, type DeepLinkHistoryMode, type DeepLinkOptions, type DeepLinkParamNames, type DeepLinkState, DefaultItemCards, DefaultItemTable, DefaultRecordCard, DefaultRecordRow, DeleteButton, type DirtyDraft, DirtyDraftProvider, type DirtyDraftStatus, type DirtyDraftStore, type DirtyStrategy, DrawerPreview, type EditorContext, EditorItemNav, EmptyState, ErrorState, FacetList, InheritanceMarker, InheritanceProvider, InlinePreview, IntroCard, type ItemColumn, ItemListView, type ItemSlotContext, type ItemView, type ItemViewContext, ItemViewSwitcher, LoadingState, type MergeStrategy, type MergedRecord, type NavConfirmI18n, type ParsedRef, type PasteCompatibility, type PasteCompatibilityResult, PresentationSwitcher, type PreviewMode, PreviewScopePicker, PreviewToggleButton, type ProductBrowseItem, type ProductChildItem, ProductDrillDown, ProductList, type RecordBadge, RecordBrowser, type RecordCardinality, RecordEditor, RecordList, type RecordPresentation, type RecordSlotContext, type RecordSource, type RecordStatus, type RecordSummary, type RecordsAdminI18n, type RecordsAdminIcons, RecordsAdminShell, type RecordsAdminShellProps, type ResolvedDeepLinkParamNames, ResolvedPreview, type ResolvedRecord, ScopeBreadcrumb, type ScopeKind, ScopeTabs, SiblingRail, SidePreview, type SmartLinksSDK, StatusDot, StatusFilterPills, StatusIcon, type StatusTone, TabbedPreview, type TelemetryEvent, type UseCollectionItemsArgs, type UseRecordClipboardArgs, type UseRecordClipboardReturn, type UseResolveAllRecordsArgs, type UseResolveAllResult, type UseRulePreviewArgs, type UseRulePreviewResult, UtilityRow, VariantList, buildDraftKey, buildRef, bulkDelete, bulkUpsert, checkPasteCompatibility, cloneValue, createDefaultDeepLinkAdapter, createPostMessageDeepLinkAdapter, createRecord, downloadBlob, exportCsv, getRecordById, importCsv, isInSmartLinksIframe, listRecords, matchRecords, mergeIcons, parseRef, parsedRefToScope, parsedRefToTarget, pickHeaderIcon, removeRecord, resolutionChain, resolveRecord, restoreRecord, scopesEqual, statusToneLabel, upsertRecord, useCollectedRecords, useCollectionItems, useDeepLinkState, useDirtyDraft, useDirtyDraftActions, useDirtyDraftStore, useDirtyDrafts, useDirtyNavigation, useFacetBrowse, useIntroDismissed, useItemViewPref, useMergedRecord, usePresentationPref, useProductBrowse, useProductChildren, useRecordClipboard, useRecordEditor, useRecordList, useResolveAllRecords, useResolvedRecord, useRulePreview, useScopeProbe, useUnsavedGuard };
2356
+ export { ALL_ITEM_VIEWS, ALL_PRESENTATIONS, BatchList, BulkActionsMenu, type ClipboardEntry, type CollectedRecord, type CollectedSort, type CollectionRailMode, type CsvSchema, type CsvSchemaColumn, DEFAULT_DEEP_LINK_PARAM_NAMES, DEFAULT_I18N, DEFAULT_ICONS, type DeepLinkAdapter, type DeepLinkChangeKind, type DeepLinkHistoryMode, type DeepLinkOptions, type DeepLinkParamNames, type DeepLinkState, DefaultItemCards, DefaultItemTable, DefaultRecordCard, DefaultRecordRow, DeleteButton, type DirtyDraft, DirtyDraftProvider, type DirtyDraftStatus, type DirtyDraftStore, type DirtyStrategy, DrawerPreview, type EditorContext, EditorItemNav, EmptyState, ErrorState, FacetList, InheritanceMarker, InheritanceProvider, InlinePreview, IntroCard, type ItemColumn, ItemListView, type ItemSlotContext, type ItemView, type ItemViewContext, ItemViewSwitcher, LoadingState, type MergeStrategy, type MergedRecord, type NavConfirmI18n, type NormalisedRule, type ParsedRef, type PasteCompatibility, type PasteCompatibilityResult, PresentationSwitcher, type PreviewMode, PreviewScopePicker, PreviewToggleButton, type ProductBrowseItem, type ProductChildItem, ProductDrillDown, ProductList, type RecordBadge, RecordBrowser, type RecordCardinality, RecordEditor, RecordList, type RecordPresentation, type RecordSlotContext, type RecordSource, type RecordStatus, type RecordSummary, type RecordsAdminI18n, type RecordsAdminIcons, RecordsAdminShell, type RecordsAdminShellProps, type ResolvedDeepLinkParamNames, ResolvedPreview, type ResolvedRecord, ScopeBreadcrumb, type ScopeCounts, type ScopeKind, ScopeTabs, SiblingRail, SidePreview, type SmartLinksSDK, StatusDot, StatusFilterPills, StatusIcon, type StatusTone, TabbedPreview, type TelemetryEvent, type UseCollectionItemsArgs, type UseRecordClipboardArgs, type UseRecordClipboardReturn, type UseResolveAllRecordsArgs, type UseResolveAllResult, type UseRulePreviewArgs, type UseRulePreviewResult, type UseScopeCountsArgs, type UseScopeCountsResult, UtilityRow, VariantList, buildDraftKey, buildRef, bulkDelete, bulkUpsert, checkPasteCompatibility, cloneValue, createDefaultDeepLinkAdapter, createPostMessageDeepLinkAdapter, createRecord, downloadBlob, exportCsv, getRecordById, importCsv, isInSmartLinksIframe, listRecords, matchRecords, mergeIcons, normaliseRule, parseRef, parsedRefToScope, parsedRefToTarget, pickHeaderIcon, removeRecord, resolutionChain, resolveRecord, restoreRecord, ruleHash, rulesEqual, scopeCountsQueryKey, scopesEqual, statusToneLabel, summariseRule, upsertRecord, useCollectedRecords, useCollectionItems, useDeepLinkState, useDirtyDraft, useDirtyDraftActions, useDirtyDraftStore, useDirtyDrafts, useDirtyNavigation, useFacetBrowse, useIntroDismissed, useItemViewPref, useMergedRecord, usePresentationPref, useProductBrowse, useProductChildren, useRecordClipboard, useRecordEditor, useRecordList, useResolveAllRecords, useResolvedRecord, useRulePreview, useScopeCounts, useScopeProbe, useUnsavedGuard };