@asgardeo/react 0.15.0 → 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/cjs/index.js CHANGED
@@ -12137,6 +12137,7 @@ var BaseAcceptInvite = ({
12137
12137
  delete newErrors[name];
12138
12138
  return newErrors;
12139
12139
  });
12140
+ setIsFormValid(true);
12140
12141
  }, []);
12141
12142
  const handleInputBlur = (0, import_react73.useCallback)((name) => {
12142
12143
  setTouchedFields((prev) => ({ ...prev, [name]: true }));
@@ -12149,7 +12150,7 @@ var BaseAcceptInvite = ({
12149
12150
  if ((comp.type === "PASSWORD_INPUT" || comp.type === "TEXT_INPUT" || comp.type === "EMAIL_INPUT") && comp.required && comp.ref) {
12150
12151
  const value = formValues[comp.ref];
12151
12152
  if (!value || value.trim() === "") {
12152
- errors[comp.ref] = `${comp.label || comp.ref} is required`;
12153
+ errors[comp.ref] = t("validations.required.field.error");
12153
12154
  }
12154
12155
  }
12155
12156
  if (comp.components && Array.isArray(comp.components)) {
@@ -12160,7 +12161,7 @@ var BaseAcceptInvite = ({
12160
12161
  validateComponents(components2);
12161
12162
  return { errors, isValid: Object.keys(errors).length === 0 };
12162
12163
  },
12163
- [formValues]
12164
+ [formValues, t]
12164
12165
  );
12165
12166
  const handleSubmit = (0, import_react73.useCallback)(
12166
12167
  async (component, data) => {
@@ -12170,8 +12171,8 @@ var BaseAcceptInvite = ({
12170
12171
  const components2 = currentFlow.data?.components || [];
12171
12172
  const validation = validateForm(components2);
12172
12173
  if (!validation.isValid) {
12173
- setFormErrors(validation.errors);
12174
12174
  setIsFormValid(false);
12175
+ setFormErrors(validation.errors);
12175
12176
  const touched = {};
12176
12177
  Object.keys(validation.errors).forEach((key) => {
12177
12178
  touched[key] = true;
@@ -12181,7 +12182,6 @@ var BaseAcceptInvite = ({
12181
12182
  }
12182
12183
  setIsLoading(true);
12183
12184
  setApiError(null);
12184
- setIsFormValid(true);
12185
12185
  try {
12186
12186
  const inputs = data || formValues;
12187
12187
  const payload = {
@@ -12221,7 +12221,6 @@ var BaseAcceptInvite = ({
12221
12221
  return;
12222
12222
  }
12223
12223
  setCurrentFlow(response);
12224
- setFormValues({});
12225
12224
  setFormErrors({});
12226
12225
  setTouchedFields({});
12227
12226
  } catch (err) {
@@ -12303,35 +12302,6 @@ var BaseAcceptInvite = ({
12303
12302
  ),
12304
12303
  []
12305
12304
  );
12306
- const renderComponents = (0, import_react73.useCallback)(
12307
- (components2) => renderInviteUserComponents(
12308
- components2,
12309
- formValues,
12310
- touchedFields,
12311
- formErrors,
12312
- isLoading,
12313
- isFormValid,
12314
- handleInputChange,
12315
- {
12316
- onInputBlur: handleInputBlur,
12317
- onSubmit: handleSubmit,
12318
- size,
12319
- variant
12320
- }
12321
- ),
12322
- [
12323
- formValues,
12324
- touchedFields,
12325
- formErrors,
12326
- isLoading,
12327
- isFormValid,
12328
- handleInputChange,
12329
- handleInputBlur,
12330
- handleSubmit,
12331
- size,
12332
- variant
12333
- ]
12334
- );
12335
12305
  const components = currentFlow?.data?.components || currentFlow?.data?.meta?.components || [];
12336
12306
  const { title, subtitle } = extractHeadings(components);
12337
12307
  const componentsWithoutHeadings = filterHeadings(components);
@@ -12395,7 +12365,21 @@ var BaseAcceptInvite = ({
12395
12365
  /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(Card_default.Content, { children: [
12396
12366
  apiError && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { style: { marginBottom: "1rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Alert_default, { variant: "error", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Alert_default.Description, { children: apiError.message }) }) }),
12397
12367
  /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)("div", { children: [
12398
- componentsWithoutHeadings && componentsWithoutHeadings.length > 0 ? renderComponents(componentsWithoutHeadings) : !isLoading && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Alert_default, { variant: "warning", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Typography_default, { variant: "body1", children: "No form components available" }) }),
12368
+ componentsWithoutHeadings && componentsWithoutHeadings.length > 0 ? renderInviteUserComponents(
12369
+ componentsWithoutHeadings,
12370
+ formValues,
12371
+ touchedFields,
12372
+ formErrors,
12373
+ isLoading,
12374
+ isFormValid,
12375
+ handleInputChange,
12376
+ {
12377
+ onInputBlur: handleInputBlur,
12378
+ onSubmit: handleSubmit,
12379
+ size,
12380
+ variant
12381
+ }
12382
+ ) : !isLoading && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Alert_default, { variant: "warning", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Typography_default, { variant: "body1", children: "No form components available" }) }),
12399
12383
  isLoading && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { style: { display: "flex", justifyContent: "center", padding: "1rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Spinner_default, { size: "small" }) })
12400
12384
  ] }),
12401
12385
  onGoToSignIn && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { style: { marginTop: "1.5rem", textAlign: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(Typography_default, { variant: "body2", children: [