@wise/dynamic-flow-types 2.17.0 → 2.18.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.
package/build/main.mjs CHANGED
@@ -3936,13 +3936,6 @@ var loadingIndicatorLayoutSchema = z.object({
3936
3936
  control: z.string().optional(),
3937
3937
  margin: sizeSchema.optional()
3938
3938
  });
3939
- var alertLayoutSchema = z.object({
3940
- type: z.literal("alert"),
3941
- markdown: z.string(),
3942
- context: contextSchema.optional(),
3943
- control: z.string().optional(),
3944
- margin: sizeSchema.optional()
3945
- });
3946
3939
  var paragraphLayoutSchema = z.object({
3947
3940
  type: z.literal("paragraph"),
3948
3941
  text: z.string(),
@@ -4097,6 +4090,9 @@ var actionTypeSchema = z.union([
4097
4090
  z.literal("negative")
4098
4091
  ]);
4099
4092
  var summarySchema = z.union([summaryProviderSchema, summarySummariserSchema]);
4093
+ var linkSchema = z.object({
4094
+ url: z.string()
4095
+ });
4100
4096
  var actionSchema = z.object({
4101
4097
  title: z.string().optional(),
4102
4098
  type: actionTypeSchema.optional(),
@@ -4155,6 +4151,10 @@ var reviewLayoutFieldSchema = z.object({
4155
4151
  value: z.string(),
4156
4152
  help: helpSchema.optional()
4157
4153
  });
4154
+ var behaviorSchema = z.object({
4155
+ action: actionSchema.optional(),
4156
+ link: linkSchema.optional()
4157
+ });
4158
4158
  var searchResultSearchSchema = z.object({
4159
4159
  type: z.literal("search"),
4160
4160
  title: z.string(),
@@ -4185,44 +4185,6 @@ var linkHandlerSchema = z.object({
4185
4185
  regexPattern: z.string(),
4186
4186
  action: actionSchema
4187
4187
  });
4188
- var blobSchemaSchema = z.object({
4189
- type: z.literal("blob"),
4190
- promoted: z.boolean().optional(),
4191
- $id: z.string().optional(),
4192
- title: z.string().optional(),
4193
- description: z.string().optional(),
4194
- control: z.string().optional(),
4195
- hidden: z.boolean().optional(),
4196
- icon: iconSchema.optional(),
4197
- image: imageSchema.optional(),
4198
- keywords: z.array(z.string()).optional(),
4199
- summary: summaryProviderSchema.optional(),
4200
- analyticsId: z.string().optional(),
4201
- validationAsync: validateAsyncSchema.optional(),
4202
- validationMessages: z.record(z.string()).optional(),
4203
- alert: alertLayoutSchema.optional(),
4204
- cameraConfig: jsonElementSchema.optional(),
4205
- accepts: z.array(z.string()).optional(),
4206
- maxSize: z.number().optional(),
4207
- source: uploadSourceSchema.optional(),
4208
- disabled: z.boolean().optional()
4209
- });
4210
- var constSchemaSchema = z.object({
4211
- hidden: z.boolean().optional(),
4212
- alert: alertLayoutSchema.optional(),
4213
- control: z.string().optional(),
4214
- promoted: z.boolean().optional(),
4215
- $id: z.string().optional(),
4216
- const: jsonElementSchema,
4217
- title: z.string().optional(),
4218
- description: z.string().optional(),
4219
- icon: iconSchema.optional(),
4220
- image: imageSchema.optional(),
4221
- keywords: z.array(z.string()).optional(),
4222
- summary: summaryProviderSchema.optional(),
4223
- analyticsId: z.string().optional(),
4224
- disabled: z.boolean().optional()
4225
- });
4226
4188
  var pollingOnErrorSchema = z.object({
4227
4189
  action: actionSchema
4228
4190
  });
@@ -4234,6 +4196,11 @@ var reviewLayoutCallToActionSchema = z.object({
4234
4196
  title: z.string(),
4235
4197
  action: actionSchema
4236
4198
  });
4199
+ var alertLayoutCallToActionSchema = z.object({
4200
+ title: z.string(),
4201
+ accessibilityDescription: z.string().optional(),
4202
+ behavior: behaviorSchema
4203
+ });
4237
4204
  var listLayoutSchema = z.object({
4238
4205
  type: z.literal("list"),
4239
4206
  items: z.array(listLayoutItemSchema),
@@ -4277,9 +4244,55 @@ var navigationSchema = z.object({
4277
4244
  back: navigationBackBehaviourSchema.optional(),
4278
4245
  stackBehavior: navigationStackBehaviorSchema.optional()
4279
4246
  });
4247
+ var alertLayoutSchema = z.object({
4248
+ type: z.literal("alert"),
4249
+ markdown: z.string(),
4250
+ context: contextSchema.optional(),
4251
+ control: z.string().optional(),
4252
+ margin: sizeSchema.optional(),
4253
+ callToAction: alertLayoutCallToActionSchema.optional()
4254
+ });
4280
4255
  var searchResponseBodySchema = z.object({
4281
4256
  results: z.array(searchResultSchema)
4282
4257
  });
4258
+ var blobSchemaSchema = z.object({
4259
+ type: z.literal("blob"),
4260
+ promoted: z.boolean().optional(),
4261
+ $id: z.string().optional(),
4262
+ title: z.string().optional(),
4263
+ description: z.string().optional(),
4264
+ control: z.string().optional(),
4265
+ hidden: z.boolean().optional(),
4266
+ icon: iconSchema.optional(),
4267
+ image: imageSchema.optional(),
4268
+ keywords: z.array(z.string()).optional(),
4269
+ summary: summaryProviderSchema.optional(),
4270
+ analyticsId: z.string().optional(),
4271
+ validationAsync: validateAsyncSchema.optional(),
4272
+ validationMessages: z.record(z.string()).optional(),
4273
+ alert: alertLayoutSchema.optional(),
4274
+ cameraConfig: jsonElementSchema.optional(),
4275
+ accepts: z.array(z.string()).optional(),
4276
+ maxSize: z.number().optional(),
4277
+ source: uploadSourceSchema.optional(),
4278
+ disabled: z.boolean().optional()
4279
+ });
4280
+ var constSchemaSchema = z.object({
4281
+ hidden: z.boolean().optional(),
4282
+ alert: alertLayoutSchema.optional(),
4283
+ control: z.string().optional(),
4284
+ promoted: z.boolean().optional(),
4285
+ $id: z.string().optional(),
4286
+ const: jsonElementSchema,
4287
+ title: z.string().optional(),
4288
+ description: z.string().optional(),
4289
+ icon: iconSchema.optional(),
4290
+ image: imageSchema.optional(),
4291
+ keywords: z.array(z.string()).optional(),
4292
+ summary: summaryProviderSchema.optional(),
4293
+ analyticsId: z.string().optional(),
4294
+ disabled: z.boolean().optional()
4295
+ });
4283
4296
  var layoutSchema = z.lazy(
4284
4297
  () => z.union([
4285
4298
  alertLayoutSchema,
@@ -6,7 +6,7 @@ import type { JsonElement } from '../JsonElement';
6
6
  * An action typically defines its URL and HTTP method to submit step data, and can optionally indicate that on success
7
7
  * this action will end the flow.
8
8
  * An endpoint can respond to a submitting action with an error status code and the standard error response format in order to display errors to the user.
9
- * ### Behaviour
9
+ * ### Behavior
10
10
  * #### Non-Exiting Actions
11
11
  * If an action does not specify the `exit` property as true, it is expected that the action will submit the step payload.
12
12
  * For example, the following action is a non-exiting action.
@@ -0,0 +1,17 @@
1
+ import type { Action } from './Action';
2
+ import type { Link } from './Link';
3
+ /**
4
+ * Describes the result of performing some interaction. Can be used to execute an [com.wise.dynamicflow.feature.Action]
5
+ * or open a [com.wise.dynamicflow.feature.Link].
6
+ * If both `action` and `link` are provided, `action` will take precedence.
7
+ */
8
+ export type Behavior = {
9
+ /**
10
+ * An [com.wise.dynamicflow.feature.Action] to perform.
11
+ */
12
+ action?: Action;
13
+ /**
14
+ * A [com.wise.dynamicflow.feature.Link] to open.
15
+ */
16
+ link?: Link;
17
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * External specifies a URL to be opened automatically when a step loads. Url-opening behaviour depends on the platform.
2
+ * External specifies a URL to be opened automatically when a step loads. Url-opening behavior depends on the platform.
3
3
  * General guidance is as follows:
4
4
  * Web:
5
5
  * - Open a URL in a new browser tab.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A link configuration used to connect with an external application or page.
3
+ */
4
+ export type Link = {
5
+ /**
6
+ * An url to be used when opening the link.
7
+ */
8
+ url: string;
9
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Describes the behaviour of the navigation stack when the step is presented.
2
+ * Describes the behavior of the navigation stack when the step is presented.
3
3
  * @experimental This feature may be changed in the future without notice.
4
4
  */
5
5
  export type NavigationStackBehavior = 'default' | 'remove-previous' | 'remove-all' | 'replace-current';
@@ -14,6 +14,7 @@ export type { Icon } from './misc/Icon';
14
14
  export type { Image } from './misc/Image';
15
15
  export type { Layout } from './layout/Layout';
16
16
  export type { AlertLayout } from './layout/AlertLayout';
17
+ export type { AlertLayoutCallToAction } from './layout/AlertLayoutCallToAction';
17
18
  export type { BoxLayout } from './layout/BoxLayout';
18
19
  export type { ButtonLayout } from './layout/ButtonLayout';
19
20
  export type { ColumnsLayout } from './layout/ColumnsLayout';
@@ -1,5 +1,6 @@
1
1
  import type { Context } from '../misc/Context';
2
2
  import type { Size } from '../misc/Size';
3
+ import type { AlertLayoutCallToAction } from './AlertLayoutCallToAction';
3
4
  /**
4
5
  * Show an attention-grabbing message.
5
6
  * Alerts can be used to communicate important messages to the user, drawing more attention than a standard paragraph or info layout.
@@ -26,4 +27,9 @@ export type AlertLayout = {
26
27
  * The vertical margin to apply above this component. Defaults to `md`.
27
28
  */
28
29
  margin?: Size;
30
+ /**
31
+ * A titled call to action which can be performed by the user.
32
+ * @experimental This feature may be changed in the future without notice.
33
+ */
34
+ callToAction?: AlertLayoutCallToAction;
29
35
  };
@@ -0,0 +1,18 @@
1
+ import type { Behavior } from '../feature/Behavior';
2
+ /**
3
+ * The call to action configuration to be used by the Alert.
4
+ */
5
+ export type AlertLayoutCallToAction = {
6
+ /**
7
+ * A user-facing title.
8
+ */
9
+ title: string;
10
+ /**
11
+ * A description of the call to action to be used by screen readers.
12
+ */
13
+ accessibilityDescription?: string;
14
+ /**
15
+ * Behavior that should be performed when user interacts with call to action.
16
+ */
17
+ behavior: Behavior;
18
+ };
@@ -10,7 +10,7 @@ import type { Navigation } from '../feature/Navigation';
10
10
  /**
11
11
  * A step represents a single screen in a flow. It is made up of schemas, which represent data to be collected from the
12
12
  * user, layouts which describe how the screen looks, and a number of advanced features to provide more complex
13
- * behaviours.
13
+ * behaviors.
14
14
  * ### Step Response
15
15
  * A response is determined to be a Step when the status code is in the 200-299 range, the `exit` property in the triggering action was not set to `true`, and the `X-DF-Response-Type: step` header is provided.
16
16
  */
@@ -40,10 +40,6 @@ export type Step = {
40
40
  */
41
41
  title: string;
42
42
  /**
43
- * A user-facing subtitle.
44
- */
45
- description?: string;
46
- /**
47
43
  * An array of schemas describing the data for the user to input. Each root schemas which should be displayed to the
48
44
  * user must be referenced by a [com.wise.dynamicflow.layout.FormLayout] in the `layout` property. If a schema is
49
45
  * not referenced by a [com.wise.dynamicflow.layout.FormLayout], it won't be displayed, but it will still be submitted.
@@ -56,6 +52,10 @@ export type Step = {
56
52
  */
57
53
  layout: Layout[];
58
54
  /**
55
+ * A user-facing subtitle.
56
+ */
57
+ description?: string;
58
+ /**
59
59
  * The data to use when initialising the step. It must follow the structure the schemas array describes, and any
60
60
  * data which doesn't correspond to the schema is ignored.
61
61
  */
@@ -65,7 +65,7 @@ export type Step = {
65
65
  */
66
66
  external?: External;
67
67
  /**
68
- * Used to configure a polling behaviour, allowing the flow to progress automatically.
68
+ * Used to configure a polling behavior, allowing the flow to progress automatically.
69
69
  */
70
70
  polling?: Polling;
71
71
  /**
@@ -82,7 +82,7 @@ export type Step = {
82
82
  */
83
83
  errors?: StepError;
84
84
  /**
85
- * Used to configure navigational behaviour of the step, for example to provide an
85
+ * Used to configure navigational behavior of the step, for example to provide an
86
86
  * [com.wise.dynamicflow.feature.Action] to perform when navigating back.
87
87
  */
88
88
  navigation?: Navigation;
@@ -28,6 +28,18 @@ export type ReviewCallToAction = {
28
28
  title: string;
29
29
  onClick: () => void;
30
30
  };
31
+ export type AlertCallToActionLink = {
32
+ type: 'link';
33
+ accessibilityDescription?: string;
34
+ href: string;
35
+ title: string;
36
+ };
37
+ export type AlertCallToAction = {
38
+ type: 'action';
39
+ accessibilityDescription?: string;
40
+ title: string;
41
+ onClick: () => void;
42
+ };
31
43
  export type ReviewField = {
32
44
  help?: string;
33
45
  label: string;
@@ -71,6 +83,7 @@ export type AlertRendererProps = {
71
83
  context: Context;
72
84
  margin: Margin;
73
85
  markdown: string;
86
+ callToAction?: AlertCallToAction | AlertCallToActionLink;
74
87
  };
75
88
  export type BoxRendererProps = {
76
89
  type: 'box';
@@ -2,11 +2,17 @@ import type { Action } from './Action';
2
2
  import type { ExternalStepPollingConfiguration, ExternalStepPollingResponseHandler } from './Polling';
3
3
  import type { Schema } from './Schema';
4
4
  import type { SearchConfig } from './Search';
5
- import type { Margin, Size, Icon, Image, Align, Orientation, Reference, Alert, Help } from './core';
5
+ import type { Margin, Size, Icon, Image, Align, Orientation, Reference, Alert, Help, Behavior } from './core';
6
6
  export type LayoutComponent = AlertLayout | BoxLayout | ButtonLayout | ColumnsLayout | DecisionLayout | DividerLayout | ExternalLayout | FormLayout | HeadingLayout | ImageLayout | InfoLayout | InstructionsLayout | ListLayout | LoadingIndicatorLayout | MarkdownLayout | ModalLayout | ParagraphLayout | ReviewLayout | StatusListLayout | SearchLayout;
7
- export type AlertLayout = {
7
+ export type AlertLayoutCallToAction = {
8
+ title: string;
9
+ accessibilityDescription?: string;
10
+ behavior: Behavior;
11
+ };
12
+ export type AlertLayout = Alert & {
8
13
  type: 'alert';
9
- } & Alert;
14
+ callToAction?: AlertLayoutCallToAction;
15
+ };
10
16
  export type BoxLayout = {
11
17
  type: 'box';
12
18
  components: LayoutComponent[];
@@ -1,3 +1,4 @@
1
+ import { Action } from './Action';
1
2
  export type Image = {
2
3
  type?: 'image';
3
4
  url: string;
@@ -31,3 +32,10 @@ export type Alert = {
31
32
  export type Help = {
32
33
  markdown: string;
33
34
  };
35
+ export type Behavior = {
36
+ action?: Action;
37
+ link?: Link;
38
+ };
39
+ export type Link = {
40
+ url: string;
41
+ };