@asgardeo/react 0.6.22 → 0.6.24

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,7 +7145,7 @@ 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
  }
@@ -7244,12 +7252,12 @@ var resolveTranslationsInArray = (items, t, properties) => {
7244
7252
  var resolveTranslationsInArray_default = resolveTranslationsInArray;
7245
7253
 
7246
7254
  // src/utils/v2/flowTransformer.ts
7247
- var transformComponents = (response, t) => {
7255
+ var transformComponents = (response, t, resolveTranslations = true) => {
7248
7256
  if (!response?.data?.meta?.components) {
7249
7257
  return [];
7250
7258
  }
7251
7259
  const components = response.data.meta.components;
7252
- return resolveTranslationsInArray_default(components, t);
7260
+ return resolveTranslations ? resolveTranslationsInArray_default(components, t) : components;
7253
7261
  };
7254
7262
  var extractErrorMessage = (error, t, defaultErrorKey = "errors.flow.generic") => {
7255
7263
  if (error && typeof error === "object" && error.failureReason) {
@@ -7264,14 +7272,14 @@ var checkForErrorResponse = (response, t, defaultErrorKey = "errors.flow.generic
7264
7272
  return null;
7265
7273
  };
7266
7274
  var normalizeFlowResponse = (response, t, options = {}) => {
7267
- const { throwOnError = true, defaultErrorKey = "errors.flow.generic" } = options;
7275
+ const { throwOnError = true, defaultErrorKey = "errors.flow.generic", resolveTranslations = true } = options;
7268
7276
  const errorMessage = checkForErrorResponse(response, t, defaultErrorKey);
7269
7277
  if (errorMessage && throwOnError) {
7270
7278
  throw response;
7271
7279
  }
7272
7280
  return {
7273
7281
  flowId: response.flowId,
7274
- components: transformComponents(response, t)
7282
+ components: transformComponents(response, t, resolveTranslations)
7275
7283
  };
7276
7284
  };
7277
7285
 
@@ -7433,11 +7441,13 @@ var BaseSignInContent2 = ({
7433
7441
  const handleInputBlur = (name) => {
7434
7442
  setFormTouched(name, true);
7435
7443
  };
7436
- const handleSubmit = async (component, data) => {
7437
- touchAllFields();
7438
- const validation = validateForm();
7439
- if (!validation.isValid) {
7440
- return;
7444
+ const handleSubmit = async (component, data, skipValidation) => {
7445
+ if (!skipValidation) {
7446
+ touchAllFields();
7447
+ const validation = validateForm();
7448
+ if (!validation.isValid) {
7449
+ return;
7450
+ }
7441
7451
  }
7442
7452
  setIsSubmitting(true);
7443
7453
  clearMessages();
@@ -7732,7 +7742,9 @@ var SignIn = ({ className, size = "medium", onSuccess, onError, variant, childre
7732
7742
  if (handleRedirection(response)) {
7733
7743
  return;
7734
7744
  }
7735
- const { flowId, components: components2 } = normalizeFlowResponse(response, t);
7745
+ const { flowId, components: components2 } = normalizeFlowResponse(response, t, {
7746
+ resolveTranslations: !children
7747
+ });
7736
7748
  if (flowId && components2) {
7737
7749
  setFlowId(flowId);
7738
7750
  setComponents(components2);
@@ -7768,7 +7780,9 @@ var SignIn = ({ className, size = "medium", onSuccess, onError, variant, childre
7768
7780
  if (handleRedirection(response)) {
7769
7781
  return;
7770
7782
  }
7771
- const { flowId, components: components2 } = normalizeFlowResponse(response, t);
7783
+ const { flowId, components: components2 } = normalizeFlowResponse(response, t, {
7784
+ resolveTranslations: !children
7785
+ });
7772
7786
  if (response.flowStatus === import_browser48.EmbeddedSignInFlowStatusV2.Error) {
7773
7787
  console.error("[SignIn] Flow returned Error status, clearing flow state");
7774
7788
  clearFlowState();
@@ -9123,7 +9137,8 @@ var BaseSignUpContent2 = ({
9123
9137
  if (response?.data) {
9124
9138
  try {
9125
9139
  const { components } = normalizeFlowResponse(response, t, {
9126
- defaultErrorKey: "components.signUp.errors.generic"
9140
+ defaultErrorKey: "components.signUp.errors.generic",
9141
+ resolveTranslations: !children
9127
9142
  });
9128
9143
  return {
9129
9144
  ...response,
@@ -9138,7 +9153,7 @@ var BaseSignUpContent2 = ({
9138
9153
  }
9139
9154
  return response;
9140
9155
  },
9141
- [t]
9156
+ [t, children]
9142
9157
  );
9143
9158
  const extractFormFields = (0, import_react62.useCallback)(
9144
9159
  (components) => {
@@ -9213,10 +9228,17 @@ var BaseSignUpContent2 = ({
9213
9228
  setFormValue(name, value);
9214
9229
  setFormTouched(name, true);
9215
9230
  };
9216
- const handleSubmit = async (component, data) => {
9231
+ const handleSubmit = async (component, data, skipValidation) => {
9217
9232
  if (!currentFlow) {
9218
9233
  return;
9219
9234
  }
9235
+ if (!skipValidation) {
9236
+ touchAllFields();
9237
+ const validation = validateForm();
9238
+ if (!validation.isValid) {
9239
+ return;
9240
+ }
9241
+ }
9220
9242
  setIsLoading(true);
9221
9243
  clearMessages();
9222
9244
  try {