@wise/dynamic-flow-client 2.1.3 → 2.1.5
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.js +61 -33
- package/build/main.min.js +1 -1
- package/build/types/formControl/FormControl.d.ts +1 -0
- package/build/types/jsonSchemaForm/controlFeedback/ControlFeedback.d.ts +1 -0
- package/build/types/jsonSchemaForm/schemaFormControl/SchemaFormControl.d.ts +1 -0
- package/package.json +2 -2
package/build/main.js
CHANGED
|
@@ -1415,9 +1415,6 @@ function isValidBlobSchema(value, schema) {
|
|
|
1415
1415
|
return !getBlobValidationFailures(value, schema).length;
|
|
1416
1416
|
}
|
|
1417
1417
|
function isValidSchema(value, schema) {
|
|
1418
|
-
if (schema.hidden) {
|
|
1419
|
-
return true;
|
|
1420
|
-
}
|
|
1421
1418
|
if (schema.oneOf) {
|
|
1422
1419
|
return isValidOneOfSchema(value, schema);
|
|
1423
1420
|
}
|
|
@@ -2553,7 +2550,7 @@ var ControlFeedback = (props) => {
|
|
|
2553
2550
|
const isValidationVisible = !isErrorVisible && (props.submitted || props.changed && props.blurred) && !!((_a = props.validations) == null ? void 0 : _a.length);
|
|
2554
2551
|
const isDescriptionVisible = props.focused && props.schema.description && !isValidationVisible;
|
|
2555
2552
|
const hasInfoMessage = !!props.infoMessage;
|
|
2556
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
|
|
2553
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { id: props.id, children: [
|
|
2557
2554
|
isErrorVisible ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_components6.InlineAlert, { type: "error", children: props.errors }) : null,
|
|
2558
2555
|
isValidationVisible ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_components6.InlineAlert, { type: "error", children: props.validations.map((validation) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: validationMessages[validation] }, validation)) }) : null,
|
|
2559
2556
|
(isDescriptionVisible || hasInfoMessage) && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_components6.InlineAlert, { type: "info", children: [
|
|
@@ -2761,12 +2758,14 @@ var MultipleFileUploadSchema = (props) => {
|
|
|
2761
2758
|
onFilesChange,
|
|
2762
2759
|
onDeleteFile: () => Promise.resolve()
|
|
2763
2760
|
});
|
|
2761
|
+
const feedbackId = `${uid}-feedback`;
|
|
2764
2762
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: (0, import_classnames2.default)("form-group", { "has-error": showError }), children: [
|
|
2765
2763
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { className: "d-block control-label", htmlFor: uid, children: props.schema.title }),
|
|
2766
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components7.UploadInput, __spreadValues({}, uploadInputProps)),
|
|
2764
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { "aria-describedby": feedbackId, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components7.UploadInput, __spreadValues({}, uploadInputProps)) }),
|
|
2767
2765
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2768
2766
|
ControlFeedback_default,
|
|
2769
2767
|
{
|
|
2768
|
+
id: feedbackId,
|
|
2770
2769
|
changed: inputChanged,
|
|
2771
2770
|
submitted: props.submitted,
|
|
2772
2771
|
errors: props.errors,
|
|
@@ -3555,7 +3554,8 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3555
3554
|
minDate,
|
|
3556
3555
|
maxDate,
|
|
3557
3556
|
value,
|
|
3558
|
-
mode
|
|
3557
|
+
mode,
|
|
3558
|
+
describedBy
|
|
3559
3559
|
} = this.props;
|
|
3560
3560
|
switch (type) {
|
|
3561
3561
|
case FormControlType.RADIO:
|
|
@@ -3652,7 +3652,8 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3652
3652
|
if (event.target instanceof HTMLElement) {
|
|
3653
3653
|
event.target.blur();
|
|
3654
3654
|
}
|
|
3655
|
-
}
|
|
3655
|
+
},
|
|
3656
|
+
"aria-describedby": describedBy
|
|
3656
3657
|
}
|
|
3657
3658
|
);
|
|
3658
3659
|
case FormControlType.HIDDEN:
|
|
@@ -3680,7 +3681,8 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3680
3681
|
value: getSafeStringValue(value, { coerceValue: true }),
|
|
3681
3682
|
onBlur: this.handleOnBlur,
|
|
3682
3683
|
onChange: this.handleInputOnChange,
|
|
3683
|
-
onFocus: this.handleOnFocus
|
|
3684
|
+
onFocus: this.handleOnFocus,
|
|
3685
|
+
"aria-describedby": describedBy
|
|
3684
3686
|
}
|
|
3685
3687
|
);
|
|
3686
3688
|
case FormControlType.DATE:
|
|
@@ -3758,7 +3760,13 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3758
3760
|
})
|
|
3759
3761
|
);
|
|
3760
3762
|
}
|
|
3761
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3763
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3764
|
+
"textarea",
|
|
3765
|
+
__spreadProps(__spreadValues({}, textareaProps), {
|
|
3766
|
+
onChange: this.handleInputOnChange,
|
|
3767
|
+
"aria-describedby": describedBy
|
|
3768
|
+
})
|
|
3769
|
+
);
|
|
3762
3770
|
}
|
|
3763
3771
|
case FormControlType.FILE:
|
|
3764
3772
|
case FormControlType.UPLOAD: {
|
|
@@ -3811,7 +3819,13 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3811
3819
|
})
|
|
3812
3820
|
);
|
|
3813
3821
|
}
|
|
3814
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3823
|
+
"input",
|
|
3824
|
+
__spreadProps(__spreadValues({}, inputProps), {
|
|
3825
|
+
onChange: this.handleInputOnChange,
|
|
3826
|
+
"aria-describedby": describedBy
|
|
3827
|
+
})
|
|
3828
|
+
);
|
|
3815
3829
|
}
|
|
3816
3830
|
}
|
|
3817
3831
|
}
|
|
@@ -3980,7 +3994,7 @@ var getOptions = (schema, controlType) => {
|
|
|
3980
3994
|
return null;
|
|
3981
3995
|
};
|
|
3982
3996
|
var SchemaFormControl = (props) => {
|
|
3983
|
-
const { id, schema, value, disabled, onChange, onFocus, onBlur, onSearchChange } = props;
|
|
3997
|
+
const { id, schema, value, disabled, onChange, onFocus, onBlur, onSearchChange, describedBy } = props;
|
|
3984
3998
|
const log = useLogger();
|
|
3985
3999
|
const getSanitisedValue = (value2) => isNativeInput(schema.type) && (isNull(value2) || isUndefined(value2)) ? "" : value2;
|
|
3986
4000
|
const onModelChange = (value2, type) => {
|
|
@@ -4008,9 +4022,10 @@ var SchemaFormControl = (props) => {
|
|
|
4008
4022
|
disabled: disabled || schema.disabled,
|
|
4009
4023
|
displayPattern: schema.displayFormat,
|
|
4010
4024
|
// TODO: LOW avoid type assertion below
|
|
4011
|
-
uploadProps: mapSchemaToUploadOptions(schema)
|
|
4025
|
+
uploadProps: mapSchemaToUploadOptions(schema),
|
|
4026
|
+
describedBy
|
|
4012
4027
|
};
|
|
4013
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FormControl, __spreadValues(__spreadValues({ type: controlType, value: safeValue }, events), controlProps));
|
|
4028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-describedby": describedBy, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FormControl, __spreadValues(__spreadValues({ type: controlType, value: safeValue }, events), controlProps)) });
|
|
4014
4029
|
};
|
|
4015
4030
|
SchemaFormControl.defaultProps = {
|
|
4016
4031
|
value: null,
|
|
@@ -4112,6 +4127,7 @@ var OneOfSchema = (props) => {
|
|
|
4112
4127
|
"form-group": true,
|
|
4113
4128
|
"has-error": !changed && props.errors && !isEmpty(props.errors) || (props.submitted || changed && blurred) && validations.length
|
|
4114
4129
|
};
|
|
4130
|
+
const feedbackId = `${id}-feedback`;
|
|
4115
4131
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
|
|
4116
4132
|
(props.schema.oneOf.length > 1 || isConstSchema(props.schema.oneOf[0])) && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
|
|
4117
4133
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: (0, import_classnames4.default)(formGroupClasses), children: [
|
|
@@ -4126,12 +4142,14 @@ var OneOfSchema = (props) => {
|
|
|
4126
4142
|
onChange: onChooseNewSchema,
|
|
4127
4143
|
onFocus,
|
|
4128
4144
|
onBlur,
|
|
4129
|
-
onSearchChange
|
|
4145
|
+
onSearchChange,
|
|
4146
|
+
describedBy: feedbackId
|
|
4130
4147
|
}
|
|
4131
4148
|
),
|
|
4132
4149
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4133
4150
|
ControlFeedback_default,
|
|
4134
4151
|
{
|
|
4152
|
+
id: feedbackId,
|
|
4135
4153
|
changed,
|
|
4136
4154
|
focused,
|
|
4137
4155
|
blurred,
|
|
@@ -4282,8 +4300,8 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
4282
4300
|
(0, import_react18.useEffect)(refreshValidations, [props.model, props.submitted]);
|
|
4283
4301
|
const onSuccess = async (httpResponse, _fileName) => {
|
|
4284
4302
|
const jsonResponse = await httpResponse.json();
|
|
4285
|
-
const
|
|
4286
|
-
props.onChange({ model:
|
|
4303
|
+
const id2 = getIdFromResponse(props.schema.persistAsync.idProperty, jsonResponse);
|
|
4304
|
+
props.onChange({ model: id2, triggerSchema: props.schema, triggerModel: id2 });
|
|
4287
4305
|
setChanged(true);
|
|
4288
4306
|
onEvent("Dynamic Flow - PersistAsync", { status: "success", schemaId: props.schema.$id });
|
|
4289
4307
|
};
|
|
@@ -4308,11 +4326,13 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
4308
4326
|
"form-group": true,
|
|
4309
4327
|
"has-error": (props.submitted || changed) && !!combinedValidations.length
|
|
4310
4328
|
};
|
|
4329
|
+
const id = props.schema.$id || props.schema.persistAsync.schema.$id || props.schema.persistAsync.idProperty;
|
|
4330
|
+
const feedbackId = `${id}-feedback`;
|
|
4311
4331
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: (0, import_classnames5.default)(formGroupClasses), children: [
|
|
4312
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4332
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { "aria-describedby": feedbackId, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4313
4333
|
UploadInputAdapter,
|
|
4314
4334
|
__spreadValues({
|
|
4315
|
-
id
|
|
4335
|
+
id,
|
|
4316
4336
|
fileId: props.model,
|
|
4317
4337
|
idProperty: props.schema.persistAsync.idProperty,
|
|
4318
4338
|
animationDelay: 0,
|
|
@@ -4325,10 +4345,11 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
4325
4345
|
onFailure,
|
|
4326
4346
|
onCancel
|
|
4327
4347
|
}, mapSchemaToUploadOptions(props.schema.persistAsync.schema))
|
|
4328
|
-
),
|
|
4348
|
+
) }),
|
|
4329
4349
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4330
4350
|
ControlFeedback_default,
|
|
4331
4351
|
{
|
|
4352
|
+
id: feedbackId,
|
|
4332
4353
|
blurred: true,
|
|
4333
4354
|
focused: false,
|
|
4334
4355
|
changed,
|
|
@@ -5074,7 +5095,7 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
5074
5095
|
var _a;
|
|
5075
5096
|
(_a = navigator.clipboard) == null ? void 0 : _a.writeText(text).then(() => createSnackbar({ text: formatMessage(DynamicParagraph_messages_default.copied) })).catch(noop4);
|
|
5076
5097
|
};
|
|
5077
|
-
const classNames7 = getTextAlignmentAndMargin({ align: component.align
|
|
5098
|
+
const classNames7 = getTextAlignmentAndMargin({ align: component.align }) + " form-control";
|
|
5078
5099
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: getTextAlignmentAndMargin(component), children: [
|
|
5079
5100
|
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
5080
5101
|
"input",
|
|
@@ -5086,7 +5107,7 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
5086
5107
|
style: { textOverflow: "ellipsis" }
|
|
5087
5108
|
}
|
|
5088
5109
|
),
|
|
5089
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.Button, { block: true, onClick: copy, children: formatMessage(DynamicParagraph_messages_default.copy) })
|
|
5110
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.Button, { block: true, onClick: copy, className: getMargin("sm"), children: formatMessage(DynamicParagraph_messages_default.copy) })
|
|
5090
5111
|
] });
|
|
5091
5112
|
};
|
|
5092
5113
|
function noop4() {
|
|
@@ -5145,11 +5166,11 @@ var DynamicReview = (props) => {
|
|
|
5145
5166
|
};
|
|
5146
5167
|
const orientation = getReviewLayout(review);
|
|
5147
5168
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
5148
|
-
review.title && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("h6", { className:
|
|
5169
|
+
review.title && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("h6", { className: `m-b-2 ${margin}`, children: [
|
|
5149
5170
|
review.title,
|
|
5150
5171
|
review.action && getReviewAction(review.action)
|
|
5151
5172
|
] }),
|
|
5152
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: margin, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.DefinitionList, { layout: orientation, definitions: getDefinitions(orientation, review) }) })
|
|
5173
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: review.title ? "" : margin, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.DefinitionList, { layout: orientation, definitions: getDefinitions(orientation, review) }) })
|
|
5153
5174
|
] });
|
|
5154
5175
|
};
|
|
5155
5176
|
var DynamicReview_default = DynamicReview;
|
|
@@ -5407,6 +5428,7 @@ var BasicTypeSchema = (props) => {
|
|
|
5407
5428
|
};
|
|
5408
5429
|
const showLabel = props.schema.format !== "file" && props.schema.type !== "boolean";
|
|
5409
5430
|
const schemaHelp = props.schema.help;
|
|
5431
|
+
const feedbackId = `${id}-feedback`;
|
|
5410
5432
|
return !isHidden ? /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
|
|
5411
5433
|
props.schema.alert && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DynamicAlert_default, { component: props.schema.alert }),
|
|
5412
5434
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: (0, import_classnames6.default)(formGroupClasses), children: [
|
|
@@ -5424,12 +5446,14 @@ var BasicTypeSchema = (props) => {
|
|
|
5424
5446
|
disabled: !!props.disabled,
|
|
5425
5447
|
onChange,
|
|
5426
5448
|
onFocus,
|
|
5427
|
-
onBlur
|
|
5449
|
+
onBlur,
|
|
5450
|
+
describedBy: feedbackId
|
|
5428
5451
|
}
|
|
5429
5452
|
),
|
|
5430
5453
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
5431
5454
|
ControlFeedback_default,
|
|
5432
5455
|
{
|
|
5456
|
+
id: feedbackId,
|
|
5433
5457
|
changed,
|
|
5434
5458
|
focused,
|
|
5435
5459
|
blurred,
|
|
@@ -6426,10 +6450,10 @@ var BackButton_default = BackButton;
|
|
|
6426
6450
|
// src/dynamicFlow/DynamicFlowStep.tsx
|
|
6427
6451
|
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
6428
6452
|
var DynamicFlowStep = (props) => {
|
|
6429
|
-
var _a, _b;
|
|
6453
|
+
var _a, _b, _c;
|
|
6430
6454
|
const { step, globalError, onAction } = props;
|
|
6431
6455
|
const externalUrl = (_a = step == null ? void 0 : step.external) == null ? void 0 : _a.url;
|
|
6432
|
-
const backButton = (_b = step == null ? void 0 : step.navigation) == null ? void 0 : _b.backButton;
|
|
6456
|
+
const backButton = ((_b = step == null ? void 0 : step.navigation) == null ? void 0 : _b.back) || ((_c = step == null ? void 0 : step.navigation) == null ? void 0 : _c.backButton);
|
|
6433
6457
|
const { requiresManualTrigger, dismissConfirmation } = useExternal(externalUrl);
|
|
6434
6458
|
if (step === void 0) {
|
|
6435
6459
|
return null;
|
|
@@ -6664,8 +6688,7 @@ var ErrorBoundary = class extends import_react40.Component {
|
|
|
6664
6688
|
var ErrorBoundary_default = ErrorBoundary;
|
|
6665
6689
|
|
|
6666
6690
|
// src/dynamicFlow/utils/responseParsers/response-parsers.ts
|
|
6667
|
-
var parseFetchResponseByResponseType = async (response) => {
|
|
6668
|
-
const type = response.headers.get("X-Df-ResponseType");
|
|
6691
|
+
var parseFetchResponseByResponseType = async (response, type) => {
|
|
6669
6692
|
switch (type) {
|
|
6670
6693
|
case "step":
|
|
6671
6694
|
return parseStepResponse(response);
|
|
@@ -6675,7 +6698,7 @@ var parseFetchResponseByResponseType = async (response) => {
|
|
|
6675
6698
|
return parseActionResponse(response);
|
|
6676
6699
|
default:
|
|
6677
6700
|
throw new Error(
|
|
6678
|
-
"Unsupported X-Df-
|
|
6701
|
+
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit'."
|
|
6679
6702
|
);
|
|
6680
6703
|
}
|
|
6681
6704
|
};
|
|
@@ -6707,12 +6730,17 @@ var parseExitResponse = async (response) => {
|
|
|
6707
6730
|
return { type: "exit", result: await getJsonObjectOrNull(response) };
|
|
6708
6731
|
};
|
|
6709
6732
|
var parseFetchResponse = async (response) => {
|
|
6710
|
-
var _a, _b;
|
|
6733
|
+
var _a, _b, _c;
|
|
6711
6734
|
assertResponseIsValid(response);
|
|
6712
|
-
if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-
|
|
6713
|
-
|
|
6735
|
+
if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
|
|
6736
|
+
const type = response.headers.get("X-Df-Response-Type");
|
|
6737
|
+
return parseFetchResponseByResponseType(response, type);
|
|
6738
|
+
}
|
|
6739
|
+
if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-ResponseType")) {
|
|
6740
|
+
const type = response.headers.get("X-Df-ResponseType");
|
|
6741
|
+
return parseFetchResponseByResponseType(response, type);
|
|
6714
6742
|
}
|
|
6715
|
-
if ((
|
|
6743
|
+
if ((_c = response.headers) == null ? void 0 : _c.has("X-Df-Exit")) {
|
|
6716
6744
|
return parseExitResponse(response);
|
|
6717
6745
|
}
|
|
6718
6746
|
const jsonBody = await parseResponseJson(response.clone());
|