@cratis/scene.blueprint.components 4.1.1 → 4.2.1

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 (67) hide show
  1. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +23 -22
  3. package/dist/esm/for_ArcPageHeader/when_rendering_a_gallery_screen.d.ts +0 -2
  4. package/dist/esm/for_ArcPageHeader/when_rendering_a_gallery_screen.d.ts.map +0 -1
  5. package/dist/esm/for_ArcPageHeader/when_rendering_a_gallery_screen.js +0 -58
  6. package/dist/esm/for_ArcPageHeader/when_rendering_a_gallery_screen.js.map +0 -1
  7. package/dist/esm/for_CompositeName/when_checking_the_names_against_the_packages_that_declare_them.d.ts +0 -2
  8. package/dist/esm/for_CompositeName/when_checking_the_names_against_the_packages_that_declare_them.d.ts.map +0 -1
  9. package/dist/esm/for_CompositeName/when_checking_the_names_against_the_packages_that_declare_them.js +0 -26
  10. package/dist/esm/for_CompositeName/when_checking_the_names_against_the_packages_that_declare_them.js.map +0 -1
  11. package/dist/esm/for_componentsBlueprint/when_resolving_its_dependencies.d.ts +0 -2
  12. package/dist/esm/for_componentsBlueprint/when_resolving_its_dependencies.d.ts.map +0 -1
  13. package/dist/esm/for_componentsBlueprint/when_resolving_its_dependencies.js +0 -65
  14. package/dist/esm/for_componentsBlueprint/when_resolving_its_dependencies.js.map +0 -1
  15. package/dist/esm/for_componentsBlueprint/when_validating_the_bundle.d.ts +0 -2
  16. package/dist/esm/for_componentsBlueprint/when_validating_the_bundle.d.ts.map +0 -1
  17. package/dist/esm/for_componentsBlueprint/when_validating_the_bundle.js +0 -41
  18. package/dist/esm/for_componentsBlueprint/when_validating_the_bundle.js.map +0 -1
  19. package/dist/esm/for_componentsGalleryScreens/when_checking_the_layouts_and_slots_they_fill.d.ts +0 -2
  20. package/dist/esm/for_componentsGalleryScreens/when_checking_the_layouts_and_slots_they_fill.d.ts.map +0 -1
  21. package/dist/esm/for_componentsGalleryScreens/when_checking_the_layouts_and_slots_they_fill.js +0 -38
  22. package/dist/esm/for_componentsGalleryScreens/when_checking_the_layouts_and_slots_they_fill.js.map +0 -1
  23. package/dist/esm/for_componentsScreenTemplates/when_checking_that_arrangements_reference_declared_slots.d.ts +0 -2
  24. package/dist/esm/for_componentsScreenTemplates/when_checking_that_arrangements_reference_declared_slots.d.ts.map +0 -1
  25. package/dist/esm/for_componentsScreenTemplates/when_checking_that_arrangements_reference_declared_slots.js +0 -47
  26. package/dist/esm/for_componentsScreenTemplates/when_checking_that_arrangements_reference_declared_slots.js.map +0 -1
  27. package/dist/esm/for_componentsScreenTemplates/when_following_the_nesting_chain.d.ts +0 -2
  28. package/dist/esm/for_componentsScreenTemplates/when_following_the_nesting_chain.d.ts.map +0 -1
  29. package/dist/esm/for_componentsScreenTemplates/when_following_the_nesting_chain.js +0 -56
  30. package/dist/esm/for_componentsScreenTemplates/when_following_the_nesting_chain.js.map +0 -1
  31. package/dist/esm/for_componentsScreenTemplates/when_placing_them_in_the_default_blueprint_layout.d.ts +0 -2
  32. package/dist/esm/for_componentsScreenTemplates/when_placing_them_in_the_default_blueprint_layout.d.ts.map +0 -1
  33. package/dist/esm/for_componentsScreenTemplates/when_placing_them_in_the_default_blueprint_layout.js +0 -31
  34. package/dist/esm/for_componentsScreenTemplates/when_placing_them_in_the_default_blueprint_layout.js.map +0 -1
  35. package/dist/esm/for_componentsScreenTemplates/when_resolving_the_component_names_they_reference.d.ts +0 -2
  36. package/dist/esm/for_componentsScreenTemplates/when_resolving_the_component_names_they_reference.d.ts.map +0 -1
  37. package/dist/esm/for_componentsScreenTemplates/when_resolving_the_component_names_they_reference.js +0 -54
  38. package/dist/esm/for_componentsScreenTemplates/when_resolving_the_component_names_they_reference.js.map +0 -1
  39. package/dist/esm/for_deriveArcHeading/when_no_binding_is_named.d.ts +0 -2
  40. package/dist/esm/for_deriveArcHeading/when_no_binding_is_named.d.ts.map +0 -1
  41. package/dist/esm/for_deriveArcHeading/when_no_binding_is_named.js +0 -27
  42. package/dist/esm/for_deriveArcHeading/when_no_binding_is_named.js.map +0 -1
  43. package/dist/esm/for_deriveArcHeading/when_the_binding_is_not_registered.d.ts +0 -2
  44. package/dist/esm/for_deriveArcHeading/when_the_binding_is_not_registered.d.ts.map +0 -1
  45. package/dist/esm/for_deriveArcHeading/when_the_binding_is_not_registered.js +0 -18
  46. package/dist/esm/for_deriveArcHeading/when_the_binding_is_not_registered.js.map +0 -1
  47. package/dist/esm/for_deriveArcHeading/when_the_binding_is_registered.d.ts +0 -2
  48. package/dist/esm/for_deriveArcHeading/when_the_binding_is_registered.d.ts.map +0 -1
  49. package/dist/esm/for_deriveArcHeading/when_the_binding_is_registered.js +0 -26
  50. package/dist/esm/for_deriveArcHeading/when_the_binding_is_registered.js.map +0 -1
  51. package/dist/esm/for_humanizeBindingName/when_reading_a_proxy_name.d.ts +0 -2
  52. package/dist/esm/for_humanizeBindingName/when_reading_a_proxy_name.d.ts.map +0 -1
  53. package/dist/esm/for_humanizeBindingName/when_reading_a_proxy_name.js +0 -25
  54. package/dist/esm/for_humanizeBindingName/when_reading_a_proxy_name.js.map +0 -1
  55. package/for_ArcPageHeader/when_rendering_a_gallery_screen.tsx +0 -86
  56. package/for_CompositeName/when_checking_the_names_against_the_packages_that_declare_them.ts +0 -41
  57. package/for_componentsBlueprint/when_resolving_its_dependencies.ts +0 -93
  58. package/for_componentsBlueprint/when_validating_the_bundle.ts +0 -55
  59. package/for_componentsGalleryScreens/when_checking_the_layouts_and_slots_they_fill.ts +0 -56
  60. package/for_componentsScreenTemplates/when_checking_that_arrangements_reference_declared_slots.ts +0 -66
  61. package/for_componentsScreenTemplates/when_following_the_nesting_chain.ts +0 -83
  62. package/for_componentsScreenTemplates/when_placing_them_in_the_default_blueprint_layout.ts +0 -51
  63. package/for_componentsScreenTemplates/when_resolving_the_component_names_they_reference.ts +0 -72
  64. package/for_deriveArcHeading/when_no_binding_is_named.ts +0 -42
  65. package/for_deriveArcHeading/when_the_binding_is_not_registered.ts +0 -25
  66. package/for_deriveArcHeading/when_the_binding_is_registered.ts +0 -35
  67. package/for_humanizeBindingName/when_reading_a_proxy_name.ts +0 -34
