@asgardeo/react 0.6.30 → 0.7.0

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
@@ -3919,6 +3919,7 @@ var Select = ({
3919
3919
  required,
3920
3920
  disabled,
3921
3921
  helperText,
3922
+ placeholder,
3922
3923
  options,
3923
3924
  style = {},
3924
3925
  ...rest
@@ -3941,7 +3942,7 @@ var Select = ({
3941
3942
  style,
3942
3943
  children: [
3943
3944
  label && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(InputLabel_default, { required, error: hasError, children: label }),
3944
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3945
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
3945
3946
  "select",
3946
3947
  {
3947
3948
  className: selectClassName,
@@ -3949,7 +3950,10 @@ var Select = ({
3949
3950
  "aria-invalid": hasError,
3950
3951
  "aria-required": required,
3951
3952
  ...rest,
3952
- children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: option.value, className: styles.option, children: option.label }, option.value))
3953
+ children: [
3954
+ placeholder && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", disabled: true, children: placeholder }),
3955
+ options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: option.value, className: styles.option, children: option.label }, option.value))
3956
+ ]
3953
3957
  }
3954
3958
  )
3955
3959
  ]
@@ -7173,6 +7177,32 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
7173
7177
  case import_browser45.EmbeddedFlowComponentTypeV2.Divider: {
7174
7178
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Divider_default, { children: component.label || "" }, key);
7175
7179
  }
7180
+ case import_browser45.EmbeddedFlowComponentTypeV2.Select: {
7181
+ const identifier = component.ref;
7182
+ const value = formValues[identifier] || "";
7183
+ const isTouched = touchedFields[identifier] || false;
7184
+ const error = isTouched ? formErrors[identifier] : void 0;
7185
+ const selectOptions = (component.options || []).map((opt) => ({
7186
+ value: typeof opt === "string" ? opt : String(opt.value ?? ""),
7187
+ label: typeof opt === "string" ? opt : String(opt.label ?? opt.value ?? "")
7188
+ }));
7189
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7190
+ Select_default,
7191
+ {
7192
+ name: identifier,
7193
+ label: component.label || "",
7194
+ placeholder: component.placeholder,
7195
+ required: component.required,
7196
+ options: selectOptions,
7197
+ value,
7198
+ error,
7199
+ onChange: (e) => onInputChange(identifier, e.target.value),
7200
+ onBlur: () => options.onInputBlur?.(identifier),
7201
+ className: options.inputClassName
7202
+ },
7203
+ key
7204
+ );
7205
+ }
7176
7206
  case import_browser45.EmbeddedFlowComponentTypeV2.Block: {
7177
7207
  if (component.components && component.components.length > 0) {
7178
7208
  const blockComponents = component.components.map(
@@ -7316,12 +7346,25 @@ var createActionRefMapping = (response) => {
7316
7346
  }
7317
7347
  return mapping;
7318
7348
  };
7319
- var applyInputRefMapping = (components, refMapping, actionMapping) => {
7349
+ var applyInputRefMapping = (components, refMapping, actionMapping, inputsData = []) => {
7320
7350
  return components.map((component) => {
7321
7351
  const transformedComponent = { ...component };
7322
7352
  if (transformedComponent.ref && refMapping.has(transformedComponent.ref)) {
7323
7353
  transformedComponent.ref = refMapping.get(transformedComponent.ref);
7324
7354
  }
7355
+ if (transformedComponent.type === "SELECT" && component.id) {
7356
+ const inputData = inputsData.find((input) => input.ref === component.id);
7357
+ if (inputData?.options) {
7358
+ transformedComponent.options = inputData.options.map((opt) => {
7359
+ if (typeof opt === "string") {
7360
+ return { value: opt, label: opt };
7361
+ }
7362
+ const value = typeof opt.value === "object" ? JSON.stringify(opt.value) : String(opt.value || "");
7363
+ const label = typeof opt.label === "object" ? JSON.stringify(opt.label) : String(opt.label || value);
7364
+ return { value, label };
7365
+ });
7366
+ }
7367
+ }
7325
7368
  if (transformedComponent.type === "ACTION" && transformedComponent.id && actionMapping.has(transformedComponent.id)) {
7326
7369
  transformedComponent.actionRef = actionMapping.get(transformedComponent.id);
7327
7370
  }
@@ -7329,7 +7372,8 @@ var applyInputRefMapping = (components, refMapping, actionMapping) => {
7329
7372
  transformedComponent.components = applyInputRefMapping(
7330
7373
  transformedComponent.components,
7331
7374
  refMapping,
7332
- actionMapping
7375
+ actionMapping,
7376
+ inputsData
7333
7377
  );
7334
7378
  }
7335
7379
  return transformedComponent;
@@ -7342,8 +7386,9 @@ var transformComponents = (response, t, resolveTranslations = true) => {
7342
7386
  let components = response.data.meta.components;
7343
7387
  const refMapping = createInputRefMapping(response);
7344
7388
  const actionMapping = createActionRefMapping(response);
7345
- if (refMapping.size > 0 || actionMapping.size > 0) {
7346
- components = applyInputRefMapping(components, refMapping, actionMapping);
7389
+ const inputsData = response?.data?.inputs || [];
7390
+ if (refMapping.size > 0 || actionMapping.size > 0 || inputsData.length > 0) {
7391
+ components = applyInputRefMapping(components, refMapping, actionMapping, inputsData);
7347
7392
  }
7348
7393
  return resolveTranslations ? resolveTranslationsInArray_default(components, t) : components;
7349
7394
  };
@@ -9254,7 +9299,7 @@ var BaseSignUpContent2 = ({
9254
9299
  const fields = [];
9255
9300
  const processComponents = (comps) => {
9256
9301
  comps.forEach((component) => {
9257
- if (component.type === import_browser59.EmbeddedFlowComponentTypeV2.TextInput || component.type === import_browser59.EmbeddedFlowComponentTypeV2.PasswordInput || component.type === import_browser59.EmbeddedFlowComponentTypeV2.EmailInput) {
9302
+ if (component.type === import_browser59.EmbeddedFlowComponentTypeV2.TextInput || component.type === import_browser59.EmbeddedFlowComponentTypeV2.PasswordInput || component.type === import_browser59.EmbeddedFlowComponentTypeV2.EmailInput || component.type === import_browser59.EmbeddedFlowComponentTypeV2.Select) {
9258
9303
  const fieldName = component.ref || component.id;
9259
9304
  fields.push({
9260
9305
  name: fieldName,