@asgardeo/react 0.6.23 → 0.6.25

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
@@ -7029,9 +7029,12 @@ var getTypographyVariant = (variant) => {
7029
7029
  };
7030
7030
  return variantMap[variant] || "h3";
7031
7031
  };
7032
- var matchesSocialProvider = (actionId, eventType, buttonText, provider, authType) => {
7032
+ var matchesSocialProvider = (actionId, eventType, buttonText, provider, authType, componentVariant) => {
7033
7033
  const providerId = `${provider}_auth`;
7034
7034
  const providerMatches = actionId === providerId || eventType === providerId;
7035
+ if (componentVariant?.toUpperCase() === import_browser45.EmbeddedFlowActionVariantV2.Social) {
7036
+ return buttonText.toLowerCase().includes(provider);
7037
+ }
7035
7038
  if (authType === "signup") {
7036
7039
  return providerMatches || buttonText.toLowerCase().includes(provider);
7037
7040
  }
@@ -7066,6 +7069,11 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
7066
7069
  return import_react57.default.cloneElement(field, { key });
7067
7070
  }
7068
7071
  case import_browser45.EmbeddedFlowComponentTypeV2.Action: {
7072
+ const actionId = component.id;
7073
+ const eventType = component.eventType || "";
7074
+ const buttonText = component.label || "";
7075
+ const componentVariant = component.variant || "";
7076
+ const shouldSkipValidation = eventType.toUpperCase() === import_browser45.EmbeddedFlowEventTypeV2.Trigger;
7069
7077
  const handleClick = () => {
7070
7078
  if (options.onSubmit) {
7071
7079
  const formData = {};
@@ -7074,28 +7082,25 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
7074
7082
  formData[field] = formValues[field];
7075
7083
  }
7076
7084
  });
7077
- options.onSubmit(component, formData);
7085
+ options.onSubmit(component, formData, shouldSkipValidation);
7078
7086
  }
7079
7087
  };
7080
- const actionId = component.id;
7081
- const eventType = component.eventType || "";
7082
- const buttonText = component.label || "";
7083
- if (matchesSocialProvider(actionId, eventType, buttonText, "google", authType)) {
7088
+ if (matchesSocialProvider(actionId, eventType, buttonText, "google", authType, componentVariant)) {
7084
7089
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(GoogleButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
7085
7090
  }
7086
- if (matchesSocialProvider(actionId, eventType, buttonText, "github", authType)) {
7091
+ if (matchesSocialProvider(actionId, eventType, buttonText, "github", authType, componentVariant)) {
7087
7092
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(GitHubButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
7088
7093
  }
7089
- if (matchesSocialProvider(actionId, eventType, buttonText, "facebook", authType)) {
7094
+ if (matchesSocialProvider(actionId, eventType, buttonText, "facebook", authType, componentVariant)) {
7090
7095
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(FacebookButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
7091
7096
  }
7092
- if (matchesSocialProvider(actionId, eventType, buttonText, "microsoft", authType)) {
7097
+ if (matchesSocialProvider(actionId, eventType, buttonText, "microsoft", authType, componentVariant)) {
7093
7098
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(MicrosoftButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
7094
7099
  }
7095
- if (matchesSocialProvider(actionId, eventType, buttonText, "linkedin", authType)) {
7100
+ if (matchesSocialProvider(actionId, eventType, buttonText, "linkedin", authType, componentVariant)) {
7096
7101
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(LinkedInButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
7097
7102
  }
7098
- if (matchesSocialProvider(actionId, eventType, buttonText, "ethereum", authType)) {
7103
+ if (matchesSocialProvider(actionId, eventType, buttonText, "ethereum", authType, componentVariant)) {
7099
7104
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SignInWithEthereumButton_default, { onClick: handleClick, className: options.buttonClassName }, key);
7100
7105
  }
7101
7106
  if (actionId === "prompt_mobile" || eventType === "prompt_mobile") {
@@ -7119,6 +7124,9 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
7119
7124
  const variant = getTypographyVariant(component.variant);
7120
7125
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Typography_default, { variant, children: component.label || "" }, key);
7121
7126
  }
7127
+ case import_browser45.EmbeddedFlowComponentTypeV2.Divider: {
7128
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Divider_default, { children: component.label || "" }, key);
7129
+ }
7122
7130
  case import_browser45.EmbeddedFlowComponentTypeV2.Block: {
7123
7131
  if (component.components && component.components.length > 0) {
7124
7132
  const blockComponents = component.components.map(
@@ -7137,17 +7145,13 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
7137
7145
  }
7138
7146
  )
7139
7147
  ).filter(Boolean);
7140
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { children: blockComponents }, key);
7148
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("form", { id: component.id, children: blockComponents }, key);
7141
7149
  }
7142
7150
  return null;
7143
7151
  }
7144
7152
  default:
7145
- throw new import_browser45.AsgardeoRuntimeError(
7146
- `Unsupported component type: ${component.type}`,
7147
- `${authType === "signin" ? "SignIn" : "SignUp"}-UnsupportedComponentType-001`,
7148
- "react",
7149
- `Something went wrong while rendering the ${authType} component. Please try again later.`
7150
- );
7153
+ console.warn(`Unsupported component type: ${component.type}. Skipping render.`);
7154
+ return null;
7151
7155
  }
7152
7156
  };
7153
7157
  var renderSignInComponents = (components, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, options) => components.map(
@@ -7433,11 +7437,13 @@ var BaseSignInContent2 = ({
7433
7437
  const handleInputBlur = (name) => {
7434
7438
  setFormTouched(name, true);
7435
7439
  };
7436
- const handleSubmit = async (component, data) => {
7437
- touchAllFields();
7438
- const validation = validateForm();
7439
- if (!validation.isValid) {
7440
- return;
7440
+ const handleSubmit = async (component, data, skipValidation) => {
7441
+ if (!skipValidation) {
7442
+ touchAllFields();
7443
+ const validation = validateForm();
7444
+ if (!validation.isValid) {
7445
+ return;
7446
+ }
7441
7447
  }
7442
7448
  setIsSubmitting(true);
7443
7449
  clearMessages();
@@ -9218,10 +9224,17 @@ var BaseSignUpContent2 = ({
9218
9224
  setFormValue(name, value);
9219
9225
  setFormTouched(name, true);
9220
9226
  };
9221
- const handleSubmit = async (component, data) => {
9227
+ const handleSubmit = async (component, data, skipValidation) => {
9222
9228
  if (!currentFlow) {
9223
9229
  return;
9224
9230
  }
9231
+ if (!skipValidation) {
9232
+ touchAllFields();
9233
+ const validation = validateForm();
9234
+ if (!validation.isValid) {
9235
+ return;
9236
+ }
9237
+ }
9225
9238
  setIsLoading(true);
9226
9239
  clearMessages();
9227
9240
  try {