@cratis/scene.blueprint.components 4.10.0 → 4.12.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.
Files changed (32) hide show
  1. package/dist/cjs/componentsBlueprint.js +7 -7
  2. package/dist/cjs/gallery/GalleryScreenPreview.js +109 -16
  3. package/dist/cjs/gallery/GalleryScreenPreview.js.map +1 -1
  4. package/dist/cjs/gallery/businessGallery.js +34 -0
  5. package/dist/cjs/gallery/businessGallery.js.map +1 -0
  6. package/dist/cjs/index.js +3 -0
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/esm/componentsBlueprint.js +7 -7
  9. package/dist/esm/gallery/BusinessGalleryCategory.d.ts +6 -0
  10. package/dist/esm/gallery/BusinessGalleryCategory.d.ts.map +1 -0
  11. package/dist/esm/gallery/BusinessGalleryCategory.js +2 -0
  12. package/dist/esm/gallery/BusinessGalleryCategory.js.map +1 -0
  13. package/dist/esm/gallery/GalleryScreenPreview.d.ts +4 -3
  14. package/dist/esm/gallery/GalleryScreenPreview.d.ts.map +1 -1
  15. package/dist/esm/gallery/GalleryScreenPreview.js +114 -22
  16. package/dist/esm/gallery/GalleryScreenPreview.js.map +1 -1
  17. package/dist/esm/gallery/businessGallery.d.ts +4 -0
  18. package/dist/esm/gallery/businessGallery.d.ts.map +1 -0
  19. package/dist/esm/gallery/businessGallery.js +32 -0
  20. package/dist/esm/gallery/businessGallery.js.map +1 -0
  21. package/dist/esm/gallery/index.d.ts +2 -0
  22. package/dist/esm/gallery/index.d.ts.map +1 -1
  23. package/dist/esm/gallery/index.js +2 -0
  24. package/dist/esm/gallery/index.js.map +1 -1
  25. package/dist/esm/index.js +2 -1
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  28. package/gallery/BusinessGalleryCategory.ts +12 -0
  29. package/gallery/GalleryScreenPreview.tsx +85 -19
  30. package/gallery/businessGallery.ts +19 -0
  31. package/gallery/index.ts +2 -0
  32. package/package.json +11 -11
@@ -0,0 +1,12 @@
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
+
4
+ import { ScreenTemplate } from '@cratis/scene.model';
5
+
6
+ /**
7
+ * A categorized set of templates a business gallery can show for a scope.
8
+ */
9
+ export interface BusinessGalleryCategory {
10
+ category: string;
11
+ templates: ScreenTemplate[];
12
+ }
@@ -2,12 +2,16 @@
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
4
  import { useMemo } from 'react';
5
- import { ComponentRegistry, SceneElementView, coreComponents } from '@cratis/scene.react';
6
- import { cratisComponents } from '@cratis/scene.components';
7
- import { LayoutConfigProvider, LayoutConfigState, LayoutThemeProvider, composeScreenElement, defaultBlueprintComponents, defaultBlueprintThemes, resolveElementComponentNames } from '@cratis/scene.blueprint.default';
5
+ import { PrimeReactProvider } from '@primereact/core';
6
+ import { PackageKind } from '@cratis/scene.model';
7
+ import { ComponentRegistry, PackageHostView, RegisteredComponentProps, ScenePackageBundle, corePackage, resolvePackageHost } from '@cratis/scene.react';
8
+ import { cratisComponentsPackage } from '@cratis/scene.components';
9
+ import { defaultBlueprint, LayoutConfigProvider, LayoutConfigState, LayoutThemeProvider, composeScreenElement, defaultBlueprintThemes, resolveElementComponentNames } from '@cratis/scene.blueprint.default';
8
10
  import { componentsBlueprintComponents } from '../componentsBlueprintComponents';
9
- import { componentsBlueprintCatalog, componentsBlueprintProfile } from './previewProfile';
10
- import { componentsGalleryScreen } from './screens';
11
+ import { componentsBlueprintName } from '../packageName';
12
+ import { componentsDialogTemplates, componentsScreenTemplates } from '../templates';
13
+ import { componentsBlueprintCatalog, componentsBlueprintProfile, primeReactComponentNames } from './previewProfile';
14
+ import { componentsGalleryScreen, componentsGalleryScreens } from './screens';
11
15
 
