@cratis/scene.model 3.7.0 → 4.1.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 (232) hide show
  1. package/dist/cjs/elements/SceneElement.js +3 -5
  2. package/dist/cjs/elements/SceneElement.js.map +1 -1
  3. package/dist/cjs/forms/Form.js +2 -1
  4. package/dist/cjs/forms/Form.js.map +1 -1
  5. package/dist/cjs/index.js +46 -0
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/interactions/ApplicationTriggerInteractionTrigger.js +10 -0
  8. package/dist/cjs/interactions/ApplicationTriggerInteractionTrigger.js.map +1 -0
  9. package/dist/cjs/interactions/Behavior.js +12 -0
  10. package/dist/cjs/interactions/Behavior.js.map +1 -0
  11. package/dist/cjs/interactions/BuiltInInteractionTrigger.js +10 -0
  12. package/dist/cjs/interactions/BuiltInInteractionTrigger.js.map +1 -0
  13. package/dist/cjs/interactions/CloseDialogAction.js +10 -0
  14. package/dist/cjs/interactions/CloseDialogAction.js.map +1 -0
  15. package/dist/cjs/interactions/ConfirmAction.js +11 -0
  16. package/dist/cjs/interactions/ConfirmAction.js.map +1 -0
  17. package/dist/cjs/interactions/EventInteractionTrigger.js +10 -0
  18. package/dist/cjs/interactions/EventInteractionTrigger.js.map +1 -0
  19. package/dist/cjs/interactions/ExecuteCommandAction.js +11 -0
  20. package/dist/cjs/interactions/ExecuteCommandAction.js.map +1 -0
  21. package/dist/cjs/interactions/InteractionAction.js +14 -0
  22. package/dist/cjs/interactions/InteractionAction.js.map +1 -0
  23. package/dist/cjs/interactions/InteractionActionKind.js +28 -0
  24. package/dist/cjs/interactions/InteractionActionKind.js.map +1 -0
  25. package/dist/cjs/interactions/InteractionArgument.js +11 -0
  26. package/dist/cjs/interactions/InteractionArgument.js.map +1 -0
  27. package/dist/cjs/interactions/InteractionBinding.js +12 -0
  28. package/dist/cjs/interactions/InteractionBinding.js.map +1 -0
  29. package/dist/cjs/interactions/InteractionMessage.js +12 -0
  30. package/dist/cjs/interactions/InteractionMessage.js.map +1 -0
  31. package/dist/cjs/interactions/InteractionTriggerKind.js +24 -0
  32. package/dist/cjs/interactions/InteractionTriggerKind.js.map +1 -0
  33. package/dist/cjs/interactions/IntervalInteractionTrigger.js +10 -0
  34. package/dist/cjs/interactions/IntervalInteractionTrigger.js.map +1 -0
  35. package/dist/cjs/interactions/NavigateAction.js +11 -0
  36. package/dist/cjs/interactions/NavigateAction.js.map +1 -0
  37. package/dist/cjs/interactions/NavigateBackAction.js +10 -0
  38. package/dist/cjs/interactions/NavigateBackAction.js.map +1 -0
  39. package/dist/cjs/interactions/NotificationLevel.js +17 -0
  40. package/dist/cjs/interactions/NotificationLevel.js.map +1 -0
  41. package/dist/cjs/interactions/NotifyAction.js +12 -0
  42. package/dist/cjs/interactions/NotifyAction.js.map +1 -0
  43. package/dist/cjs/interactions/OpenDialogAction.js +11 -0
  44. package/dist/cjs/interactions/OpenDialogAction.js.map +1 -0
  45. package/dist/cjs/interactions/RaiseTriggerAction.js +11 -0
  46. package/dist/cjs/interactions/RaiseTriggerAction.js.map +1 -0
  47. package/dist/cjs/interactions/RefreshQueryAction.js +11 -0
  48. package/dist/cjs/interactions/RefreshQueryAction.js.map +1 -0
  49. package/dist/cjs/interactions/SetStateAction.js +12 -0
  50. package/dist/cjs/interactions/SetStateAction.js.map +1 -0
  51. package/dist/cjs/layouts/Layout.js +2 -1
  52. package/dist/cjs/layouts/Layout.js.map +1 -1
  53. package/dist/cjs/profiles/UiProfile.js.map +1 -1
  54. package/dist/cjs/screens/DialogTemplate.js +2 -1
  55. package/dist/cjs/screens/DialogTemplate.js.map +1 -1
  56. package/dist/cjs/screens/Screen.js +2 -1
  57. package/dist/cjs/screens/Screen.js.map +1 -1
  58. package/dist/cjs/screens/ScreenTemplate.js +2 -1
  59. package/dist/cjs/screens/ScreenTemplate.js.map +1 -1
  60. package/dist/cjs/sizeClasses/TargetSizeClass.js +20 -0
  61. package/dist/cjs/sizeClasses/TargetSizeClass.js.map +1 -0
  62. package/dist/esm/elements/SceneElement.d.ts +2 -0
  63. package/dist/esm/elements/SceneElement.d.ts.map +1 -1
  64. package/dist/esm/elements/SceneElement.js +3 -5
  65. package/dist/esm/elements/SceneElement.js.map +1 -1
  66. package/dist/esm/forms/Form.d.ts +2 -0
  67. package/dist/esm/forms/Form.d.ts.map +1 -1
  68. package/dist/esm/forms/Form.js +2 -1
  69. package/dist/esm/forms/Form.js.map +1 -1
  70. package/dist/esm/index.d.ts +1 -0
  71. package/dist/esm/index.d.ts.map +1 -1
  72. package/dist/esm/index.js +23 -0
  73. package/dist/esm/index.js.map +1 -1
  74. package/dist/esm/interactions/ApplicationTriggerInteractionTrigger.d.ts +6 -0
  75. package/dist/esm/interactions/ApplicationTriggerInteractionTrigger.d.ts.map +1 -0
  76. package/dist/esm/interactions/ApplicationTriggerInteractionTrigger.js +8 -0
  77. package/dist/esm/interactions/ApplicationTriggerInteractionTrigger.js.map +1 -0
  78. package/dist/esm/interactions/Behavior.d.ts +8 -0
  79. package/dist/esm/interactions/Behavior.d.ts.map +1 -0
  80. package/dist/esm/interactions/Behavior.js +10 -0
  81. package/dist/esm/interactions/Behavior.js.map +1 -0
  82. package/dist/esm/interactions/BuiltInInteractionTrigger.d.ts +7 -0
  83. package/dist/esm/interactions/BuiltInInteractionTrigger.d.ts.map +1 -0
  84. package/dist/esm/interactions/BuiltInInteractionTrigger.js +8 -0
  85. package/dist/esm/interactions/BuiltInInteractionTrigger.js.map +1 -0
  86. package/dist/esm/interactions/CloseDialogAction.d.ts +5 -0
  87. package/dist/esm/interactions/CloseDialogAction.d.ts.map +1 -0
  88. package/dist/esm/interactions/CloseDialogAction.js +8 -0
  89. package/dist/esm/interactions/CloseDialogAction.js.map +1 -0
  90. package/dist/esm/interactions/ConfirmAction.d.ts +7 -0
  91. package/dist/esm/interactions/ConfirmAction.d.ts.map +1 -0
  92. package/dist/esm/interactions/ConfirmAction.js +9 -0
  93. package/dist/esm/interactions/ConfirmAction.js.map +1 -0
  94. package/dist/esm/interactions/EventInteractionTrigger.d.ts +6 -0
  95. package/dist/esm/interactions/EventInteractionTrigger.d.ts.map +1 -0
  96. package/dist/esm/interactions/EventInteractionTrigger.js +8 -0
  97. package/dist/esm/interactions/EventInteractionTrigger.js.map +1 -0
  98. package/dist/esm/interactions/ExecuteCommandAction.d.ts +6 -0
  99. package/dist/esm/interactions/ExecuteCommandAction.d.ts.map +1 -0
  100. package/dist/esm/interactions/ExecuteCommandAction.js +9 -0
  101. package/dist/esm/interactions/ExecuteCommandAction.js.map +1 -0
  102. package/dist/esm/interactions/InteractionAction.d.ts +11 -0
  103. package/dist/esm/interactions/InteractionAction.d.ts.map +1 -0
  104. package/dist/esm/interactions/InteractionAction.js +12 -0
  105. package/dist/esm/interactions/InteractionAction.js.map +1 -0
  106. package/dist/esm/interactions/InteractionActionKind.d.ts +13 -0
  107. package/dist/esm/interactions/InteractionActionKind.d.ts.map +1 -0
  108. package/dist/esm/interactions/InteractionActionKind.js +26 -0
  109. package/dist/esm/interactions/InteractionActionKind.js.map +1 -0
  110. package/dist/esm/interactions/InteractionArgument.d.ts +7 -0
  111. package/dist/esm/interactions/InteractionArgument.d.ts.map +1 -0
  112. package/dist/esm/interactions/InteractionArgument.js +9 -0
  113. package/dist/esm/interactions/InteractionArgument.js.map +1 -0
  114. package/dist/esm/interactions/InteractionBinding.d.ts +10 -0
  115. package/dist/esm/interactions/InteractionBinding.d.ts.map +1 -0
  116. package/dist/esm/interactions/InteractionBinding.js +10 -0
  117. package/dist/esm/interactions/InteractionBinding.js.map +1 -0
  118. package/dist/esm/interactions/InteractionMessage.d.ts +8 -0
  119. package/dist/esm/interactions/InteractionMessage.d.ts.map +1 -0
  120. package/dist/esm/interactions/InteractionMessage.js +10 -0
  121. package/dist/esm/interactions/InteractionMessage.js.map +1 -0
  122. package/dist/esm/interactions/InteractionTrigger.d.ts +3 -0
  123. package/dist/esm/interactions/InteractionTrigger.d.ts.map +1 -0
  124. package/dist/esm/interactions/InteractionTrigger.js +2 -0
  125. package/dist/esm/interactions/InteractionTrigger.js.map +1 -0
  126. package/dist/esm/interactions/InteractionTriggerKind.d.ts +12 -0
  127. package/dist/esm/interactions/InteractionTriggerKind.d.ts.map +1 -0
  128. package/dist/esm/interactions/InteractionTriggerKind.js +22 -0
  129. package/dist/esm/interactions/InteractionTriggerKind.js.map +1 -0
  130. package/dist/esm/interactions/IntervalInteractionTrigger.d.ts +6 -0
  131. package/dist/esm/interactions/IntervalInteractionTrigger.d.ts.map +1 -0
  132. package/dist/esm/interactions/IntervalInteractionTrigger.js +8 -0
  133. package/dist/esm/interactions/IntervalInteractionTrigger.js.map +1 -0
  134. package/dist/esm/interactions/NavigateAction.d.ts +6 -0
  135. package/dist/esm/interactions/NavigateAction.d.ts.map +1 -0
  136. package/dist/esm/interactions/NavigateAction.js +9 -0
  137. package/dist/esm/interactions/NavigateAction.js.map +1 -0
  138. package/dist/esm/interactions/NavigateBackAction.d.ts +5 -0
  139. package/dist/esm/interactions/NavigateBackAction.d.ts.map +1 -0
  140. package/dist/esm/interactions/NavigateBackAction.js +8 -0
  141. package/dist/esm/interactions/NavigateBackAction.js.map +1 -0
  142. package/dist/esm/interactions/NotificationLevel.d.ts +6 -0
  143. package/dist/esm/interactions/NotificationLevel.d.ts.map +1 -0
  144. package/dist/esm/interactions/NotificationLevel.js +15 -0
  145. package/dist/esm/interactions/NotificationLevel.js.map +1 -0
  146. package/dist/esm/interactions/NotifyAction.d.ts +9 -0
  147. package/dist/esm/interactions/NotifyAction.d.ts.map +1 -0
  148. package/dist/esm/interactions/NotifyAction.js +10 -0
  149. package/dist/esm/interactions/NotifyAction.js.map +1 -0
  150. package/dist/esm/interactions/OpenDialogAction.d.ts +6 -0
  151. package/dist/esm/interactions/OpenDialogAction.d.ts.map +1 -0
  152. package/dist/esm/interactions/OpenDialogAction.js +9 -0
  153. package/dist/esm/interactions/OpenDialogAction.js.map +1 -0
  154. package/dist/esm/interactions/RaiseTriggerAction.d.ts +6 -0
  155. package/dist/esm/interactions/RaiseTriggerAction.d.ts.map +1 -0
  156. package/dist/esm/interactions/RaiseTriggerAction.js +9 -0
  157. package/dist/esm/interactions/RaiseTriggerAction.js.map +1 -0
  158. package/dist/esm/interactions/RefreshQueryAction.d.ts +6 -0
  159. package/dist/esm/interactions/RefreshQueryAction.d.ts.map +1 -0
  160. package/dist/esm/interactions/RefreshQueryAction.js +9 -0
  161. package/dist/esm/interactions/RefreshQueryAction.js.map +1 -0
  162. package/dist/esm/interactions/SetStateAction.d.ts +8 -0
  163. package/dist/esm/interactions/SetStateAction.d.ts.map +1 -0
  164. package/dist/esm/interactions/SetStateAction.js +10 -0
  165. package/dist/esm/interactions/SetStateAction.js.map +1 -0
  166. package/dist/esm/interactions/index.d.ts +24 -0
  167. package/dist/esm/interactions/index.d.ts.map +1 -0
  168. package/dist/esm/interactions/index.js +24 -0
  169. package/dist/esm/interactions/index.js.map +1 -0
  170. package/dist/esm/layouts/Layout.d.ts +2 -0
  171. package/dist/esm/layouts/Layout.d.ts.map +1 -1
  172. package/dist/esm/layouts/Layout.js +2 -1
  173. package/dist/esm/layouts/Layout.js.map +1 -1
  174. package/dist/esm/profiles/UiProfile.d.ts +2 -2
  175. package/dist/esm/profiles/UiProfile.d.ts.map +1 -1
  176. package/dist/esm/profiles/UiProfile.js.map +1 -1
  177. package/dist/esm/screens/DialogTemplate.d.ts +2 -0
  178. package/dist/esm/screens/DialogTemplate.d.ts.map +1 -1
  179. package/dist/esm/screens/DialogTemplate.js +2 -1
  180. package/dist/esm/screens/DialogTemplate.js.map +1 -1
  181. package/dist/esm/screens/Screen.d.ts +2 -0
  182. package/dist/esm/screens/Screen.d.ts.map +1 -1
  183. package/dist/esm/screens/Screen.js +2 -1
  184. package/dist/esm/screens/Screen.js.map +1 -1
  185. package/dist/esm/screens/ScreenTemplate.d.ts +2 -0
  186. package/dist/esm/screens/ScreenTemplate.d.ts.map +1 -1
  187. package/dist/esm/screens/ScreenTemplate.js +2 -1
  188. package/dist/esm/screens/ScreenTemplate.js.map +1 -1
  189. package/dist/esm/sizeClasses/TargetSizeClass.d.ts +6 -0
  190. package/dist/esm/sizeClasses/TargetSizeClass.d.ts.map +1 -0
  191. package/dist/esm/sizeClasses/TargetSizeClass.js +18 -0
  192. package/dist/esm/sizeClasses/TargetSizeClass.js.map +1 -0
  193. package/dist/esm/sizeClasses/index.d.ts +1 -0
  194. package/dist/esm/sizeClasses/index.d.ts.map +1 -1
  195. package/dist/esm/sizeClasses/index.js +1 -0
  196. package/dist/esm/sizeClasses/index.js.map +1 -1
  197. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  198. package/elements/SceneElement.ts +8 -1
  199. package/forms/Form.ts +7 -1
  200. package/index.ts +1 -0
  201. package/interactions/ApplicationTriggerInteractionTrigger.ts +13 -0
  202. package/interactions/Behavior.ts +19 -0
  203. package/interactions/BuiltInInteractionTrigger.ts +14 -0
  204. package/interactions/CloseDialogAction.ts +11 -0
  205. package/interactions/ConfirmAction.ts +14 -0
  206. package/interactions/EventInteractionTrigger.ts +13 -0
  207. package/interactions/ExecuteCommandAction.ts +13 -0
  208. package/interactions/InteractionAction.ts +22 -0
  209. package/interactions/InteractionActionKind.ts +24 -0
  210. package/interactions/InteractionArgument.ts +14 -0
  211. package/interactions/InteractionBinding.ts +17 -0
  212. package/interactions/InteractionMessage.ts +16 -0
  213. package/interactions/InteractionTrigger.ts +10 -0
  214. package/interactions/InteractionTriggerKind.ts +20 -0
  215. package/interactions/IntervalInteractionTrigger.ts +13 -0
  216. package/interactions/NavigateAction.ts +13 -0
  217. package/interactions/NavigateBackAction.ts +11 -0
  218. package/interactions/NotificationLevel.ts +13 -0
  219. package/interactions/NotifyAction.ts +16 -0
  220. package/interactions/OpenDialogAction.ts +13 -0
  221. package/interactions/RaiseTriggerAction.ts +13 -0
  222. package/interactions/RefreshQueryAction.ts +13 -0
  223. package/interactions/SetStateAction.ts +15 -0
  224. package/interactions/index.ts +26 -0
  225. package/layouts/Layout.ts +7 -1
  226. package/package.json +1 -1
  227. package/profiles/UiProfile.ts +2 -2
  228. package/screens/DialogTemplate.ts +7 -0
  229. package/screens/Screen.ts +7 -1
  230. package/screens/ScreenTemplate.ts +7 -0
  231. package/sizeClasses/TargetSizeClass.ts +16 -0
  232. package/sizeClasses/index.ts +1 -0
