@cratis/event-models 0.344.0 → 0.345.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
- import { L as N, R as E, c as B, d as L, f as F, h as I, l as j, m as M, t as R, u as Q } from "./DataBindingSections-DGWtMxlD.js";
2
- import { useState as k } from "react";
1
+ import { F as N, P as E, c as B, d as F, f as I, h as L, l as j, m as M, t as k, u as Q } from "./DataBindingSections-wybsadzf.js";
2
+ import { useState as R } from "react";
3
3
  import { Fragment as S, jsx as o, jsxs as d } from "react/jsx-runtime";
4
4
  import { validateBinding as D } from "@cratis/scene.engine";
5
5
  var c = /* @__PURE__ */ (function(r) {
@@ -16,7 +16,7 @@ function b(r, i, u, l) {
16
16
  };
17
17
  }
18
18
  var V = (r) => r.origin.map((i) => i.name).join(" / "), T = ({ property: r, candidates: i, scope: u, strings: l, disabled: s, onChange: m }) => {
19
- const t = l.properties.query, [g, y] = k(), h = Q(r.effectiveValue) ? r.effectiveValue : void 0, n = g ?? h, p = n ? i.find((e) => e.id === n.queryId) : void 0, _ = n ? b(r.descriptor, p, n, u).diagnostics : [], v = (e) => {
19
+ const t = l.properties.query, [g, y] = R(), h = Q(r.effectiveValue) ? r.effectiveValue : void 0, n = g ?? h, p = n ? i.find((e) => e.id === n.queryId) : void 0, _ = n ? b(r.descriptor, p, n, u).diagnostics : [], v = (e) => {
20
20
  if (!e) {
21
21
  y(void 0), m(void 0);
22
22
  return;
@@ -67,7 +67,7 @@ var V = (r) => r.origin.map((i) => i.name).join(" / "), T = ({ property: r, cand
67
67
  className: "studio-editor-query__group",
68
68
  children: [/* @__PURE__ */ o("strong", { children: t.parameters }), p.parameters.map((e) => /* @__PURE__ */ d("label", { children: [/* @__PURE__ */ d("span", { children: [t.sourceFor(e.name), e.required ? " *" : ""] }), /* @__PURE__ */ d("select", {
69
69
  value: M(n, e),
70
- onChange: (a) => v(F(n, e.name, a.target.value)),
70
+ onChange: (a) => v(I(n, e.name, a.target.value)),
71
71
  children: [/* @__PURE__ */ o("option", {
72
72
  value: "",
73
73
  children: t.noSource
@@ -83,7 +83,7 @@ var V = (r) => r.origin.map((i) => i.name).join(" / "), T = ({ property: r, cand
83
83
  children: [/* @__PURE__ */ o("input", {
84
84
  type: "checkbox",
85
85
  checked: j(n, e),
86
- onChange: (a) => v(a.target.checked ? L(n, e.name) : I(n, e.name))
86
+ onChange: (a) => v(a.target.checked ? F(n, e.name) : L(n, e.name))
87
87
  }), /* @__PURE__ */ o("span", { children: t.showColumn(e.name) })]
88
88
  }, e.name))]
89
89
  })] }),
@@ -93,7 +93,7 @@ var V = (r) => r.origin.map((i) => i.name).join(" / "), T = ({ property: r, cand
93
93
  "data-state": q,
94
94
  children: $(q, t.preview)
95
95
  }),
96
- /* @__PURE__ */ o(N, {
96
+ /* @__PURE__ */ o(E, {
97
97
  diagnostics: _,
98
98
  label: l.properties.diagnostics
99
99
  })
@@ -127,7 +127,7 @@ var J = ({ value: r, onChange: i, context: u, disabled: l }) => {
127
127
  strings: s.screenStrings,
128
128
  disabled: l === !0,
129
129
  onChange: i
130
- }), m && t && /* @__PURE__ */ o(R, {
130
+ }), m && t && /* @__PURE__ */ o(k, {
131
131
  controller: s.controller,
132
132
  environment: s.environment,
133
133
  strings: s.screenStrings,
@@ -135,7 +135,7 @@ var J = ({ value: r, onChange: i, context: u, disabled: l }) => {
135
135
  candidate: t,
136
136
  disabled: l === !0,
137
137
  onChange: (g, y, h) => {
138
- const n = h === "" ? s.bindingScope : E({
138
+ const n = h === "" ? s.bindingScope : N({
139
139
  ...s.bindingScope.types,
140
140
  [h]: y.type
141
141
  });
@@ -2,14 +2,19 @@ import { type RefObject } from 'react';
2
2
  import type { ScreenEditorController } from '../Host/ScreenEditorController';
3
3
  import type { ScreenEditorEnvironment } from '../Host/ScreenEditorHost';
4
4
  import type { ScreenEditorStrings } from '../Inspector/ScreenEditorStrings';
5
+ import type { EditorContext } from '../PropertyEditors/Registry/PropertyEditorProps';
5
6
  import type { DesignModeStrings } from './DesignModeStrings';
6
7
  import type { DesignModeState } from './useDesignMode';
7
- export interface DesignModeChromeProps {
8
+ export type DesignModeEditorSource = {
9
+ controller: ScreenEditorController;
10
+ editorStrings: ScreenEditorStrings;
11
+ } | {
12
+ editorContext: () => EditorContext;
13
+ };
14
+ export type DesignModeChromeProps = {
8
15
  surface: RefObject<HTMLDivElement | null>;
9
16
  state: DesignModeState;
10
- controller: ScreenEditorController;
11
17
  environment: ScreenEditorEnvironment;
12
- editorStrings: ScreenEditorStrings;
13
18
  strings: DesignModeStrings;
14
- }
15
- export declare const DesignModeChrome: ({ surface, state, controller, environment, editorStrings, strings }: DesignModeChromeProps) => import("react").JSX.Element | null;
19
+ } & DesignModeEditorSource;
20
+ export declare const DesignModeChrome: (props: DesignModeChromeProps) => import("react").JSX.Element | null;
@@ -0,0 +1,13 @@
1
+ import type { OutletRefinement, SceneDocument } from '@cratis/scene.model';
2
+ import { OutletLevelKind } from '@cratis/scene.engine';
3
+ export interface LevelRefinements {
4
+ kind: OutletLevelKind.Module | OutletLevelKind.Feature;
5
+ name: string;
6
+ refinements: readonly OutletRefinement[];
7
+ }
8
+ export declare const isHostedLevel: (kind: OutletLevelKind) => kind is LevelRefinements['kind'];
9
+ export declare function withLevelOutlets(document: SceneDocument, levels: readonly LevelRefinements[]): SceneDocument;
10
+ export declare function withoutLevelOutlets(document: SceneDocument): {
11
+ document: SceneDocument;
12
+ levels: LevelRefinements[];
13
+ };
@@ -0,0 +1,6 @@
1
+ import type { SceneDocument } from '@cratis/scene.model';
2
+ import { type LevelRefinements } from './levelOutlets';
3
+ export declare function savedScreenDocument(document: SceneDocument, screen: string | undefined, hostKeepsLevels: boolean): {
4
+ document: SceneDocument;
5
+ levelOutlets?: LevelRefinements[];
6
+ };
@@ -1,4 +1,5 @@
1
1
  import { type RefObject } from 'react';
2
+ import { type SurfaceOrigin } from '../Surface/elementRect';
2
3
  import type { Rect } from '../Surface/dropRegionRects';
3
4
  import type { DesignModeSubject } from './designModeTypes';
4
5
  export interface DesignModeMeasurement {
@@ -6,5 +7,5 @@ export interface DesignModeMeasurement {
6
7
  component: Rect | undefined;
7
8
  items: Readonly<Record<string, Rect>>;
8
9
  }
9
- export declare function useSurfaceMeasured<T>(surface: RefObject<HTMLDivElement | null>, compute: (root: HTMLDivElement, origin: DOMRect) => T | undefined, same: (a: T, b: T) => boolean): T | undefined;
10
+ export declare function useSurfaceMeasured<T>(surface: RefObject<HTMLDivElement | null>, compute: (root: HTMLDivElement, origin: SurfaceOrigin) => T | undefined, same: (a: T, b: T) => boolean): T | undefined;
10
11
  export declare function useDesignModeMeasurement(surface: RefObject<HTMLDivElement | null>, subject: DesignModeSubject | undefined): DesignModeMeasurement | undefined;
@@ -5,6 +5,7 @@ import type { ConfigurationDestination } from '@cratis/components/ConfigurationE
5
5
  import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
6
6
  import type { QuillLoader } from '@cratis/scene.primereact';
7
7
  import type { StateChangeSlice } from '../Actions/StateChangeSlice';
8
+ import type { LevelRefinements } from '../DesignMode/Outlets/levelOutlets';
8
9
  import type { ScreenEditorFileUpload } from './ScreenEditorFileUpload';
9
10
  import type { ColorToken, EditorReference, EditorSlice } from '../PropertyEditors/Registry/PropertyEditorProps';
10
11
  import type { PropertyEditorRegistry } from '../PropertyEditors/Registry/PropertyEditorRegistry';
@@ -51,6 +52,7 @@ export interface ScreenEditorEnvironment {
51
52
  templateScope?: TemplateScope;
52
53
  navigation?: ScreenEditorNavigation;
53
54
  location?: ScreenEditorLocation;
55
+ levelOutlets?: readonly LevelRefinements[];
54
56
  }
55
57
  export interface ScreenEditorLocation {
56
58
  path: readonly string[];
@@ -69,6 +71,7 @@ export interface ScreenEditorNavigation {
69
71
  }
70
72
  export interface ScreenEditorResult {
71
73
  document: SceneDocument;
74
+ levelOutlets?: LevelRefinements[];
72
75
  legacyElements: unknown[];
73
76
  windowSize: {
74
77
  width: number;
@@ -19,5 +19,6 @@ export interface ScreenEditorEnvironmentSource {
19
19
  selectableTemplates?: readonly ScreenTemplate[];
20
20
  navigation?: ScreenEditorEnvironment['navigation'];
21
21
  location?: ScreenEditorEnvironment['location'];
22
+ levelOutlets?: ScreenEditorEnvironment['levelOutlets'];
22
23
  }
23
24
  export declare function createScreenEditorEnvironment(source: ScreenEditorEnvironmentSource): ScreenEditorEnvironment;
@@ -1,5 +1,6 @@
1
1
  import type { SceneDocument, ScreenTemplate } from '@cratis/scene.model';
2
2
  import { type SceneDocumentProblem } from '../Document/readSceneDocument';
3
+ import { type LevelRefinements } from '../DesignMode/Outlets/levelOutlets';
3
4
  import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
4
5
  import type { ScreenEditorSelection, ScreenEditorSubject } from './ScreenEditorHost';
5
6
  export interface OpenedSubject {
@@ -14,5 +15,5 @@ export type OpenResult = {
14
15
  problem: SceneDocumentProblem;
15
16
  };
16
17
  type OpeningRuntime = Pick<ScreenEditorRuntime, 'profile' | 'packages'> & Partial<Pick<ScreenEditorRuntime, 'bundles'>>;
17
- export declare function openSubject(subject: ScreenEditorSubject, runtime?: OpeningRuntime, selectableTemplates?: readonly ScreenTemplate[]): OpenResult;
18
+ export declare function openSubject(subject: ScreenEditorSubject, runtime?: OpeningRuntime, selectableTemplates?: readonly ScreenTemplate[], levelOutlets?: readonly LevelRefinements[]): OpenResult;
18
19
  export {};
@@ -5,8 +5,9 @@ import type { ScreenEditorEnvironment } from '../../Host/ScreenEditorHost';
5
5
  import type { ScreenEditorStrings } from '../../Inspector/ScreenEditorStrings';
6
6
  import type { Ownership } from '../../Structure/Ownership';
7
7
  import type { EditorContext } from './PropertyEditorProps';
8
- export interface EditorContextInputs {
9
- controller: ScreenEditorController;
8
+ export type EditorControllerView = Pick<ScreenEditorController, 'selection' | 'selectedId' | 'inspection' | 'document' | 'structure' | 'navigationModule'>;
9
+ export interface EditorContextInputs<TController extends EditorControllerView = ScreenEditorController> {
10
+ controller: TController;
10
11
  environment: ScreenEditorEnvironment;
11
12
  strings: ScreenEditorStrings;
12
13
  ownership: Ownership | undefined;
@@ -17,5 +18,5 @@ export interface EditorContextInputs {
17
18
  slotNames?: Readonly<Record<string, string>>;
18
19
  }
19
20
  export declare function fieldsOfBoundQuery(properties: Readonly<Record<string, unknown>> | undefined, candidates: readonly QueryCandidate[]): readonly QueryResultField[];
20
- export declare function createEditorContext(inputs: EditorContextInputs): EditorContext;
21
+ export declare function createEditorContext(inputs: EditorContextInputs<EditorControllerView>): EditorContext;
21
22
  export declare function withSession(context: EditorContext, inputs: EditorContextInputs, property: InspectedProperty): EditorContext;
@@ -1,3 +1,20 @@
1
1
  import type { Rect } from './dropRegionRects';
2
- export declare function elementRect(surface: Element, elementId: string, origin: DOMRect): Rect | undefined;
3
- export declare function nodeRect(node: Element, origin: DOMRect): Rect | undefined;
2
+ export interface SurfaceOrigin {
3
+ left: number;
4
+ top: number;
5
+ width: number;
6
+ height: number;
7
+ scaleX?: number;
8
+ scaleY?: number;
9
+ }
10
+ /** The origin of a surface: its place on the page, its own size and the scale the page applies to it. */
11
+ export declare function surfaceOrigin(root: HTMLElement): SurfaceOrigin;
12
+ /** A box on the page, in the surface's own pixels. */
13
+ export declare function inSurfacePixels(box: {
14
+ left: number;
15
+ top: number;
16
+ width: number;
17
+ height: number;
18
+ }, origin: SurfaceOrigin): Rect;
19
+ export declare function elementRect(surface: Element, elementId: string, origin: SurfaceOrigin): Rect | undefined;
20
+ export declare function nodeRect(node: Element, origin: SurfaceOrigin): Rect | undefined;