@cratis/scene.react 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 (62) hide show
  1. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +11 -10
  3. package/NavBar/for_NavBar/when_rendering_navigation_contributions.tsx +0 -62
  4. package/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.ts +0 -53
  5. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.d.ts +0 -2
  6. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.d.ts.map +0 -1
  7. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.js +0 -53
  8. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.js.map +0 -1
  9. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.d.ts +0 -2
  10. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.d.ts.map +0 -1
  11. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.js +0 -45
  12. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.js.map +0 -1
  13. package/dist/esm/for_SceneElementView/when_rendering_a_tree.d.ts +0 -2
  14. package/dist/esm/for_SceneElementView/when_rendering_a_tree.d.ts.map +0 -1
  15. package/dist/esm/for_SceneElementView/when_rendering_a_tree.js +0 -44
  16. package/dist/esm/for_SceneElementView/when_rendering_a_tree.js.map +0 -1
  17. package/dist/esm/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.d.ts +0 -2
  18. package/dist/esm/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.d.ts.map +0 -1
  19. package/dist/esm/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.js +0 -46
  20. package/dist/esm/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.js.map +0 -1
  21. package/dist/esm/for_applyThemeTokens/when_switching_themes.d.ts +0 -2
  22. package/dist/esm/for_applyThemeTokens/when_switching_themes.d.ts.map +0 -1
  23. package/dist/esm/for_applyThemeTokens/when_switching_themes.js +0 -59
  24. package/dist/esm/for_applyThemeTokens/when_switching_themes.js.map +0 -1
  25. package/dist/esm/for_panelLayout/when_arranging_a_panel.d.ts +0 -2
  26. package/dist/esm/for_panelLayout/when_arranging_a_panel.d.ts.map +0 -1
  27. package/dist/esm/for_panelLayout/when_arranging_a_panel.js +0 -110
  28. package/dist/esm/for_panelLayout/when_arranging_a_panel.js.map +0 -1
  29. package/dist/esm/for_themeTokens/when_converting_a_token_name.d.ts +0 -2
  30. package/dist/esm/for_themeTokens/when_converting_a_token_name.d.ts.map +0 -1
  31. package/dist/esm/for_themeTokens/when_converting_a_token_name.js +0 -16
  32. package/dist/esm/for_themeTokens/when_converting_a_token_name.js.map +0 -1
  33. package/dist/esm/for_useInteractionHosts/when_a_document_asks_the_user_something.d.ts +0 -2
  34. package/dist/esm/for_useInteractionHosts/when_a_document_asks_the_user_something.d.ts.map +0 -1
  35. package/dist/esm/for_useInteractionHosts/when_a_document_asks_the_user_something.js +0 -73
  36. package/dist/esm/for_useInteractionHosts/when_a_document_asks_the_user_something.js.map +0 -1
  37. package/dist/esm/for_useInteractionHosts/when_the_host_cannot_do_what_was_asked.d.ts +0 -2
  38. package/dist/esm/for_useInteractionHosts/when_the_host_cannot_do_what_was_asked.d.ts.map +0 -1
  39. package/dist/esm/for_useInteractionHosts/when_the_host_cannot_do_what_was_asked.js +0 -43
  40. package/dist/esm/for_useInteractionHosts/when_the_host_cannot_do_what_was_asked.js.map +0 -1
  41. package/dist/esm/for_useInteractions/when_clicking_an_element_that_executes_a_command.d.ts +0 -2
  42. package/dist/esm/for_useInteractions/when_clicking_an_element_that_executes_a_command.d.ts.map +0 -1
  43. package/dist/esm/for_useInteractions/when_clicking_an_element_that_executes_a_command.js +0 -94
  44. package/dist/esm/for_useInteractions/when_clicking_an_element_that_executes_a_command.js.map +0 -1
  45. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.d.ts +0 -2
  46. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.d.ts.map +0 -1
  47. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.js +0 -59
  48. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.js.map +0 -1
  49. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.d.ts +0 -2
  50. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.d.ts.map +0 -1
  51. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.js +0 -8
  52. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.js.map +0 -1
  53. package/for_SceneElementView/when_rendering_a_tree.tsx +0 -53
  54. package/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.tsx +0 -60
  55. package/for_applyThemeTokens/when_switching_themes.ts +0 -74
  56. package/for_panelLayout/when_arranging_a_panel.ts +0 -135
  57. package/for_themeTokens/when_converting_a_token_name.ts +0 -22
  58. package/for_useInteractionHosts/when_a_document_asks_the_user_something.tsx +0 -106
  59. package/for_useInteractionHosts/when_the_host_cannot_do_what_was_asked.tsx +0 -66
  60. package/for_useInteractions/when_clicking_an_element_that_executes_a_command.tsx +0 -141
  61. package/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.ts +0 -72
  62. package/for_validatePackageBundle/when_the_bundle_matches_its_manifest.ts +0 -12