@@ -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
+ import { Behavior } from '../interactions';
5
+
4
6
  /**
5
7
  * The root of every node in a Scene element tree. Named `SceneElement` rather than `Element` to avoid
6
8
  * colliding with the DOM's own global `Element` type, which every consumer of this package also has in scope.
@@ -8,6 +10,11 @@
8
10
  export interface SceneElement {
9
11
  id: string;
10
12
  properties: Record<string, unknown>;
13
+ /**
14
+ * The behaviors attached here - what happens when someone interacts with it. Additive with whatever is
15
+ * attached further out or further in.
16
+ */
17
+ behaviors?: Behavior[];
11
18
  }
12
19
 
13
- export const SceneElementPropertyNames: (keyof SceneElement)[] = ['id', 'properties'];
20
+ export const SceneElementPropertyNames: (keyof SceneElement)[] = ['id', 'properties', 'behaviors'];
package/forms/Form.ts CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { PopulateSource } from './PopulateSource';
5
5
  import { FormField } from './FormField';
6
+ import { Behavior } from '../interactions';
6
7
 
7
8
  /**
8
9
  * The command-side counterpart to a table or summary: a named, typed form for one command.
@@ -12,6 +13,11 @@ export interface Form {
12
13
  forCommand: string;
13
14
  populateSource?: PopulateSource;
14
15
  fields: FormField[];
16
+ /**
17
+ * The behaviors attached here - what happens when someone interacts with it. Additive with whatever is
18
+ * attached further out or further in.
19
+ */
20
+ behaviors?: Behavior[];
15
21
  }
