@cratis/scene.components 4.15.0 → 4.17.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 (62) hide show
  1. package/cratisComponentsDescriptors.ts +16 -0
  2. package/cratisComponentsPackage.ts +9 -125
  3. package/cratisComponentsPackageManifest.ts +106 -0
  4. package/cratisComponentsRuntimePackage.ts +22 -0
  5. package/designTime/cratisComponentsDesignTime.ts +22 -0
  6. package/dist/cjs/cratisComponentsDescriptors.js +68 -1
  7. package/dist/cjs/cratisComponentsDescriptors.js.map +1 -1
  8. package/dist/cjs/cratisComponentsPackage.js +10 -144
  9. package/dist/cjs/cratisComponentsPackage.js.map +1 -1
  10. package/dist/cjs/cratisComponentsPackageManifest.js +126 -0
  11. package/dist/cjs/cratisComponentsPackageManifest.js.map +1 -0
  12. package/dist/cjs/cratisComponentsRuntimePackage.js +24 -0
  13. package/dist/cjs/cratisComponentsRuntimePackage.js.map +1 -0
  14. package/dist/cjs/designTime/cratisComponentsDesignTime.js +24 -0
  15. package/dist/cjs/designTime/cratisComponentsDesignTime.js.map +1 -0
  16. package/dist/cjs/forms/generateCommandFieldsAction.js +10 -1
  17. package/dist/cjs/forms/generateCommandFieldsAction.js.map +1 -1
  18. package/dist/cjs/index.js +6 -1
  19. package/dist/cjs/index.js.map +1 -1
  20. package/dist/cjs/runtime.js +15 -0
  21. package/dist/cjs/runtime.js.map +1 -0
  22. package/dist/cjs/toolbar/SceneToolbarButton.js +34 -2
  23. package/dist/cjs/toolbar/SceneToolbarButton.js.map +1 -1
  24. package/dist/esm/cratisComponentsDescriptors.d.ts.map +1 -1
  25. package/dist/esm/cratisComponentsDescriptors.js +68 -1
  26. package/dist/esm/cratisComponentsDescriptors.js.map +1 -1
  27. package/dist/esm/cratisComponentsPackage.d.ts +1 -2
  28. package/dist/esm/cratisComponentsPackage.d.ts.map +1 -1
  29. package/dist/esm/cratisComponentsPackage.js +10 -144
  30. package/dist/esm/cratisComponentsPackage.js.map +1 -1
  31. package/dist/esm/cratisComponentsPackageManifest.d.ts +3 -0
  32. package/dist/esm/cratisComponentsPackageManifest.d.ts.map +1 -0
  33. package/dist/esm/cratisComponentsPackageManifest.js +124 -0
  34. package/dist/esm/cratisComponentsPackageManifest.js.map +1 -0
  35. package/dist/esm/cratisComponentsRuntimePackage.d.ts +3 -0
  36. package/dist/esm/cratisComponentsRuntimePackage.d.ts.map +1 -0
  37. package/dist/esm/cratisComponentsRuntimePackage.js +22 -0
  38. package/dist/esm/cratisComponentsRuntimePackage.js.map +1 -0
  39. package/dist/esm/designTime/cratisComponentsDesignTime.d.ts +3 -0
  40. package/dist/esm/designTime/cratisComponentsDesignTime.d.ts.map +1 -0
  41. package/dist/esm/designTime/cratisComponentsDesignTime.js +22 -0
  42. package/dist/esm/designTime/cratisComponentsDesignTime.js.map +1 -0
  43. package/dist/esm/forms/generateCommandFieldsAction.js +10 -1
  44. package/dist/esm/forms/generateCommandFieldsAction.js.map +1 -1
  45. package/dist/esm/index.d.ts +2 -0
  46. package/dist/esm/index.d.ts.map +1 -1
  47. package/dist/esm/index.js +4 -1
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/esm/runtime.d.ts +5 -0
  50. package/dist/esm/runtime.d.ts.map +1 -0
  51. package/dist/esm/runtime.js +5 -0
  52. package/dist/esm/runtime.js.map +1 -0
  53. package/dist/esm/toolbar/SceneToolbarButton.d.ts +1 -1
  54. package/dist/esm/toolbar/SceneToolbarButton.d.ts.map +1 -1
  55. package/dist/esm/toolbar/SceneToolbarButton.js +34 -2
  56. package/dist/esm/toolbar/SceneToolbarButton.js.map +1 -1
  57. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  58. package/forms/generateCommandFieldsAction.ts +5 -1
  59. package/index.ts +2 -0
  60. package/package.json +12 -7
  61. package/runtime.ts +9 -0
  62. package/toolbar/SceneToolbarButton.tsx +24 -2