@@ -1,83 +0,0 @@
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 { isScreenTemplateResolutionValid, resolveScreenTemplates } from '@cratis/scene.engine';
5
- import { appShellLayout } from '@cratis/scene.blueprint.default';
6
- import { nestingChainTemplates } from '../templates';
7
-
8
- /**
9
- * The three-level chain, put through the real resolver rather than checked by walking slot lists.
10
- *
11
- * "It composes recursively" is the kind of claim that is true in a design document and wrong in the code,
12
- * and the way it goes wrong is specific: a chain that reuses one slot name at several levels reads
13
- * perfectly and resolves to nothing, because the resolver refuses to guess which of two containers a
14
- * template belongs to. Only running it proves the chain is really placeable.
15
- */
16
- describe('when following the nesting chain', () => {
17
- const resolution = resolveScreenTemplates(appShellLayout, nestingChainTemplates);
18
- const placementOf = (name: string) => resolution.placements.find(placement => placement.template === name);
19
-
20
- it('should be a valid resolution', () => {
21
- isScreenTemplateResolutionValid(resolution).should.be.true;
22
- });
23
-
24
- it('should place all three levels', () => {
25
- resolution.placements.should.have.lengthOf(3);
26
- });
27
-
28
- it('should leave nothing unplaced', () => {
29
- resolution.unplaced.should.be.empty;
30
- });
31
-
32
- describe('and it is the module level', () => {
33
- const placement = placementOf('DataModulePage')!;
34
-
35
- it('should sit directly inside the application layout', () => {
36
- placement.container.should.equal(appShellLayout.name);
37
- });
38
-
39
- it('should fill the content slot', () => {
40
- placement.slot.should.equal('content');
41
- });
42
-
43
- it('should be one level below the layout', () => {
44
- placement.depth.should.equal(1);
45
- });
46
- });
47
-
48
- describe('and it is the feature level', () => {
49
- const placement = placementOf('DataFeatureSection')!;
50
-
51
- it('should sit inside the module template', () => {
52
- placement.container.should.equal('DataModulePage');
53
- });
54
-
55
- it('should fill a slot the module template declares', () => {
56
- placement.slot.should.equal('body');
57
- });
58
-
59
- it('should be two levels below the layout', () => {
60
- placement.depth.should.equal(2);
61
- });
62
- });
63
-
64
- describe('and it is the slice level', () => {
65
- const placement = placementOf('CommandSliceSection')!;
66
-
67
- it('should sit inside the feature template', () => {
68
- placement.container.should.equal('DataFeatureSection');
69
- });
70
-
71
- it('should fill a slot the feature template declares', () => {
72
- placement.slot.should.equal('primary');
73
- });
74
-
75
- it('should be three levels below the layout', () => {
76
- placement.depth.should.equal(3);
77
- });
78
- });
79
-
80
- it('should order the placements shallowest first, so a caller can build the tree top down', () => {
81
- resolution.placements.map(placement => placement.depth).should.deep.equal([1, 2, 3]);
82
- });
83
- });
@@ -1,51 +0,0 @@
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 { resolveScreenTemplates } from '@cratis/scene.engine';
5
- import { appShellLayout, defaultBlueprint } from '@cratis/scene.blueprint.default';
6
- import { componentsPageTemplates } from '../templates';
7
-
8
- /**
9
- * The page templates are resolved against the default blueprint's layout *and its templates*, because that
10
- * is the situation an application is actually in: a profile that activates both blueprints has every one of
11
- * those templates in scope, and a `fitsSlot` that became ambiguous once they were is a `fitsSlot` that
12
- * works only in isolation.
13
- *
14
- * Only this package's templates are asserted on. The default blueprint's own nesting chain reuses `body` at
15
- * three levels, so it is reported unplaced in this combined scope - which is `resolveScreenTemplates`
16
- * behaving correctly, and not this package's result to claim or to fix.
17
- */
18
- describe('when placing them in the default blueprint layout', () => {
19
- const templates = [...(defaultBlueprint.screenTemplates ?? []), ...componentsPageTemplates];
20
- const resolution = resolveScreenTemplates(appShellLayout, templates);
21
- const ownNames = new Set(componentsPageTemplates.map(template => template.name));
22
- const ownPlacements = resolution.placements.filter(placement => ownNames.has(placement.template));
23
-
24
- it('should have templates to place', () => {
25
- componentsPageTemplates.should.not.be.empty;
26
- });
27
-
28
- it('should place every one of them', () => {
29
- ownPlacements.map(placement => placement.template).sort().should.deep.equal([...ownNames].sort());
30
- });
31
-
32
- it('should leave none of them unplaced, even with the other blueprint templates in scope', () => {
33
- resolution.unplaced.filter(unplaced => ownNames.has(unplaced.template)).should.be.empty;
34
- });
35
-
36
- it('should place every one directly inside the layout rather than inside another template', () => {
37
- ownPlacements.filter(placement => placement.container !== appShellLayout.name).should.be.empty;
38
- });
39
-
40
- it('should place every one at the first level below the layout', () => {
41
- ownPlacements.filter(placement => placement.depth !== 1).should.be.empty;
42
- });
43
-
44
- it('should place every one in the content slot, which is the only region a layout offers a screen', () => {
45
- ownPlacements.filter(placement => placement.slot !== 'content').should.be.empty;
46
- });
47
-
48
- it('should introduce no nesting cycle', () => {
49
- resolution.cycles.should.deep.equal([]);
50
- });
51
- });
@@ -1,72 +0,0 @@
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 { resolveComponentName } from '@cratis/scene.engine';
5
- import { composeScreenElement, defaultBlueprintName, distinctComponentNames } from '@cratis/scene.blueprint.default';
6
- import { cratisComponentsPackageManifest } from '@cratis/scene.components';
7
- import { ComponentName } from '../ComponentName';
8
- import { CompositeName } from '../CompositeName';
9
- import { componentsBlueprintCatalog, componentsBlueprintProfile, componentsGalleryScreens } from '../gallery';
10
- import { componentsBlueprintName } from '../packageName';
11
- import { componentsDialogTemplates } from '../templates';
12
-
13
- /**
14
- * Every name a template writes has to resolve against the profile, or it renders as a dashed red box in
15
- * the middle of an otherwise fine page with nothing pointing back at the template that wrote it. The
16
- * catalog is built from the real manifests of the packages this blueprint depends on, so a name renamed
17
- * upstream fails here rather than in an application.
18
- */
19
- describe('when resolving the component names they reference', () => {
20
- const fromScreens = distinctComponentNames(componentsGalleryScreens.map(composeScreenElement));
21
- const fromDialogs = distinctComponentNames(componentsDialogTemplates.flatMap(template => Object.values(template.content ?? {}).flat()));
22
- const names = [...new Set([...fromScreens, ...fromDialogs])].sort();
23
- const resolutions = names.map(name => ({ name, resolution: resolveComponentName(name, componentsBlueprintProfile, componentsBlueprintCatalog) }));
24
-
25
- it('should reference something', () => {
26
- names.should.not.be.empty;
27
- });
28
-
29
- it('should reference something from the dialog templates too', () => {
30
- fromDialogs.should.not.be.empty;
31
- });
32
-
33
- it('should resolve every referenced name against the profile', () => {
34
- resolutions
35
- .filter(entry => entry.resolution === undefined)
36
- .map(entry => entry.name)
37
- .should.be.empty;
38
- });
39
-
40
- it('should resolve its own page header to itself', () => {
41
- resolveComponentName(ComponentName.ArcPageHeader, componentsBlueprintProfile, componentsBlueprintCatalog)!.package.should.equal(componentsBlueprintName);
42
- });
43
-
44
- it('should reference every component it registers, so nothing is declared and then unused', () => {
45
- const referenced = new Set(names);
46
- Object.values(ComponentName)
47
- .filter(name => !referenced.has(name))
48
- .should.be.empty;
49
- });
50
-
51
- it('should resolve the shell components to the blueprint it layers on', () => {
52
- resolveComponentName('appShell', componentsBlueprintProfile, componentsBlueprintCatalog)!.package.should.equal(defaultBlueprintName);
53
- });
54
-
55
- it('should resolve the Arc-bound composites to the component library', () => {
56
- resolutions
57
- .filter(entry => (Object.values(CompositeName) as string[]).includes(entry.name))
58
- .filter(entry => entry.resolution?.package !== cratisComponentsPackageManifest.name)
59
- .map(entry => entry.name)
60
- .should.be.empty;
61
- });
62
-
63
- it('should resolve a name both libraries declare to the Arc-aware one, and record the other as shadowed', () => {
64
- const dataTable = resolveComponentName(CompositeName.DataTable, componentsBlueprintProfile, componentsBlueprintCatalog)!;
65
- dataTable.package.should.equal(cratisComponentsPackageManifest.name);
66
- dataTable.shadows.should.contain('PrimeReact');
67
- });
68
-
69
- it('should resolve the borrowed column to PrimeReact, since neither library declares one', () => {
70
- resolveComponentName('column', componentsBlueprintProfile, componentsBlueprintCatalog)!.package.should.equal('PrimeReact');
71
- });
72
- });
@@ -1,42 +0,0 @@
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 { BindingKind } from '@cratis/scene.components';
5
- import { deriveArcHeading } from '../header';
6
-
7
- /**
8
- * The third state, and the one that is easiest to conflate with the second. A template that names nothing
9
- * is not broken - the schema editor page genuinely has no query behind it - so this reads as a statement
10
- * rather than as a problem to fix.
11
- */
12
- describe('when no binding is named', () => {
13
- const heading = deriveArcHeading({ title: 'InvoiceRegistered' }, {}, BindingKind.Query);
14
-
15
- it('should use the title the template gave it', () => {
16
- heading.title.should.equal('InvoiceRegistered');
17
- });
18
-
19
- it('should build a trail of just the title when no section was given', () => {
20
- heading.trail.should.deep.equal(['InvoiceRegistered']);
21
- });
22
-
23
- it('should report that it is not bound', () => {
24
- heading.isBound.should.be.false;
25
- });
26
-
27
- it('should state the absence plainly rather than naming a binding nobody asked for', () => {
28
- heading.bindingLabel.should.equal('No binding');
29
- });
30
-
31
- it('should carry no binding name', () => {
32
- (heading.bindingName === undefined).should.be.true;
33
- });
34
-
35
- describe('and the template gave no title either', () => {
36
- const untitled = deriveArcHeading({}, {}, BindingKind.Query);
37
-
38
- it('should fall back to something readable rather than an empty heading', () => {
39
- untitled.title.should.equal('Untitled page');
40
- });
41
- });
42
- });
@@ -1,25 +0,0 @@
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 { BindingKind } from '@cratis/scene.components';
5
- import { deriveArcHeading } from '../header';
6
-
7
- describe('when the binding is not registered', () => {
8
- const heading = deriveArcHeading({ section: 'Billing' }, { name: 'RecordAdjustment' }, BindingKind.Command);
9
-
10
- it('should fall back to the binding name read as a sentence, so the page is legible before anyone writes a title', () => {
11
- heading.title.should.equal('Record adjustment');
12
- });
13
-
14
- it('should build the trail from the derived title', () => {
15
- heading.trail.should.deep.equal(['Billing', 'Record adjustment']);
16
- });
17
-
18
- it('should report that it is not bound', () => {
19
- heading.isBound.should.be.false;
20
- });
21
-
22
- it('should say which name a host has to register, which is the only actionable part', () => {
23
- heading.bindingLabel.should.equal('No command registered as RecordAdjustment');
24
- });
25
- });
@@ -1,35 +0,0 @@
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 { BindingKind } from '@cratis/scene.components';
5
- import { deriveArcHeading } from '../header';
6
-
7
- class AllInvoices {}
8
-
9
- describe('when the binding is registered', () => {
10
- const heading = deriveArcHeading({ title: 'Invoices', subtitle: 'Every invoice', section: 'Billing' }, { name: 'AllInvoices', target: AllInvoices }, BindingKind.Query);
11
-
12
- it('should use the title the template gave it', () => {
13
- heading.title.should.equal('Invoices');
14
- });
15
-
16
- it('should keep the subtitle', () => {
17
- heading.subtitle!.should.equal('Every invoice');
18
- });
19
-
20
- it('should build the trail from the section and the title, rather than a second literal', () => {
21
- heading.trail.should.deep.equal(['Billing', 'Invoices']);
22
- });
23
-
24
- it('should report that it is bound', () => {
25
- heading.isBound.should.be.true;
26
- });
27
-
28
- it('should say what it is bound to, naming the kind so a query is not mistaken for a command', () => {
29
- heading.bindingLabel.should.equal('Bound to query AllInvoices');
30
- });
31
-
32
- it('should keep the binding name for anything that wants to report it', () => {
33
- heading.bindingName!.should.equal('AllInvoices');
34
- });
35
- });
@@ -1,34 +0,0 @@
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 { humanizeBindingName } from '../header';
5
-
6
- describe('when reading a proxy name', () => {
7
- it('should read a two-word query name as a sentence', () => {
8
- humanizeBindingName('AllInvoices').should.equal('All invoices');
9
- });
10
-
11
- it('should read a command name as a sentence', () => {
12
- humanizeBindingName('RecordAdjustment').should.equal('Record adjustment');
13
- });
14
-
15
- it('should lower every word after the first', () => {
16
- humanizeBindingName('InvoicesInFlight').should.equal('Invoices in flight');
17
- });
18
-
19
- it('should leave a single word alone', () => {
20
- humanizeBindingName('Invoices').should.equal('Invoices');
21
- });
22
-
23
- it('should split a word boundary that follows a digit', () => {
24
- humanizeBindingName('Top10Customers').should.equal('Top10 customers');
25
- });
26
-
27
- it('should keep a run of capitals together rather than chopping it into initials', () => {
28
- humanizeBindingName('AllPIIRecords').should.equal('All PIIRecords');
29
- });
30
-
31
- it('should return an empty name unchanged rather than inventing a heading', () => {
32
- humanizeBindingName('').should.equal('');
33
- });
34
- });