16
22
 
17
- export const FormPropertyNames: (keyof Form)[] = ['name', 'forCommand', 'populateSource', 'fields'];
23
+ export const FormPropertyNames: (keyof Form)[] = ['name', 'forCommand', 'populateSource', 'fields', 'behaviors'];
package/index.ts CHANGED
@@ -9,5 +9,6 @@ export * from './forms';
9
9
  export * from './contributionPoints';
10
10
  export * from './profiles';
11
11
  export * from './packages';
12
+ export * from './interactions';
12
13
  export * from './screens';
13
14
  export * from './starters';
@@ -0,0 +1,13 @@
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 { InteractionTrigger } from './InteractionTrigger';
5
+
6
+ /**
7
+ * An interaction started by a declared application trigger firing.
8
+ */
9
+ export interface ApplicationTriggerInteractionTrigger extends InteractionTrigger {
10
+ triggerName: string;
11
+ }
12
+
13
+ export const ApplicationTriggerInteractionTriggerPropertyNames: (keyof ApplicationTriggerInteractionTrigger)[] = ['triggerName'];
@@ -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 { InteractionBinding } from './InteractionBinding';
5
+
6
+ /**
7
+ * A bundle of interaction trigger to action bindings, attached to something that can be interacted with.
8
+ *
9
+ * A named behavior and an inline one are the same shape - anonymity is a property rather than a separate kind
10
+ * of node. Attachments are additive: a behavior on a template and one on an element both run, outermost first,
11
+ * unless the order says otherwise.
12
+ */
13
+ export interface Behavior {
14
+ name?: string;
15
+ bindings: InteractionBinding[];
16
+ order?: number;
17
+ }
18
+
19
+ export const BehaviorPropertyNames: (keyof Behavior)[] = ['name', 'bindings', 'order'];
@@ -0,0 +1,14 @@
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 { InteractionTrigger } from './InteractionTrigger';
5
+ import { InteractionTriggerKind } from './InteractionTriggerKind';
6
+
7
+ /**
8
+ * One of the built-in interaction kinds.
9
+ */
10
+ export interface BuiltInInteractionTrigger extends InteractionTrigger {
11
+ kind: InteractionTriggerKind;
12
+ }
13
+
14
+ export const BuiltInInteractionTriggerPropertyNames: (keyof BuiltInInteractionTrigger)[] = ['kind'];
@@ -0,0 +1,11 @@
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 { InteractionAction } from './InteractionAction';
5
+
6
+ /**
7
+ * Dismisses the innermost dialog.
8
+ */
9
+ export interface CloseDialogAction extends InteractionAction {}
10
+
11
+ export const CloseDialogActionPropertyNames: (keyof CloseDialogAction)[] = ['kind'];
@@ -0,0 +1,14 @@
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 { InteractionAction } from './InteractionAction';
5
+ import { InteractionMessage } from './InteractionMessage';
6
+
7
+ /**
8
+ * Gates the actions that follow on the user agreeing.
9
+ */
10
+ export interface ConfirmAction extends InteractionAction {
11
+ message: InteractionMessage;
12
+ }
13
+
14
+ export const ConfirmActionPropertyNames: (keyof ConfirmAction)[] = ['message', 'kind'];
@@ -0,0 +1,13 @@
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 { InteractionTrigger } from './InteractionTrigger';
5
+
6
+ /**
7
+ * An interaction started by observing a modeled domain event.
8
+ */
9
+ export interface EventInteractionTrigger extends InteractionTrigger {
10
+ eventName: string;
11
+ }
12
+
13
+ export const EventInteractionTriggerPropertyNames: (keyof EventInteractionTrigger)[] = ['eventName'];
@@ -0,0 +1,13 @@
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 { InteractionAction } from './InteractionAction';
5
+
6
+ /**
7
+ * Submits a modeled command.
8
+ */
9
+ export interface ExecuteCommandAction extends InteractionAction {
10
+ command: string;
11
+ }
12
+
13
+ export const ExecuteCommandActionPropertyNames: (keyof ExecuteCommandAction)[] = ['command', 'kind'];
@@ -0,0 +1,22 @@
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 { InteractionActionKind } from './InteractionActionKind';
5
+ import { InteractionArgument } from './InteractionArgument';
6
+
7
+ /**
8
+ * One declarative effect inside a binding.
9
+ *
10
+ * The set is closed and every operand references something the model declares rather than being a string a
11
+ * renderer interprets - that is what lets an action naming nothing be reported instead of becoming a control
12
+ * that does nothing when clicked.
13
+ */
14
+ export interface InteractionAction {
15
+ kind: InteractionActionKind;
16
+ arguments?: InteractionArgument[];
17
+ onSuccess?: InteractionAction[];
18
+ onFailure?: InteractionAction[];
19
+ onResult?: InteractionAction[];
20
+ }
21
+
22
+ export const InteractionActionPropertyNames: (keyof InteractionAction)[] = ['kind', 'arguments', 'onSuccess', 'onFailure', 'onResult'];
@@ -0,0 +1,24 @@
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
+ /**
5
+ * Which effect an {@link InteractionAction} is.
6
+ *
7
+ * An explicit discriminator rather than a structural one: NavigateBackAction and CloseDialogAction both carry no
8
+ * operand, so nothing about their shape tells them apart. It also means a renderer meeting an action it does not
9
+ * know can name it in a finding instead of reporting that something unidentifiable failed.
10
+ *
11
+ * Append only.
12
+ */
13
+ export enum InteractionActionKind {
14
+ ExecuteCommand = 'ExecuteCommand',
15
+ Navigate = 'Navigate',
16
+ NavigateBack = 'NavigateBack',
17
+ OpenDialog = 'OpenDialog',
18
+ CloseDialog = 'CloseDialog',
19
+ RefreshQuery = 'RefreshQuery',
20
+ SetState = 'SetState',
21
+ Notify = 'Notify',
22
+ Confirm = 'Confirm',
23
+ RaiseTrigger = 'RaiseTrigger',
24
+ }
@@ -0,0 +1,14 @@
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 { BindingExpression } from '../common';
5
+
6
+ /**
7
+ * One argument passed to an action.
8
+ */
9
+ export interface InteractionArgument {
10
+ name: string;
11
+ value: BindingExpression;
12
+ }
13
+
14
+ export const InteractionArgumentPropertyNames: (keyof InteractionArgument)[] = ['name', 'value'];
@@ -0,0 +1,17 @@
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 { BindingExpression } from '../common';
5
+ import { InteractionAction } from './InteractionAction';
6
+ import { InteractionTrigger } from './InteractionTrigger';
7
+
8
+ /**
9
+ * One interaction trigger to actions binding.
10
+ */
11
+ export interface InteractionBinding {
12
+ trigger: InteractionTrigger;
13
+ actions: InteractionAction[];
14
+ condition?: BindingExpression;
15
+ }
16
+
17
+ export const InteractionBindingPropertyNames: (keyof InteractionBinding)[] = ['trigger', 'actions', 'condition'];
@@ -0,0 +1,16 @@
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 { BindingExpression } from '../common';
5
+
6
+ /**
7
+ * The text an action shows: a literal, a localization key, or a binding resolved when the action runs. Exactly
8
+ * one is set.
9
+ */
10
+ export interface InteractionMessage {
11
+ text?: string;
12
+ stringsKey?: string;
13
+ binding?: BindingExpression;
14
+ }
15
+
16
+ export const InteractionMessagePropertyNames: (keyof InteractionMessage)[] = ['text', 'stringsKey', 'binding'];
@@ -0,0 +1,10 @@
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
+ /**
5
+ * What starts an interaction.
6
+ *
7
+ * Never declared - it exists only as part of a binding, which is what makes it a different concept from the
8
+ * application trigger a backend reaction consumes.
9
+ */
10
+ export interface InteractionTrigger {}
@@ -0,0 +1,20 @@
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
+ /**
5
+ * The built-in interaction kinds - what a user or a lifecycle did, rather than something the document declared.
6
+ *
7
+ * Append only: a renderer that does not know a member reports it rather than guessing, so members are never
8
+ * renumbered or reordered.
9
+ */
10
+ export enum InteractionTriggerKind {
11
+ Click = 'Click',
12
+ DoubleClick = 'DoubleClick',
13
+ Select = 'Select',
14
+ Submit = 'Submit',
15
+ Change = 'Change',
16
+ Load = 'Load',
17
+ Unload = 'Unload',
18
+ Enter = 'Enter',
19
+ Leave = 'Leave',
20
+ }
@@ -0,0 +1,13 @@
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 { InteractionTrigger } from './InteractionTrigger';
5
+
6
+ /**
7
+ * An interaction started by an elapsed interval, normalized to seconds so nothing downstream carries a unit.
8
+ */
9
+ export interface IntervalInteractionTrigger extends InteractionTrigger {
10
+ seconds: number;
11
+ }
12
+
13
+ export const IntervalInteractionTriggerPropertyNames: (keyof IntervalInteractionTrigger)[] = ['seconds'];
@@ -0,0 +1,13 @@
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 { InteractionAction } from './InteractionAction';
5
+
6
+ /**
7
+ * Changes the active screen. The screen is named, never addressed - turning that into a URL is a renderer's job.
8
+ */
9
+ export interface NavigateAction extends InteractionAction {
10
+ screen: string;
11
+ }
12
+
13
+ export const NavigateActionPropertyNames: (keyof NavigateAction)[] = ['screen', 'kind'];
@@ -0,0 +1,11 @@
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 { InteractionAction } from './InteractionAction';
5
+
6
+ /**
7
+ * Pops navigation history.
8
+ */
9
+ export interface NavigateBackAction extends InteractionAction {}
10
+
11
+ export const NavigateBackActionPropertyNames: (keyof NavigateBackAction)[] = ['kind'];
@@ -0,0 +1,13 @@
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
+ /**
5
+ * How prominently a {@link NotifyAction} surfaces its message.
6
+ *
7
+ * Append only.
8
+ */
9
+ export enum NotificationLevel {
10
+ Info = 'Info',
11
+ Warning = 'Warning',
12
+ Error = 'Error',
13
+ }
@@ -0,0 +1,16 @@
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 { InteractionAction } from './InteractionAction';
5
+ import { InteractionMessage } from './InteractionMessage';
6
+ import { NotificationLevel } from './NotificationLevel';
7
+
8
+ /**
9
+ * Surfaces a message.
10
+ */
11
+ export interface NotifyAction extends InteractionAction {
12
+ level: NotificationLevel;
13
+ message: InteractionMessage;
14
+ }
15
+
16
+ export const NotifyActionPropertyNames: (keyof NotifyAction)[] = ['level', 'message', 'kind'];
@@ -0,0 +1,13 @@
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 { InteractionAction } from './InteractionAction';
5
+
6
+ /**
7
+ * Opens a dialog over the application.
8
+ */
9
+ export interface OpenDialogAction extends InteractionAction {
10
+ dialogTemplate: string;
11
+ }
12
+
13
+ export const OpenDialogActionPropertyNames: (keyof OpenDialogAction)[] = ['dialogTemplate', 'kind'];
@@ -0,0 +1,13 @@
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 { InteractionAction } from './InteractionAction';
5
+
6
+ /**
7
+ * Fires a declared application trigger.
8
+ */
9
+ export interface RaiseTriggerAction extends InteractionAction {
10
+ trigger: string;
11
+ }
12
+
13
+ export const RaiseTriggerActionPropertyNames: (keyof RaiseTriggerAction)[] = ['trigger', 'kind'];
@@ -0,0 +1,13 @@
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 { InteractionAction } from './InteractionAction';
5
+
6
+ /**
7
+ * Re-runs a query-backed element.
8
+ */
9
+ export interface RefreshQueryAction extends InteractionAction {
10
+ query: string;
11
+ }
12
+
13
+ export const RefreshQueryActionPropertyNames: (keyof RefreshQueryAction)[] = ['query', 'kind'];
@@ -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
+
4
+ import { BindingExpression } from '../common';
5
+ import { InteractionAction } from './InteractionAction';
6
+
7
+ /**
8
+ * Writes screen state.
9
+ */
10
+ export interface SetStateAction extends InteractionAction {
11
+ target: string;
12
+ value: BindingExpression;
13
+ }
14
+
15
+ export const SetStateActionPropertyNames: (keyof SetStateAction)[] = ['target', 'value', 'kind'];
@@ -0,0 +1,26 @@
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
+ export * from './InteractionTriggerKind';
5
+ export * from './NotificationLevel';
6
+ export * from './InteractionTrigger';
7
+ export * from './BuiltInInteractionTrigger';
8
+ export * from './EventInteractionTrigger';
9
+ export * from './IntervalInteractionTrigger';
10
+ export * from './ApplicationTriggerInteractionTrigger';
11
+ export * from './InteractionMessage';
12
+ export * from './InteractionArgument';
13
+ export * from './InteractionActionKind';
14
+ export * from './InteractionAction';
15
+ export * from './ExecuteCommandAction';
16
+ export * from './NavigateAction';
17
+ export * from './NavigateBackAction';
18
+ export * from './OpenDialogAction';
19
+ export * from './CloseDialogAction';
20
+ export * from './RefreshQueryAction';
21
+ export * from './SetStateAction';
22
+ export * from './NotifyAction';
23
+ export * from './ConfirmAction';
24
+ export * from './RaiseTriggerAction';
25
+ export * from './InteractionBinding';
26
+ export * from './Behavior';
package/layouts/Layout.ts CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { Arrangement } from './Arrangement';
5
5
  import { Slot } from './Slot';