@@ -13,16 +13,20 @@ export const generateCommandFieldsAction: DesignTimeAction = {
13
13
  description: 'Creates a deterministic editable field layout from the selected command metadata.',
14
14
  },
15
15
  isVisible: context => context.element.componentName.endsWith(':commandForm'),
16
- isEnabled: context => Array.isArray(context.commandMetadata?.properties) && !Array.isArray(context.element.properties.inputs),
16
+ isEnabled: context => Array.isArray(context.commandMetadata?.properties) && context.element.properties.inputs === undefined,
17
17
  execute: context => generateCommandFields(context),
18
18
  };
19
19
 
20
20
  function generateCommandFields(context: DesignTimeActionContext): DesignTimeActionResult {
21
21
  const properties = context.commandMetadata?.properties ?? [];
22
22
  if (!properties.length) return { edits: [], diagnostics: ['No command metadata was supplied.'] };
23
+ // Authored fields, or a binding that supplies them, are never overwritten.
23
24
  if (Array.isArray(context.element.properties.inputs)) {
24
25
  return { edits: [], diagnostics: ['The form already has authored fields; Generate fields will not overwrite them.'] };
25
26
  }
27
+ if (context.element.properties.inputs !== undefined) {
28
+ return { edits: [], diagnostics: ['The form\'s fields come from a binding; Generate fields will not overwrite it.'] };
29
+ }
26
30
 
27
31
  return {
28
32
  diagnostics: [],
package/index.ts CHANGED
@@ -13,3 +13,5 @@ export * from './toolbar';
13
13
  export * from './cratisComponents';
14
14
  export * from './cratisComponentsDescriptors';
15
15
  export * from './cratisComponentsPackage';
16
+ export * from './cratisComponentsRuntimePackage';
17
+ export * from './designTime/cratisComponentsDesignTime';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/scene.components",
3
- "version": "4.15.0",
3
+ "version": "4.17.0",
4
4
  "description": "The Cratis Components package: exposes @cratis/components' Arc-bound data, form and dialog composites as Scene components. Built on PrimeReact and Tailwind, and declares both as dependencies.",
5
5
  "keywords": [
6
6
  "cratis",
@@ -39,6 +39,11 @@
39
39
  "require": "./dist/cjs/index.js",
40
40
  "import": "./dist/esm/index.js"
41
41
  },
42
+ "./runtime": {
43
+ "types": "./dist/esm/runtime.d.ts",
44
+ "require": "./dist/cjs/runtime.js",
45
+ "import": "./dist/esm/runtime.js"
46
+ },
42
47
  "./styles": "./theme/sceneTokenBridge.css"
43
48
  },
44
49
  "scripts": {
@@ -54,17 +59,17 @@
54
59
  "build-storybook": "storybook build"
55
60
  },
56
61
  "dependencies": {
57
- "@cratis/scene.engine": "4.15.0",
58
- "@cratis/scene.model": "4.15.0",
59
- "@cratis/scene.react": "4.15.0"
62
+ "@cratis/scene.engine": "4.17.0",
63
+ "@cratis/scene.model": "4.17.0",
64
+ "@cratis/scene.react": "4.17.0"
60
65
  },
61
66
  "devDependencies": {
62
67
  "@cratis/arc": "22.50.5",
63
68
  "@cratis/arc.react": "22.50.5",
64
69
  "@cratis/components": "4.25.0",
65
- "@cratis/scene.engine": "4.15.0",
66
- "@cratis/scene.model": "4.15.0",
67
- "@cratis/scene.react": "4.15.0",
70
+ "@cratis/scene.engine": "4.17.0",
71
+ "@cratis/scene.model": "4.17.0",
72
+ "@cratis/scene.react": "4.17.0",
68
73
  "@storybook/addon-links": "^10.6.1",
69
74
  "@storybook/react": "^10.6.1",
70
75
  "@storybook/react-vite": "^10.6.1",
package/runtime.ts ADDED
@@ -0,0 +1,9 @@
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
+ // The runtime entry point, published as `@cratis/scene.components/runtime`. Nothing reachable from here is
5
+ // design-time code; the bundle content specification walks the built output to prove it.
6
+ export * from './cratisComponents';
7
+ export * from './cratisComponentsDescriptors';
8
+ export * from './cratisComponentsPackageManifest';
9
+ export * from './cratisComponentsRuntimePackage';
@@ -1,8 +1,10 @@
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
+ import { useContext } from 'react';
4
5
  import { ToolbarButton } from '@cratis/components/Toolbar';
5
- import { RegisteredComponentProps } from '@cratis/scene.react';
6
+ import { DestinationReference } from '@cratis/scene.model';
7
+ import { RegisteredComponentProps, SceneNavigationContextInternal } from '@cratis/scene.react';
6
8
  import { booleanProperty, stringProperty, unionProperty } from '../properties';
7
9
 
8
10
  /** Which side of the button its tooltip appears on. */
@@ -16,8 +18,21 @@ const tooltipPositions = ['top', 'right', 'bottom', 'left'] as const;
16
18
  * icons. It defaults to the `text` property rather than to an empty string, so a button that has a
17
19
  * visible label is never left nameless.
18
20
  */
19
- export function SceneToolbarButton({ element }: RegisteredComponentProps) {
21
+ /**
22
+ * A toolbar button. Its authored `destination` - a screen in an outlet, or a dialog - is executed by the
23
+ * enclosing navigation host; outside one it is announced with the host-neutral `cratis.scene.navigate` event.
24
+ * Interactions attached by the document run first.
25
+ */
26
+ export function SceneToolbarButton({ element, interactions }: RegisteredComponentProps) {
20
27
  const text = stringProperty(element.properties, 'text');
28
+ const navigation = useContext(SceneNavigationContextInternal);
29
+ const destination = isDestination(element.properties.destination) ? element.properties.destination : undefined;
30
+ const onClick = () => {
31
+ interactions?.onClick?.({ stopPropagation: () => undefined });
32
+ if (!destination) return;
33
+ if (navigation) navigation.navigate(destination);
34
+ else globalThis.dispatchEvent(new CustomEvent('cratis.scene.navigate', { detail: { destination, element } }));
35
+ };
21
36
 
22
37
  return (
23
38
  <ToolbarButton
@@ -26,6 +41,13 @@ export function SceneToolbarButton({ element }: RegisteredComponentProps) {
26
41
  title={stringProperty(element.properties, 'title') ?? text ?? ''}
27
42
  active={booleanProperty(element.properties, 'active')}
28
43
  tooltipPosition={unionProperty(element.properties, 'tooltipPosition', tooltipPositions)}
44
+ onClick={onClick}
29
45
  />
30
46
  );
31
47
  }
48
+
49
+ function isDestination(value: unknown): value is DestinationReference {
50
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return false;
51
+ const candidate = value as Record<string, unknown>;
52
+ return ['screen', 'module', 'route', 'dialog'].some(key => typeof candidate[key] === 'string');
53
+ }