@asgardeo/react 0.6.29 → 0.6.31

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.
@@ -51,6 +51,10 @@ export interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement
51
51
  * Helper text to display below the select
52
52
  */
53
53
  helperText?: string;
54
+ /**
55
+ * Placeholder text for the default/empty option
56
+ */
57
+ placeholder?: string;
54
58
  /**
55
59
  * The options to display in the select
56
60
  */
package/dist/index.js CHANGED
@@ -769,9 +769,7 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
769
769
  });
770
770
  }
771
771
  async signInSilently(options) {
772
- return this.withLoading(async () => {
773
- return this.asgardeo.signInSilently(options);
774
- });
772
+ return this.asgardeo.signInSilently(options);
775
773
  }
776
774
  async signOut(...args) {
777
775
  if (args[1] && typeof args[1] !== "function") {
@@ -3826,6 +3824,7 @@ var Select = ({
3826
3824
  required,
3827
3825
  disabled,
3828
3826
  helperText,
3827
+ placeholder,
3829
3828
  options,
3830
3829
  style = {},
3831
3830
  ...rest
@@ -3848,7 +3847,7 @@ var Select = ({
3848
3847
  style,
3849
3848
  children: [
3850
3849
  label && /* @__PURE__ */ jsx23(InputLabel_default, { required, error: hasError, children: label }),
3851
- /* @__PURE__ */ jsx23(
3850
+ /* @__PURE__ */ jsxs5(
3852
3851
  "select",
3853
3852
  {
3854
3853
  className: selectClassName,
@@ -3856,7 +3855,10 @@ var Select = ({
3856
3855
  "aria-invalid": hasError,
3857
3856
  "aria-required": required,
3858
3857
  ...rest,
3859
- children: options.map((option) => /* @__PURE__ */ jsx23("option", { value: option.value, className: styles.option, children: option.label }, option.value))
3858
+ children: [
3859
+ placeholder && /* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: placeholder }),
3860
+ options.map((option) => /* @__PURE__ */ jsx23("option", { value: option.value, className: styles.option, children: option.label }, option.value))
3861
+ ]
3860
3862
  }
3861
3863
  )
3862
3864
  ]
@@ -7091,6 +7093,32 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
7091
7093
  case EmbeddedFlowComponentType.Divider: {
7092
7094
  return /* @__PURE__ */ jsx55(Divider_default, { children: component.label || "" }, key);
7093
7095
  }
7096
+ case EmbeddedFlowComponentType.Select: {
7097
+ const identifier = component.ref;
7098
+ const value = formValues[identifier] || "";
7099
+ const isTouched = touchedFields[identifier] || false;
7100
+ const error = isTouched ? formErrors[identifier] : void 0;
7101
+ const selectOptions = (component.options || []).map((opt) => ({
7102
+ value: typeof opt === "string" ? opt : String(opt.value ?? ""),
7103
+ label: typeof opt === "string" ? opt : String(opt.label ?? opt.value ?? "")
7104
+ }));
7105
+ return /* @__PURE__ */ jsx55(
7106
+ Select_default,
7107
+ {
7108
+ name: identifier,
7109
+ label: component.label || "",
7110
+ placeholder: component.placeholder,
7111
+ required: component.required,
7112
+ options: selectOptions,
7113
+ value,
7114
+ error,
7115
+ onChange: (e) => onInputChange(identifier, e.target.value),
7116
+ onBlur: () => options.onInputBlur?.(identifier),
7117
+ className: options.inputClassName
7118
+ },
7119
+ key
7120
+ );
7121
+ }
7094
7122
  case EmbeddedFlowComponentType.Block: {
7095
7123
  if (component.components && component.components.length > 0) {
7096
7124
  const blockComponents = component.components.map(
@@ -7234,12 +7262,25 @@ var createActionRefMapping = (response) => {
7234
7262
  }
7235
7263
  return mapping;
7236
7264
  };
7237
- var applyInputRefMapping = (components, refMapping, actionMapping) => {
7265
+ var applyInputRefMapping = (components, refMapping, actionMapping, inputsData = []) => {
7238
7266
  return components.map((component) => {
7239
7267
  const transformedComponent = { ...component };
7240
7268
  if (transformedComponent.ref && refMapping.has(transformedComponent.ref)) {
7241
7269
  transformedComponent.ref = refMapping.get(transformedComponent.ref);
7242
7270
  }
7271
+ if (transformedComponent.type === "SELECT" && component.id) {
7272
+ const inputData = inputsData.find((input) => input.ref === component.id);
7273
+ if (inputData?.options) {
7274
+ transformedComponent.options = inputData.options.map((opt) => {
7275
+ if (typeof opt === "string") {
7276
+ return { value: opt, label: opt };
7277
+ }
7278
+ const value = typeof opt.value === "object" ? JSON.stringify(opt.value) : String(opt.value || "");
7279
+ const label = typeof opt.label === "object" ? JSON.stringify(opt.label) : String(opt.label || value);
7280
+ return { value, label };
7281
+ });
7282
+ }
7283
+ }
7243
7284
  if (transformedComponent.type === "ACTION" && transformedComponent.id && actionMapping.has(transformedComponent.id)) {
7244
7285
  transformedComponent.actionRef = actionMapping.get(transformedComponent.id);
7245
7286
  }
@@ -7247,7 +7288,8 @@ var applyInputRefMapping = (components, refMapping, actionMapping) => {
7247
7288
  transformedComponent.components = applyInputRefMapping(
7248
7289
  transformedComponent.components,
7249
7290
  refMapping,
7250
- actionMapping
7291
+ actionMapping,
7292
+ inputsData
7251
7293
  );
7252
7294
  }
7253
7295
  return transformedComponent;
@@ -7260,8 +7302,9 @@ var transformComponents = (response, t, resolveTranslations = true) => {
7260
7302
  let components = response.data.meta.components;
7261
7303
  const refMapping = createInputRefMapping(response);
7262
7304
  const actionMapping = createActionRefMapping(response);
7263
- if (refMapping.size > 0 || actionMapping.size > 0) {
7264
- components = applyInputRefMapping(components, refMapping, actionMapping);
7305
+ const inputsData = response?.data?.inputs || [];
7306
+ if (refMapping.size > 0 || actionMapping.size > 0 || inputsData.length > 0) {
7307
+ components = applyInputRefMapping(components, refMapping, actionMapping, inputsData);
7265
7308
  }
7266
7309
  return resolveTranslations ? resolveTranslationsInArray_default(components, t) : components;
7267
7310
  };
@@ -9189,7 +9232,7 @@ var BaseSignUpContent2 = ({
9189
9232
  const fields = [];
9190
9233
  const processComponents = (comps) => {
9191
9234
  comps.forEach((component) => {
9192
- if (component.type === EmbeddedFlowComponentType4.TextInput || component.type === EmbeddedFlowComponentType4.PasswordInput || component.type === EmbeddedFlowComponentType4.EmailInput) {
9235
+ if (component.type === EmbeddedFlowComponentType4.TextInput || component.type === EmbeddedFlowComponentType4.PasswordInput || component.type === EmbeddedFlowComponentType4.EmailInput || component.type === EmbeddedFlowComponentType4.Select) {
9193
9236
  const fieldName = component.ref || component.id;
9194
9237
  fields.push({
9195
9238
  name: fieldName,