core/context

React context providers for Stately's core functionality.

This module provides context providers and hooks for managing shared state across Stately components. The LinkExplorerProvider enables a dialog-based interface for exploring entity relationships with breadcrumb navigation.

Example

import {
  LinkExplorerProvider,
  useLinkExplorer,
  ViewLinkControl,
} from '@statelyjs/stately/core/context';

// Wrap your app to enable link exploration dialogs
<LinkExplorerProvider>
  <App />
</LinkExplorerProvider>

// Use ViewLinkControl to open the explorer for a linked entity
<ViewLinkControl entityType="User" entityName={user.name} entity={user} />

// Or open programmatically via the hook
function MyComponent() {
  const { openLinkExplorer } = useLinkExplorer();
  return (
    <button onClick={() => openLinkExplorer({ entityType: 'User', entity })}>
      Explore
    </button>
  );
}

Interfaces

LinkExplorerContextValue

Defined in: packages/stately/src/core/context/link-explore-context.tsx:23

Type Parameters

Schema

Schema extends Schemas = Schemas

Properties

breadcrumbs: LinkEntityProps<Schema>[]

Defined in: packages/stately/src/core/context/link-explore-context.tsx:27

closeLinkExplorer()

closeLinkExplorer: () => void

Defined in: packages/stately/src/core/context/link-explore-context.tsx:25

Returns

void

navigateToIndex: (index) => void

Defined in: packages/stately/src/core/context/link-explore-context.tsx:26

Parameters
index

number

Returns

void

openLinkExplorer()

openLinkExplorer: (info) => void

Defined in: packages/stately/src/core/context/link-explore-context.tsx:24

Parameters
info

LinkEntityProps<Schema>

Returns

void

Functions

LinkExplorerProvider()

LinkExplorerProvider(__namedParameters): Element

Defined in: packages/stately/src/core/context/link-explore-context.tsx:32

Parameters

__namedParameters
children

ReactNode

Returns

Element


useLinkExplorer()

useLinkExplorer<Schema>(): LinkExplorerContextValue<Schema>

Defined in: packages/stately/src/core/context/link-explore-context.tsx:86

Type Parameters

Schema

Schema extends Schemas = Schemas

Returns

LinkExplorerContextValue<Schema>


ViewLinkControl()

ViewLinkControl<Schema>(props): Element

Defined in: packages/stately/src/core/context/link-explore-context.tsx:7

Type Parameters

Schema

Schema extends Schemas = Schemas

Parameters

props

LinkEntityProps<Schema>

Returns

Element