6
+ import { Behavior } from '../interactions';
6
7
 
7
8
  /**
8
9
  * A named template of slots that a {@link Screen} fills with content. Mirrors Screenplay's `layout`
@@ -21,6 +22,11 @@ export interface Layout {
21
22
  * themselves.
22
23
  */
23
24
  arrangement?: Arrangement;
25
+ /**
26
+ * The behaviors attached here - what happens when someone interacts with it. Additive with whatever is
27
+ * attached further out or further in.
28
+ */
29
+ behaviors?: Behavior[];
24
30
  }
25
31
 
26
- export const LayoutPropertyNames: (keyof Layout)[] = ['name', 'slots', 'arrangement'];
32
+ export const LayoutPropertyNames: (keyof Layout)[] = ['name', 'slots', 'arrangement', 'behaviors'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/scene.model",
3
- "version": "3.7.0",
3
+ "version": "4.1.0",
4
4
  "description": "The TypeScript mirror of Cratis.Scene.Model — the platform-agnostic Screen object model.",
5
5
  "keywords": [
6
6
  "cratis",
@@ -1,7 +1,7 @@
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 { SizeClass } from '../sizeClasses';
4
+ import { TargetSizeClass } from '../sizeClasses';
5
5
 
6
6
  /**
7
7
  * A named target: a platform, a default size class, an ordered list of component packages, and the
@@ -33,7 +33,7 @@ export interface UiProfile {
33
33
  /**
34
34
  * The size class assumed when the renderer cannot otherwise determine one.
35
35
  */
36
- defaultSizeClass?: SizeClass;
36
+ defaultSizeClass?: TargetSizeClass;
37
37
 
38
38
  /**
39
39
  * The name of the {@link Layout} this profile renders inside — the application's base navigational
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { SceneElement } from '../elements';
5
5
  import { Arrangement, Slot } from '../layouts';
6
+ import { Behavior } from '../interactions';
6
7
 
7
8
  /**
8
9
  * A reusable dialog structure — the same idea as a {@link ScreenTemplate}, for content that opens over an
@@ -45,6 +46,11 @@ export interface DialogTemplate {
45
46
  * A one-line description for a template picker.
46
47
  */
47
48
  description?: string;
49
+ /**
50
+ * The behaviors attached here - what happens when someone interacts with it. Additive with whatever is
51
+ * attached further out or further in.
52
+ */
53
+ behaviors?: Behavior[];
48
54
  }
49
55
 
50
56
  export const DialogTemplatePropertyNames: (keyof DialogTemplate)[] = [
@@ -54,4 +60,5 @@ export const DialogTemplatePropertyNames: (keyof DialogTemplate)[] = [
54
60
  'content',
55
61
  'displayName',
56
62
  'description',
63
+ 'behaviors',
57
64
  ];
package/screens/Screen.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  import { SceneElement } from '../elements';
5
5
  import { Form } from '../forms';
6
6
  import { Contribution } from '../contributionPoints';
7
+ import { Behavior } from '../interactions';
7
8
 
8
9
  /**
9
10
  * A named screen: the structure it fills, the content that fills it, the forms it hosts, and whatever it
@@ -45,6 +46,11 @@ export interface Screen {
45
46
  * never has to state its own position.
46
47
  */
47
48
  screenTemplate?: string;
49
+ /**
50
+ * The behaviors attached here - what happens when someone interacts with it. Additive with whatever is
51
+ * attached further out or further in.
52
+ */
53
+ behaviors?: Behavior[];
48
54
  }
49
55
 
50
- export const ScreenPropertyNames: (keyof Screen)[] = ['name', 'layout', 'slotContent', 'forms', 'contributions', 'screenTemplate'];
56
+ export const ScreenPropertyNames: (keyof Screen)[] = ['name', 'layout', 'slotContent', 'forms', 'contributions', 'screenTemplate', 'behaviors'];
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { SceneElement } from '../elements';
5
5
  import { Arrangement, Slot } from '../layouts';
6
+ import { Behavior } from '../interactions';
6
7
 
7
8
  /**
8
9
  * A reusable screen structure that fills a named slot on whatever contains it, and offers slots of its
@@ -57,6 +58,11 @@ export interface ScreenTemplate {
57
58
  * A one-line description for a template picker.
58
59
  */
59
60
  description?: string;
61
+ /**
62
+ * The behaviors attached here - what happens when someone interacts with it. Additive with whatever is
63
+ * attached further out or further in.
64
+ */
65
+ behaviors?: Behavior[];
60
66
  }
61
67
 
62
68
  export const ScreenTemplatePropertyNames: (keyof ScreenTemplate)[] = [
@@ -67,4 +73,5 @@ export const ScreenTemplatePropertyNames: (keyof ScreenTemplate)[] = [
67
73
  'content',
68
74
  'displayName',
69
75
  'description',
76
+ 'behaviors',
70
77
  ];
@@ -0,0 +1,16 @@
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
+ /**
5
+ * Defines the size a deployment target assumes by default.
6
+ *
7
+ * Deliberately a different vocabulary from {@link WidthSizeClass} and {@link HeightSizeClass}. Those two form
8
+ * the matrix an arrangement resolves against, where the only distinction that matters is whether an axis is
9
+ * cramped. What a target assumes is a coarser, one-dimensional statement about the device - a desktop is not
10
+ * merely 'regular' - and it carries a third value because of it.
11
+ */
12
+ export enum TargetSizeClass {
13
+ Compact = 'Compact',
14
+ Regular = 'Regular',
15
+ Expanded = 'Expanded'
16
+ }
@@ -4,3 +4,4 @@
4
4
  export * from './WidthSizeClass';
5
5
  export * from './HeightSizeClass';
6
6
  export * from './SizeClass';
7
+ export * from './TargetSizeClass';