@cratis/stage.runtime 4.228.0 → 5.0.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.
@@ -60,7 +60,7 @@ export declare function navigationTree(entries: NavigationEntry[]): NavigationNo
60
60
  * @returns The labels from the outermost group to the entry, or an empty list when no entry opens the screen.
61
61
  */
62
62
  export declare function navigationPathTo(nodes: NavigationNode[], screen: string): string[];
63
- /** Whether an entry opens somewhere a plain link to its screen does not reach: an outlet, a dialog or an external route. */
63
+ /** Whether an entry opens somewhere a plain link to its screen does not reach: a slot, a dialog or an external route. */
64
64
  export declare function opensElsewhere(destination: DestinationReference): boolean;
65
65
  /**
66
66
  * The hierarchy the screens declare, for the screens no navigation entry lists.
@@ -29,6 +29,8 @@ export declare function StageAction({ element, interactions, slots }: Registered
29
29
  * address or the session already supplies it; the form then submits what was not asked by the same rule.
30
30
  */
31
31
  export declare function StageSliceDialog(props: Partial<RegisteredProps>): import("react").JSX.Element;
32
+ /** The component the Stage draws an outlet button that names a slice or a command with. */
33
+ export declare const stageToolbarItemComponent = "core:toolbarItem";
32
34
  /**
33
35
  * The components the Stage renders a scene with: Scene's own core vocabulary, with the two that have to reach
34
36
  * this running application - the table that reads a modeled query, and the action that executes a modeled
@@ -1,14 +1,18 @@
1
- import type { ApplicationStructure, NavigationModel, Screen } from '@cratis/scene.model';
1
+ import { type ApplicationStructure, type NavigationModel, type Screen } from '@cratis/scene.model';
2
2
  import type { EffectiveNavItem } from '@cratis/scene.engine';
3
3
  import type { SceneNavigationModel } from '@cratis/scene.react';
4
- /** Whether the model declares navigation regions of its own - the application's or a module's. */
4
+ /**
5
+ * Whether the model declares navigation items of its own - an application navigation outlet that lists items, or a module's refinement
6
+ * or contribution. An outlet that lists nothing only says where navigation goes: the entries the screens authored stay the menu.
7
+ */
5
8
  export declare function declaresRegions(navigation: NavigationModel | undefined): boolean;
6
9
  /**
7
10
  * The screen a navigation item opens: the screen declared in the feature the item resolves to (a screen's `path` is the modules and
8
11
  * features it was declared in), the first screen declared beneath it, or the screen named like the feature - which is how the
9
- * application structure names a feature's screen.
12
+ * application structure names a feature's screen. Only a screen that fits a page is a place to go: one that fits only a dialog, drawer,
13
+ * pane or panel is opened by an action, never navigated to.
10
14
  */
11
- export declare function stageScreenFor(screens: Screen[]): (item: EffectiveNavItem) => string | undefined;
15
+ export declare function stageScreenFor(allScreens: Screen[]): (item: EffectiveNavItem) => string | undefined;
12
16
  /** The module a screen was declared in - the first of its `path` - which decides whose sidebar the page shows. */
13
17
  export declare function stageModuleOf(screens: Screen[]): (screen: string | undefined) => string | undefined;
