@wise/dynamic-flow-client 2.8.14 → 2.9.0-beta-5eeb4d.27

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 CHANGED
@@ -4587,65 +4587,68 @@ function UploadInputAdapter(props) {
4587
4587
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
4588
4588
  var import_jsx_runtime32 = require("react/jsx-runtime");
4589
4589
  function PersistAsyncBlobSchema(props) {
4590
+ const { model, schema, submitted, required, errors, onChange } = props;
4590
4591
  const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0, import_react19.useState)({});
4591
4592
  const [persistAsyncValidations, setPersistAsyncValidations] = (0, import_react19.useState)(null);
4592
4593
  const [validations, setValidations] = (0, import_react19.useState)([]);
4593
4594
  const [changed, setChanged] = (0, import_react19.useState)(false);
4594
4595
  const httpClient = useHttpClient();
4595
4596
  const onEvent = useEventDispatcher();
4596
- const refreshValidations = () => {
4597
- if (props.submitted) {
4598
- setValidations(getValidationFailures(props.model, props.schema, Boolean(props.required)));
4597
+ (0, import_react19.useEffect)(() => {
4598
+ console.log(submitted);
4599
+ if (submitted) {
4600
+ setValidations(getValidationFailures(model, schema, Boolean(required)));
4601
+ } else {
4602
+ setValidations([]);
4599
4603
  }
4600
- };
4601
- (0, import_react19.useEffect)(refreshValidations, [props.model, props.submitted]);
4604
+ }, [model, schema, submitted, required]);
4602
4605
  const onSuccess = async (httpResponse, _fileName) => {
4603
4606
  const jsonResponse = await httpResponse.json();
4604
- const id2 = getIdFromResponse(props.schema.persistAsync.idProperty, jsonResponse);
4605
- props.onChange({ model: id2, triggerSchema: props.schema, triggerModel: id2 });
4607
+ const id2 = getIdFromResponse(schema.persistAsync.idProperty, jsonResponse);
4608
+ onChange({ model: id2, triggerSchema: schema, triggerModel: id2 });
4606
4609
  setChanged(true);
4607
- onEvent("Dynamic Flow - PersistAsync", { status: "success", schemaId: props.schema.$id });
4610
+ onEvent("Dynamic Flow - PersistAsync", { status: "success", schemaId: schema.$id });
4608
4611
  };
4609
4612
  const onFailure = async (errorResponse) => {
4610
4613
  if (errorResponse.response && isStatus422(errorResponse.response.status)) {
4611
4614
  const jsonResponse = await errorResponse.response.json();
4612
4615
  setPersistAsyncValidationMessages(jsonResponse.validation || {});
4613
- setPersistAsyncValidations([props.schema.persistAsync.param]);
4616
+ setPersistAsyncValidations([schema.persistAsync.param]);
4614
4617
  }
4615
- props.onChange({ model: null, triggerSchema: props.schema, triggerModel: null });
4618
+ onChange({ model: null, triggerSchema: schema, triggerModel: null });
4616
4619
  setChanged(true);
4617
- onEvent("Dynamic Flow - PersistAsync", { status: "failure", schemaId: props.schema.$id });
4620
+ onEvent("Dynamic Flow - PersistAsync", { status: "failure", schemaId: schema.$id });
4618
4621
  };
4619
4622
  const onCancel = () => {
4620
4623
  setPersistAsyncValidations(null);
4621
- props.onChange({ model: null, triggerSchema: props.schema, triggerModel: null });
4624
+ onChange({ model: null, triggerSchema: schema, triggerModel: null });
4622
4625
  setChanged(true);
4623
4626
  };
4624
- const { url, method } = props.schema.persistAsync;
4627
+ const { url, method } = schema.persistAsync;
4625
4628
  const combinedValidations = persistAsyncValidations || validations;
4626
4629
  const formGroupClasses = {
4627
4630
  "form-group": true,
4628
- "has-error": (props.submitted || changed) && Boolean(combinedValidations.length)
4631
+ "has-error": (submitted || changed) && Boolean(combinedValidations.length)
4629
4632
  };
4630
- const id = props.schema.$id || props.schema.persistAsync.schema.$id || props.schema.persistAsync.idProperty;
4633
+ const id = schema.$id || schema.persistAsync.schema.$id || schema.persistAsync.idProperty;
4631
4634
  const feedbackId = `${id}-feedback`;
4632
4635
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: (0, import_classnames5.default)(formGroupClasses), children: [
4633
4636
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { "aria-describedby": feedbackId, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4634
4637
  UploadInputAdapter,
4635
4638
  __spreadValues({
4636
4639
  id,
4637
- fileId: props.model,
4638
- idProperty: props.schema.persistAsync.idProperty,
4640
+ fileId: model,
4641
+ idProperty: schema.persistAsync.idProperty,
4639
4642
  animationDelay: 0,
4640
- maxSize: props.schema.persistAsync.schema.maxSize,
4641
- usLabel: props.schema.title || props.schema.persistAsync.schema.title,
4642
- usPlaceholder: props.schema.description || props.schema.persistAsync.schema.description,
4643
- httpOptions: { url, method, fileInputName: props.schema.persistAsync.param },
4643
+ maxSize: schema.persistAsync.schema.maxSize,
4644
+ usLabel: schema.title || schema.persistAsync.schema.title,
4645
+ usPlaceholder: schema.description || schema.persistAsync.schema.description,
4646
+ httpOptions: { url, method, fileInputName: schema.persistAsync.param },
4644
4647
  httpClient,
4645
4648
  onSuccess,
4646
4649
  onFailure,
4647
4650
  onCancel
4648
- }, mapSchemaToUploadOptions(props.schema.persistAsync.schema))
4651
+ }, mapSchemaToUploadOptions(schema.persistAsync.schema))
4649
4652
  ) }),
4650
4653
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4651
4654
  ControlFeedback_default,
@@ -4654,9 +4657,9 @@ function PersistAsyncBlobSchema(props) {
4654
4657
  blurred: true,
4655
4658
  focused: false,
4656
4659
  changed,
4657
- submitted: props.submitted,
4658
- errors: props.errors,
4659
- schema: props.schema,
4660
+ submitted,
4661
+ errors,
4662
+ schema,
4660
4663
  validations: combinedValidations,
4661
4664
  validationMessages: __spreadValues({
4662
4665
  required: "Value is required..."