@cratis/scene.blueprint.default 4.33.0 → 4.35.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.
- package/dist/cjs/index.js +53 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/preview-host/ApplicationDocument.js +17 -0
- package/dist/cjs/preview-host/ApplicationDocument.js.map +1 -0
- package/dist/cjs/preview-host/ApplicationHost.js +134 -0
- package/dist/cjs/preview-host/ApplicationHost.js.map +1 -0
- package/dist/cjs/preview-host/FlowArrangementView.js +75 -0
- package/dist/cjs/preview-host/FlowArrangementView.js.map +1 -0
- package/dist/cjs/preview-host/PreviewProblem.js +32 -0
- package/dist/cjs/preview-host/PreviewProblem.js.map +1 -0
- package/dist/cjs/preview-host/PreviewProblemsView.js +51 -0
- package/dist/cjs/preview-host/PreviewProblemsView.js.map +1 -0
- package/dist/cjs/preview-host/PreviewSliceFragment.js +55 -0
- package/dist/cjs/preview-host/PreviewSliceFragment.js.map +1 -0
- package/dist/cjs/preview-host/PreviewTarget.js +17 -0
- package/dist/cjs/preview-host/PreviewTarget.js.map +1 -0
- package/dist/cjs/preview-host/PreviewTemplate.js +49 -0
- package/dist/cjs/preview-host/PreviewTemplate.js.map +1 -0
- package/dist/cjs/preview-host/PreviewToast.js +45 -0
- package/dist/cjs/preview-host/PreviewToast.js.map +1 -0
- package/dist/cjs/preview-host/ScenePreviewHost.js +290 -0
- package/dist/cjs/preview-host/ScenePreviewHost.js.map +1 -0
- package/dist/cjs/preview-host/composeApplication.js +249 -0
- package/dist/cjs/preview-host/composeApplication.js.map +1 -0
- package/dist/cjs/preview-host/defaultApplicationChrome.js +43 -0
- package/dist/cjs/preview-host/defaultApplicationChrome.js.map +1 -0
- package/dist/cjs/preview-host/diagnosePreview.js +100 -0
- package/dist/cjs/preview-host/diagnosePreview.js.map +1 -0
- package/dist/cjs/preview-host/previewProfile.js +53 -0
- package/dist/cjs/preview-host/previewProfile.js.map +1 -0
- package/dist/cjs/preview-host/previewSampleData.js +116 -0
- package/dist/cjs/preview-host/previewSampleData.js.map +1 -0
- package/dist/cjs/preview-host/resolvePreviewPlan.js +126 -0
- package/dist/cjs/preview-host/resolvePreviewPlan.js.map +1 -0
- package/dist/cjs/preview-host/useSizeClass.js +23 -0
- package/dist/cjs/preview-host/useSizeClass.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/preview-host/ApplicationDocument.d.ts +7 -0
- package/dist/esm/preview-host/ApplicationDocument.d.ts.map +1 -0
- package/dist/esm/preview-host/ApplicationDocument.js +15 -0
- package/dist/esm/preview-host/ApplicationDocument.js.map +1 -0
- package/dist/esm/preview-host/ApplicationHost.d.ts +24 -0
- package/dist/esm/preview-host/ApplicationHost.d.ts.map +1 -0
- package/dist/esm/preview-host/ApplicationHost.js +132 -0
- package/dist/esm/preview-host/ApplicationHost.js.map +1 -0
- package/dist/esm/preview-host/FlowArrangementView.d.ts +7 -0
- package/dist/esm/preview-host/FlowArrangementView.d.ts.map +1 -0
- package/dist/esm/preview-host/FlowArrangementView.js +73 -0
- package/dist/esm/preview-host/FlowArrangementView.js.map +1 -0
- package/dist/esm/preview-host/PreviewProblem.d.ts +26 -0
- package/dist/esm/preview-host/PreviewProblem.d.ts.map +1 -0
- package/dist/esm/preview-host/PreviewProblem.js +28 -0
- package/dist/esm/preview-host/PreviewProblem.js.map +1 -0
- package/dist/esm/preview-host/PreviewProblemsView.d.ts +7 -0
- package/dist/esm/preview-host/PreviewProblemsView.d.ts.map +1 -0
- package/dist/esm/preview-host/PreviewProblemsView.js +49 -0
- package/dist/esm/preview-host/PreviewProblemsView.js.map +1 -0
- package/dist/esm/preview-host/PreviewSliceFragment.d.ts +3 -0
- package/dist/esm/preview-host/PreviewSliceFragment.d.ts.map +1 -0
- package/dist/esm/preview-host/PreviewSliceFragment.js +53 -0
- package/dist/esm/preview-host/PreviewSliceFragment.js.map +1 -0
- package/dist/esm/preview-host/PreviewTarget.d.ts +10 -0
- package/dist/esm/preview-host/PreviewTarget.d.ts.map +1 -0
- package/dist/esm/preview-host/PreviewTarget.js +15 -0
- package/dist/esm/preview-host/PreviewTarget.js.map +1 -0
- package/dist/esm/preview-host/PreviewTemplate.d.ts +5 -0
- package/dist/esm/preview-host/PreviewTemplate.d.ts.map +1 -0
- package/dist/esm/preview-host/PreviewTemplate.js +45 -0
- package/dist/esm/preview-host/PreviewTemplate.js.map +1 -0
- package/dist/esm/preview-host/PreviewToast.d.ts +10 -0
- package/dist/esm/preview-host/PreviewToast.d.ts.map +1 -0
- package/dist/esm/preview-host/PreviewToast.js +43 -0
- package/dist/esm/preview-host/PreviewToast.js.map +1 -0
- package/dist/esm/preview-host/ScenePreviewHost.d.ts +32 -0
- package/dist/esm/preview-host/ScenePreviewHost.d.ts.map +1 -0
- package/dist/esm/preview-host/ScenePreviewHost.js +288 -0
- package/dist/esm/preview-host/ScenePreviewHost.js.map +1 -0
- package/dist/esm/preview-host/composeApplication.d.ts +34 -0
- package/dist/esm/preview-host/composeApplication.d.ts.map +1 -0
- package/dist/esm/preview-host/composeApplication.js +239 -0
- package/dist/esm/preview-host/composeApplication.js.map +1 -0
- package/dist/esm/preview-host/defaultApplicationChrome.d.ts +4 -0
- package/dist/esm/preview-host/defaultApplicationChrome.d.ts.map +1 -0
- package/dist/esm/preview-host/defaultApplicationChrome.js +41 -0
- package/dist/esm/preview-host/defaultApplicationChrome.js.map +1 -0
- package/dist/esm/preview-host/diagnosePreview.d.ts +22 -0
- package/dist/esm/preview-host/diagnosePreview.d.ts.map +1 -0
- package/dist/esm/preview-host/diagnosePreview.js +98 -0
- package/dist/esm/preview-host/diagnosePreview.js.map +1 -0
- package/dist/esm/preview-host/index.d.ts +18 -0
- package/dist/esm/preview-host/index.d.ts.map +1 -0
- package/dist/esm/preview-host/index.js +18 -0
- package/dist/esm/preview-host/index.js.map +1 -0
- package/dist/esm/preview-host/previewProfile.d.ts +6 -0
- package/dist/esm/preview-host/previewProfile.d.ts.map +1 -0
- package/dist/esm/preview-host/previewProfile.js +49 -0
- package/dist/esm/preview-host/previewProfile.js.map +1 -0
- package/dist/esm/preview-host/previewSampleData.d.ts +22 -0
- package/dist/esm/preview-host/previewSampleData.d.ts.map +1 -0
- package/dist/esm/preview-host/previewSampleData.js +113 -0
- package/dist/esm/preview-host/previewSampleData.js.map +1 -0
- package/dist/esm/preview-host/resolvePreviewPlan.d.ts +18 -0
- package/dist/esm/preview-host/resolvePreviewPlan.d.ts.map +1 -0
- package/dist/esm/preview-host/resolvePreviewPlan.js +124 -0
- package/dist/esm/preview-host/resolvePreviewPlan.js.map +1 -0
- package/dist/esm/preview-host/useSizeClass.d.ts +3 -0
- package/dist/esm/preview-host/useSizeClass.d.ts.map +1 -0
- package/dist/esm/preview-host/useSizeClass.js +21 -0
- package/dist/esm/preview-host/useSizeClass.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/index.ts +1 -0
- package/package.json +8 -8
- package/preview-host/ApplicationDocument.ts +31 -0
- package/preview-host/ApplicationHost.tsx +155 -0
- package/preview-host/FlowArrangementView.tsx +59 -0
- package/preview-host/PreviewProblem.ts +68 -0
- package/preview-host/PreviewProblemsView.tsx +31 -0
- package/preview-host/PreviewSliceFragment.ts +43 -0
- package/preview-host/PreviewTarget.ts +19 -0
- package/preview-host/PreviewTemplate.tsx +45 -0
- package/preview-host/PreviewToast.tsx +32 -0
- package/preview-host/ScenePreviewHost.tsx +250 -0
- package/preview-host/composeApplication.ts +273 -0
- package/preview-host/defaultApplicationChrome.ts +33 -0
- package/preview-host/diagnosePreview.ts +132 -0
- package/preview-host/index.ts +20 -0
- package/preview-host/previewProfile.ts +47 -0
- package/preview-host/previewSampleData.ts +144 -0
- package/preview-host/resolvePreviewPlan.ts +100 -0
- package/preview-host/useSizeClass.ts +23 -0
- package/shell/layout.css +22 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var scene_engine = require('@cratis/scene.engine');
|
|
5
|
+
|
|
6
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
7
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
8
|
+
/**
|
|
9
|
+
* Tracks the browser window's {@link SizeClass}, recomputing whenever it resizes across a boundary the
|
|
10
|
+
* shared engine cares about. This is what lets a modeled `when width compact` override actually take
|
|
11
|
+
* effect on a narrow window instead of the arrangement engine's size-aware logic never being asked.
|
|
12
|
+
*/ function useSizeClass() {
|
|
13
|
+
const [sizeClass, setSizeClass] = react.useState(()=>scene_engine.computeSizeClass(globalThis.innerWidth, globalThis.innerHeight));
|
|
14
|
+
react.useEffect(()=>{
|
|
15
|
+
const onResize = ()=>setSizeClass(scene_engine.computeSizeClass(globalThis.innerWidth, globalThis.innerHeight));
|
|
16
|
+
globalThis.addEventListener('resize', onResize);
|
|
17
|
+
return ()=>globalThis.removeEventListener('resize', onResize);
|
|
18
|
+
}, []);
|
|
19
|
+
return sizeClass;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.useSizeClass = useSizeClass;
|
|
23
|
+
//# sourceMappingURL=useSizeClass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSizeClass.js","sources":["../../../preview-host/useSizeClass.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useState } from 'react';\nimport type { SizeClass } from '@cratis/scene.model';\nimport { computeSizeClass } from '@cratis/scene.engine';\n\n/**\n * Tracks the browser window's {@link SizeClass}, recomputing whenever it resizes across a boundary the\n * shared engine cares about. This is what lets a modeled `when width compact` override actually take\n * effect on a narrow window instead of the arrangement engine's size-aware logic never being asked.\n */\nexport function useSizeClass(): SizeClass {\n const [sizeClass, setSizeClass] = useState<SizeClass>(() => computeSizeClass(globalThis.innerWidth, globalThis.innerHeight));\n\n useEffect(() => {\n const onResize = () => setSizeClass(computeSizeClass(globalThis.innerWidth, globalThis.innerHeight));\n globalThis.addEventListener('resize', onResize);\n return () => globalThis.removeEventListener('resize', onResize);\n }, []);\n\n return sizeClass;\n}\n"],"names":["useSizeClass","sizeClass","setSizeClass","useState","computeSizeClass","globalThis","innerWidth","innerHeight","useEffect","onResize","addEventListener","removeEventListener"],"mappings":";;;;;AAAA;AACA;AAMA;;;;AAIC,IACM,SAASA,YAAAA,GAAAA;IACZ,MAAM,CAACC,SAAAA,EAAWC,YAAAA,CAAa,GAAGC,cAAAA,CAAoB,IAAMC,6BAAAA,CAAiBC,UAAAA,CAAWC,UAAU,EAAED,UAAAA,CAAWE,WAAW,CAAA,CAAA;IAE1HC,eAAAA,CAAU,IAAA;QACN,MAAMC,QAAAA,GAAW,IAAMP,YAAAA,CAAaE,6BAAAA,CAAiBC,WAAWC,UAAU,EAAED,WAAWE,WAAW,CAAA,CAAA;QAClGF,UAAAA,CAAWK,gBAAgB,CAAC,QAAA,EAAUD,QAAAA,CAAAA;AACtC,QAAA,OAAO,IAAMJ,UAAAA,CAAWM,mBAAmB,CAAC,QAAA,EAAUF,QAAAA,CAAAA;AAC1D,IAAA,CAAA,EAAG,EAAE,CAAA;IAEL,OAAOR,SAAAA;AACX;;"}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -84,4 +84,21 @@ export { LayoutThemeProvider } from './themes/LayoutThemeProvider.js';
|
|
|
84
84
|
export { defaultBlueprintComponents } from './defaultBlueprintComponents.js';
|
|
85
85
|
export { defaultBlueprint, defaultBlueprintManifest } from './defaultBlueprint.js';
|
|
86
86
|
export { defaultBlueprintTemplateProvenance, sakaiCompositionProvenance } from './templateProvenance.js';
|
|
87
|
+
export { isSliceTarget } from './preview-host/PreviewTarget.js';
|
|
88
|
+
export { PreviewProblemCode, PreviewProblemSeverity, hasBlockingProblem } from './preview-host/PreviewProblem.js';
|
|
89
|
+
export { completeDocument } from './preview-host/ApplicationDocument.js';
|
|
90
|
+
export { blueprintPackageCatalog, previewProfile, requiredPackages } from './preview-host/previewProfile.js';
|
|
91
|
+
export { defaultApplicationChrome } from './preview-host/defaultApplicationChrome.js';
|
|
92
|
+
export { FlowArrangementView } from './preview-host/FlowArrangementView.js';
|
|
93
|
+
export { useSizeClass } from './preview-host/useSizeClass.js';
|
|
94
|
+
export { PreviewTemplate, previewComponents, previewTemplateComponent } from './preview-host/PreviewTemplate.js';
|
|
95
|
+
export { collectDestinations, composeApplicationScreen, composeDialog, composeOutletScreen, findLayout, screenContent, templateChainOf, templatePoolFor, templatesOf } from './preview-host/composeApplication.js';
|
|
96
|
+
export { resolvePreviewPlan } from './preview-host/resolvePreviewPlan.js';
|
|
97
|
+
export { diagnosePreview } from './preview-host/diagnosePreview.js';
|
|
98
|
+
export { collectQueryNames, createPreviewSampleData } from './preview-host/previewSampleData.js';
|
|
99
|
+
export { findSliceFragment } from './preview-host/PreviewSliceFragment.js';
|
|
100
|
+
export { PreviewToast } from './preview-host/PreviewToast.js';
|
|
101
|
+
export { PreviewProblemsView } from './preview-host/PreviewProblemsView.js';
|
|
102
|
+
export { ApplicationHost } from './preview-host/ApplicationHost.js';
|
|
103
|
+
export { ScenePreviewHost } from './preview-host/ScenePreviewHost.js';
|
|
87
104
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SceneDocument, Theme, UiProfile } from '@cratis/scene.model';
|
|
2
|
+
export type ApplicationDocument = Pick<SceneDocument, 'layouts' | 'screenTemplates' | 'screens'> & Partial<Pick<SceneDocument, 'dialogTemplates' | 'exposures' | 'instanceContributions'>> & {
|
|
3
|
+
uiProfiles?: UiProfile[];
|
|
4
|
+
themes?: Theme[];
|
|
5
|
+
};
|
|
6
|
+
export declare function completeDocument(application: ApplicationDocument): SceneDocument;
|
|
7
|
+
//# sourceMappingURL=ApplicationDocument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicationDocument.d.ts","sourceRoot":"","sources":["../../../preview-host/ApplicationDocument.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAO3E,MAAM,MAAM,mBAAmB,GACzB,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAAC,GAC9D,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,iBAAiB,GAAG,WAAW,GAAG,uBAAuB,CAAC,CAAC,GACvF;IAEE,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IAEzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CACpB,CAAC;AAGN,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,mBAAmB,GAAG,aAAa,CAShF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** The document with everything a template chain needs filled in. */ function completeDocument(application) {
|
|
4
|
+
return {
|
|
5
|
+
layouts: application.layouts,
|
|
6
|
+
screenTemplates: application.screenTemplates,
|
|
7
|
+
dialogTemplates: application.dialogTemplates ?? [],
|
|
8
|
+
screens: application.screens,
|
|
9
|
+
exposures: application.exposures ?? [],
|
|
10
|
+
instanceContributions: application.instanceContributions ?? []
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { completeDocument };
|
|
15
|
+
//# sourceMappingURL=ApplicationDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicationDocument.js","sources":["../../../preview-host/ApplicationDocument.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { SceneDocument, Theme, UiProfile } from '@cratis/scene.model';\n\n/**\n * What an application is made of: the document a designer edits - layouts, templates, screens, and what a template exposes and\n * each instance contributes - and the profile and theme the application renders with. Stage assembles it from a Screenplay\n * model, Studio from the model in memory (unsaved edits included); the composition and the hosts take nothing else.\n */\nexport type ApplicationDocument =\n & Pick<SceneDocument, 'layouts' | 'screenTemplates' | 'screens'>\n & Partial<Pick<SceneDocument, 'dialogTemplates' | 'exposures' | 'instanceContributions'>>\n & {\n /** The profiles the application declares; the first for the web is the one rendered with. */\n uiProfiles?: UiProfile[];\n\n themes?: Theme[];\n };\n\n/** The document with everything a template chain needs filled in. */\nexport function completeDocument(application: ApplicationDocument): SceneDocument {\n return {\n layouts: application.layouts,\n screenTemplates: application.screenTemplates,\n dialogTemplates: application.dialogTemplates ?? [],\n screens: application.screens,\n exposures: application.exposures ?? [],\n instanceContributions: application.instanceContributions ?? [],\n };\n}\n"],"names":["completeDocument","application","layouts","screenTemplates","dialogTemplates","screens","exposures","instanceContributions"],"mappings":"AAAA;AACA;AAmBA,sEACO,SAASA,gBAAAA,CAAiBC,WAAgC,EAAA;IAC7D,OAAO;AACHC,QAAAA,OAAAA,EAASD,YAAYC,OAAO;AAC5BC,QAAAA,eAAAA,EAAiBF,YAAYE,eAAe;QAC5CC,eAAAA,EAAiBH,WAAAA,CAAYG,eAAe,IAAI,EAAE;AAClDC,QAAAA,OAAAA,EAASJ,YAAYI,OAAO;QAC5BC,SAAAA,EAAWL,WAAAA,CAAYK,SAAS,IAAI,EAAE;QACtCC,qBAAAA,EAAuBN,WAAAA,CAAYM,qBAAqB,IAAI;AAChE,KAAA;AACJ;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DialogTemplate, SceneElement, type EffectiveConfiguration } from '@cratis/scene.model';
|
|
3
|
+
import { BindingResolver } from '@cratis/scene.engine';
|
|
4
|
+
import { ComponentRegistry, SceneHistory, SceneNavigationContextValue, SceneNavigationModel } from '@cratis/scene.react';
|
|
5
|
+
import { ApplicationDocument } from './ApplicationDocument';
|
|
6
|
+
import { CompositionOptions } from './composeApplication';
|
|
7
|
+
export interface ApplicationHostProps {
|
|
8
|
+
application: ApplicationDocument;
|
|
9
|
+
composition?: CompositionOptions;
|
|
10
|
+
navigationModel: SceneNavigationModel;
|
|
11
|
+
registry: ComponentRegistry;
|
|
12
|
+
initialScreen: string;
|
|
13
|
+
history?: SceneHistory;
|
|
14
|
+
resolveBinding?: BindingResolver;
|
|
15
|
+
queryResults?: Record<string, unknown>;
|
|
16
|
+
renderScreen?(element: SceneElement, configuration: EffectiveConfiguration | undefined, navigation: SceneNavigationContextValue): ReactNode;
|
|
17
|
+
renderDialog?(navigation: SceneNavigationContextValue): ReactNode;
|
|
18
|
+
renderDialogTemplate?(template: DialogTemplate, content: SceneElement, navigation: SceneNavigationContextValue): ReactNode;
|
|
19
|
+
scope?(navigation: SceneNavigationContextValue, children: ReactNode): ReactNode;
|
|
20
|
+
layoutConfigStorage?: Storage | null;
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export declare function ApplicationHost({ application, composition, navigationModel, registry: hostRegistry, initialScreen, history, resolveBinding, queryResults, renderScreen, renderDialog, renderDialogTemplate, scope, layoutConfigStorage, children }: ApplicationHostProps): import("react").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=ApplicationHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicationHost.d.ts","sourceRoot":"","sources":["../../../preview-host/ApplicationHost.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAgB,MAAM,sBAAsB,CAAC;AACrE,OAAO,EACH,iBAAiB,EAAoB,YAAY,EAAE,2BAA2B,EAAE,oBAAoB,EAGvG,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAqF,MAAM,sBAAsB,CAAC;AAE7I,MAAM,WAAW,oBAAoB;IAEjC,WAAW,EAAE,mBAAmB,CAAC;IAGjC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAGjC,eAAe,EAAE,oBAAoB,CAAC;IAEtC,QAAQ,EAAE,iBAAiB,CAAC;IAG5B,aAAa,EAAE,MAAM,CAAC;IAGtB,OAAO,CAAC,EAAE,YAAY,CAAC;IAGvB,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAQvC,YAAY,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,GAAG,SAAS,EAAE,UAAU,EAAE,2BAA2B,GAAG,SAAS,CAAC;IAM5I,YAAY,CAAC,CAAC,UAAU,EAAE,2BAA2B,GAAG,SAAS,CAAC;IASlE,oBAAoB,CAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,2BAA2B,GAAG,SAAS,CAAC;IAS3H,KAAK,CAAC,CAAC,UAAU,EAAE,2BAA2B,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,CAAC;IAMhF,mBAAmB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAGrC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AASD,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,WAAgB,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,KAAK,EAAE,mBAA0B,EAAE,QAAQ,EAAE,EAAE,oBAAoB,+BA8DpR"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useMemo } from 'react';
|
|
3
|
+
import { createMemorySceneHistory, collectOutletOwners, navigationDestinations, sceneRoutesFrom, useSceneHistoryNavigation, sliceDialogParameters, SceneElementView, SliceDialogView, SceneNavigationProvider, SceneOutletContext, SceneNavigationModelProvider } from '@cratis/scene.react';
|
|
4
|
+
import { LayoutConfigProvider } from '../configuration/LayoutConfigProvider.js';
|
|
5
|
+
import { previewComponents } from './PreviewTemplate.js';
|
|
6
|
+
import { composeOutletScreen, collectDestinations, composeApplicationScreen, composeDialog } from './composeApplication.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The application as both Stage and the preview host run it: the shell composed for the screen on the page
|
|
10
|
+
* (`composeApplicationScreen`), nested outlets holding the screens placed in them, the navigation model in scope for the shell's
|
|
11
|
+
* topbar and sidebar regions, every destination the document and the navigation lead to routed, and the dialog a toolbar slice
|
|
12
|
+
* button or a dialog destination opened shown over it - one place for all of it (spec PRV9), so a behaviour that differs between
|
|
13
|
+
* the two hosts is a bug in the host, not a second implementation.
|
|
14
|
+
*/ function ApplicationHost({ application, composition = {}, navigationModel, registry: hostRegistry, initialScreen, history, resolveBinding, queryResults, renderScreen, renderDialog, renderDialogTemplate, scope, layoutConfigStorage = null, children }) {
|
|
15
|
+
const [memoryHistory] = useState(()=>createMemorySceneHistory());
|
|
16
|
+
const registry = useMemo(()=>({
|
|
17
|
+
...previewComponents,
|
|
18
|
+
...hostRegistry
|
|
19
|
+
}), [
|
|
20
|
+
hostRegistry
|
|
21
|
+
]);
|
|
22
|
+
const hostHistory = history ?? memoryHistory;
|
|
23
|
+
const screens = application.screens;
|
|
24
|
+
const outletScreens = useMemo(()=>Object.fromEntries(screens.map((candidate)=>[
|
|
25
|
+
candidate.name,
|
|
26
|
+
composeOutletScreen(application, candidate, composition)
|
|
27
|
+
])), [
|
|
28
|
+
application,
|
|
29
|
+
composition,
|
|
30
|
+
screens
|
|
31
|
+
]);
|
|
32
|
+
const owners = useMemo(()=>collectOutletOwners(outletScreens), [
|
|
33
|
+
outletScreens
|
|
34
|
+
]);
|
|
35
|
+
const destinations = useMemo(()=>[
|
|
36
|
+
...collectDestinations(application),
|
|
37
|
+
...navigationDestinations(navigationModel.structure, navigationModel.navigation, navigationModel.screenFor)
|
|
38
|
+
], [
|
|
39
|
+
application,
|
|
40
|
+
navigationModel
|
|
41
|
+
]);
|
|
42
|
+
const routes = useMemo(()=>sceneRoutesFrom(screens.map((candidate)=>candidate.name), destinations), [
|
|
43
|
+
destinations,
|
|
44
|
+
screens
|
|
45
|
+
]);
|
|
46
|
+
const bindingScope = useMemo(()=>({
|
|
47
|
+
queryResults
|
|
48
|
+
}), [
|
|
49
|
+
queryResults
|
|
50
|
+
]);
|
|
51
|
+
const navigation = useSceneHistoryNavigation(hostHistory, routes, initialScreen, bindingScope, owners, destinations);
|
|
52
|
+
const screen = screens.find((candidate)=>candidate.name === navigation.primaryScreen) ?? screens.find((candidate)=>candidate.name === initialScreen) ?? screens[0];
|
|
53
|
+
const composed = useMemo(()=>screen ? composeApplicationScreen(application, screen, composition) : undefined, [
|
|
54
|
+
application,
|
|
55
|
+
composition,
|
|
56
|
+
screen
|
|
57
|
+
]);
|
|
58
|
+
const outletContext = useMemo(()=>({
|
|
59
|
+
screens: outletScreens,
|
|
60
|
+
registry
|
|
61
|
+
}), [
|
|
62
|
+
outletScreens,
|
|
63
|
+
registry
|
|
64
|
+
]);
|
|
65
|
+
const dialogTemplate = navigation.currentDialog ? application.dialogTemplates?.find((candidate)=>candidate.name === navigation.currentDialog) : undefined;
|
|
66
|
+
const sliceDialog = !dialogTemplate && navigation.currentDialog && sliceDialogParameters(navigation.currentDialogParameters) !== undefined;
|
|
67
|
+
const dialogName = sliceDialogParameters(navigation.currentDialogParameters)?.title ?? navigation.currentDialog;
|
|
68
|
+
const dialogContent = dialogTemplate ? composeDialog(application, dialogTemplate, composition) : undefined;
|
|
69
|
+
const body = /*#__PURE__*/ jsxs(Fragment, {
|
|
70
|
+
children: [
|
|
71
|
+
/*#__PURE__*/ jsx("div", {
|
|
72
|
+
"data-scene-outlet": "primary",
|
|
73
|
+
"data-scene-url": navigation.currentUrl,
|
|
74
|
+
"data-scene-screen": navigation.primaryScreen,
|
|
75
|
+
children: composed && /*#__PURE__*/ jsx(Drawn, {
|
|
76
|
+
children: renderScreen ? ()=>renderScreen(composed.element, composed.configuration, navigation) : ()=>/*#__PURE__*/ jsx(SceneElementView, {
|
|
77
|
+
element: composed.element,
|
|
78
|
+
registry: registry,
|
|
79
|
+
resolveBinding: resolveBinding,
|
|
80
|
+
queryResults: queryResults,
|
|
81
|
+
configuration: composed.configuration
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
}),
|
|
85
|
+
dialogTemplate && dialogContent && (renderDialogTemplate ? /*#__PURE__*/ jsx(Drawn, {
|
|
86
|
+
children: ()=>renderDialogTemplate(dialogTemplate, dialogContent, navigation)
|
|
87
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
88
|
+
role: "dialog",
|
|
89
|
+
"aria-modal": "true",
|
|
90
|
+
"aria-label": dialogName,
|
|
91
|
+
"data-scene-dialog": navigation.currentDialog,
|
|
92
|
+
children: /*#__PURE__*/ jsx(SceneElementView, {
|
|
93
|
+
element: dialogContent,
|
|
94
|
+
registry: registry,
|
|
95
|
+
resolveBinding: resolveBinding,
|
|
96
|
+
queryResults: queryResults
|
|
97
|
+
})
|
|
98
|
+
})),
|
|
99
|
+
sliceDialog && /*#__PURE__*/ jsx("div", {
|
|
100
|
+
role: "dialog",
|
|
101
|
+
"aria-modal": "true",
|
|
102
|
+
"aria-label": dialogName,
|
|
103
|
+
"data-scene-dialog": navigation.currentDialog,
|
|
104
|
+
children: renderDialog?.(navigation) ?? /*#__PURE__*/ jsx(SliceDialogView, {})
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
return /*#__PURE__*/ jsx(SceneNavigationProvider, {
|
|
109
|
+
value: navigation,
|
|
110
|
+
children: /*#__PURE__*/ jsx(SceneOutletContext.Provider, {
|
|
111
|
+
value: outletContext,
|
|
112
|
+
children: /*#__PURE__*/ jsx(SceneNavigationModelProvider, {
|
|
113
|
+
model: navigationModel,
|
|
114
|
+
children: /*#__PURE__*/ jsxs(LayoutConfigProvider, {
|
|
115
|
+
storage: layoutConfigStorage,
|
|
116
|
+
children: [
|
|
117
|
+
scope ? scope(navigation, body) : body,
|
|
118
|
+
children
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/** Calls what a host draws as part of this component, so a hook it uses runs under the providers the host put in scope. */ function Drawn({ children }) {
|
|
126
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
127
|
+
children: children()
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { ApplicationHost };
|
|
132
|
+
//# sourceMappingURL=ApplicationHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicationHost.js","sources":["../../../preview-host/ApplicationHost.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode, useMemo, useState } from 'react';\nimport { DialogTemplate, SceneElement, type EffectiveConfiguration } from '@cratis/scene.model';\nimport { BindingResolver, BindingScope } from '@cratis/scene.engine';\nimport {\n ComponentRegistry, SceneElementView, SceneHistory, SceneNavigationContextValue, SceneNavigationModel, SceneNavigationModelProvider,\n SceneNavigationProvider, SceneOutletContext, SliceDialogView, collectOutletOwners, createMemorySceneHistory, navigationDestinations,\n sceneRoutesFrom, sliceDialogParameters, useSceneHistoryNavigation,\n} from '@cratis/scene.react';\nimport { LayoutConfigProvider } from '../configuration';\nimport { ApplicationDocument } from './ApplicationDocument';\nimport { previewComponents } from './PreviewTemplate';\nimport { CompositionOptions, collectDestinations, composeApplicationScreen, composeDialog, composeOutletScreen } from './composeApplication';\n\nexport interface ApplicationHostProps {\n /** The document the application is composed from. */\n application: ApplicationDocument;\n\n /** What the host decides about composition; Stage and the preview host differ only here. */\n composition?: CompositionOptions;\n\n /** The structure and navigation the shell's regions show and the items' destinations resolve against. */\n navigationModel: SceneNavigationModel;\n\n registry: ComponentRegistry;\n\n /** The screen shown first. */\n initialScreen: string;\n\n /** Where entries are recorded: the address bar for Stage, an in-memory history for a preview, which never touches the host's URL (PRV4). */\n history?: SceneHistory;\n\n /** What the screens' bindings resolve against. */\n resolveBinding?: BindingResolver;\n queryResults?: Record<string, unknown>;\n\n /**\n * Draws the composed screen. The default renders it with `SceneElementView`; Stage wraps it with its data and command scope.\n * @param element The composed screen.\n * @param configuration What the screen's templates were configured with.\n * @param navigation Where the user is.\n */\n renderScreen?(element: SceneElement, configuration: EffectiveConfiguration | undefined, navigation: SceneNavigationContextValue): ReactNode;\n\n /**\n * Draws what the open dialog shows when the document has no dialog template of that name - a toolbar slice button's task\n * dialog by default.\n */\n renderDialog?(navigation: SceneNavigationContextValue): ReactNode;\n\n /**\n * Draws a dialog the document declares, in place of the host's plain one - a host that wants its own backdrop, a close button\n * and keyboard handling around the template's content. Called inside {@link scope}.\n * @param template The dialog template that is open.\n * @param content The template's composed content.\n * @param navigation Where the user is.\n */\n renderDialogTemplate?(template: DialogTemplate, content: SceneElement, navigation: SceneNavigationContextValue): ReactNode;\n\n /**\n * What a host provides around everything that renders - the screen on the page and the dialog over it: its data, its command\n * dispatcher, its chrome state. Inside the navigation providers, so it can read where the user is. Stage puts its data and\n * interaction scope here, so the screen, a dialog template and a slice dialog all share them.\n * @param navigation Where the user is.\n * @param children The screen and the dialog.\n */\n scope?(navigation: SceneNavigationContextValue, children: ReactNode): ReactNode;\n\n /**\n * Where the shell keeps its layout configuration - the sidebar's state, the chosen theme. A preview keeps none (null, the default);\n * a running application passes its storage so what a user chose is still chosen on the next visit.\n */\n layoutConfigStorage?: Storage | null;\n\n /** Rendered inside the host's providers, after the application. */\n children?: ReactNode;\n}\n\n/**\n * The application as both Stage and the preview host run it: the shell composed for the screen on the page\n * (`composeApplicationScreen`), nested outlets holding the screens placed in them, the navigation model in scope for the shell's\n * topbar and sidebar regions, every destination the document and the navigation lead to routed, and the dialog a toolbar slice\n * button or a dialog destination opened shown over it - one place for all of it (spec PRV9), so a behaviour that differs between\n * the two hosts is a bug in the host, not a second implementation.\n */\nexport function ApplicationHost({ application, composition = {}, navigationModel, registry: hostRegistry, initialScreen, history, resolveBinding, queryResults, renderScreen, renderDialog, renderDialogTemplate, scope, layoutConfigStorage = null, children }: ApplicationHostProps) {\n const [memoryHistory] = useState(() => createMemorySceneHistory());\n const registry = useMemo(() => ({ ...previewComponents, ...hostRegistry }), [hostRegistry]);\n const hostHistory = history ?? memoryHistory;\n const screens = application.screens;\n\n const outletScreens = useMemo(\n () => Object.fromEntries(screens.map(candidate => [candidate.name, composeOutletScreen(application, candidate, composition)])),\n [application, composition, screens]);\n const owners = useMemo(() => collectOutletOwners(outletScreens), [outletScreens]);\n const destinations = useMemo(\n () => [...collectDestinations(application), ...navigationDestinations(navigationModel.structure, navigationModel.navigation, navigationModel.screenFor)],\n [application, navigationModel]);\n const routes = useMemo(() => sceneRoutesFrom(screens.map(candidate => candidate.name), destinations), [destinations, screens]);\n const bindingScope = useMemo<BindingScope>(() => ({ queryResults }), [queryResults]);\n const navigation = useSceneHistoryNavigation(hostHistory, routes, initialScreen, bindingScope, owners, destinations);\n\n const screen = screens.find(candidate => candidate.name === navigation.primaryScreen) ?? screens.find(candidate => candidate.name === initialScreen) ?? screens[0];\n const composed = useMemo(() => screen ? composeApplicationScreen(application, screen, composition) : undefined, [application, composition, screen]);\n const outletContext = useMemo(() => ({ screens: outletScreens, registry }), [outletScreens, registry]);\n\n const dialogTemplate = navigation.currentDialog ? application.dialogTemplates?.find(candidate => candidate.name === navigation.currentDialog) : undefined;\n const sliceDialog = !dialogTemplate && navigation.currentDialog && sliceDialogParameters(navigation.currentDialogParameters) !== undefined;\n const dialogName = sliceDialogParameters(navigation.currentDialogParameters)?.title ?? navigation.currentDialog;\n\n const dialogContent = dialogTemplate ? composeDialog(application, dialogTemplate, composition) : undefined;\n\n const body = (\n <>\n <div data-scene-outlet='primary' data-scene-url={navigation.currentUrl} data-scene-screen={navigation.primaryScreen}>\n {composed && <Drawn>{renderScreen\n ? () => renderScreen(composed.element, composed.configuration, navigation)\n : () => <SceneElementView element={composed.element} registry={registry} resolveBinding={resolveBinding} queryResults={queryResults} configuration={composed.configuration} />}</Drawn>}\n </div>\n {dialogTemplate && dialogContent && (renderDialogTemplate\n ? <Drawn>{() => renderDialogTemplate(dialogTemplate, dialogContent, navigation)}</Drawn>\n : (\n <div role='dialog' aria-modal='true' aria-label={dialogName} data-scene-dialog={navigation.currentDialog}>\n <SceneElementView element={dialogContent} registry={registry} resolveBinding={resolveBinding} queryResults={queryResults} />\n </div>\n ))}\n {sliceDialog && (\n <div role='dialog' aria-modal='true' aria-label={dialogName} data-scene-dialog={navigation.currentDialog}>\n {renderDialog?.(navigation) ?? <SliceDialogView />}\n </div>\n )}\n </>\n );\n\n return (\n <SceneNavigationProvider value={navigation}>\n <SceneOutletContext.Provider value={outletContext}>\n <SceneNavigationModelProvider model={navigationModel}>\n {/* The shell reads its layout configuration from a provider; nothing is saved unless the host gives it somewhere to. */}\n <LayoutConfigProvider storage={layoutConfigStorage}>\n {scope ? scope(navigation, body) : body}\n {children}\n </LayoutConfigProvider>\n </SceneNavigationModelProvider>\n </SceneOutletContext.Provider>\n </SceneNavigationProvider>\n );\n}\n\n/** Calls what a host draws as part of this component, so a hook it uses runs under the providers the host put in scope. */\nfunction Drawn({ children }: { children(): ReactNode }) {\n return <>{children()}</>;\n}\n"],"names":["ApplicationHost","application","composition","navigationModel","registry","hostRegistry","initialScreen","history","resolveBinding","queryResults","renderScreen","renderDialog","renderDialogTemplate","scope","layoutConfigStorage","children","memoryHistory","useState","createMemorySceneHistory","useMemo","previewComponents","hostHistory","screens","outletScreens","Object","fromEntries","map","candidate","name","composeOutletScreen","owners","collectOutletOwners","destinations","collectDestinations","navigationDestinations","structure","navigation","screenFor","routes","sceneRoutesFrom","bindingScope","useSceneHistoryNavigation","screen","find","primaryScreen","composed","composeApplicationScreen","undefined","outletContext","dialogTemplate","currentDialog","dialogTemplates","sliceDialog","sliceDialogParameters","currentDialogParameters","dialogName","title","dialogContent","composeDialog","body","_jsxs","_Fragment","_jsx","div","data-scene-outlet","data-scene-url","currentUrl","data-scene-screen","Drawn","element","configuration","SceneElementView","role","aria-modal","aria-label","data-scene-dialog","SliceDialogView","SceneNavigationProvider","value","SceneOutletContext","Provider","SceneNavigationModelProvider","model","LayoutConfigProvider","storage"],"mappings":";;;;;;;AAgFA;;;;;;AAMC,IACM,SAASA,eAAAA,CAAgB,EAAEC,WAAW,EAAEC,WAAAA,GAAc,EAAE,EAAEC,eAAe,EAAEC,QAAAA,EAAUC,YAAY,EAAEC,aAAa,EAAEC,OAAO,EAAEC,cAAc,EAAEC,YAAY,EAAEC,YAAY,EAAEC,YAAY,EAAEC,oBAAoB,EAAEC,KAAK,EAAEC,mBAAAA,GAAsB,IAAI,EAAEC,QAAQ,EAAwB,EAAA;AACjR,IAAA,MAAM,CAACC,aAAAA,CAAc,GAAGC,QAAAA,CAAS,IAAMC,wBAAAA,EAAAA,CAAAA;IACvC,MAAMd,QAAAA,GAAWe,OAAAA,CAAQ,KAAO;AAAE,YAAA,GAAGC,iBAAiB;AAAE,YAAA,GAAGf;AAAa,SAAA,CAAA,EAAI;AAACA,QAAAA;AAAa,KAAA,CAAA;AAC1F,IAAA,MAAMgB,cAAcd,OAAAA,IAAWS,aAAAA;IAC/B,MAAMM,OAAAA,GAAUrB,YAAYqB,OAAO;IAEnC,MAAMC,aAAAA,GAAgBJ,OAAAA,CAClB,IAAMK,MAAAA,CAAOC,WAAW,CAACH,OAAAA,CAAQI,GAAG,CAACC,CAAAA,SAAAA,GAAa;AAACA,gBAAAA,SAAAA,CAAUC,IAAI;AAAEC,gBAAAA,mBAAAA,CAAoB5B,aAAa0B,SAAAA,EAAWzB,WAAAA;aAAa,CAAA,CAAA,EAC5H;AAACD,QAAAA,WAAAA;AAAaC,QAAAA,WAAAA;AAAa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A,CAACmB,4BAAAA,EAAAA;gBAA6BC,KAAAA,EAAO/E,eAAAA;AAEjC,gBAAA,QAAA,gBAAAyD,IAAA,CAACuB,oBAAAA,EAAAA;oBAAqBC,OAAAA,EAAStE,mBAAAA;;wBAC1BD,KAAAA,GAAQA,KAAAA,CAAMuB,YAAYuB,IAAAA,CAAAA,GAAQA,IAAAA;AAClC5C,wBAAAA;;;;;;AAMzB;AAEA,4HACA,SAASqD,KAAAA,CAAM,EAAErD,QAAQ,EAA6B,EAAA;IAClD,qBAAO+C,GAAA,CAAAD,QAAA,EAAA;AAAG9C,QAAAA,QAAAA,EAAAA,QAAAA;;AACd;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type FlowNode } from '@cratis/scene.model';
|
|
3
|
+
export declare function FlowArrangementView({ node, slots }: {
|
|
4
|
+
node: FlowNode;
|
|
5
|
+
slots: Record<string, ReactNode>;
|
|
6
|
+
}): import("react").JSX.Element | null;
|
|
7
|
+
//# sourceMappingURL=FlowArrangementView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowArrangementView.d.ts","sourceRoot":"","sources":["../../../preview-host/FlowArrangementView.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAevE,wBAAgB,mBAAmB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAAE,sCA4BxG"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { FlowContainerKind } from '@cratis/scene.model';
|
|
3
|
+
import { isFlowSlotLeaf, isFlowGrid, isFlowContainer } from '@cratis/scene.engine';
|
|
4
|
+
|
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
/**
|
|
8
|
+
* Renders a {@link FlowNode} tree - the same one `evaluateFlowArrangement` picks for the current size
|
|
9
|
+
* class - by walking it into nested flex/grid containers and dropping each named slot's real content into
|
|
10
|
+
* its {@link FlowSlotLeaf}. This is what turns a modeled `arrangement flow` (a layout's topbar/sidebar/
|
|
11
|
+
* content/footer, or a screen template's header/body/aside) into something that actually looks like more
|
|
12
|
+
* than one column, rather than every slot's content stacked flat regardless of what the document said.
|
|
13
|
+
*
|
|
14
|
+
* A fixed `width`/`height` on a slot is a known, documented gap in the arrangement it is fed (see
|
|
15
|
+
* the Screenplay converter) - only `grow` and `span` survive conversion. A slot that does not grow
|
|
16
|
+
* therefore sizes to its own content here, which is a reasonable rendering of "not growing" even though
|
|
17
|
+
* the exact pixel the author wrote is not carried this far yet.
|
|
18
|
+
*/ function FlowArrangementView({ node, slots }) {
|
|
19
|
+
if (isFlowSlotLeaf(node)) {
|
|
20
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
21
|
+
children: slots[node.slotName] ?? null
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (isFlowGrid(node)) {
|
|
25
|
+
const style = {
|
|
26
|
+
gap: `${node.gap}px`,
|
|
27
|
+
gridTemplateColumns: node.columns ? `repeat(${node.columns}, 1fr)` : undefined,
|
|
28
|
+
gridTemplateRows: node.rows ? `repeat(${node.rows}, 1fr)` : undefined
|
|
29
|
+
};
|
|
30
|
+
return /*#__PURE__*/ jsx("div", {
|
|
31
|
+
className: "flow-container flow-container--grid",
|
|
32
|
+
style: style,
|
|
33
|
+
children: node.children.map((child, index)=>/*#__PURE__*/ jsx(FlowChild, {
|
|
34
|
+
node: child,
|
|
35
|
+
slots: slots
|
|
36
|
+
}, index))
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (isFlowContainer(node)) {
|
|
40
|
+
const direction = node.kind === FlowContainerKind.Row ? 'row' : 'column';
|
|
41
|
+
return /*#__PURE__*/ jsx("div", {
|
|
42
|
+
className: `flow-container flow-container--${direction}`,
|
|
43
|
+
style: {
|
|
44
|
+
gap: `${node.gap}px`
|
|
45
|
+
},
|
|
46
|
+
children: node.children.map((child, index)=>/*#__PURE__*/ jsx(FlowChild, {
|
|
47
|
+
node: child,
|
|
48
|
+
slots: slots
|
|
49
|
+
}, index))
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function FlowChild({ node, slots }) {
|
|
55
|
+
const style = node.grow ? {
|
|
56
|
+
flex: `${node.grow} 1 0%`,
|
|
57
|
+
minWidth: 0,
|
|
58
|
+
minHeight: 0
|
|
59
|
+
} : {
|
|
60
|
+
flex: '0 0 auto'
|
|
61
|
+
};
|
|
62
|
+
return /*#__PURE__*/ jsx("div", {
|
|
63
|
+
className: "flow-child",
|
|
64
|
+
style: style,
|
|
65
|
+
children: /*#__PURE__*/ jsx(FlowArrangementView, {
|
|
66
|
+
node: node,
|
|
67
|
+
slots: slots
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { FlowArrangementView };
|
|
73
|
+
//# sourceMappingURL=FlowArrangementView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowArrangementView.js","sources":["../../../preview-host/FlowArrangementView.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { CSSProperties, ReactNode } from 'react';\nimport { FlowContainerKind, type FlowNode } from '@cratis/scene.model';\nimport { isFlowContainer, isFlowGrid, isFlowSlotLeaf } from '@cratis/scene.engine';\n\n/**\n * Renders a {@link FlowNode} tree - the same one `evaluateFlowArrangement` picks for the current size\n * class - by walking it into nested flex/grid containers and dropping each named slot's real content into\n * its {@link FlowSlotLeaf}. This is what turns a modeled `arrangement flow` (a layout's topbar/sidebar/\n * content/footer, or a screen template's header/body/aside) into something that actually looks like more\n * than one column, rather than every slot's content stacked flat regardless of what the document said.\n *\n * A fixed `width`/`height` on a slot is a known, documented gap in the arrangement it is fed (see\n * the Screenplay converter) - only `grow` and `span` survive conversion. A slot that does not grow\n * therefore sizes to its own content here, which is a reasonable rendering of \"not growing\" even though\n * the exact pixel the author wrote is not carried this far yet.\n */\nexport function FlowArrangementView({ node, slots }: { node: FlowNode; slots: Record<string, ReactNode> }) {\n if (isFlowSlotLeaf(node)) {\n return <>{slots[node.slotName] ?? null}</>;\n }\n\n if (isFlowGrid(node)) {\n const style: CSSProperties = {\n gap: `${node.gap}px`,\n gridTemplateColumns: node.columns ? `repeat(${node.columns}, 1fr)` : undefined,\n gridTemplateRows: node.rows ? `repeat(${node.rows}, 1fr)` : undefined,\n };\n return (\n <div className='flow-container flow-container--grid' style={style}>\n {node.children.map((child, index) => <FlowChild key={index} node={child} slots={slots} />)}\n </div>\n );\n }\n\n if (isFlowContainer(node)) {\n const direction = node.kind === FlowContainerKind.Row ? 'row' : 'column';\n return (\n <div className={`flow-container flow-container--${direction}`} style={{ gap: `${node.gap}px` }}>\n {node.children.map((child, index) => <FlowChild key={index} node={child} slots={slots} />)}\n </div>\n );\n }\n\n return null;\n}\n\nfunction FlowChild({ node, slots }: { node: FlowNode; slots: Record<string, ReactNode> }) {\n const style: CSSProperties = node.grow\n ? { flex: `${node.grow} 1 0%`, minWidth: 0, minHeight: 0 }\n : { flex: '0 0 auto' };\n return (\n <div className='flow-child' style={style}>\n <FlowArrangementView node={node} slots={slots} />\n </div>\n );\n}\n"],"names":["FlowArrangementView","node","slots","isFlowSlotLeaf","_jsx","_Fragment","slotName","isFlowGrid","style","gap","gridTemplateColumns","columns","undefined","gridTemplateRows","rows","div","className","children","map","child","index","FlowChild","isFlowContainer","direction","kind","FlowContainerKind","Row","grow","flex","minWidth","minHeight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AAAA,EAAAA;YAAIC,SAAAA,EAAW,CAAC,+BAA+B,EAAEO,SAAAA,CAAAA,CAAW;YAAEf,KAAAA,EAAO;AAAEC,gBAAAA,GAAAA,EAAK,CAAA,EAAGR,IAAAA,CAAKQ,GAAG,CAAC,EAAE;AAAE,aAAA;AACxFR,YAAAA,QAAAA,EAAAA,IAAAA,CAAKgB,QAAQ,CAACC,GAAG,CAAC,CAACC,KAAAA,EAAOC,sBAAUhB,GAAA,CAACiB,SAAAA,EAAAA;oBAAsBpB,IAAAA,EAAMkB,KAAAA;oBAAOjB,KAAAA,EAAOA;AAA3BkB,iBAAAA,EAAAA,KAAAA,CAAAA;;AAGjE,IAAA;IAEA,OAAO,IAAA;AACX;AAEA,SAASC,SAAAA,CAAU,EAAEpB,IAAI,EAAEC,KAAK,EAAwD,EAAA;IACpF,MAAMM,KAAAA,GAAuBP,IAAAA,CAAK0B,IAAI,GAChC;AAAEC,QAAAA,IAAAA,EAAM,CAAA,EAAG3B,IAAAA,CAAK0B,IAAI,CAAC,KAAK,CAAC;QAAEE,QAAAA,EAAU,CAAA;QAAGC,SAAAA,EAAW;KAAE,GACvD;QAAEF,IAAAA,EAAM;AAAW,KAAA;AACzB,IAAA,qBACIxB,GAAA,CAACW,KAAAA,EAAAA;QAAIC,SAAAA,EAAU,YAAA;QAAaR,KAAAA,EAAOA,KAAAA;AAC/B,QAAA,QAAA,gBAAAJ,GAAA,CAACJ,mBAAAA,EAAAA;YAAoBC,IAAAA,EAAMA,IAAAA;YAAMC,KAAAA,EAAOA;;;AAGpD;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare enum PreviewProblemCode {
|
|
2
|
+
TargetNotFound = "targetNotFound",
|
|
3
|
+
ModuleWithoutFeatures = "moduleWithoutFeatures",
|
|
4
|
+
ScreenMissing = "screenMissing",
|
|
5
|
+
SliceNotPreviewable = "sliceNotPreviewable",
|
|
6
|
+
SliceFragmentMissing = "sliceFragmentMissing",
|
|
7
|
+
LayoutMissing = "layoutMissing",
|
|
8
|
+
TemplateMissing = "templateMissing",
|
|
9
|
+
TemplateUnplaced = "templateUnplaced",
|
|
10
|
+
StructureInvalid = "structureInvalid",
|
|
11
|
+
NavigationInvalid = "navigationInvalid",
|
|
12
|
+
ToolbarInvalid = "toolbarInvalid",
|
|
13
|
+
SampleDataInvalid = "sampleDataInvalid"
|
|
14
|
+
}
|
|
15
|
+
export declare enum PreviewProblemSeverity {
|
|
16
|
+
Error = "error",
|
|
17
|
+
Warning = "warning"
|
|
18
|
+
}
|
|
19
|
+
export interface PreviewProblem {
|
|
20
|
+
code: PreviewProblemCode;
|
|
21
|
+
severity: PreviewProblemSeverity;
|
|
22
|
+
message: string;
|
|
23
|
+
nodeId?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function hasBlockingProblem(problems: PreviewProblem[]): boolean;
|
|
26
|
+
//# sourceMappingURL=PreviewProblem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewProblem.d.ts","sourceRoot":"","sources":["../../../preview-host/PreviewProblem.ts"],"names":[],"mappings":"AAIA,oBAAY,kBAAkB;IAE1B,cAAc,mBAAmB;IAGjC,qBAAqB,0BAA0B;IAG/C,aAAa,kBAAkB;IAG/B,mBAAmB,wBAAwB;IAG3C,oBAAoB,yBAAyB;IAG7C,aAAa,kBAAkB;IAG/B,eAAe,oBAAoB;IAGnC,gBAAgB,qBAAqB;IAGrC,gBAAgB,qBAAqB;IAGrC,iBAAiB,sBAAsB;IAGvC,cAAc,mBAAmB;IAGjC,iBAAiB,sBAAsB;CAC1C;AAGD,oBAAY,sBAAsB;IAE9B,KAAK,UAAU;IAGf,OAAO,YAAY;CACtB;AAMD,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,sBAAsB,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAGhB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAEtE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** Why a preview could not be rendered, or rendered with a caveat. */ var PreviewProblemCode = /*#__PURE__*/ function(PreviewProblemCode) {
|
|
4
|
+
/** The module, feature or slice the preview was asked for is not in the application structure. */ PreviewProblemCode["TargetNotFound"] = "targetNotFound";
|
|
5
|
+
/** The module has no feature to show. */ PreviewProblemCode["ModuleWithoutFeatures"] = "moduleWithoutFeatures";
|
|
6
|
+
/** The feature the preview shows has no screen in the document. */ PreviewProblemCode["ScreenMissing"] = "screenMissing";
|
|
7
|
+
/** The slice is neither a State Change nor a State View, so there is nothing to preview. */ PreviewProblemCode["SliceNotPreviewable"] = "sliceNotPreviewable";
|
|
8
|
+
/** A State View slice's data fragment was not found, so its feature's page is shown. */ PreviewProblemCode["SliceFragmentMissing"] = "sliceFragmentMissing";
|
|
9
|
+
/** The layout a screen names is neither in the document nor one the blueprint provides. */ PreviewProblemCode["LayoutMissing"] = "layoutMissing";
|
|
10
|
+
/** The screen template a screen names is neither in the document nor one the blueprint provides. */ PreviewProblemCode["TemplateMissing"] = "templateMissing";
|
|
11
|
+
/** A template found no single home in the layout, or nests inside itself. */ PreviewProblemCode["TemplateUnplaced"] = "templateUnplaced";
|
|
12
|
+
/** The application structure has a duplicate or ambiguous id. */ PreviewProblemCode["StructureInvalid"] = "structureInvalid";
|
|
13
|
+
/** A navigation item leads nowhere or collides with another (the engine's navigation diagnostics). */ PreviewProblemCode["NavigationInvalid"] = "navigationInvalid";
|
|
14
|
+
/** A toolbar button's slice does not exist, is not a State Change or is empty (the engine's toolbar diagnostics). */ PreviewProblemCode["ToolbarInvalid"] = "toolbarInvalid";
|
|
15
|
+
/** The profile's sample data selection names a pack or set that does not exist. */ PreviewProblemCode["SampleDataInvalid"] = "sampleDataInvalid";
|
|
16
|
+
return PreviewProblemCode;
|
|
17
|
+
}({});
|
|
18
|
+
/** How a problem affects the preview. */ var PreviewProblemSeverity = /*#__PURE__*/ function(PreviewProblemSeverity) {
|
|
19
|
+
/** The preview cannot show what was asked for; the problems are shown instead of a blank screen. */ PreviewProblemSeverity["Error"] = "error";
|
|
20
|
+
/** The preview renders, but something in the model will not behave as authored. */ PreviewProblemSeverity["Warning"] = "warning";
|
|
21
|
+
return PreviewProblemSeverity;
|
|
22
|
+
}({});
|
|
23
|
+
/** Whether any of the problems stops the preview from rendering. */ function hasBlockingProblem(problems) {
|
|
24
|
+
return problems.some((problem)=>problem.severity === "error");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { PreviewProblemCode, PreviewProblemSeverity, hasBlockingProblem };
|
|
28
|
+
//# sourceMappingURL=PreviewProblem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewProblem.js","sources":["../../../preview-host/PreviewProblem.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** Why a preview could not be rendered, or rendered with a caveat. */\nexport enum PreviewProblemCode {\n /** The module, feature or slice the preview was asked for is not in the application structure. */\n TargetNotFound = 'targetNotFound',\n\n /** The module has no feature to show. */\n ModuleWithoutFeatures = 'moduleWithoutFeatures',\n\n /** The feature the preview shows has no screen in the document. */\n ScreenMissing = 'screenMissing',\n\n /** The slice is neither a State Change nor a State View, so there is nothing to preview. */\n SliceNotPreviewable = 'sliceNotPreviewable',\n\n /** A State View slice's data fragment was not found, so its feature's page is shown. */\n SliceFragmentMissing = 'sliceFragmentMissing',\n\n /** The layout a screen names is neither in the document nor one the blueprint provides. */\n LayoutMissing = 'layoutMissing',\n\n /** The screen template a screen names is neither in the document nor one the blueprint provides. */\n TemplateMissing = 'templateMissing',\n\n /** A template found no single home in the layout, or nests inside itself. */\n TemplateUnplaced = 'templateUnplaced',\n\n /** The application structure has a duplicate or ambiguous id. */\n StructureInvalid = 'structureInvalid',\n\n /** A navigation item leads nowhere or collides with another (the engine's navigation diagnostics). */\n NavigationInvalid = 'navigationInvalid',\n\n /** A toolbar button's slice does not exist, is not a State Change or is empty (the engine's toolbar diagnostics). */\n ToolbarInvalid = 'toolbarInvalid',\n\n /** The profile's sample data selection names a pack or set that does not exist. */\n SampleDataInvalid = 'sampleDataInvalid',\n}\n\n/** How a problem affects the preview. */\nexport enum PreviewProblemSeverity {\n /** The preview cannot show what was asked for; the problems are shown instead of a blank screen. */\n Error = 'error',\n\n /** The preview renders, but something in the model will not behave as authored. */\n Warning = 'warning',\n}\n\n/**\n * One problem the preview found (PRV8): what it is, where, and a sentence an author can act on. The node id is what a host\n * links to - a screen, a template, a navigation item, a toolbar button, a module, feature or slice.\n */\nexport interface PreviewProblem {\n code: PreviewProblemCode;\n severity: PreviewProblemSeverity;\n message: string;\n\n /** The model node the problem is about, when it has one. */\n nodeId?: string;\n}\n\n/** Whether any of the problems stops the preview from rendering. */\nexport function hasBlockingProblem(problems: PreviewProblem[]): boolean {\n return problems.some(problem => problem.severity === PreviewProblemSeverity.Error);\n}\n"],"names":["PreviewProblemCode","PreviewProblemSeverity","hasBlockingProblem","problems","some","problem","severity"],"mappings":"AAAA;AACA;AAEA,uEACO,IAAKA,kBAAAA,iBAAAA,SAAAA,kBAAAA,EAAAA;uGACwF,kBAAA,CAAA,gBAAA,CAAA,GAAA,gBAAA;8CAGzD,kBAAA,CAAA,uBAAA,CAAA,GAAA,uBAAA;wEAG0B,kBAAA,CAAA,eAAA,CAAA,GAAA,eAAA;iGAGyB,kBAAA,CAAA,qBAAA,CAAA,GAAA,qBAAA;6FAGJ,kBAAA,CAAA,sBAAA,CAAA,GAAA,sBAAA;gGAGG,kBAAA,CAAA,eAAA,CAAA,GAAA,eAAA;yGAGS,kBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAA;kFAGvB,kBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAA;sEAGZ,kBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAA;2GAGqC,kBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAA;0HAGe,kBAAA,CAAA,gBAAA,CAAA,GAAA,gBAAA;wFAGlC,kBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAA;AAlCzEA,IAAAA,OAAAA,kBAAAA;AAoCX,CAAA,CAAA,EAAA;AAED,0CACO,IAAKC,sBAAAA,iBAAAA,SAAAA,sBAAAA,EAAAA;yGAC0F,sBAAA,CAAA,OAAA,CAAA,GAAA,OAAA;wFAGjB,sBAAA,CAAA,SAAA,CAAA,GAAA,SAAA;AAJzEA,IAAAA,OAAAA,sBAAAA;AAMX,CAAA,CAAA,EAAA;AAeD,qEACO,SAASC,kBAAAA,CAAmBC,QAA0B,EAAA;AACzD,IAAA,OAAOA,SAASC,IAAI,CAACC,CAAAA,OAAAA,GAAWA,QAAQC,QAAQ,KAAA,OAAA,CAAA;AACpD;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PreviewProblem } from './PreviewProblem';
|
|
2
|
+
export interface PreviewProblemsViewProps {
|
|
3
|
+
problems: PreviewProblem[];
|
|
4
|
+
onSelectProblem?(problem: PreviewProblem): void;
|
|
5
|
+
}
|
|
6
|
+
export declare function PreviewProblemsView({ problems, onSelectProblem }: PreviewProblemsViewProps): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=PreviewProblemsView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewProblemsView.d.ts","sourceRoot":"","sources":["../../../preview-host/PreviewProblemsView.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,WAAW,wBAAwB;IACrC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAG3B,eAAe,CAAC,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CACnD;AAMD,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,wBAAwB,+BAc1F"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* What a preview shows instead of a blank screen when the model has errors that would break rendering (PRV8): each problem
|
|
7
|
+
* with its code, its message and a link to the offending node.
|
|
8
|
+
*/ function PreviewProblemsView({ problems, onSelectProblem }) {
|
|
9
|
+
return /*#__PURE__*/ jsxs("section", {
|
|
10
|
+
className: "scene-preview-problems",
|
|
11
|
+
role: "alert",
|
|
12
|
+
"data-scene-preview-problems": true,
|
|
13
|
+
children: [
|
|
14
|
+
/*#__PURE__*/ jsx("h2", {
|
|
15
|
+
children: "This preview cannot be shown"
|
|
16
|
+
}),
|
|
17
|
+
/*#__PURE__*/ jsx("ul", {
|
|
18
|
+
children: problems.map((problem, index)=>/*#__PURE__*/ jsxs("li", {
|
|
19
|
+
"data-severity": problem.severity,
|
|
20
|
+
"data-code": problem.code,
|
|
21
|
+
"data-node-id": problem.nodeId,
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ jsx("code", {
|
|
24
|
+
children: problem.code
|
|
25
|
+
}),
|
|
26
|
+
" ",
|
|
27
|
+
problem.message,
|
|
28
|
+
problem.nodeId !== undefined && onSelectProblem && /*#__PURE__*/ jsxs(Fragment, {
|
|
29
|
+
children: [
|
|
30
|
+
" ",
|
|
31
|
+
/*#__PURE__*/ jsxs("button", {
|
|
32
|
+
type: "button",
|
|
33
|
+
onClick: ()=>onSelectProblem(problem),
|
|
34
|
+
children: [
|
|
35
|
+
"Show ",
|
|
36
|
+
problem.nodeId
|
|
37
|
+
]
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
}, `${problem.code}-${problem.nodeId ?? index}-${index}`))
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { PreviewProblemsView };
|
|
49
|
+
//# sourceMappingURL=PreviewProblemsView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewProblemsView.js","sources":["../../../preview-host/PreviewProblemsView.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PreviewProblem } from './PreviewProblem';\n\nexport interface PreviewProblemsViewProps {\n problems: PreviewProblem[];\n\n /** Called when the author follows a problem to the node it is about. */\n onSelectProblem?(problem: PreviewProblem): void;\n}\n\n/**\n * What a preview shows instead of a blank screen when the model has errors that would break rendering (PRV8): each problem\n * with its code, its message and a link to the offending node.\n */\nexport function PreviewProblemsView({ problems, onSelectProblem }: PreviewProblemsViewProps) {\n return (\n <section className='scene-preview-problems' role='alert' data-scene-preview-problems>\n <h2>This preview cannot be shown</h2>\n <ul>\n {problems.map((problem, index) => (\n <li key={`${problem.code}-${problem.nodeId ?? index}-${index}`} data-severity={problem.severity} data-code={problem.code} data-node-id={problem.nodeId}>\n <code>{problem.code}</code> {problem.message}\n {problem.nodeId !== undefined && onSelectProblem && <> <button type='button' onClick={() => onSelectProblem(problem)}>Show {problem.nodeId}</button></>}\n </li>\n ))}\n </ul>\n </section>\n );\n}\n"],"names":["PreviewProblemsView","problems","onSelectProblem","_jsxs","section","className","role","data-scene-preview-problems","_jsx","h2","ul","map","problem","index","li","data-severity","severity","data-code","code","data-node-id","nodeId","message","undefined","_Fragment","button","type","onClick"],"mappings":";;AAAA;AACA;AAWA;;;AAGC,IACM,SAASA,mBAAAA,CAAoB,EAAEC,QAAQ,EAAEC,eAAe,EAA4B,EAAA;AACvF,IAAA,qBACIC,IAAA,CAACC,SAAAA,EAAAA;QAAQC,SAAAA,EAAU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