@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.
@@ -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
@@ -3824,6 +3824,7 @@ var Select = ({
3824
3824
  required,
3825
3825
  disabled,
3826
3826
  helperText,
3827
+ placeholder,
3827
3828
  options,
3828
3829
  style = {},
3829
3830
  ...rest
@@ -3846,7 +3847,7 @@ var Select = ({
3846
3847
  style,
3847
3848
  children: [
3848
3849
  label && /* @__PURE__ */ jsx23(InputLabel_default, { required, error: hasError, children: label }),
3849
- /* @__PURE__ */ jsx23(
3850
+ /* @__PURE__ */ jsxs5(
3850
3851
  "select",
3851
3852
  {
3852
3853
  className: selectClassName,
@@ -3854,7 +3855,10 @@ var Select = ({
3854
3855
  "aria-invalid": hasError,
3855
3856
  "aria-required": required,
3856
3857
  ...rest,
3857
- 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
+ ]
3858
3862
  }
3859
3863
  )
3860
3864
  ]
@@ -7089,6 +7093,32 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
7089
7093
  case EmbeddedFlowComponentType.Divider: {
7090
7094
  return /* @__PURE__ */ jsx55(Divider_default, { children: component.label || "" }, key);
7091
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
+ }
7092
7122
  case EmbeddedFlowComponentType.Block: {
7093
7123
  if (component.components && component.components.length > 0) {
7094
7124
  const blockComponents = component.components.map(
@@ -7232,12 +7262,25 @@ var createActionRefMapping = (response) => {
7232
7262
  }
7233
7263
  return mapping;
7234
7264
  };
7235
- var applyInputRefMapping = (components, refMapping, actionMapping) => {
7265
+ var applyInputRefMapping = (components, refMapping, actionMapping, inputsData = []) => {
7236
7266
  return components.map((component) => {
7237
7267
  const transformedComponent = { ...component };
7238
7268
  if (transformedComponent.ref && refMapping.has(transformedComponent.ref)) {
7239
7269
  transformedComponent.ref = refMapping.get(transformedComponent.ref);
7240
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
+ }
7241
7284
  if (transformedComponent.type === "ACTION" && transformedComponent.id && actionMapping.has(transformedComponent.id)) {
7242
7285
  transformedComponent.actionRef = actionMapping.get(transformedComponent.id);
7243
7286
  }
@@ -7245,7 +7288,8 @@ var applyInputRefMapping = (components, refMapping, actionMapping) => {
7245
7288
  transformedComponent.components = applyInputRefMapping(
7246
7289
  transformedComponent.components,
7247
7290
  refMapping,
7248
- actionMapping
7291
+ actionMapping,
7292
+ inputsData
7249
7293
  );
7250
7294
  }
7251
7295
  return transformedComponent;
@@ -7258,8 +7302,9 @@ var transformComponents = (response, t, resolveTranslations = true) => {
7258
7302
  let components = response.data.meta.components;
7259
7303
  const refMapping = createInputRefMapping(response);
7260
7304
  const actionMapping = createActionRefMapping(response);
7261
- if (refMapping.size > 0 || actionMapping.size > 0) {
7262
- 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);
7263
7308
  }
7264
7309
  return resolveTranslations ? resolveTranslationsInArray_default(components, t) : components;
7265
7310
  };
@@ -9187,7 +9232,7 @@ var BaseSignUpContent2 = ({
9187
9232
  const fields = [];
9188
9233
  const processComponents = (comps) => {
9189
9234
  comps.forEach((component) => {
9190
- 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) {
9191
9236
  const fieldName = component.ref || component.id;
9192
9237
  fields.push({
9193
9238
  name: fieldName,