@asgardeo/react 0.15.1 → 0.15.2

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/dist/index.js CHANGED
@@ -12100,6 +12100,7 @@ var BaseAcceptInvite = ({
12100
12100
  delete newErrors[name];
12101
12101
  return newErrors;
12102
12102
  });
12103
+ setIsFormValid(true);
12103
12104
  }, []);
12104
12105
  const handleInputBlur = useCallback15((name) => {
12105
12106
  setTouchedFields((prev) => ({ ...prev, [name]: true }));
@@ -12112,7 +12113,7 @@ var BaseAcceptInvite = ({
12112
12113
  if ((comp.type === "PASSWORD_INPUT" || comp.type === "TEXT_INPUT" || comp.type === "EMAIL_INPUT") && comp.required && comp.ref) {
12113
12114
  const value = formValues[comp.ref];
12114
12115
  if (!value || value.trim() === "") {
12115
- errors[comp.ref] = `${comp.label || comp.ref} is required`;
12116
+ errors[comp.ref] = t("validations.required.field.error");
12116
12117
  }
12117
12118
  }
12118
12119
  if (comp.components && Array.isArray(comp.components)) {
@@ -12123,7 +12124,7 @@ var BaseAcceptInvite = ({
12123
12124
  validateComponents(components2);
12124
12125
  return { errors, isValid: Object.keys(errors).length === 0 };
12125
12126
  },
12126
- [formValues]
12127
+ [formValues, t]
12127
12128
  );
12128
12129
  const handleSubmit = useCallback15(
12129
12130
  async (component, data) => {
@@ -12133,8 +12134,8 @@ var BaseAcceptInvite = ({
12133
12134
  const components2 = currentFlow.data?.components || [];
12134
12135
  const validation = validateForm(components2);
12135
12136
  if (!validation.isValid) {
12136
- setFormErrors(validation.errors);
12137
12137
  setIsFormValid(false);
12138
+ setFormErrors(validation.errors);
12138
12139
  const touched = {};
12139
12140
  Object.keys(validation.errors).forEach((key) => {
12140
12141
  touched[key] = true;
@@ -12144,7 +12145,6 @@ var BaseAcceptInvite = ({
12144
12145
  }
12145
12146
  setIsLoading(true);
12146
12147
  setApiError(null);
12147
- setIsFormValid(true);
12148
12148
  try {
12149
12149
  const inputs = data || formValues;
12150
12150
  const payload = {
@@ -12184,7 +12184,6 @@ var BaseAcceptInvite = ({
12184
12184
  return;
12185
12185
  }
12186
12186
  setCurrentFlow(response);
12187
- setFormValues({});
12188
12187
  setFormErrors({});
12189
12188
  setTouchedFields({});
12190
12189
  } catch (err) {
@@ -12266,35 +12265,6 @@ var BaseAcceptInvite = ({
12266
12265
  ),
12267
12266
  []
12268
12267
  );
12269
- const renderComponents = useCallback15(
12270
- (components2) => renderInviteUserComponents(
12271
- components2,
12272
- formValues,
12273
- touchedFields,
12274
- formErrors,
12275
- isLoading,
12276
- isFormValid,
12277
- handleInputChange,
12278
- {
12279
- onInputBlur: handleInputBlur,
12280
- onSubmit: handleSubmit,
12281
- size,
12282
- variant
12283
- }
12284
- ),
12285
- [
12286
- formValues,
12287
- touchedFields,
12288
- formErrors,
12289
- isLoading,
12290
- isFormValid,
12291
- handleInputChange,
12292
- handleInputBlur,
12293
- handleSubmit,
12294
- size,
12295
- variant
12296
- ]
12297
- );
12298
12268
  const components = currentFlow?.data?.components || currentFlow?.data?.meta?.components || [];
12299
12269
  const { title, subtitle } = extractHeadings(components);
12300
12270
  const componentsWithoutHeadings = filterHeadings(components);
@@ -12358,7 +12328,21 @@ var BaseAcceptInvite = ({
12358
12328
  /* @__PURE__ */ jsxs34(Card_default.Content, { children: [
12359
12329
  apiError && /* @__PURE__ */ jsx85("div", { style: { marginBottom: "1rem" }, children: /* @__PURE__ */ jsx85(Alert_default, { variant: "error", children: /* @__PURE__ */ jsx85(Alert_default.Description, { children: apiError.message }) }) }),
12360
12330
  /* @__PURE__ */ jsxs34("div", { children: [
12361
- componentsWithoutHeadings && componentsWithoutHeadings.length > 0 ? renderComponents(componentsWithoutHeadings) : !isLoading && /* @__PURE__ */ jsx85(Alert_default, { variant: "warning", children: /* @__PURE__ */ jsx85(Typography_default, { variant: "body1", children: "No form components available" }) }),
12331
+ componentsWithoutHeadings && componentsWithoutHeadings.length > 0 ? renderInviteUserComponents(
12332
+ componentsWithoutHeadings,
12333
+ formValues,
12334
+ touchedFields,
12335
+ formErrors,
12336
+ isLoading,
12337
+ isFormValid,
12338
+ handleInputChange,
12339
+ {
12340
+ onInputBlur: handleInputBlur,
12341
+ onSubmit: handleSubmit,
12342
+ size,
12343
+ variant
12344
+ }
12345
+ ) : !isLoading && /* @__PURE__ */ jsx85(Alert_default, { variant: "warning", children: /* @__PURE__ */ jsx85(Typography_default, { variant: "body1", children: "No form components available" }) }),
12362
12346
  isLoading && /* @__PURE__ */ jsx85("div", { style: { display: "flex", justifyContent: "center", padding: "1rem" }, children: /* @__PURE__ */ jsx85(Spinner_default, { size: "small" }) })
12363
12347
  ] }),
12364
12348
  onGoToSignIn && /* @__PURE__ */ jsx85("div", { style: { marginTop: "1.5rem", textAlign: "center" }, children: /* @__PURE__ */ jsxs34(Typography_default, { variant: "body2", children: [