14
18
  /**
@@ -0,0 +1,40 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { ApplicationStructure, Layout, NavigationModel, Screen, ScreenTemplate } from '@cratis/scene.model';
3
+ import { type ActionSlice, type OutletLevel } from '@cratis/scene.engine';
4
+ import { type SceneOutletsContextValue } from '@cratis/scene.react';
5
+ /** The parts of a Stage application the outlets of a screen resolve through. */
6
+ export interface StageOutletsSource {
7
+ layouts: Layout[];
8
+ screenTemplates: ScreenTemplate[];
9
+ screens: Screen[];
10
+ navigation?: NavigationModel;
11
+ outletLevels?: OutletLevel[];
12
+ structure?: ApplicationStructure;
13
+ commandSchemas?: Record<string, string>;
14
+ }
15
+ /**
16
+ * The slices the hooks of an application run, as placement and the slice invoker see them: each slice's command, its screen and where
17
+ * that screen fits, and the inputs its command takes - which an item or the route feed by name. The identifier the command acts on
18
+ * (`x-identity`) has the item or screen as its source, so a hook can run the slice directly; any other input needs the form.
19
+ *
20
+ * @param source The application.
21
+ * @returns The slices, by their qualified id.
22
+ */
23
+ export declare function stageActionSlicesOf(source: StageOutletsSource): ActionSlice[];
24
+ /**
25
+ * What the outlets of a screen resolve through: the levels from the layout down to the screen, the levels that contribute to them, the
26
+ * slices their hooks run, and the slots of the screen a hook can open in.
27
+ *
28
+ * @param source The application.
29
+ * @param screenName The screen.
30
+ * @returns The outlets' context.
31
+ */
32
+ export declare function stageOutletsOf(source: StageOutletsSource, screenName: string | undefined): SceneOutletsContextValue;
33
+ /**
34
+ * Gives the outlets of a screen what they resolve through (see {@link stageOutletsOf}).
35
+ */
36
+ export declare function StageOutletsScope({ source, screen, children }: {
37
+ source: StageOutletsSource;
38
+ screen: string | undefined;
39
+ children: ReactNode;
40
+ }): import("react").JSX.Element;
@@ -0,0 +1,130 @@
1
+ import { type Layout, type Screen, type ScreenTemplate } from '@cratis/scene.model';
2
+ import { type OutletLevel } from '@cratis/scene.engine';
3
+ import { type SceneHistory, type SceneRouter, type SceneRouteState, type SlotRoute } from '@cratis/scene.react';
4
+ /**
5
+ * What the Stage needs to know of an application to put its routed slots, tabs and filters in the address.
6
+ */
7
+ export interface StageRouteShape {
8
+ /** The routed slots - never a panel - by name, with the parameters each is routed by, in order. */
9
+ routedSlots: Record<string, string[]>;
10
+ /** The outlets of tabs that own a routed slot, with the slot each owns: the chosen tab is a segment of that slot. */
11
+ tabSlots: Record<string, string>;
12
+ /** The query parameter each filter writes, with the query it sets; undefined when it names none. */
13
+ filters: Record<string, string | undefined>;
14
+ /** Whether the page slot is routed, so the filters' values are in the address. */
15
+ pageRouted: boolean;
16
+ /** The screen a slot route's segment opens, by segment (`set-product-price`). */
17
+ segmentScreens: Record<string, string>;
18
+ /** The screen a slot shows for a selection (`show ProductDetails by sku from products.selection`), by slot. */
19
+ slotDefaults: Record<string, string>;
20
+ }
21
+ /** The parts of a Stage application the route shape is read from. */
22
+ export interface StageRouteSource {
23
+ layouts?: Layout[];
24
+ screenTemplates?: ScreenTemplate[];
25
+ screens?: Screen[];
26
+ outletLevels?: OutletLevel[];
27
+ }
28
+ /** A shape with nothing routed: every slot, tab and filter stays in memory. */
29
+ export declare const unroutedShape: StageRouteShape;
30
+ /**
31
+ * Reads what is routed in an application: the routed slots of its layouts and templates, the outlets of tabs that own one, the parameters
32
+ * its filters write, whether its page slot is routed, and the screens a slot route can name.
33
+ *
34
+ * @param source The layouts, templates, screens and outlet levels of the application.
35
+ * @returns The route shape.
36
+ */
37
+ export declare function stageRouteShapeOf(source: StageRouteSource): StageRouteShape;
38
+ /** An address the Stage reads: the Scene navigation's part, and what the routed slots, tabs and filters say. */
39
+ export interface StageAddress {
40
+ /** The part the Scene navigation host matches against its routes (`ProductCatalog?id=1`), or undefined when there is none. */
41
+ scene: string | undefined;
42
+ /** What the address says the routed slots, tabs and filters show. */
43
+ route: SceneRouteState;
44
+ }
45
+ /**
46
+ * Reads an address relative to the application (`ProductCatalog/@detail/NK-101/@detail.detailTabs/pricing?q=kettle`): the Scene
47
+ * navigation's part, then a group per routed slot (`@<slot>` with its route values and segment) and per chosen tab of a routed slot
48
+ * (`@<slot>.<outlet>` with the tab), and the filters' values among the query parameters when the page slot is routed.
49
+ *
50
+ * @param address The address, without a leading slash or hash.
51
+ * @param shape What is routed in the application.
52
+ * @returns The Scene navigation's part, and the route state.
53
+ */
54
+ export declare function parseStageAddress(address: string, shape: StageRouteShape): StageAddress;
55
+ /**
56
+ * Writes an address relative to the application from the Scene navigation's part and the route state - the reverse of
57
+ * {@link parseStageAddress}. Only what is routed is written: a slot that is not routed, a tab whose slot is not routed and, unless the
58
+ * page slot is routed, the filters' values stay out of the address.
59
+ *
60
+ * @param scene The Scene navigation's part.
61
+ * @param route The route state.
62
+ * @param shape What is routed in the application.
63
+ * @returns The address, without a leading slash or hash.
64
+ */
65
+ export declare function stageAddress(scene: string | undefined, route: SceneRouteState, shape: StageRouteShape): string;
66
+ /** How the Stage addresses screens: by the fragment (`#/Screen`) or by the path (`/Screen`). */
67
+ export type StageRoutingMode = 'hash' | 'path';
68
+ /** The browser the routing reads and writes the address of. */
69
+ export type StageRoutingBrowser = Pick<Window, 'location' | 'history' | 'addEventListener' | 'removeEventListener'>;
70
+ /**
71
+ * The Stage's router: one address for the Scene navigation host (its {@link SceneHistory}) and for the routed slots, tabs and filters
72
+ * (a {@link SceneRouter} through {@link useStageSceneRouter}).
73
+ */
74
+ export interface StageSceneRouting {
75
+ /** The history the Scene navigation host reads and writes its part of the address through. */
76
+ history: SceneHistory;
77
+ /** The route state. */
78
+ getState(): SceneRouteState;
79
+ /** Listens for changes of the route state. */
80
+ subscribe(listener: () => void): () => void;
81
+ /** Opens a screen in a slot: a history entry when the slot is routed. */
82
+ openInSlot(slot: string, route: SlotRoute): void;
83
+ /** Empties a slot: a history entry when the slot is routed. */
84
+ closeSlot(slot: string): void;
85
+ /** Chooses a tab: a history entry when the slot the tabs own is routed. */
86
+ selectTab(outlet: string, tab: string): void;
87
+ /** Writes a filter's value: in the address, without a history entry, when the page slot is routed. */
88
+ setQueryParameter(name: string, value: string | undefined): void;
89
+ /** Stops listening to the browser. */
90
+ dispose(): void;
91
+ }
92
+ /**
93
+ * Creates the Stage's router over the browser's address.
94
+ *
95
+ * Only routed slot changes and chosen tabs are history entries, so back and forward move through them. A filter replaces the current
96
+ * entry. A dialog or drawer opened over the page does not change the address and is not a history entry either: the Scene navigation
97
+ * host's push of the same address replaces the entry, and closing it puts the page it opened over back.
98
+ *
99
+ * @param browser The browser.
100
+ * @param mode Whether screens are addressed by the fragment or by the path.
101
+ * @param shape What is routed in the application.
102
+ * @returns The routing.
103
+ */
104
+ export declare function createStageSceneRouting(browser: StageRoutingBrowser, mode: StageRoutingMode, shape: StageRouteShape): StageSceneRouting;
105
+ /**
106
+ * The {@link SceneRouter} of the Stage's routing, for `SceneRouterProvider`: a new one each time the route state changes, so what reads it
107
+ * draws again.
108
+ *
109
+ * @param routing The Stage's routing.
110
+ * @returns The router.
111
+ */
112
+ export declare function useStageSceneRouter(routing: StageSceneRouting): SceneRouter;
113
+ /** The route shape of the running application, for what reads the filters' values. */
114
+ export declare const StageRouteShapeContext: import("react").Context<StageRouteShape>;
115
+ /**
116
+ * The values the filters wrote for a query: those of the filters that set one of its parameters, and of those that name no query.
117
+ *
118
+ * @param shape What is routed in the application, and which query each filter sets.
119
+ * @param query The values the filters wrote, by query parameter.
120
+ * @param queryName The query.
121
+ * @returns The query's arguments from the filters.
122
+ */
123
+ export declare function filterArgumentsFor(shape: StageRouteShape, query: Record<string, string>, queryName: string | undefined): Record<string, string>;
124
+ /**
125
+ * The values the filters on the page wrote for a query.
126
+ *
127
+ * @param queryName The query.
128
+ * @returns The query's arguments from the filters.
129
+ */
130
+ export declare function useStageFilterArguments(queryName: string | undefined): Record<string, string>;
@@ -12,7 +12,8 @@ export declare function sliceFieldsFrom(schemas: Record<string, string> | undefi
12
12
  /**
13
13
  * The invoker the running application submits a task dialog through: the command is posted to the route the Stage registered for
14
14
  * it, exactly as an action or a form posts it, and the application's own validation results come back to the dialog against the
15
- * fields they name. A successful command refreshes what the screen shows.
15
+ * fields they name. A successful command refreshes what the page shows. A hook that runs its slice directly (`runs`) comes through here
16
+ * too, once Scene has asked its confirmation, with the inputs the item and the route resolve.
16
17
  *
17
18
  * @param executeCommand Executes a registered Arc proxy with the host's configuration.
18
19
  * @param routesReady Whether the lookup has finished, so a command with no route is not-registered rather than not-yet.
@@ -0,0 +1,16 @@
1
+ import { type RegisteredComponentProps } from '@cratis/scene.react';
2
+ /**
3
+ * The `core:slot` the Stage renders, drawn inside the Stage's own data scope so the queries, selections and commands of the screen it
4
+ * shows work as they do on a primary screen.
5
+ *
6
+ * - A **routed** slot shows what the router says (the address, in the running application): a hook that opens a screen in it, or a
7
+ * selection it shows, changes the address, and the address brings it back on a reload or a shared link. The screen it shows reads the
8
+ * route values it was opened with - its own scope's parameters win over the page's - so `ProductDetails by sku` reads the row's sku.
9
+ * - A slot a `show <Screen> by <param> from <element>.selection` line stands in opens that screen, keyed by the selected row, whenever the
10
+ * element's selection changes.
11
+ * - Otherwise it shows the screen the Scene navigation host placed in it (`navigate to … in slot side`).
12
+ *
13
+ * A panel is drawn as a landmark (`aside`), an optional slot is hidden until something fills it, and an optional pane or panel - like a
14
+ * slot the host put a screen in - can be closed.
15
+ */
16
+ export declare function StageSlot({ element }: RegisteredComponentProps): import("react").JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/stage.runtime",
3
- "version": "4.228.0",
3
+ "version": "5.0.0",
4
4
  "description": "The Cratis Stage application runtime for Arc and Scene",
5
5
  "author": "Cratis",
6
6
  "type": "module",
@@ -41,16 +41,16 @@
41
41
  "test": "vitest run"
42
42
  },
43
43
  "peerDependencies": {
44
- "@cratis/arc": "22.168.0",
45
- "@cratis/arc.react": "22.168.0",
44
+ "@cratis/arc": "22.176.0",
45
+ "@cratis/arc.react": "22.176.0",
46
46
  "@cratis/components": "4.40.0",
47
47
  "@cratis/fundamentals": "7.33.1",
48
- "@cratis/scene.blueprint.default": "4.88.0",
49
- "@cratis/scene.components": "4.88.0",
50
- "@cratis/scene.engine": "4.88.0",
51
- "@cratis/scene.model": "4.88.0",
52
- "@cratis/scene.primereact": "4.88.0",
53
- "@cratis/scene.react": "4.88.0",
48
+ "@cratis/scene.blueprint.default": "5.1.0",
49
+ "@cratis/scene.components": "5.1.0",
50
+ "@cratis/scene.engine": "5.1.0",
51
+ "@cratis/scene.model": "5.1.0",
52
+ "@cratis/scene.primereact": "5.1.0",
53
+ "@cratis/scene.react": "5.1.0",
54
54
  "@cratis/showrunner.notes": "1.0.0",
55
55
  "@cratis/showrunner.notes.react": "1.0.0",
56
56
  "@primereact/ui": "11.2.2",