@asgardeo/react 0.6.25 → 0.6.26

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
@@ -7042,9 +7042,6 @@ var matchesSocialProvider = (actionId, eventType, buttonText, provider, authType
7042
7042
  };
7043
7043
  var createAuthComponentFromFlow = (component, formValues, touchedFields, formErrors, isLoading, isFormValid, onInputChange, authType, options = {}) => {
7044
7044
  const key = options.key || component.id;
7045
- if (authType === "signin") {
7046
- console.log("Creating sign-in component for:", component);
7047
- }
7048
7045
  switch (component.type) {
7049
7046
  case import_browser45.EmbeddedFlowComponentTypeV2.TextInput:
7050
7047
  case import_browser45.EmbeddedFlowComponentTypeV2.PasswordInput:
@@ -7078,9 +7075,7 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
7078
7075
  if (options.onSubmit) {
7079
7076
  const formData = {};
7080
7077
  Object.keys(formValues).forEach((field) => {
7081
- if (formValues[field]) {
7082
- formData[field] = formValues[field];
7083
- }
7078
+ formData[field] = formValues[field];
7084
7079
  });
7085
7080
  options.onSubmit(component, formData, shouldSkipValidation);
7086
7081
  }
@@ -7248,11 +7243,57 @@ var resolveTranslationsInArray = (items, t, properties) => {
7248
7243
  var resolveTranslationsInArray_default = resolveTranslationsInArray;
7249
7244
 
7250
7245
  // src/utils/v2/flowTransformer.ts
7246
+ var createInputRefMapping = (response) => {
7247
+ const mapping = /* @__PURE__ */ new Map();
7248
+ if (response?.data?.inputs && Array.isArray(response.data.inputs)) {
7249
+ response.data.inputs.forEach((input) => {
7250
+ if (input.ref && input.identifier) {
7251
+ mapping.set(input.ref, input.identifier);
7252
+ }
7253
+ });
7254
+ }
7255
+ return mapping;
7256
+ };
7257
+ var createActionRefMapping = (response) => {
7258
+ const mapping = /* @__PURE__ */ new Map();
7259
+ if (response?.data?.actions && Array.isArray(response.data.actions)) {
7260
+ response.data.actions.forEach((action) => {
7261
+ if (action.ref && action.nextNode) {
7262
+ mapping.set(action.ref, action.nextNode);
7263
+ }
7264
+ });
7265
+ }
7266
+ return mapping;
7267
+ };
7268
+ var applyInputRefMapping = (components, refMapping, actionMapping) => {
7269
+ return components.map((component) => {
7270
+ const transformedComponent = { ...component };
7271
+ if (transformedComponent.ref && refMapping.has(transformedComponent.ref)) {
7272
+ transformedComponent.ref = refMapping.get(transformedComponent.ref);
7273
+ }
7274
+ if (transformedComponent.type === "ACTION" && transformedComponent.id && actionMapping.has(transformedComponent.id)) {
7275
+ transformedComponent.actionRef = actionMapping.get(transformedComponent.id);
7276
+ }
7277
+ if (transformedComponent.components && Array.isArray(transformedComponent.components)) {
7278
+ transformedComponent.components = applyInputRefMapping(
7279
+ transformedComponent.components,
7280
+ refMapping,
7281
+ actionMapping
7282
+ );
7283
+ }
7284
+ return transformedComponent;
7285
+ });
7286
+ };
7251
7287
  var transformComponents = (response, t, resolveTranslations = true) => {
7252
7288
  if (!response?.data?.meta?.components) {
7253
7289
  return [];
7254
7290
  }
7255
- const components = response.data.meta.components;
7291
+ let components = response.data.meta.components;
7292
+ const refMapping = createInputRefMapping(response);
7293
+ const actionMapping = createActionRefMapping(response);
7294
+ if (refMapping.size > 0 || actionMapping.size > 0) {
7295
+ components = applyInputRefMapping(components, refMapping, actionMapping);
7296
+ }
7256
7297
  return resolveTranslations ? resolveTranslationsInArray_default(components, t) : components;
7257
7298
  };
7258
7299
  var extractErrorMessage = (error, t, defaultErrorKey = "errors.flow.generic") => {
@@ -9157,8 +9198,9 @@ var BaseSignUpContent2 = ({
9157
9198
  const processComponents = (comps) => {
9158
9199
  comps.forEach((component) => {
9159
9200
  if (component.type === import_browser59.EmbeddedFlowComponentTypeV2.TextInput) {
9201
+ const fieldName = component.ref || component.id;
9160
9202
  fields.push({
9161
- name: component.id,
9203
+ name: fieldName,
9162
9204
  required: component.required || false,
9163
9205
  initialValue: "",
9164
9206
  validator: (value) => {
@@ -9249,7 +9291,7 @@ var BaseSignUpContent2 = ({
9249
9291
  const payload = {
9250
9292
  ...currentFlow.flowId && { flowId: currentFlow.flowId },
9251
9293
  flowType: currentFlow.flowType || "REGISTRATION",
9252
- ...component.id && { action: component.id },
9294
+ ...component.id && { actionId: component.id },
9253
9295
  inputs: filteredInputs
9254
9296
  };
9255
9297
  const rawResponse = await onSubmit(payload);