@proveanything/smartlinks-utils-ui 0.9.12 → 0.10.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.
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode, ComponentType } from 'react';
2
+ import { ComponentType, ReactNode } from 'react';
3
3
  import { FacetRule, MatchedAt, RecordTarget, AppRecord, MatchResult, ResolveAllEntry } from '@proveanything/smartlinks/dist/types/appObjects';
4
4
  import { LucideIcon } from 'lucide-react';
5
5
  import * as _tanstack_query_core from '@tanstack/query-core';
@@ -295,6 +295,13 @@ type TelemetryEvent = {
295
295
  sourceRef: string;
296
296
  destinationRef: string;
297
297
  replaced: boolean;
298
+ }
299
+ /** Host-defined `recordActions` menu item invoked from a row / card / item-table row. */
300
+ | {
301
+ type: 'recordAction.invoke';
302
+ recordType?: string;
303
+ key: string;
304
+ ref: string;
298
305
  };
299
306
 
300
307
  interface RecordsAdminI18n {
@@ -396,6 +403,15 @@ interface RecordsAdminI18n {
396
403
  clipboardEmpty: string;
397
404
  copyToast: string;
398
405
  pasteToast: string;
406
+ /**
407
+ * Row-menu label for the one-shot Duplicate action — copies the row's
408
+ * value (through the host's `clipboard.onCopy` if any) and immediately
409
+ * seeds a fresh draft with it. Apps can rebrand for their domain
410
+ * (e.g. "Run this vote again", "Clone competition", "Duplicate FAQ").
411
+ */
412
+ duplicateAction: string;
413
+ /** Toast shown after a successful Duplicate. `{name}` = source label. */
414
+ duplicateToast: string;
399
415
  /** Confirm dialog when pasting onto a destination with an existing saved value. */
400
416
  pasteConfirmTitle: string;
401
417
  pasteConfirmBody: string;
@@ -636,6 +652,33 @@ type RecordsAdminActionKey = 'save' | 'discard' | 'delete' | 'saveAll' | 'revert
636
652
  type RecordsAdminActionIcon = ComponentType<{
637
653
  className?: string;
638
654
  }>;
655
+ /**
656
+ * Host-defined action that appears in the row / card / table-row context
657
+ * menu (the `…` kebab) for a single record. Use this to surface domain
658
+ * actions like "Run again", "Archive", "Publish" without forking the
659
+ * default row renderers.
660
+ *
661
+ * Visibility / disable is computed by the host in the
662
+ * `recordActions(record, scope)` callback — return only the actions that
663
+ * apply to this record. Returning `[]` (or omitting the prop) leaves the
664
+ * menu showing only the built-in Copy / Duplicate items.
665
+ */
666
+ interface RecordAction {
667
+ /** Stable key — used for React keys and telemetry. */
668
+ key: string;
669
+ /** Visible menu label. */
670
+ label: string;
671
+ /** Optional Lucide-style icon component rendered before the label. */
672
+ icon?: RecordsAdminActionIcon;
673
+ /** Visual tone. `'danger'` paints the item with the destructive colour. */
674
+ variant?: 'default' | 'danger';
675
+ /** Disable the menu item. Combine with `disabledReason` for a tooltip. */
676
+ disabled?: boolean;
677
+ /** Tooltip shown when the item is disabled. */
678
+ disabledReason?: string;
679
+ /** Invoked when the user clicks the item. */
680
+ onAction: () => void | Promise<void>;
681
+ }
639
682
  /** Minimal SDK shape consumed by the shell. */
640
683
  type SmartLinksSDK = any;
641
684
  /** Slot context passed to renderCard / renderListRow. */
@@ -657,6 +700,14 @@ interface RecordSlotContext {
657
700
  * clipboard. Wired by the shell — apps don't need to implement it.
658
701
  */
659
702
  onCopy?: () => void;
703
+ /**
704
+ * One-shot Duplicate — copies this row's value (running through
705
+ * `clipboard.onCopy` if the host supplied one) and immediately seeds a
706
+ * fresh draft with it. Only present in collection cardinality where
707
+ * "create another item" makes sense. Apps rebrand the menu label via
708
+ * `i18n.duplicateAction` (e.g. "Run this vote again").
709
+ */
710
+ onDuplicate?: () => void;
660
711
  /**
661
712
  * Paste the current clipboard entry onto this row. Disabled when there is
662
713
  * nothing to paste, when the source ref equals this row, or when the
@@ -673,6 +724,13 @@ interface RecordSlotContext {
673
724
  canPaste?: boolean;
674
725
  /** Friendly label for "Paste from {sourceLabel}" in row menus. */
675
726
  clipboardSourceLabel?: string;
727
+ /**
728
+ * Host-supplied custom actions for this row's `…` menu. Rendered after
729
+ * the built-in Copy / Duplicate items, separated by a divider. Wired by
730
+ * the shell from the top-level `recordActions` prop — apps don't need
731
+ * to populate this directly.
732
+ */
733
+ actions?: RecordAction[];
676
734
  }
677
735
  /**
678
736
  * Declarative column definition for the built-in default item table.
@@ -720,6 +778,12 @@ interface ItemSlotContext extends ItemViewContext {
720
778
  * without having to remember the item id or fight click-bubbling.
721
779
  */
722
780
  onSelect: () => void;
781
+ /**
782
+ * Host-supplied custom actions for this item — same shape as the rail's
783
+ * `RecordSlotContext.actions`. Wired by the shell from `recordActions`.
784
+ * The built-in card / table renderers expose them in a `…` menu.
785
+ */
786
+ actions?: RecordAction[];
723
787
  }
724
788
  interface RecordsAdminShellProps<TData = unknown> {
725
789
  SL: SmartLinksSDK;
@@ -784,6 +848,25 @@ interface RecordsAdminShellProps<TData = unknown> {
784
848
  unsaved?: UnsavedConfig<TData>;
785
849
  clipboard?: ClipboardConfig<TData>;
786
850
  actions?: ActionsConfig;
851
+ /**
852
+ * Return host-defined custom actions for a given record. Rendered in
853
+ * the `…` context menu on the rail row, the rail card, the item-table
854
+ * row, and the item card — after the built-in Copy / Duplicate items.
855
+ *
856
+ * Use the host's own predicate to gate per-record visibility — e.g.
857
+ * only return a `"Run again"` action for ended competitions:
858
+ *
859
+ * ```ts
860
+ * recordActions: (record) =>
861
+ * record.data?.endedAt
862
+ * ? [{ key: 'rerun', label: 'Run this vote again', icon: RotateCcw,
863
+ * onAction: () => duplicateAndOpen(record) }]
864
+ * : []
865
+ * ```
866
+ *
867
+ * Return `null` / `undefined` / `[]` to add no extra items.
868
+ */
869
+ recordActions?: (record: RecordSummary<TData>, scope: ParsedRef) => RecordAction[] | null | undefined;
787
870
  /**
788
871
  * Opt-in awaited callbacks fired around record save/delete. See
789
872
  * {@link RecordsAdminShellHooks} for the contract.
@@ -1138,19 +1221,22 @@ interface Props$c {
1138
1221
  */
1139
1222
  rowClipboard?: (record: RecordSummary) => {
1140
1223
  onCopy?: () => void;
1141
- onPaste?: () => void;
1142
- canPaste?: boolean;
1143
- pasteWillReplace?: boolean;
1144
- clipboardSourceLabel?: string;
1224
+ onDuplicate?: () => void;
1145
1225
  } | null;
1226
+ /**
1227
+ * Optional host-supplied per-record action lookup. Returned actions are
1228
+ * appended to each row's `…` menu after Copy / Duplicate. The shell
1229
+ * wires this from its top-level `recordActions` prop.
1230
+ */
1231
+ rowActions?: (record: RecordSummary) => RecordAction[] | null | undefined;
1146
1232
  /** Resolved i18n strings — used by default row/card renderers. */
1147
1233
  i18n?: RecordsAdminI18n;
1148
1234
  }
1149
- declare const RecordList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1150
- declare const ProductList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1151
- declare const FacetList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1152
- declare const VariantList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1153
- declare const BatchList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1235
+ declare const RecordList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, rowActions, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1236
+ declare const ProductList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, rowActions, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1237
+ declare const FacetList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, rowActions, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1238
+ declare const VariantList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, rowActions, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1239
+ declare const BatchList: ({ items, selectedId, selectedAnchorKey, onSelect, dirtyId, dirtyAnchorKey, dirtyKeys, errorKeys, presentation, renderListRow, groupBy, renderGroupActions, rowClipboard, rowActions, i18n, }: Props$c) => react_jsx_runtime.JSX.Element;
1154
1240
 
1155
1241
  interface DefaultRecordRowProps {
1156
1242
  record: RecordSummary;
@@ -2256,9 +2342,20 @@ interface Props$5<T> {
2256
2342
  itemColumns?: ItemColumn<T>[];
2257
2343
  /** Card density for cards/gallery views. */
2258
2344
  cardSize?: 'sm' | 'md' | 'lg';
2345
+ /** Per-record host actions for the `…` menu in cards / table rows. */
2346
+ rowActions?: (record: RecordSummary<T>) => RecordAction[] | null | undefined;
2347
+ /**
2348
+ * Per-record clipboard wiring. When supplied, the built-in card / table
2349
+ * row `…` menu also offers Copy / Duplicate next to host actions. Wired
2350
+ * by the shell from `enableClipboard`.
2351
+ */
2352
+ rowClipboard?: (record: RecordSummary<T>) => {
2353
+ onCopy?: () => void;
2354
+ onDuplicate?: () => void;
2355
+ } | null;
2259
2356
  i18n: RecordsAdminI18n;
2260
2357
  }
2261
- declare function ItemListView<T>({ items, isLoading, error, ctx, itemNoun, ruleSummary, view, views, onViewChange, renderItemList, renderItemCard, renderItemEmpty, itemColumns, cardSize, i18n, }: Props$5<T>): react_jsx_runtime.JSX.Element;
2358
+ declare function ItemListView<T>({ items, isLoading, error, ctx, itemNoun, ruleSummary, view, views, onViewChange, renderItemList, renderItemCard, renderItemEmpty, itemColumns, cardSize, rowActions, rowClipboard, i18n, }: Props$5<T>): react_jsx_runtime.JSX.Element;
2262
2359
 
2263
2360
  interface Props$4 {
2264
2361
  options: ItemView[];
@@ -2274,9 +2371,16 @@ interface Props$3<T> {
2274
2371
  selectedId?: string;
2275
2372
  onOpen: (itemId: string) => void;
2276
2373
  onDelete: (itemId: string) => void;
2374
+ /** Host-supplied per-record menu actions for each row's `…` kebab. */
2375
+ rowActions?: (record: RecordSummary<T>) => RecordAction[] | null | undefined;
2376
+ /** Per-record Copy / Duplicate wiring from the shell clipboard. */
2377
+ rowClipboard?: (record: RecordSummary<T>) => {
2378
+ onCopy?: () => void;
2379
+ onDuplicate?: () => void;
2380
+ } | null;
2277
2381
  i18n: Pick<RecordsAdminI18n, 'itemColumnLabel' | 'itemColumnUpdated' | 'itemActions' | 'delete'>;
2278
2382
  }
2279
- declare function DefaultItemTable<T>({ items, columns, selectedId, onOpen, onDelete, i18n, }: Props$3<T>): react_jsx_runtime.JSX.Element;
2383
+ declare function DefaultItemTable<T>({ items, columns, selectedId, onOpen, onDelete, rowActions, rowClipboard, i18n, }: Props$3<T>): react_jsx_runtime.JSX.Element;
2280
2384
 
2281
2385
  interface Props$2<T> {
2282
2386
  items: RecordSummary<T>[];
@@ -2285,9 +2389,16 @@ interface Props$2<T> {
2285
2389
  ctx: ItemViewContext;
2286
2390
  renderCard?: (record: RecordSummary<T>, slotCtx: ItemSlotContext) => ReactNode;
2287
2391
  cardSize?: 'sm' | 'md' | 'lg';
2392
+ /** Host-supplied per-record menu actions appended to each card's `…`. */
2393
+ rowActions?: (record: RecordSummary<T>) => RecordAction[] | null | undefined;
2394
+ /** Per-record Copy / Duplicate wiring from the shell clipboard. */
2395
+ rowClipboard?: (record: RecordSummary<T>) => {
2396
+ onCopy?: () => void;
2397
+ onDuplicate?: () => void;
2398
+ } | null;
2288
2399
  i18n: Pick<RecordsAdminI18n, 'delete'>;
2289
2400
  }
2290
- declare function DefaultItemCards<T>({ items, variant, selectedId, ctx, renderCard, cardSize, i18n, }: Props$2<T>): react_jsx_runtime.JSX.Element;
2401
+ declare function DefaultItemCards<T>({ items, variant, selectedId, ctx, renderCard, cardSize, rowActions, rowClipboard, i18n, }: Props$2<T>): react_jsx_runtime.JSX.Element;
2291
2402
 
2292
2403
  interface Props$1 {
2293
2404
  /** Friendly name of the item being edited (mostly for screen readers). */
@@ -2487,4 +2598,4 @@ declare const exportCsv: <T>(records: RecordSummary<T>[], schema: CsvSchema<T>)
2487
2598
  declare const importCsv: <T>(file: File, schema: CsvSchema<T>, ctx: RecordsCtx) => Promise<ImportReport>;
2488
2599
  declare const downloadBlob: (blob: Blob, filename: string) => void;
2489
2600
 
2490
- 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, type RouterParamsGetter, type RouterParamsSetter, 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, createRouterDeepLinkAdapter, 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 };
2601
+ 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 RecordAction, type RecordBadge, RecordBrowser, type RecordCardinality, RecordEditor, RecordList, type RecordPresentation, type RecordSlotContext, type RecordSource, type RecordStatus, type RecordSummary, type RecordsAdminActionIcon, type RecordsAdminActionKey, type RecordsAdminI18n, type RecordsAdminIcons, RecordsAdminShell, type RecordsAdminShellProps, type ResolvedDeepLinkParamNames, ResolvedPreview, type ResolvedRecord, type RouterParamsGetter, type RouterParamsSetter, 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, createRouterDeepLinkAdapter, 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 };