12
16
  /**
13
17
  * The registry a preview resolves against: `core`, `Cratis.Components`, the default blueprint, and this one.
@@ -20,12 +24,66 @@ import { componentsGalleryScreen } from './screens';
20
24
  * table comes out unresolved - and it never reaches the DOM, because the table it belongs to is a
21
25
  * placeholder until a host registers its query.
22
26
  */
23
- export const componentsPreviewRegistry: ComponentRegistry = {
24
- ...coreComponents,
25
- ...cratisComponents,
26
- ...defaultBlueprintComponents,
27
- ...componentsBlueprintComponents,
28
- };
27
+ const previewComponent = ({ element }: RegisteredComponentProps) => <span data-preview-component={element.componentName}>{String(element.properties.label ?? element.componentName)}</span>;
28
+
29
+ export const componentsPreviewBundles: ScenePackageBundle[] = [
30
+ corePackage,
31
+ {
32
+ manifest: {
33
+ name: 'Tailwind',
34
+ version: '4.0.0',
35
+ kind: PackageKind.Styling,
36
+ dependencies: [],
37
+ components: [],
38
+ layouts: [],
39
+ screenTemplates: [],
40
+ dialogTemplates: [],
41
+ themes: [],
42
+ assets: ['styles/tailwind.css', 'fonts/inter.woff2'],
43
+ },
44
+ components: {},
45
+ },
46
+ {
47
+ manifest: {
48
+ name: 'PrimeReact',
49
+ version: '11.1.0',
50
+ kind: PackageKind.ComponentLibrary,
51
+ dependencies: [{ name: 'Tailwind' }],
52
+ components: primeReactComponentNames,
53
+ layouts: [],
54
+ screenTemplates: [],
55
+ dialogTemplates: [],
56
+ themes: [],
57
+ },
58
+ components: Object.fromEntries(primeReactComponentNames.map(name => [`PrimeReact:${name}`, previewComponent])),
59
+ },
60
+ cratisComponentsPackage,
61
+ defaultBlueprint,
62
+ {
63
+ manifest: {
64
+ name: componentsBlueprintName,
65
+ version: '1.0.0',
66
+ kind: PackageKind.Blueprint,
67
+ dependencies: [{ name: 'Cratis.Blueprint.Default' }, { name: 'Cratis.Components' }],
68
+ components: Object.keys(componentsBlueprintComponents).map(name => name.slice(`${componentsBlueprintName}:`.length)),
69
+ layouts: [],
70
+ screenTemplates: componentsScreenTemplates.map(template => template.name),
71
+ dialogTemplates: componentsDialogTemplates.map(template => template.name),
72
+ themes: [],
73
+ },
74
+ components: componentsBlueprintComponents,
75
+ screenTemplates: componentsScreenTemplates,
76
+ dialogTemplates: componentsDialogTemplates,
77
+ screens: componentsGalleryScreens,
78
+ },
79
+ ];
80
+
81
+ /** Compatibility registry for callers that render individual gallery elements directly. */
82
+ export const componentsPreviewRegistry: ComponentRegistry = resolvePackageHost({
83
+ profile: componentsBlueprintProfile,
84
+ bundles: componentsPreviewBundles,
85
+ policy: { allowExecutableImports: false, allowNetworkAssets: false },
86
+ }).components;
29
87
 