@@ -1,16 +0,0 @@
1
- import { themeTokenProperty } from '../index';
2
- describe('when converting a token name', () => {
3
- it('should prefix a single-segment name', () => {
4
- themeTokenProperty('primary').should.equal('--scene-primary');
5
- });
6
- it('should join dotted segments with dashes', () => {
7
- themeTokenProperty('primary.color').should.equal('--scene-primary-color');
8
- });
9
- it('should split camelCase within a segment', () => {
10
- themeTokenProperty('surface.borderColor').should.equal('--scene-surface-border-color');
11
- });
12
- it('should handle a segment with a digit boundary', () => {
13
- themeTokenProperty('surface.level2Background').should.equal('--scene-surface-level2-background');
14
- });
15
- });
16
- //# sourceMappingURL=when_converting_a_token_name.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_converting_a_token_name.js","sourceRoot":"","sources":["../../../for_themeTokens/when_converting_a_token_name.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC3C,kBAAkB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,kBAAkB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,kBAAkB,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACrD,kBAAkB,CAAC,0BAA0B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACrG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=when_a_document_asks_the_user_something.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_a_document_asks_the_user_something.d.ts","sourceRoot":"","sources":["../../../for_useInteractionHosts/when_a_document_asks_the_user_something.tsx"],"names":[],"mappings":""}
@@ -1,73 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { render, screen, within } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import { useMemo } from 'react';
5
- import { InteractionActionKind, InteractionTriggerKind, NotificationLevel } from '@cratis/scene.model';
6
- import { InteractionScope, createBrowserDispatcher, useInteractionHosts, useInteractions } from '../interactions';
7
- const executed = [];
8
- const confirmThenExecute = {
9
- name: 'CancelInvoice',
10
- bindings: [
11
- {
12
- trigger: { kind: InteractionTriggerKind.Click },
13
- actions: [
14
- { kind: InteractionActionKind.Confirm, message: { text: 'Cancel this invoice?' } },
15
- { kind: InteractionActionKind.ExecuteCommand, command: 'CancelInvoice' },
16
- { kind: InteractionActionKind.Notify, level: NotificationLevel.Info, message: { text: 'Invoice cancelled' } },
17
- ],
18
- },
19
- ],
20
- };
21
- function Button({ behaviors }) {
22
- const handlers = useInteractions('element', behaviors);
23
- return _jsx("button", { type: "button", ...handlers, children: "Cancel" });
24
- }
25
- function Application({ behaviors }) {
26
- const { host, surfaces } = useInteractionHosts();
27
- const dispatcher = useMemo(() => createBrowserDispatcher({
28
- ...host,
29
- executeCommand: async (command) => {
30
- executed.push(command);
31
- return { isSuccess: true };
32
- },
33
- }), [host]);
34
- return (_jsxs(InteractionScope, { dispatcher: dispatcher, attachments: [], children: [_jsx(Button, { behaviors: behaviors }), surfaces] }));
35
- }
36
- describe('when a document asks the user something', () => {
37
- beforeEach(() => { executed.length = 0; });
38
- it('should ask in the page rather than in a browser prompt', async () => {
39
- render(_jsx(Application, { behaviors: [confirmThenExecute] }));
40
- await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
41
- screen.getByRole('alertdialog').getAttribute('aria-label').should.equal('Cancel this invoice?');
42
- });
43
- it('should not run what follows until the question is answered', async () => {
44
- render(_jsx(Application, { behaviors: [confirmThenExecute] }));
45
- await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
46
- executed.should.have.lengthOf(0);
47
- });
48
- it('should run what follows when the answer is yes', async () => {
49
- render(_jsx(Application, { behaviors: [confirmThenExecute] }));
50
- await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
51
- await userEvent.click(screen.getByRole('button', { name: 'OK' }));
52
- executed.should.eql(['CancelInvoice']);
53
- });
54
- it('should abandon the sequence when the answer is no', async () => {
55
- render(_jsx(Application, { behaviors: [confirmThenExecute] }));
56
- await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
57
- await userEvent.click(within(screen.getByRole('alertdialog')).getByRole('button', { name: 'Cancel' }));
58
- executed.should.have.lengthOf(0);
59
- });
60
- it('should take the question down once it is answered', async () => {
61
- render(_jsx(Application, { behaviors: [confirmThenExecute] }));
62
- await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
63
- await userEvent.click(screen.getByRole('button', { name: 'OK' }));
64
- (screen.queryByRole('alertdialog') === null).should.equal(true);
65
- });
66
- it('should show what the document said after the command ran', async () => {
67
- render(_jsx(Application, { behaviors: [confirmThenExecute] }));
68
- await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
69
- await userEvent.click(screen.getByRole('button', { name: 'OK' }));
70
- screen.getByText('Invoice cancelled').textContent.should.equal('Invoice cancelled');
71
- });
72
- });
73
- //# sourceMappingURL=when_a_document_asks_the_user_something.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_a_document_asks_the_user_something.js","sourceRoot":"","sources":["../../../for_useInteractionHosts/when_a_document_asks_the_user_something.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAY,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElH,MAAM,QAAQ,GAAa,EAAE,CAAC;AAE9B,MAAM,kBAAk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C,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,CAAC,KAAC,WAAW,IAAC,SAAS,EAAE,CAAC,kBAAkB,CAAC,GAAI,CAAC,CAAC;QAEzD,MAAM,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QACtE,MAAM,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAElE,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,WAAY,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=when_the_host_cannot_do_what_was_asked.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_the_host_cannot_do_what_was_asked.d.ts","sourceRoot":"","sources":["../../../for_useInteractionHosts/when_the_host_cannot_do_what_was_asked.tsx"],"names":[],"mappings":""}
@@ -1,43 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { render, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import { useMemo } from 'react';
5
- import { InteractionActionKind, InteractionTriggerKind } from '@cratis/scene.model';
6
- import { InteractionScope, createBrowserDispatcher, useInteractionHosts, useInteractions } from '../interactions';
7
- const navigateSomewhere = {
8
- name: 'GoToInvoice',
9
- bindings: [
10
- {
11
- trigger: { kind: InteractionTriggerKind.Click },
12
- actions: [{ kind: InteractionActionKind.Navigate, screen: 'InvoiceDetails' }],
13
- },
14
- ],
15
- };
16
- function Button() {
17
- const handlers = useInteractions('element', [navigateSomewhere]);
18
- return _jsx("button", { type: "button", ...handlers, children: "Open" });
19
- }
20
- function Application() {
21
- const { host, surfaces } = useInteractionHosts();
22
- const dispatcher = useMemo(() => createBrowserDispatcher(host), [host]);
23
- return (_jsxs(InteractionScope, { dispatcher: dispatcher, attachments: [], children: [_jsx(Button, {}), surfaces] }));
24
- }
25
- describe('when the host cannot do what was asked', () => {
26
- it('should say so on the screen rather than do nothing', async () => {
27
- render(_jsx(Application, {}));
28
- await userEvent.click(screen.getByRole('button', { name: 'Open' }));
29
- screen.getByText('navigate to InvoiceDetails').textContent.should.equal('navigate to InvoiceDetails');
30
- });
31
- it('should report the same action once however often it is asked for', async () => {
32
- render(_jsx(Application, {}));
33
- await userEvent.click(screen.getByRole('button', { name: 'Open' }));
34
- await userEvent.click(screen.getByRole('button', { name: 'Open' }));
35
- await userEvent.click(screen.getByRole('button', { name: 'Open' }));
36
- screen.getAllByText('navigate to InvoiceDetails').should.have.lengthOf(1);
37
- });
38
- it('should say nothing when nothing has failed', () => {
39
- render(_jsx(Application, {}));
40
- (screen.queryByText(/cannot do what the document asked/) === null).should.equal(true);
41
- });
42
- });
43
- //# sourceMappingURL=when_the_host_cannot_do_what_was_asked.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_the_host_cannot_do_what_was_asked.js","sourceRoot":"","sources":["../../../for_useInteractionHosts/when_the_host_cannot_do_what_was_asked.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAY,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElH,MAAM,iBAAiB,GAAa;IAChC,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE;QACN;YACI,OA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K,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACpE,MAAM,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACpE,MAAM,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAEpE,MAAM,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QAClD,MAAM,CAAC,KAAC,WAAW,KAAG,CAAC,CAAC;QAExB,CAAC,MAAM,CAAC,WAAW,CAAC,mCAAmC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=when_clicking_an_element_that_executes_a_command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_clicking_an_element_that_executes_a_command.d.ts","sourceRoot":"","sources":["../../../for_useInteractions/when_clicking_an_element_that_executes_a_command.tsx"],"names":[],"mappings":""}
@@ -1,94 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import { InteractionActionKind, InteractionTriggerKind, NotificationLevel } from '@cratis/scene.model';
5
- import { InteractionScope, useInteractions } from '../interactions';
6
- const calls = [];
7
- const dispatcher = {
8
- async executeCommand(command, args) {
9
- calls.push(`executeCommand:${command}:${JSON.stringify(args)}`);
10
- return { isSuccess: true };
11
- },
12
- navigate: (screenName) => { calls.push(`navigate:${screenName}`); },
13
- navigateBack: () => { calls.push('navigateBack'); },
14
- openDialog: async () => { calls.push('openDialog'); return { isConfirmed: true }; },
15
- closeDialog: () => { calls.push('closeDialog'); },
16
- refreshQuery: async (query) => { calls.push(`refreshQuery:${query}`); },
17
- setState: (target) => { calls.push(`setState:${target}`); },
18
- notify: (level, message) => { calls.push(`notify:${level}:${message}`); },
19
- confirm: async () => { calls.push('confirm'); return true; },
20
- raise: async (trigger) => { calls.push(`raise:${trigger}`); },
21
- };
22
- const context = { resolve: binding => `<${binding.path}>` };
23
- const cancelOnClick = {
24
- name: 'CancelInvoice',
25
- bindings: [
26
- {
27
- trigger: { kind: InteractionTriggerKind.Click },
28
- actions: [
29
- {
30
- kind: InteractionActionKind.ExecuteCommand,
31
- command: 'CancelInvoice',
32
- arguments: [{ name: 'invoiceId', value: { path: 'item.invoiceId' } }],
33
- onSuccess: [{ kind: InteractionActionKind.RefreshQuery, query: 'Invoices' }],
34
- },
35
- ],
36
- },
37
- ],
38
- };
39
- function Button({ behaviors }) {
40
- const handlers = useInteractions('element', behaviors);
41
- return _jsx("button", { type: "button", ...handlers, children: "Cancel" });
42
- }
43
- function renderInScope(behaviors) {
44
- return render(_jsx(InteractionScope, { dispatcher: dispatcher, context: context, attachments: [], children: _jsx(Button, { behaviors: behaviors }) }));
45
- }
46
- describe('when clicking an element that executes a command', () => {
47
- beforeEach(() => { calls.length = 0; });
48
- it('should execute the command the document declared', async () => {
49
- renderInScope([cancelOnClick]);
50
- await userEvent.click(screen.getByRole('button'));
51
- calls.should.eql(['executeCommand:CancelInvoice:{"invoiceId":"<item.invoiceId>"}', 'refreshQuery:Invoices']);
52
- });
53
- it('should not make an element interactive when nothing is attached', async () => {
54
- renderInScope();
55
- await userEvent.click(screen.getByRole('button'));
56
- calls.should.have.lengthOf(0);
57
- });
58
- it('should attach no handler for a trigger the document does not use', async () => {
59
- renderInScope([cancelOnClick]);
60
- await userEvent.dblClick(screen.getByRole('button'));
61
- calls.filter(call => call.startsWith('executeCommand')).should.have.lengthOf(2);
62
- });
63
- it('should run a behavior attached further out as well as its own', async () => {
64
- render(_jsx(InteractionScope, { dispatcher: dispatcher, context: context, attachments: [{
65
- level: 'module',
66
- behaviors: [{
67
- name: 'ModuleWide',
68
- bindings: [{
69
- trigger: { kind: InteractionTriggerKind.Click },
70
- actions: [{ kind: InteractionActionKind.Notify, level: NotificationLevel.Info, message: { text: 'from the module' } }],
71
- }],
72
- }],
73
- }], children: _jsx(Button, { behaviors: [cancelOnClick] }) }));
74
- await userEvent.click(screen.getByRole('button'));
75
- calls.should.eql([
76
- 'notify:Info:from the module',
77
- 'executeCommand:CancelInvoice:{"invoiceId":"<item.invoiceId>"}',
78
- 'refreshQuery:Invoices',
79
- ]);
80
- });
81
- it('should not run a binding whose guard is false', async () => {
82
- render(_jsx(InteractionScope, { dispatcher: dispatcher, context: { resolve: () => false }, attachments: [], children: _jsx(Button, { behaviors: [{
83
- name: 'Guarded',
84
- bindings: [{
85
- trigger: { kind: InteractionTriggerKind.Click },
86
- condition: { path: 'item.canCancel' },
87
- actions: [{ kind: InteractionActionKind.ExecuteCommand, command: 'CancelInvoice' }],
88
- }],
89
- }] }) }));
90
- await userEvent.click(screen.getByRole('button'));
91
- calls.should.have.lengthOf(0);
92
- });
93
- });
94
- //# sourceMappingURL=when_clicking_an_element_that_executes_a_command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_clicking_an_element_that_executes_a_command.js","sourceRoot":"","sources":["../../../for_useInteractions/when_clicking_an_element_that_executes_a_command.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,OAAO,EAAY,qBAAqB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE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AC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=when_the_bundle_and_manifest_disagree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_the_bundle_and_manifest_disagree.d.ts","sourceRoot":"","sources":["../../../for_validatePackageBundle/when_the_bundle_and_manifest_disagree.ts"],"names":[],"mappings":""}
@@ -1,59 +0,0 @@
1
- import { PackageKind } from '@cratis/scene.model';
2
- import { componentRegistryKey, validatePackageBundle } from '../index';
3
- import { CoreText } from '../core';
4
- function manifestFor(components, layouts = [], themes = [], screenTemplates = []) {
5
- return {
6
- name: 'Test',
7
- version: '1.0.0',
8
- kind: PackageKind.ComponentLibrary,
9
- dependencies: [],
10
- components,
11
- layouts,
12
- screenTemplates,
13
- dialogTemplates: [],
14
- themes,
15
- };
16
- }
17
- describe('when the bundle and manifest disagree', () => {
18
- const declaredButNotRegistered = validatePackageBundle({
19
- manifest: manifestFor(['text', 'missing']),
20
- components: { [componentRegistryKey('Test', 'text')]: CoreText },
21
- });
22
- const registeredButNotDeclared = validatePackageBundle({
23
- manifest: manifestFor([]),
24
- components: { [componentRegistryKey('Test', 'text')]: CoreText },
25
- });
26
- const layoutDeclaredButNotProvided = validatePackageBundle({
27
- manifest: manifestFor([], ['AppShell']),
28
- components: {},
29
- });
30
- const screenTemplateDeclaredButNotProvided = validatePackageBundle({
31
- manifest: manifestFor([], [], [], ['ModuleWorkspace']),
32
- components: {},
33
- });
34
- const themeDeclaredButNotProvided = validatePackageBundle({
35
- manifest: manifestFor([], [], ['Midnight']),
36
- components: {},
37
- });
38
- it('should report a component the manifest declares without an implementation', () => {
39
- declaredButNotRegistered.should.have.lengthOf(1);
40
- declaredButNotRegistered[0].should.contain("'missing'");
41
- });
42
- it('should report a component registered without being declared', () => {
43
- registeredButNotDeclared.should.have.lengthOf(1);
44
- registeredButNotDeclared[0].should.contain('Test:text');
45
- });
46
- it('should report a layout the manifest declares without a definition', () => {
47
- layoutDeclaredButNotProvided.should.have.lengthOf(1);
48
- layoutDeclaredButNotProvided[0].should.contain("'AppShell'");
49
- });
50
- it('should report a screen template the manifest declares without a definition', () => {
51
- screenTemplateDeclaredButNotProvided.should.have.lengthOf(1);
52
- screenTemplateDeclaredButNotProvided[0].should.contain("'ModuleWorkspace'");
53
- });
54
- it('should report a theme the manifest declares without a definition', () => {
55
- themeDeclaredButNotProvided.should.have.lengthOf(1);
56
- themeDeclaredButNotProvided[0].should.contain("'Midnight'");
57
- });
58
- });
59
- //# sourceMappingURL=when_the_bundle_and_manifest_disagree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_the_bundle_and_manifest_disagree.js","sourceRoot":"","sources":["../../../for_validatePackageBundle/when_the_bundle_and_manifest_disagree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAsB,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,SAAS,WAAW,CAAC,UAAoB,EAAE,OAAO,GAAa,EAAE,EAAE,MAAM,GAAa,EAAE,EAAE,eAAe,GAAa,EAAE;IACpH,OAAO;QACH,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,WAAW,CAAC,gBAAgB;QAClC,YAAY,EAAE,EAAE;QAChB,UAAU;QACV,OAAO;QACP,eAAe;QACf,eAAe,EAAE,EAAE;QACnB,MAAM;KACT,CAAC;AACN,CAAC;AAED,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;IACnD,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;QACnD,QAAQ,EAAE,WAAW,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC1C,UAAU,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAA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mE,EAAE,GAAG,EAAE;QACzE,4BAA4B,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACrD,4BAA4B,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4EAA4E,EAAE,GAAG,EAAE;QAClF,oCAAoC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC7D,oCAAoC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QACxE,2BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACpD,2BAA2B,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=when_the_bundle_matches_its_manifest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_the_bundle_matches_its_manifest.d.ts","sourceRoot":"","sources":["../../../for_validatePackageBundle/when_the_bundle_matches_its_manifest.ts"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- import { corePackage, validatePackageBundle } from '../index';
2
- describe('when the bundle matches its manifest', () => {
3
- const problems = validatePackageBundle(corePackage);
4
- it('should report no problems', () => {
5
- problems.should.be.empty;
6
- });
7
- });
8
- //# sourceMappingURL=when_the_bundle_matches_its_manifest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when_the_bundle_matches_its_manifest.js","sourceRoot":"","sources":["../../../for_validatePackageBundle/when_the_bundle_matches_its_manifest.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAE9D,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IAClD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAEpD,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IAC7B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,53 +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 { expect } from 'chai';
5
- import { render, screen } from '@testing-library/react';
6
- import { Control, ExternalComponent, HorizontalAlignment, VerticalAlignment, Visibility } from '@cratis/scene.model';
7
- import { SceneElementView } from '../SceneElementView';
8
- import { coreComponents } from '../core';
9
-
10
- function control(id: string): Control {
11
- return {
12
- id,
13
- name: id,
14
- properties: {},
15
- visibility: Visibility.Visible,
16
- isEnabled: true,
17
- opacity: 1,
18
- size: {},
19
- zIndex: 0,
20
- minimumSize: {},
21
- maximumSize: {},
22
- margin: { left: 0, top: 0, right: 0, bottom: 0 },
23
- horizontalAlignment: HorizontalAlignment.Stretch,
24
- verticalAlignment: VerticalAlignment.Stretch,
25
- borderThickness: { left: 0, top: 0, right: 0, bottom: 0 },
26
- padding: { left: 0, top: 0, right: 0, bottom: 0 },
27
- tabIndex: 0,
28
- };
29
- }
30
-
31
- describe('when rendering a tree', () => {
32
- describe('and every component resolves', () => {
33
- const text: ExternalComponent = { ...control('greeting'), componentName: 'core:text', properties: { text: 'Hello Scene' }, slots: {} };
34
- const card: ExternalComponent = { ...control('card'), componentName: 'core:card', slots: { content: [text] } };
35
-
36
- beforeEach(() => {
37
- render(<SceneElementView element={card} registry={coreComponents} resolveBinding={() => undefined} />);
38
- });
39
-
40
- it('should render the nested core:text content', () => expect(screen.getByText('Hello Scene')).to.exist);
41
- });
42
-
43
- describe('and a component does not resolve', () => {
44
- const missing: ExternalComponent = { ...control('missing'), componentName: 'vendor:fancy-widget', slots: {} };
45
-
46
- beforeEach(() => {
47
- render(<SceneElementView element={missing} registry={coreComponents} resolveBinding={() => undefined} />);
48
- });
49
-
50
- it('should render a visible unresolved-component placeholder', () =>
51
- expect(screen.getByText('Unresolved component: vendor:fancy-widget')).to.exist);
52
- });
53
- });
@@ -1,60 +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 { expect } from 'chai';
5
- import { fireEvent, render, screen } from '@testing-library/react';
6
- import { Control, ExternalComponent, HorizontalAlignment, VerticalAlignment, Visibility } from '@cratis/scene.model';
7
- import { SceneElementView } from '../SceneElementView';
8
- import { coreComponents } from '../core';
9
-
10
- function control(id: string): Control {
11
- return {
12
- id,
13
- name: id,
14
- properties: {},
15
- visibility: Visibility.Visible,
16
- isEnabled: true,
17
- opacity: 1,
18
- size: {},
19
- zIndex: 0,
20
- minimumSize: {},
21
- maximumSize: {},
22
- margin: { left: 0, top: 0, right: 0, bottom: 0 },
23
- horizontalAlignment: HorizontalAlignment.Stretch,
24
- verticalAlignment: VerticalAlignment.Stretch,
25
- borderThickness: { left: 0, top: 0, right: 0, bottom: 0 },
26
- padding: { left: 0, top: 0, right: 0, bottom: 0 },
27
- tabIndex: 0,
28
- };
29
- }
30
-
31
- const component = (
32
- id: string,
33
- componentName: string,
34
- properties: Record<string, unknown> = {},
35
- slots: Record<string, ExternalComponent[]> = {},
36
- ): ExternalComponent => ({ ...control(id), componentName, properties, slots });
37
-
38
- describe('when rendering a translated Screenplay screen', () => {
39
- const title = component('title', 'core:title', { text: 'Invoices' });
40
- const action = component('create', 'core:action', { command: 'CreateInvoice', label: 'Create invoice' });
41
- const section = component('section', 'core:section', { name: 'Open invoices' }, { content: [title, action] });
42
-
43
- beforeEach(() => {
44
- render(<SceneElementView element={section} registry={coreComponents} resolveBinding={() => undefined} />);
45
- });
46
-
47
- it('should render the section heading', () => expect(screen.getByRole('heading', { name: 'Open invoices' })).to.exist);
48
- it('should render the translated title', () => expect(screen.getByRole('heading', { name: 'Invoices' })).to.exist);
49
- it('should render the modeled action', () => expect(screen.getByRole('button', { name: 'Create invoice' })).to.exist);
50
-
51
- it('should announce the modeled command to the host', () => {
52
- let command = '';
53
- const listener = (event: Event) => { command = (event as CustomEvent).detail.command; };
54
- globalThis.addEventListener('cratis.scene.command', listener, { once: true });
55
-
56
- fireEvent.click(screen.getByRole('button', { name: 'Create invoice' }));
57
-
58
- command.should.equal('CreateInvoice');
59
- });
60
- });
@@ -1,74 +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 { JSDOM } from 'jsdom';
5
- import { Theme } from '@cratis/scene.model';
6
- import { applyThemeTokens } from '../index';
7
-
8
- const light: Theme = {
9
- name: 'Daylight',
10
- compatibleWith: ['core'],
11
- tokens: { 'primary.color': '#2563eb', 'surface.background': '#ffffff' },
12
- };
13
-
14
- const dark: Theme = {
15
- name: 'Midnight',
16
- compatibleWith: ['core'],
17
- isDark: true,
18
- tokens: { 'primary.color': '#60a5fa' },
19
- };
20
-
21
- describe('when switching themes', () => {
22
- const dom = new JSDOM('<div id="root"></div>');
23
- const element = dom.window.document.getElementById('root') as unknown as HTMLElement;
24
-
25
- applyThemeTokens(element, light);
26
- const afterLight = {
27
- primary: element.style.getPropertyValue('--scene-primary-color'),
28
- surface: element.style.getPropertyValue('--scene-surface-background'),
29
- theme: element.getAttribute('data-scene-theme'),
30
- scheme: element.getAttribute('data-scene-color-scheme'),
31
- };
32
-
33
- applyThemeTokens(element, dark, light);
34
- const afterDark = {
35
- primary: element.style.getPropertyValue('--scene-primary-color'),
36
- surface: element.style.getPropertyValue('--scene-surface-background'),
37
- theme: element.getAttribute('data-scene-theme'),
38
- scheme: element.getAttribute('data-scene-color-scheme'),
39
- };
40
-
41
- applyThemeTokens(element, undefined, dark);
42
- const afterClearing = {
43
- primary: element.style.getPropertyValue('--scene-primary-color'),
44
- theme: element.getAttribute('data-scene-theme'),
45
- };
46
-
47
- it('should write the first theme tokens as custom properties', () => {
48
- afterLight.primary.should.equal('#2563eb');
49
- afterLight.surface.should.equal('#ffffff');
50
- });
51
-
52
- it('should mark the element with the first theme name and scheme', () => {
53
- afterLight.theme!.should.equal('Daylight');
54
- afterLight.scheme!.should.equal('light');
55
- });
56
-
57
- it('should overwrite a token the next theme also defines', () => {
58
- afterDark.primary.should.equal('#60a5fa');
59
- });
60
-
61
- it('should remove a token the next theme does not define, rather than leaving it stale', () => {
62
- afterDark.surface.should.equal('');
63
- });
64
-
65
- it('should mark the element as dark for a dark theme', () => {
66
- afterDark.theme!.should.equal('Midnight');
67
- afterDark.scheme!.should.equal('dark');
68
- });
69
-
70
- it('should clear every token and marker when the theme is removed', () => {
71
- afterClearing.primary.should.equal('');
72
- (afterClearing.theme === null).should.be.true;
73
- });
74
- });