30
88
  export interface GalleryScreenPreviewProps {
31
89
  /** The name of the gallery screen to boot. */
@@ -34,8 +92,8 @@ export interface GalleryScreenPreviewProps {
34
92
  /** Configuration to start from - a story pinning a layout mode, or a host restoring a session. */
35
93
  initialConfig?: Partial<LayoutConfigState>;
36
94
 
37
- /** The component registry to render against. Defaults to {@link componentsPreviewRegistry}. */
38
- registry?: ComponentRegistry;
95
+ /** The approved package set to render against. Defaults to {@link componentsPreviewBundles}. */
96
+ bundles?: ScenePackageBundle[];
39
97
  }
40
98
 
41
99
  /**
@@ -50,7 +108,7 @@ export interface GalleryScreenPreviewProps {
50
108
  * previewed is the default blueprint's shell. This package provides Arc-bound pages to put inside it, and
51
109
  * previewing them without the thing they were designed to sit in would prove the wrong thing.
52
110
  */
53
- export function GalleryScreenPreview({ screenName, initialConfig, registry = componentsPreviewRegistry }: GalleryScreenPreviewProps) {
111
+ export function GalleryScreenPreview({ screenName, initialConfig, bundles = componentsPreviewBundles }: GalleryScreenPreviewProps) {
54
112
  const element = useMemo(() => {
55
113
  const screen = componentsGalleryScreen(screenName);
56
114
  if (!screen) {
@@ -61,10 +119,18 @@ export function GalleryScreenPreview({ screenName, initialConfig, registry = com
61
119
  }, [screenName]);
62
120
 
63
121
  return (
64
- <LayoutConfigProvider initialConfig={initialConfig} storage={null}>
65
- <LayoutThemeProvider themes={defaultBlueprintThemes}>
66
- <SceneElementView element={element} registry={registry} resolveBinding={() => undefined} />
67
- </LayoutThemeProvider>
68
- </LayoutConfigProvider>
122
+ <PrimeReactProvider>
123
+ <LayoutConfigProvider initialConfig={initialConfig} storage={null}>
124
+ <LayoutThemeProvider themes={defaultBlueprintThemes}>
125
+ <PackageHostView
126
+ configuration={{
127
+ profile: componentsBlueprintProfile,
128
+ bundles,
129
+ policy: { allowExecutableImports: false, allowNetworkAssets: false },
130
+ }}
131
+ element={element} />
132
+ </LayoutThemeProvider>
133
+ </LayoutConfigProvider>
134
+ </PrimeReactProvider>
69
135
  );
70
136
  }
@@ -0,0 +1,19 @@
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
+
4
+ import { ScreenTemplate, TemplateScope } from '@cratis/scene.model';
5
+ import { BusinessGalleryCategory } from './BusinessGalleryCategory';
6
+ import { componentsPageTemplates } from '../templates';
7
+
8
+ /**
9
+ * Returns templates grouped by visible gallery category and filtered by scope metadata.
10
+ */
11
+ export function businessGallery(scope: TemplateScope, templates: ScreenTemplate[] = componentsPageTemplates): BusinessGalleryCategory[] {
12
+ const categories = new Map<string, ScreenTemplate[]>();
13
+ for (const template of templates.filter(template => template.metadata?.scopes?.includes(scope))) {
14
+ const category = template.metadata?.category ?? 'Business / Other';
15
+ categories.set(category, [...(categories.get(category) ?? []), template]);
16
+ }
17
+
18
+ return [...categories.entries()].map(([category, categoryTemplates]) => ({ category, templates: categoryTemplates }));
19
+ }
package/gallery/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  // Copyright (c) Cratis. All rights reserved.
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
+ export * from './BusinessGalleryCategory';
5
+ export * from './businessGallery';
4
6
  export * from './navigation';
5
7
  export * from './applicationChrome';
6
8
  export * from './screens';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/scene.blueprint.components",
3
- "version": "4.10.0",
3
+ "version": "4.12.0",
4
4
  "description": "A blueprint of Arc-bound screen and dialog templates: full pages built from Cratis Components composites, so a data list, a command form or a master-detail screen is a template rather than something you assemble.",
5
5
  "keywords": [
6
6
  "cratis",
@@ -52,19 +52,19 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@cratis/components": "^4.25.0",
55
- "@cratis/scene.blueprint.default": "4.10.0",
56
- "@cratis/scene.components": "4.10.0",
57
- "@cratis/scene.engine": "4.10.0",
58
- "@cratis/scene.model": "4.10.0",
59
- "@cratis/scene.react": "4.10.0"
55
+ "@cratis/scene.blueprint.default": "4.12.0",
56
+ "@cratis/scene.components": "4.12.0",
57
+ "@cratis/scene.engine": "4.12.0",
58
+ "@cratis/scene.model": "4.12.0",
59
+ "@cratis/scene.react": "4.12.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@cratis/components": "^4.25.0",
63
- "@cratis/scene.blueprint.default": "4.10.0",
64
- "@cratis/scene.components": "4.10.0",
65
- "@cratis/scene.engine": "4.10.0",
66
- "@cratis/scene.model": "4.10.0",
67
- "@cratis/scene.react": "4.10.0",
63
+ "@cratis/scene.blueprint.default": "4.12.0",
64
+ "@cratis/scene.components": "4.12.0",
65
+ "@cratis/scene.engine": "4.12.0",
66
+ "@cratis/scene.model": "4.12.0",
67
+ "@cratis/scene.react": "4.12.0",
68
68
  "@primereact/core": "11.2.0",
69
69
  "@primereact/headless": "11.2.0",
70
70
  "@storybook/addon-links": "^10.6.1",