@thunderid/react 0.13.0 → 1.0.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.
Files changed (67) hide show
  1. package/dist/api/getUsersMeMeta.d.ts +22 -0
  2. package/dist/api/getUsersMeMeta.d.ts.map +1 -0
  3. package/dist/api/getUsersMeMeta.js +32 -0
  4. package/dist/api/getUsersMeMeta.js.map +1 -0
  5. package/dist/cjs/api/getUsersMeMeta.cjs +34 -0
  6. package/dist/cjs/api/getUsersMeMeta.cjs.map +1 -0
  7. package/dist/cjs/components/adapters/GoogleButton.cjs +425 -31
  8. package/dist/cjs/components/adapters/GoogleButton.cjs.map +1 -1
  9. package/dist/cjs/components/factories/FieldFactory.cjs +4 -1
  10. package/dist/cjs/components/factories/FieldFactory.cjs.map +1 -1
  11. package/dist/cjs/components/presentation/UserProfile/BaseUserProfile.cjs +91 -35
  12. package/dist/cjs/components/presentation/UserProfile/BaseUserProfile.cjs.map +1 -1
  13. package/dist/cjs/components/presentation/UserProfile/UserProfile.cjs +4 -2
  14. package/dist/cjs/components/presentation/UserProfile/UserProfile.cjs.map +1 -1
  15. package/dist/cjs/components/presentation/auth/AuthOptionFactory.cjs +5 -0
  16. package/dist/cjs/components/presentation/auth/AuthOptionFactory.cjs.map +1 -1
  17. package/dist/cjs/components/primitives/OtpField/OtpField.cjs +4 -3
  18. package/dist/cjs/components/primitives/OtpField/OtpField.cjs.map +1 -1
  19. package/dist/cjs/contexts/ThunderID/ThunderIDContext.cjs +1 -0
  20. package/dist/cjs/contexts/ThunderID/ThunderIDContext.cjs.map +1 -1
  21. package/dist/cjs/contexts/ThunderID/ThunderIDProvider.cjs +32 -13
  22. package/dist/cjs/contexts/ThunderID/ThunderIDProvider.cjs.map +1 -1
  23. package/dist/cjs/contexts/User/UserContext.cjs +2 -1
  24. package/dist/cjs/contexts/User/UserContext.cjs.map +1 -1
  25. package/dist/cjs/contexts/User/UserProvider.cjs +5 -3
  26. package/dist/cjs/contexts/User/UserProvider.cjs.map +1 -1
  27. package/dist/cjs/index.cjs +2 -0
  28. package/dist/components/adapters/GoogleButton.d.ts.map +1 -1
  29. package/dist/components/adapters/GoogleButton.js +425 -31
  30. package/dist/components/adapters/GoogleButton.js.map +1 -1
  31. package/dist/components/factories/FieldFactory.d.ts +8 -0
  32. package/dist/components/factories/FieldFactory.d.ts.map +1 -1
  33. package/dist/components/factories/FieldFactory.js +4 -1
  34. package/dist/components/factories/FieldFactory.js.map +1 -1
  35. package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +2 -1
  36. package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts.map +1 -1
  37. package/dist/components/presentation/UserProfile/BaseUserProfile.js +91 -35
  38. package/dist/components/presentation/UserProfile/BaseUserProfile.js.map +1 -1
  39. package/dist/components/presentation/UserProfile/UserProfile.d.ts.map +1 -1
  40. package/dist/components/presentation/UserProfile/UserProfile.js +5 -3
  41. package/dist/components/presentation/UserProfile/UserProfile.js.map +1 -1
  42. package/dist/components/presentation/auth/AuthOptionFactory.d.ts.map +1 -1
  43. package/dist/components/presentation/auth/AuthOptionFactory.js +5 -0
  44. package/dist/components/presentation/auth/AuthOptionFactory.js.map +1 -1
  45. package/dist/components/primitives/OtpField/OtpField.d.ts +4 -0
  46. package/dist/components/primitives/OtpField/OtpField.d.ts.map +1 -1
  47. package/dist/components/primitives/OtpField/OtpField.js +4 -3
  48. package/dist/components/primitives/OtpField/OtpField.js.map +1 -1
  49. package/dist/contexts/ThunderID/ThunderIDContext.d.ts +5 -1
  50. package/dist/contexts/ThunderID/ThunderIDContext.d.ts.map +1 -1
  51. package/dist/contexts/ThunderID/ThunderIDContext.js +1 -0
  52. package/dist/contexts/ThunderID/ThunderIDContext.js.map +1 -1
  53. package/dist/contexts/ThunderID/ThunderIDProvider.d.ts.map +1 -1
  54. package/dist/contexts/ThunderID/ThunderIDProvider.js +32 -13
  55. package/dist/contexts/ThunderID/ThunderIDProvider.js.map +1 -1
  56. package/dist/contexts/User/UserContext.d.ts +2 -1
  57. package/dist/contexts/User/UserContext.d.ts.map +1 -1
  58. package/dist/contexts/User/UserContext.js +2 -1
  59. package/dist/contexts/User/UserContext.js.map +1 -1
  60. package/dist/contexts/User/UserProvider.d.ts +5 -2
  61. package/dist/contexts/User/UserProvider.d.ts.map +1 -1
  62. package/dist/contexts/User/UserProvider.js +5 -3
  63. package/dist/contexts/User/UserProvider.js.map +1 -1
  64. package/dist/index.d.ts +2 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +2 -1
  67. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"FieldFactory.cjs","names":["FieldType","numValue: number","validationError: string | null","commonProps: Record<string, any>","PasswordField","TextField","DatePicker","isChecked: boolean","Checkbox","OtpField","fieldOptions: SelectOption[]","Select","FieldFactory: FC<FieldConfig>"],"sources":["../../../../src/components/factories/FieldFactory.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {FieldType} from '@thunderid/browser';\nimport {ChangeEvent, FC, ReactElement} from 'react';\nimport Checkbox from '../primitives/Checkbox/Checkbox';\nimport DatePicker from '../primitives/DatePicker/DatePicker';\nimport OtpField from '../primitives/OtpField/OtpField';\nimport PasswordField from '../primitives/PasswordField/PasswordField';\nimport Select, {SelectOption} from '../primitives/Select/Select';\nimport TextField from '../primitives/TextField/TextField';\n\n/**\n * Interface for field configuration.\n */\nexport interface FieldConfig {\n /**\n * Additional CSS class name.\n */\n className?: string;\n /**\n * Whether the field is disabled.\n */\n disabled?: boolean;\n /**\n * Error message to display.\n */\n error?: string;\n /**\n * HTML id to apply to the rendered field.\n */\n id?: string;\n /**\n * Display name for the field.\n */\n label: string;\n /**\n * The name of the field.\n */\n name: string;\n /**\n * Callback function when the field loses focus.\n */\n onBlur?: () => void;\n /**\n * Callback function when the field value changes.\n */\n onChange: (value: string) => void;\n /**\n * Additional options for multi-valued fields.\n */\n options?: SelectOption[];\n /**\n * Placeholder text for the field.\n */\n placeholder?: string;\n /**\n * Whether the field is required.\n */\n required: boolean;\n /**\n * Whether the field has been touched/interacted with by the user.\n */\n touched?: boolean;\n /**\n * The field type.\n */\n type: FieldType;\n /**\n * Current value of the field.\n */\n value: string;\n}\n\n/**\n * Utility function to validate field values based on type\n */\nexport const validateFieldValue = (\n value: string,\n type: FieldType,\n required = false,\n touched = false,\n): string | null => {\n if (required && touched && (!value || value.trim() === '')) {\n return 'This field is required';\n }\n\n if (!value || value.trim() === '') {\n return null;\n }\n\n switch (type) {\n case FieldType.Number: {\n const numValue: number = parseInt(value, 10);\n if (Number.isNaN(numValue)) {\n return 'Please enter a valid number';\n }\n break;\n }\n default:\n break;\n }\n\n return null;\n};\n\n/**\n * Factory function to create form fields based on field type.\n *\n * @param config - The field configuration\n * @returns The appropriate React component for the field type\n *\n * @example\n * ```tsx\n * const field = createField({\n * param: 'username',\n * type: FieldType.Text,\n * label: 'Username',\n * confidential: false,\n * required: true,\n * value: '',\n * onChange: (value) => console.log(value)\n * });\n * ```\n */\nexport const createField = (config: FieldConfig): ReactElement => {\n const {\n name,\n type,\n label,\n required,\n value,\n onChange,\n onBlur,\n disabled = false,\n error,\n className,\n id,\n options = [],\n touched = false,\n placeholder,\n } = config;\n\n const validationError: string | null = error || validateFieldValue(value, type, required, touched);\n\n const commonProps: Record<string, any> = {\n className,\n 'data-testid': `thunderid-signin-${name}`,\n disabled,\n error: validationError,\n id,\n label,\n name,\n onBlur,\n placeholder,\n required,\n value,\n };\n\n switch (type) {\n case FieldType.Password:\n return <PasswordField {...commonProps} onChange={onChange} />;\n case FieldType.Text:\n return (\n <TextField\n {...commonProps}\n type=\"text\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n autoComplete=\"off\"\n />\n );\n case FieldType.Email:\n return (\n <TextField\n {...commonProps}\n type=\"email\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n autoComplete=\"email\"\n />\n );\n case FieldType.Tel:\n return (\n <TextField\n {...commonProps}\n type=\"tel\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n autoComplete=\"tel\"\n />\n );\n case FieldType.Date:\n return (\n <DatePicker {...commonProps} onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)} />\n );\n case FieldType.Checkbox: {\n const isChecked: boolean = value === 'true' || (value as any) === true;\n return (\n <Checkbox\n {...commonProps}\n checked={isChecked}\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.checked.toString())}\n />\n );\n }\n case FieldType.Otp:\n return (\n <OtpField {...commonProps} onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)} />\n );\n case FieldType.Number:\n return (\n <TextField\n {...commonProps}\n type=\"number\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n helperText=\"Enter a numeric value\"\n />\n );\n case FieldType.Select: {\n const fieldOptions: SelectOption[] = options.length > 0 ? options : [];\n\n if (fieldOptions.length > 0) {\n return (\n <Select\n {...commonProps}\n options={fieldOptions}\n onChange={(e: ChangeEvent<HTMLSelectElement>): void => onChange(e.target.value)}\n helperText=\"Select from available options\"\n />\n );\n }\n\n return (\n <TextField\n {...commonProps}\n type=\"text\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n helperText=\"Enter multiple values separated by commas (e.g., value1, value2, value3)\"\n placeholder=\"value1, value2, value3\"\n />\n );\n }\n default:\n return (\n <TextField\n {...commonProps}\n type=\"text\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n helperText=\"Unknown field type, treating as text\"\n />\n );\n }\n};\n\n/**\n * React component wrapper for the field factory.\n */\nexport const FieldFactory: FC<FieldConfig> = (props: FieldConfig): ReactElement => createField(props);\n\nexport default FieldFactory;\n"],"mappings":";;;;;;;;;;;;;;;;AA6EA,MAAa,sBACX,OACA,MACA,WAAW,OACX,UAAU,UACQ;AACl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ACC,GAAI;IACJ,SAAS;IACT,WAAW,MAA2C,SAAS,EAAE,OAAO,QAAQ,UAAU,CAAC;KAC3F;;EAGN,KAAKR,8BAAU,IACb,QACE,2CAACS;GAAS,GAAI;GAAa,WAAW,MAA2C,SAAS,EAAE,OAAO,MAAM;IAAI;EAEjH,KAAKT,8BAAU,OACb,QACE,2CAACK;GACC,GAAI;GACJ,MAAK;GACL,WAAW,MAA2C,SAAS,EAAE,OAAO,MAAM;GAC9E,YAAW;IACX;EAEN,KAAKL,8BAAU,QAAQ;GACrB,MAAMU,eAA+B,QAAQ,SAAS,IAAI,UAAU,EAAE;AAEtE,OAAI,aAAa,SAAS,EACxB,QACE,2CAACC;IACC,GAAI;IACJ,SAAS;IACT,WAAW,MAA4C,SAAS,EAAE,OAAO,MAAM;IAC/E,YAAW;KACX;AAIN,UACE,2CAACN;IACC,GAAI;IACJ,MAAK;IACL,WAAW,MAA2C,SAAS,EAAE,OAAO,MAAM;IAC9E,YAAW;IACX,aAAY;KACZ;;EAGN,QACE,QACE,2CAACA;GACC,GAAI;GACJ,MAAK;GACL,WAAW,MAA2C,SAAS,EAAE,OAAO,MAAM;GAC9E,YAAW;IACX;;;;;;AAQV,MAAaO,gBAAiC,UAAqC,YAAY,MAAM"}
1
+ {"version":3,"file":"FieldFactory.cjs","names":["FieldType","numValue: number","validationError: string | null","commonProps: Record<string, any>","PasswordField","TextField","DatePicker","isChecked: boolean","Checkbox","OtpField","fieldOptions: SelectOption[]","Select","FieldFactory: FC<FieldConfig>"],"sources":["../../../../src/components/factories/FieldFactory.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {FieldType} from '@thunderid/browser';\nimport {ChangeEvent, FC, ReactElement} from 'react';\nimport Checkbox from '../primitives/Checkbox/Checkbox';\nimport DatePicker from '../primitives/DatePicker/DatePicker';\nimport OtpField from '../primitives/OtpField/OtpField';\nimport PasswordField from '../primitives/PasswordField/PasswordField';\nimport Select, {SelectOption} from '../primitives/Select/Select';\nimport TextField from '../primitives/TextField/TextField';\n\n/**\n * Interface for field configuration.\n */\nexport interface FieldConfig {\n /**\n * Additional CSS class name.\n */\n className?: string;\n /**\n * Whether the field is disabled.\n */\n disabled?: boolean;\n /**\n * Error message to display.\n */\n error?: string;\n /**\n * HTML id to apply to the rendered field.\n */\n id?: string;\n /**\n * Display name for the field.\n */\n label: string;\n /**\n * Number of characters for OTP fields.\n */\n length?: number;\n /**\n * The name of the field.\n */\n name: string;\n /**\n * Whether an OTP field accepts digits only. Defaults to true.\n */\n numericOnly?: boolean;\n /**\n * Callback function when the field loses focus.\n */\n onBlur?: () => void;\n /**\n * Callback function when the field value changes.\n */\n onChange: (value: string) => void;\n /**\n * Additional options for multi-valued fields.\n */\n options?: SelectOption[];\n /**\n * Placeholder text for the field.\n */\n placeholder?: string;\n /**\n * Whether the field is required.\n */\n required: boolean;\n /**\n * Whether the field has been touched/interacted with by the user.\n */\n touched?: boolean;\n /**\n * The field type.\n */\n type: FieldType;\n /**\n * Current value of the field.\n */\n value: string;\n}\n\n/**\n * Utility function to validate field values based on type\n */\nexport const validateFieldValue = (\n value: string,\n type: FieldType,\n required = false,\n touched = false,\n): string | null => {\n if (required && touched && (!value || value.trim() === '')) {\n return 'This field is required';\n }\n\n if (!value || value.trim() === '') {\n return null;\n }\n\n switch (type) {\n case FieldType.Number: {\n const numValue: number = parseInt(value, 10);\n if (Number.isNaN(numValue)) {\n return 'Please enter a valid number';\n }\n break;\n }\n default:\n break;\n }\n\n return null;\n};\n\n/**\n * Factory function to create form fields based on field type.\n *\n * @param config - The field configuration\n * @returns The appropriate React component for the field type\n *\n * @example\n * ```tsx\n * const field = createField({\n * param: 'username',\n * type: FieldType.Text,\n * label: 'Username',\n * confidential: false,\n * required: true,\n * value: '',\n * onChange: (value) => console.log(value)\n * });\n * ```\n */\nexport const createField = (config: FieldConfig): ReactElement => {\n const {\n name,\n type,\n label,\n required,\n value,\n onChange,\n onBlur,\n disabled = false,\n error,\n className,\n id,\n options = [],\n touched = false,\n placeholder,\n length,\n numericOnly = true,\n } = config;\n\n const validationError: string | null = error || validateFieldValue(value, type, required, touched);\n\n const commonProps: Record<string, any> = {\n className,\n 'data-testid': `thunderid-signin-${name}`,\n disabled,\n error: validationError,\n id,\n label,\n name,\n onBlur,\n placeholder,\n required,\n value,\n };\n\n switch (type) {\n case FieldType.Password:\n return <PasswordField {...commonProps} onChange={onChange} />;\n case FieldType.Text:\n return (\n <TextField\n {...commonProps}\n type=\"text\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n autoComplete=\"off\"\n />\n );\n case FieldType.Email:\n return (\n <TextField\n {...commonProps}\n type=\"email\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n autoComplete=\"email\"\n />\n );\n case FieldType.Tel:\n return (\n <TextField\n {...commonProps}\n type=\"tel\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n autoComplete=\"tel\"\n />\n );\n case FieldType.Date:\n return (\n <DatePicker {...commonProps} onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)} />\n );\n case FieldType.Checkbox: {\n const isChecked: boolean = value === 'true' || (value as any) === true;\n return (\n <Checkbox\n {...commonProps}\n checked={isChecked}\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.checked.toString())}\n />\n );\n }\n case FieldType.Otp:\n return (\n <OtpField\n {...commonProps}\n length={length}\n type={numericOnly ? 'number' : 'text'}\n uppercase={!numericOnly}\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n />\n );\n case FieldType.Number:\n return (\n <TextField\n {...commonProps}\n type=\"number\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n helperText=\"Enter a numeric value\"\n />\n );\n case FieldType.Select: {\n const fieldOptions: SelectOption[] = options.length > 0 ? options : [];\n\n if (fieldOptions.length > 0) {\n return (\n <Select\n {...commonProps}\n options={fieldOptions}\n onChange={(e: ChangeEvent<HTMLSelectElement>): void => onChange(e.target.value)}\n helperText=\"Select from available options\"\n />\n );\n }\n\n return (\n <TextField\n {...commonProps}\n type=\"text\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n helperText=\"Enter multiple values separated by commas (e.g., value1, value2, value3)\"\n placeholder=\"value1, value2, value3\"\n />\n );\n }\n default:\n return (\n <TextField\n {...commonProps}\n type=\"text\"\n onChange={(e: ChangeEvent<HTMLInputElement>): void => onChange(e.target.value)}\n helperText=\"Unknown field type, treating as text\"\n />\n );\n }\n};\n\n/**\n * React component wrapper for the field factory.\n */\nexport const FieldFactory: FC<FieldConfig> = (props: FieldConfig): ReactElement => createField(props);\n\nexport default FieldFactory;\n"],"mappings":";;;;;;;;;;;;;;;;AAqFA,MAAa,sBACX,OACA,MACA,WAAW,OACX,UAAU,UACQ;AAClB,KAAI,YAAY,YAAY,CAAC,SAAS,MAAM,MAAM,KAAK,IACrD,QAAO;AAGT,KAAI,CAAC,SAAS,MAAM,MAAM,KAAK,GAC7B,QAAO;AAGT,SAAQ,MAAR;EACE,KAAKA,8BAAU,QAAQ;GACrB,MAAMC,WAAmB,SAAS,OAAO,GAAG;AAC5C,OAAI,OAAO,MAAM,SAAS,CACxB,QAAO;AAET;;EAEF,QACE;;AAGJ,QAAO;;;;;;;;;;;;;;;;;;;;;AAsBT,MAAa,eAAe,WAAsC;CAChE,MAAM,EACJ,MACA,MACA,OACA,UACA,OACA,UACA,QACA,WAAW,OACX,OACA,WACA,IACA,UAAU,EAAE,EACZ,UAAU,OACV,aACA,QACA,cAAc,SACZ;CAEJ,MAAMC,kBAAiC,SAAS,mBAAmB,OAAO,MAAM,UAAU,QAAQ;CAElG,MAAMC,cAAmC;EACvC;EACA,eAAe,oBAAoB;EACnC;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACD;AAED,SAAQ,MAAR;EACE,KAAKH,8BAAU,SACb,QA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YAAW;IACX,aAAY;KACZ;;EAGN,QACE,QACE,2CAACA;GACC,GAAI;GACJ,MAAK;GACL,WAAW,MAA2C,SAAS,EAAE,OAAO,MAAM;GAC9E,YAAW;IACX;;;;;;AAQV,MAAaO,gBAAiC,UAAqC,YAAY,MAAM"}
@@ -53,12 +53,14 @@ const readonlyFields = [
53
53
  "id",
54
54
  "isReadOnly",
55
55
  "ouId",
56
- "username"
56
+ "username",
57
+ "sub"
57
58
  ];
58
- const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, profile, flattenedProfile, mode = "inline", title, attributeMapping = {}, editable = true, onOpenChange, onUpdate, open = false, error = null, isLoading = false, preferences, showFields = [], hideFields = [], displayNameAttributes = [] }) => {
59
+ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, profile, flattenedProfile, userSchema, mode = "inline", title, attributeMapping = {}, editable = true, onOpenChange, onUpdate, open = false, error = null, isLoading = false, preferences, showFields = [], hideFields = [], displayNameAttributes = [] }) => {
59
60
  const { theme, colorScheme } = require_useTheme.default();
60
61
  const [editedUser, setEditedUser] = (0, react.useState)(flattenedProfile || profile);
61
62
  const [editingFields, setEditingFields] = (0, react.useState)({});
63
+ const [fieldErrors, setFieldErrors] = (0, react.useState)({});
62
64
  const { t } = require_useTranslation.default(preferences?.i18n);
63
65
  (0, react.useEffect)(() => {
64
66
  const nextUser = flattenedProfile ?? profile;
@@ -77,15 +79,11 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
77
79
  editingFields
78
80
  ]);
79
81
  /**
80
- * Determines if a field should be visible based on showFields, hideFields, and fieldsToSkip arrays.
81
- * Priority order:
82
- * 1. fieldsToSkip (always hidden) - highest priority
83
- * 2. hideFields (explicitly hidden)
84
- * 3. showFields (explicitly shown, if array is not empty)
85
- * 4. Default behavior (show all fields not in fieldsToSkip)
82
+ * Determines if a field should be visible based on showFields, hideFields, and fallback fieldsToSkip arrays.
83
+ * When isSchemaBased is true, fieldsToSkip is bypassed so schema-defined fields render dynamically.
86
84
  */
87
- const shouldShowField = (0, react.useCallback)((fieldName) => {
88
- if (fieldsToSkip.includes(fieldName)) return false;
85
+ const shouldShowField = (0, react.useCallback)((fieldName, isSchemaBased = false) => {
86
+ if (!isSchemaBased && fieldsToSkip.includes(fieldName)) return false;
89
87
  if (hideFields.length > 0 && hideFields.includes(fieldName)) return false;
90
88
  if (showFields.length > 0) return showFields.includes(fieldName);
91
89
  return true;
@@ -111,12 +109,11 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
111
109
  const { type, displayName, description, name } = schema;
112
110
  const fieldLabel = displayName || description || name || "value";
113
111
  switch (type) {
114
- case "DATE_TIME": return `Enter your ${fieldLabel.toLowerCase()}`;
115
- case "BOOLEAN": return `Select ${fieldLabel.toLowerCase()}`;
116
- case "COMPLEX": return `Enter ${fieldLabel.toLowerCase()} details`;
117
- default: return `Enter your ${fieldLabel.toLowerCase()}`;
112
+ case "DATE_TIME":
113
+ case "STRING":
114
+ default: return t("elements.fields.generic.placeholder", { field: fieldLabel.toLowerCase() });
118
115
  }
119
- }, []);
116
+ }, [t]);
120
117
  const formatLabel = (0, react.useCallback)((key) => key.split(/(?=[A-Z])|_/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" "), []);
121
118
  const styles = require_BaseUserProfile_styles.default(theme, colorScheme);
122
119
  const ObjectDisplay = ({ data }) => {
@@ -147,11 +144,36 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
147
144
  const handleFieldSave = (0, react.useCallback)((schema) => {
148
145
  if (!onUpdate || !schema.name) return;
149
146
  const fieldName = schema.name;
147
+ const currentUser$1 = flattenedProfile || profile;
150
148
  let fieldValue;
151
149
  if (editedUser && fieldName && editedUser[fieldName] !== void 0) fieldValue = editedUser[fieldName];
150
+ else if (currentUser$1?.attributes?.[fieldName] !== void 0) fieldValue = currentUser$1.attributes[fieldName];
152
151
  else if (flattenedProfile?.[fieldName] !== void 0) fieldValue = flattenedProfile[fieldName];
153
152
  else fieldValue = "";
154
153
  if (Array.isArray(fieldValue)) fieldValue = fieldValue.filter((v) => v !== void 0 && v !== null && v !== "");
154
+ const strVal = String(fieldValue ?? "").trim();
155
+ schema.displayName || schema.name && (0, __thunderid_browser.startCase)(schema.name);
156
+ if (schema.required && !strVal) {
157
+ setFieldErrors((prev) => ({
158
+ ...prev,
159
+ [fieldName]: t("validations.required.field.error")
160
+ }));
161
+ return;
162
+ }
163
+ if (schema.regex && strVal) try {
164
+ if (!new RegExp(schema.regex).test(strVal)) {
165
+ setFieldErrors((prev) => ({
166
+ ...prev,
167
+ [fieldName]: t("validation.pattern.invalid")
168
+ }));
169
+ return;
170
+ }
171
+ } catch (e) {}
172
+ setFieldErrors((prev) => {
173
+ const next = { ...prev };
174
+ delete next[fieldName];
175
+ return next;
176
+ });
155
177
  let payload = {};
156
178
  set(payload, fieldName, fieldValue);
157
179
  onUpdate(payload);
@@ -159,15 +181,23 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
159
181
  }, [
160
182
  editedUser,
161
183
  flattenedProfile,
184
+ profile,
162
185
  onUpdate,
163
- toggleFieldEdit
186
+ toggleFieldEdit,
187
+ t
164
188
  ]);
165
189
  const handleFieldCancel = (0, react.useCallback)((fieldName) => {
166
190
  const currentUser$1 = flattenedProfile || profile;
191
+ const initialVal = currentUser$1?.attributes?.[fieldName] ?? currentUser$1?.[fieldName];
167
192
  setEditedUser((prev) => ({
168
193
  ...prev,
169
- [fieldName]: currentUser$1[fieldName]
194
+ [fieldName]: initialVal
170
195
  }));
196
+ setFieldErrors((prev) => {
197
+ const next = { ...prev };
198
+ delete next[fieldName];
199
+ return next;
200
+ });
171
201
  toggleFieldEdit(fieldName);
172
202
  }, [
173
203
  flattenedProfile,
@@ -341,13 +371,21 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
341
371
  if (!(hasValue || isFieldEditing || editable && schema.mutability === "READ_WRITE")) return null;
342
372
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
343
373
  className: styles.field,
344
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
374
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
345
375
  className: styles.fieldInner,
346
- children: renderSchemaField(schema, isFieldEditing, (value) => {
376
+ children: [renderSchemaField(schema, isFieldEditing, (value) => {
347
377
  const tempEditedUser = { ...editedUser };
348
378
  tempEditedUser[schema.name] = value;
349
379
  setEditedUser(tempEditedUser);
350
- }, () => toggleFieldEdit(schema.name))
380
+ }, () => toggleFieldEdit(schema.name)), fieldErrors[schema.name] && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
381
+ style: {
382
+ color: "#d32f2f",
383
+ fontSize: "0.8rem",
384
+ marginTop: "4px",
385
+ fontWeight: 500
386
+ },
387
+ children: fieldErrors[schema.name]
388
+ })]
351
389
  }), editable && schema.mutability !== "READ_ONLY" && !isReadonlyField && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
352
390
  className: styles.fieldActions,
353
391
  children: [isFieldEditing && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button.default, {
@@ -377,13 +415,38 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
377
415
  if (!profile && !flattenedProfile) return fallback;
378
416
  const containerClasses = require_emotion.cx(styles.root, cardLayout ? styles.card : "", (0, __thunderid_browser.withVendorCSSClassPrefix)("user-profile"), className);
379
417
  const currentUser = flattenedProfile || profile;
380
- const renderProfileWithoutSchemas = () => {
418
+ const renderProfileContent = () => {
381
419
  if (!currentUser) return null;
382
420
  const displayName = require_getDisplayName.default(mergedMappings, profile, displayNameAttributes);
383
- const profileEntries = Object.entries(currentUser).filter(([key, value]) => {
421
+ let schemaItems = [];
422
+ if (userSchema && typeof userSchema === "object" && Object.keys(userSchema).length > 0) schemaItems = Object.entries(userSchema).filter(([key, metaAttr]) => {
423
+ if (metaAttr?.credential) return false;
424
+ return shouldShowField(key, true);
425
+ }).map(([key, metaAttr]) => {
426
+ const val = editedUser?.[key] ?? currentUser?.attributes?.[key] ?? currentUser?.[key] ?? "";
427
+ const isReadonly = metaAttr.readOnly === true || metaAttr.mutability === "READ_ONLY" || readonlyFields.includes(key);
428
+ return {
429
+ name: key,
430
+ displayName: metaAttr.displayName ?? (key ? (0, __thunderid_browser.startCase)(key) : ""),
431
+ type: (metaAttr.type ?? "STRING").toUpperCase(),
432
+ regex: metaAttr.regex,
433
+ required: !!metaAttr.required,
434
+ mutability: isReadonly ? "READ_ONLY" : "READ_WRITE",
435
+ value: val
436
+ };
437
+ });
438
+ else schemaItems = Object.entries(currentUser).filter(([key, value]) => {
384
439
  if (!shouldShowField(key)) return false;
385
440
  return value !== void 0 && value !== "" && value !== null;
386
- }).sort(([a], [b]) => a.localeCompare(b));
441
+ }).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => {
442
+ const isReadonly = readonlyFields.includes(key);
443
+ return {
444
+ name: key,
445
+ displayName: (0, __thunderid_browser.startCase)(key),
446
+ mutability: isReadonly ? "READ_ONLY" : "READ_WRITE",
447
+ value
448
+ };
449
+ });
387
450
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
388
451
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
389
452
  className: styles.profileSummary,
@@ -408,17 +471,10 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
408
471
  ]
409
472
  }),
410
473
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Divider.default, {}),
411
- profileEntries.map(([key, value]) => {
412
- const schemaWithValue = {
413
- name: key,
414
- mutability: readonlyFields.includes(key) ? "READ_ONLY" : "READ_WRITE",
415
- value
416
- };
417
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
418
- className: styles.info,
419
- children: renderUserInfo(schemaWithValue)
420
- }, key);
421
- })
474
+ schemaItems.map((schemaWithValue) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
475
+ className: styles.info,
476
+ children: renderUserInfo(schemaWithValue)
477
+ }, schemaWithValue.name))
422
478
  ] });
423
479
  };
424
480
  const profileContent = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Card.default, {
@@ -429,7 +485,7 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
429
485
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Alert.default.Title, { children: t("errors.heading") || "Error" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Alert.default.Description, { children: error })]
430
486
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
431
487
  className: styles.infoContainer,
432
- children: renderProfileWithoutSchemas()
488
+ children: renderProfileContent()
433
489
  })]
434
490
  });
435
491
  if (mode === "popup") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Dialog.default, {
@@ -1 +1 @@
1
- {"version":3,"file":"BaseUserProfile.cjs","names":["fieldsToSkip: string[]","readonlyFields: string[]","BaseUserProfile: FC<BaseUserProfileProps>","useTheme","useTranslation","shouldShowField: any","toggleFieldEdit: any","getFieldPlaceholder: any","fieldLabel: any","formatLabel: any","styles: any","useStyles","ObjectDisplay: FC<{data: unknown}>","keys: any","current: any","i: any","key: any","handleFieldSave: any","fieldName: string","fieldValue: any","payload: Record<string, any>","handleFieldCancel: any","currentUser: any","currentUser","mergedMappings: Record<string, string | string[]>","label: any","displayValue: string","displayValue","hasValues: any","isEditable: any","isEditable","currentValue: any","fieldValues: string[]","MultiInput","cx","Button","commonProps: any","field: ReactElement","TextField","DatePicker","Checkbox","hasValue: any","isFieldEditing: any","isReadonlyField: any","tempEditedUser: any","containerClasses: any","displayName: any","getDisplayName","profileEntries: any","Avatar","getMappedUserProfileValue","Typography","Divider","schemaWithValue: any","profileContent: any","CardPrimitive","AlertPrimitive","DialogPrimitive"],"sources":["../../../../../src/components/presentation/UserProfile/BaseUserProfile.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {User, withVendorCSSClassPrefix, bem, Preferences, startCase} from '@thunderid/browser';\nimport {FC, ReactElement, useState, useCallback, useEffect} from 'react';\nimport useStyles from './BaseUserProfile.styles';\nimport useTheme from '../../../contexts/Theme/useTheme';\nimport useTranslation from '../../../hooks/useTranslation';\nimport {cx} from '../../../styles/emotion';\nimport getDisplayName from '../../../utils/getDisplayName';\nimport getMappedUserProfileValue from '../../../utils/getMappedUserProfileValue';\nimport AlertPrimitive from '../../primitives/Alert/Alert';\nimport {Avatar} from '../../primitives/Avatar/Avatar';\nimport Button from '../../primitives/Button/Button';\nimport CardPrimitive from '../../primitives/Card/Card';\nimport Checkbox from '../../primitives/Checkbox/Checkbox';\nimport DatePicker from '../../primitives/DatePicker/DatePicker';\nimport DialogPrimitive from '../../primitives/Dialog/Dialog';\nimport Divider from '../../primitives/Divider/Divider';\nimport MultiInput from '../../primitives/MultiInput/MultiInput';\nimport TextField from '../../primitives/TextField/TextField';\nimport Typography from '../../primitives/Typography/Typography';\n\ninterface ExtendedFlatSchema {\n path?: string;\n schemaId?: string;\n}\n\ninterface Schema extends ExtendedFlatSchema {\n caseExact?: boolean;\n description?: string;\n displayName?: string;\n displayOrder?: string;\n multiValued?: boolean;\n mutability?: string;\n name?: string;\n required?: boolean;\n returned?: string;\n subAttributes?: Schema[];\n type?: string;\n uniqueness?: string;\n value?: any;\n}\n\nexport interface BaseUserProfileProps {\n attributeMapping?: {\n [key: string]: string | string[] | undefined;\n firstName?: string | string[];\n lastName?: string | string[];\n picture?: string | string[];\n username?: string | string[];\n };\n cardLayout?: boolean;\n className?: string;\n displayNameAttributes?: string[];\n editable?: boolean;\n error?: string | null;\n fallback?: ReactElement | null;\n flattenedProfile?: User;\n hideFields?: string[];\n isLoading?: boolean;\n mode?: 'inline' | 'popup';\n onOpenChange?: (open: boolean) => void;\n onUpdate?: (payload: any) => Promise<void>;\n open?: boolean;\n /**\n * Component-level preferences to override global i18n and theme settings.\n * Preferences are deep-merged with global ones, with component preferences\n * taking precedence. Affects this component and all its descendants.\n */\n preferences?: Preferences;\n profile?: User;\n showFields?: string[];\n\n title?: string;\n}\n\n// Fields to skip based on schema.name\nconst fieldsToSkip: string[] = [\n 'roles.default',\n 'active',\n 'groups',\n 'accountLocked',\n 'accountDisabled',\n 'oneTimePassword',\n 'userSourceId',\n 'idpType',\n 'localCredentialExists',\n 'active',\n 'ResourceType',\n 'ExternalID',\n 'MetaData',\n 'verifiedMobileNumbers',\n 'verifiedEmailAddresses',\n 'phoneNumbers.mobile',\n 'emailAddresses',\n 'preferredMFAOption',\n 'attributes',\n 'picture',\n 'isReadOnly',\n 'isReadonly',\n];\n\n// Fields that should be readonly\nconst readonlyFields: string[] = ['attributes', 'id', 'isReadOnly', 'ouId', 'username'];\n\nconst BaseUserProfile: FC<BaseUserProfileProps> = ({\n fallback = null,\n className = '',\n cardLayout = true,\n profile,\n flattenedProfile,\n mode = 'inline',\n title,\n attributeMapping = {},\n editable = true,\n onOpenChange,\n onUpdate,\n open = false,\n error = null,\n isLoading = false,\n preferences,\n showFields = [],\n hideFields = [],\n displayNameAttributes = [],\n}: BaseUserProfileProps): ReactElement | null => {\n const {theme, colorScheme} = useTheme();\n const [editedUser, setEditedUser] = useState(flattenedProfile || profile);\n const [editingFields, setEditingFields] = useState<Record<string, boolean>>({});\n const {t} = useTranslation(preferences?.i18n);\n\n useEffect(() => {\n const nextUser = flattenedProfile ?? profile;\n if (!nextUser) return;\n\n setEditedUser((prev: any) => {\n if (!prev) return nextUser;\n\n const updated = {...nextUser};\n Object.keys(prev).forEach((key) => {\n if (editingFields[key]) {\n updated[key] = prev[key];\n }\n });\n return updated;\n });\n }, [flattenedProfile, profile, editingFields]);\n\n /**\n * Determines if a field should be visible based on showFields, hideFields, and fieldsToSkip arrays.\n * Priority order:\n * 1. fieldsToSkip (always hidden) - highest priority\n * 2. hideFields (explicitly hidden)\n * 3. showFields (explicitly shown, if array is not empty)\n * 4. Default behavior (show all fields not in fieldsToSkip)\n */\n const shouldShowField: any = useCallback(\n (fieldName: string): boolean => {\n // Always skip fields in the hardcoded fieldsToSkip array\n if (fieldsToSkip.includes(fieldName)) {\n return false;\n }\n\n // If hideFields is provided and contains this field, hide it\n if (hideFields.length > 0 && hideFields.includes(fieldName)) {\n return false;\n }\n\n // If showFields is provided and not empty, only show fields in that array\n if (showFields.length > 0) {\n return showFields.includes(fieldName);\n }\n\n return true;\n },\n [showFields, hideFields],\n );\n\n const PencilIcon = (): any => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z\" />\n </svg>\n );\n\n const toggleFieldEdit: any = useCallback((fieldName: string) => {\n setEditingFields((prev: any) => ({\n ...prev,\n [fieldName]: !prev[fieldName],\n }));\n }, []);\n\n const getFieldPlaceholder: any = useCallback((schema: Schema): string => {\n const {type, displayName, description, name} = schema;\n\n const fieldLabel: any = displayName || description || name || 'value';\n\n switch (type) {\n case 'DATE_TIME':\n return `Enter your ${fieldLabel.toLowerCase()}`;\n case 'BOOLEAN':\n return `Select ${fieldLabel.toLowerCase()}`;\n case 'COMPLEX':\n return `Enter ${fieldLabel.toLowerCase()} details`;\n default:\n return `Enter your ${fieldLabel.toLowerCase()}`;\n }\n }, []);\n\n const formatLabel: any = useCallback(\n (key: string): string =>\n key\n .split(/(?=[A-Z])|_/)\n .map((word: any) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(' '),\n [],\n );\n\n const styles: any = useStyles(theme, colorScheme);\n\n const ObjectDisplay: FC<{data: unknown}> = ({data}: {data: unknown}): ReactElement | null => {\n if (!data || typeof data !== 'object') return null;\n\n return (\n <table className={styles.value}>\n <tbody>\n {Object.entries(data).map(([key, value]: any) => (\n <tr key={key}>\n <td className={styles.objectKey}>\n <strong>{formatLabel(key)}:</strong>\n </td>\n <td className={styles.objectValue}>\n {typeof value === 'object' ? <ObjectDisplay data={value} /> : String(value)}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n };\n\n function set(obj: Record<string, any>, path: string, value: any): void {\n const keys: any = path.split('.');\n let current: any = obj;\n\n for (let i: any = 0; i < keys.length; i += 1) {\n const key: any = keys[i];\n\n if (i === keys.length - 1) {\n current[key] = value;\n } else {\n if (!current[key] || typeof current[key] !== 'object') {\n current[key] = {};\n }\n current = current[key];\n }\n }\n }\n\n const handleFieldSave: any = useCallback(\n (schema: Schema): void => {\n if (!onUpdate || !schema.name) return;\n\n const fieldName: string = schema.name;\n let fieldValue: any;\n if (editedUser && fieldName && editedUser[fieldName] !== undefined) {\n fieldValue = editedUser[fieldName];\n } else if (flattenedProfile?.[fieldName] !== undefined) {\n fieldValue = flattenedProfile[fieldName];\n } else {\n fieldValue = '';\n }\n\n if (Array.isArray(fieldValue)) {\n fieldValue = fieldValue.filter((v: any) => v !== undefined && v !== null && v !== '');\n }\n\n let payload: Record<string, any> = {};\n set(payload, fieldName, fieldValue);\n\n onUpdate(payload);\n\n toggleFieldEdit(fieldName);\n },\n [editedUser, flattenedProfile, onUpdate, toggleFieldEdit],\n );\n\n const handleFieldCancel: any = useCallback(\n (fieldName: string) => {\n const currentUser: any = flattenedProfile || profile;\n setEditedUser((prev: any) => ({\n ...prev,\n [fieldName]: currentUser[fieldName],\n }));\n toggleFieldEdit(fieldName);\n },\n [flattenedProfile, profile, toggleFieldEdit],\n );\n\n const defaultAttributeMappings: Record<string, string | string[]> = {\n email: ['emails', 'email'],\n firstName: ['name.givenName', 'given_name'],\n lastName: ['name.familyName', 'family_name'],\n picture: ['profile', 'profileUrl', 'picture', 'URL'],\n username: ['userName', 'username', 'user_name'],\n };\n\n const mergedMappings: Record<string, string | string[]> = Object.fromEntries(\n Object.entries({...defaultAttributeMappings, ...attributeMapping}).filter(\n (entry): entry is [string, string | string[]] => entry[1] !== undefined,\n ),\n );\n\n const renderSchemaField = (\n schema: Schema,\n isEditing: boolean,\n onEditValue?: (value: any) => void,\n onStartEdit?: () => void,\n ): ReactElement | null => {\n if (!schema) return null;\n const {value, displayName, description, name, type, required, mutability, subAttributes, multiValued} = schema;\n const label: any = displayName || description || (name ? startCase(name) : '');\n\n if (subAttributes && Array.isArray(subAttributes)) {\n return (\n <>\n {subAttributes.map((subAttr: any, index: any) => {\n let displayValue: string;\n if (Array.isArray(subAttr.value)) {\n displayValue = subAttr.value\n .map((item: any) => (typeof item === 'object' ? JSON.stringify(item) : String(item)))\n .join(', ');\n } else if (typeof subAttr.value === 'object') {\n displayValue = JSON.stringify(subAttr.value);\n } else {\n displayValue = String(subAttr.value);\n }\n\n return (\n <div key={index} className={styles.field}>\n <span className={styles.label}>{subAttr.displayName || subAttr.description || ''}</span>\n <div className={styles.value}>{displayValue}</div>\n </div>\n );\n })}\n </>\n );\n }\n\n if (Array.isArray(value) || multiValued) {\n const hasValues: any = Array.isArray(value)\n ? value.length > 0\n : value !== undefined && value !== null && value !== '';\n const isEditable: any = editable && mutability !== 'READ_ONLY' && !readonlyFields.includes(name || '');\n\n if (isEditing && onEditValue && isEditable) {\n let currentValue: any;\n if (editedUser && name && editedUser[name] !== undefined) {\n currentValue = editedUser[name];\n } else if (flattenedProfile && name && flattenedProfile[name] !== undefined) {\n currentValue = flattenedProfile[name];\n } else {\n currentValue = value;\n }\n\n let fieldValues: string[];\n if (Array.isArray(currentValue)) {\n fieldValues = currentValue.map(String);\n } else if (currentValue !== undefined && currentValue !== null && currentValue !== '') {\n fieldValues = [String(currentValue)];\n } else {\n fieldValues = [];\n }\n\n return (\n <>\n <span className={styles.label}>{label}</span>\n <div className={styles.value}>\n <MultiInput\n values={fieldValues}\n onChange={(newValues: any): void => {\n if (multiValued || Array.isArray(currentValue)) {\n onEditValue(newValues);\n } else {\n onEditValue(newValues[0] || '');\n }\n }}\n placeholder={getFieldPlaceholder(schema)}\n fieldType={type as 'STRING' | 'DATE_TIME' | 'BOOLEAN'}\n type={type === 'DATE_TIME' ? 'date' : 'text'}\n required={required}\n />\n </div>\n </>\n );\n }\n\n let displayValue: string;\n if (hasValues) {\n if (Array.isArray(value)) {\n displayValue = value\n .map((item: any) => (typeof item === 'object' ? JSON.stringify(item) : String(item)))\n .join(', ');\n } else {\n displayValue = String(value);\n }\n } else if (isEditable) {\n displayValue = getFieldPlaceholder(schema);\n } else {\n displayValue = '-';\n }\n\n return (\n <>\n <span className={styles.label}>{label}</span>\n <div className={cx(styles.value, !hasValues ? styles.valuePlaceholder : '')}>\n {!hasValues && isEditable && onStartEdit ? (\n <Button\n onClick={onStartEdit}\n variant=\"text\"\n color=\"secondary\"\n size=\"small\"\n title=\"Click to edit\"\n className={styles.editButton}\n >\n {displayValue}\n </Button>\n ) : (\n displayValue\n )}\n </div>\n </>\n );\n }\n if (type === 'COMPLEX' && typeof value === 'object') {\n return <ObjectDisplay data={value} />;\n }\n\n if (isEditing && onEditValue && mutability !== 'READ_ONLY' && !readonlyFields.includes(name || '')) {\n let fieldValue: any;\n if (editedUser && name && editedUser[name] !== undefined) {\n fieldValue = editedUser[name];\n } else if (flattenedProfile && name && flattenedProfile[name] !== undefined) {\n fieldValue = flattenedProfile[name];\n } else {\n fieldValue = value || '';\n }\n\n const commonProps: any = {\n label: undefined,\n onChange: (e: any) => onEditValue(e.target ? e.target.value : e),\n placeholder: getFieldPlaceholder(schema),\n required,\n value: fieldValue,\n // Removed inline style, use .styles.ts for marginBottom if needed\n };\n let field: ReactElement;\n switch (type) {\n case 'STRING':\n field = <TextField {...commonProps} />;\n break;\n case 'DATE_TIME':\n field = <DatePicker {...commonProps} />;\n break;\n case 'BOOLEAN':\n field = (\n <Checkbox\n {...commonProps}\n checked={!!fieldValue}\n onChange={(e: any): void => {\n onEditValue(e.target.checked);\n }}\n />\n );\n break;\n case 'COMPLEX':\n field = (\n <textarea\n value={fieldValue}\n onChange={(e: any): void => onEditValue(e.target.value)}\n placeholder={getFieldPlaceholder(schema)}\n required={required}\n className={styles.complexTextarea}\n />\n );\n break;\n default:\n field = <TextField {...commonProps} />;\n }\n return (\n <>\n <span className={styles.label}>{label}</span>\n <div className={styles.value}>{field}</div>\n </>\n );\n }\n\n const hasValue: any = value !== undefined && value !== null && value !== '';\n const isEditable: any = editable && mutability !== 'READ_ONLY' && !readonlyFields.includes(name || '');\n\n let displayValue: string;\n if (hasValue) {\n displayValue = String(value);\n } else if (isEditable) {\n displayValue = getFieldPlaceholder(schema);\n } else {\n displayValue = '-';\n }\n\n return (\n <>\n <span className={styles.label}>{label}</span>\n <div className={cx(styles.value, !hasValue ? styles.valuePlaceholder : '')}>\n {!hasValue && isEditable && onStartEdit ? (\n <Button\n onClick={onStartEdit}\n variant=\"text\"\n color=\"secondary\"\n size=\"small\"\n title=\"Click to edit\"\n className={styles.editButton}\n >\n {displayValue}\n </Button>\n ) : (\n displayValue\n )}\n </div>\n </>\n );\n };\n\n const renderUserInfo = (schema: Schema): any => {\n if (!schema?.name) return null;\n\n const hasValue: any = schema.value !== undefined && schema.value !== '' && schema.value !== null;\n const isFieldEditing: any = editingFields[schema.name];\n const isReadonlyField: any = readonlyFields.includes(schema.name);\n\n const shouldShow: any = hasValue || isFieldEditing || (editable && schema.mutability === 'READ_WRITE');\n\n if (!shouldShow) {\n return null;\n }\n\n return (\n <div className={styles.field}>\n <div className={styles.fieldInner}>\n {renderSchemaField(\n schema,\n isFieldEditing,\n (value: any) => {\n const tempEditedUser: any = {...editedUser};\n tempEditedUser[schema.name!] = value;\n setEditedUser(tempEditedUser);\n },\n () => toggleFieldEdit(schema.name),\n )}\n </div>\n {editable && schema.mutability !== 'READ_ONLY' && !isReadonlyField && (\n <div className={styles.fieldActions}>\n {isFieldEditing && (\n <>\n <Button size=\"small\" color=\"primary\" variant=\"solid\" onClick={(): any => handleFieldSave(schema)}>\n Save\n </Button>\n <Button\n size=\"small\"\n color=\"secondary\"\n variant=\"solid\"\n onClick={(): any => handleFieldCancel(schema.name)}\n >\n Cancel\n </Button>\n </>\n )}\n {!isFieldEditing && hasValue && (\n <Button\n size=\"small\"\n color=\"tertiary\"\n variant=\"icon\"\n onClick={(): any => toggleFieldEdit(schema.name)}\n title=\"Edit\"\n className={styles.editButton}\n >\n <PencilIcon />\n </Button>\n )}\n </div>\n )}\n </div>\n );\n };\n\n if (!profile && !flattenedProfile) {\n return fallback;\n }\n\n const containerClasses: any = cx(\n styles.root,\n cardLayout ? styles.card : '',\n withVendorCSSClassPrefix('user-profile'),\n className,\n );\n\n const currentUser: any = flattenedProfile || profile;\n\n const renderProfileWithoutSchemas = (): any => {\n if (!currentUser) return null;\n\n const displayName: any = getDisplayName(mergedMappings, profile!, displayNameAttributes);\n\n const profileEntries: any = Object.entries(currentUser)\n .filter(([key, value]: [string, any]) => {\n if (!shouldShowField(key)) return false;\n\n return value !== undefined && value !== '' && value !== null;\n })\n .sort(([a]: [string, ...any[]], [b]: [string, ...any[]]) => a.localeCompare(b));\n\n return (\n <>\n <div className={styles.profileSummary}>\n <Avatar\n imageUrl={getMappedUserProfileValue('picture', mergedMappings, currentUser)}\n name={displayName}\n size={70}\n alt={`${displayName}'s avatar`}\n isLoading={isLoading}\n />\n <Typography variant=\"h3\" fontWeight=\"medium\">\n {displayName}\n </Typography>\n {getMappedUserProfileValue('email', mergedMappings, currentUser) && (\n <Typography variant=\"body2\" color=\"textSecondary\">\n {getMappedUserProfileValue('email', mergedMappings, currentUser)}\n </Typography>\n )}\n </div>\n <Divider />\n {profileEntries.map(([key, value]: any) => {\n const isReadonly = readonlyFields.includes(key);\n const schema: Schema = {name: key, mutability: isReadonly ? 'READ_ONLY' : 'READ_WRITE'};\n const schemaWithValue: any = {...schema, value};\n\n return (\n <div key={key} className={styles.info}>\n {renderUserInfo(schemaWithValue)}\n </div>\n );\n })}\n </>\n );\n };\n\n const profileContent: any = (\n <CardPrimitive className={containerClasses}>\n {error && (\n <AlertPrimitive\n variant=\"error\"\n className={cx(withVendorCSSClassPrefix(bem('user-profile', 'alert')), styles.alert)}\n >\n <AlertPrimitive.Title>{t('errors.heading') || 'Error'}</AlertPrimitive.Title>\n <AlertPrimitive.Description>{error}</AlertPrimitive.Description>\n </AlertPrimitive>\n )}\n <div className={styles.infoContainer}>{renderProfileWithoutSchemas()}</div>\n </CardPrimitive>\n );\n\n if (mode === 'popup') {\n return (\n <DialogPrimitive open={open} onOpenChange={onOpenChange}>\n <DialogPrimitive.Content>\n <DialogPrimitive.Heading>{title ?? t('user.profile.heading')}</DialogPrimitive.Heading>\n <div className={styles.popup}>{profileContent}</div>\n </DialogPrimitive.Content>\n </DialogPrimitive>\n );\n }\n\n return profileContent;\n};\n\nexport default BaseUserProfile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,MAAMA,eAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAGD,MAAMC,iBAA2B;CAAC;CAAc;CAAM;CAAc;CAAQ;CAAW;AAEvF,MAAMC,mBAA6C,EACjD,WAAW,MACX,YAAY,IACZ,aAAa,MACb,SACA,kBACA,OAAO,UACP,OACA,mBAAmB,EAAE,EACrB,WAAW,MACX,cACA,UACA,OAAO,OACP,QAAQ,MACR,YAAY,OACZ,aACA,aAAa,EAAE,EACf,aAAa,EAAE,EACf,wBAAwB,EAAE,OACqB;CAC/C,MAAM,EAAC,OAAO,gBAAeC,0BAAU;CACvC,MAAM,CAAC,YAAY,qCAA0B,oBAAoB,QAAQ;CACzE,MAAM,CAAC,eAAe,wCAAsD,EAAE,CAAC;CAC/E,MAAM,EAAC,MAAKC,+BAAe,aAAa,KAAK;AAE7C,4BAAgB;EACd,MAAM,WAAW,oBAAoB;AACrC,MAAI,CAAC,SAAU;AAEf,iBAAe,SAAc;AAC3B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GACR,WAAWtB,kGAAgC,gBAAgB,QAAQ,CAAC,EAAE,OAAO,MAAM;cAEnF,2CAACsB,sBAAe,mBAAO,EAAE,iBAAiB,IAAI,UAA+B,EAC7E,2CAACA,sBAAe,yBAAa,QAAmC;IACjD,EAEnB,2CAAC;GAAI,WAAW,OAAO;aAAgB,6BAA6B;IAAO;GAC7D;AAGlB,KAAI,SAAS,QACX,QACE,2CAACC;EAAsB;EAAoB;YACzC,4CAACA,uBAAgB,sBACf,2CAACA,uBAAgB,qBAAS,SAAS,EAAE,uBAAuB,GAA2B,EACvF,2CAAC;GAAI,WAAW,OAAO;aAAQ;IAAqB,IAC5B;GACV;AAItB,QAAO;;AAGT,8BAAe"}
1
+ {"version":3,"file":"BaseUserProfile.cjs","names":["fieldsToSkip: string[]","readonlyFields: string[]","BaseUserProfile: FC<BaseUserProfileProps>","useTheme","useTranslation","toggleFieldEdit: any","getFieldPlaceholder: any","fieldLabel: any","formatLabel: any","styles: any","useStyles","ObjectDisplay: FC<{data: unknown}>","keys: any","current: any","i: any","key: any","handleFieldSave: any","fieldName: string","currentUser: any","fieldValue: any","currentUser","payload: Record<string, any>","handleFieldCancel: any","mergedMappings: Record<string, string | string[]>","label: any","displayValue: string","displayValue","hasValues: any","isEditable: any","isEditable","currentValue: any","fieldValues: string[]","MultiInput","cx","Button","commonProps: any","field: ReactElement","TextField","DatePicker","Checkbox","hasValue: any","isFieldEditing: any","isReadonlyField: any","tempEditedUser: any","containerClasses: any","displayName: any","getDisplayName","schemaItems: Schema[]","Avatar","getMappedUserProfileValue","Typography","Divider","profileContent: any","CardPrimitive","AlertPrimitive","DialogPrimitive"],"sources":["../../../../../src/components/presentation/UserProfile/BaseUserProfile.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {User, withVendorCSSClassPrefix, bem, Preferences, startCase, AttributeSchema} from '@thunderid/browser';\nimport {FC, ReactElement, useState, useCallback, useEffect} from 'react';\nimport useStyles from './BaseUserProfile.styles';\nimport useTheme from '../../../contexts/Theme/useTheme';\nimport useTranslation from '../../../hooks/useTranslation';\nimport {cx} from '../../../styles/emotion';\nimport getDisplayName from '../../../utils/getDisplayName';\nimport getMappedUserProfileValue from '../../../utils/getMappedUserProfileValue';\nimport AlertPrimitive from '../../primitives/Alert/Alert';\nimport {Avatar} from '../../primitives/Avatar/Avatar';\nimport Button from '../../primitives/Button/Button';\nimport CardPrimitive from '../../primitives/Card/Card';\nimport Checkbox from '../../primitives/Checkbox/Checkbox';\nimport DatePicker from '../../primitives/DatePicker/DatePicker';\nimport DialogPrimitive from '../../primitives/Dialog/Dialog';\nimport Divider from '../../primitives/Divider/Divider';\nimport MultiInput from '../../primitives/MultiInput/MultiInput';\nimport TextField from '../../primitives/TextField/TextField';\nimport Typography from '../../primitives/Typography/Typography';\n\ninterface ExtendedFlatSchema {\n path?: string;\n schemaId?: string;\n}\n\ninterface Schema extends ExtendedFlatSchema {\n caseExact?: boolean;\n description?: string;\n displayName?: string;\n displayOrder?: string;\n multiValued?: boolean;\n mutability?: string;\n name?: string;\n regex?: string;\n required?: boolean;\n returned?: string;\n subAttributes?: Schema[];\n type?: string;\n uniqueness?: string;\n value?: any;\n}\n\nexport interface BaseUserProfileProps {\n attributeMapping?: {\n [key: string]: string | string[] | undefined;\n firstName?: string | string[];\n lastName?: string | string[];\n picture?: string | string[];\n username?: string | string[];\n };\n cardLayout?: boolean;\n className?: string;\n displayNameAttributes?: string[];\n editable?: boolean;\n error?: string | null;\n fallback?: ReactElement | null;\n flattenedProfile?: User;\n hideFields?: string[];\n isLoading?: boolean;\n mode?: 'inline' | 'popup';\n onOpenChange?: (open: boolean) => void;\n onUpdate?: (payload: any) => Promise<void>;\n open?: boolean;\n /**\n * Component-level preferences to override global i18n and theme settings.\n * Preferences are deep-merged with global ones, with component preferences\n * taking precedence. Affects this component and all its descendants.\n */\n preferences?: Preferences;\n profile?: User;\n showFields?: string[];\n\n title?: string;\n userSchema?: Record<string, AttributeSchema> | null;\n}\n\n// Fields to skip based on schema.name\nconst fieldsToSkip: string[] = [\n 'roles.default',\n 'active',\n 'groups',\n 'accountLocked',\n 'accountDisabled',\n 'oneTimePassword',\n 'userSourceId',\n 'idpType',\n 'localCredentialExists',\n 'active',\n 'ResourceType',\n 'ExternalID',\n 'MetaData',\n 'verifiedMobileNumbers',\n 'verifiedEmailAddresses',\n 'phoneNumbers.mobile',\n 'emailAddresses',\n 'preferredMFAOption',\n 'attributes',\n 'picture',\n 'isReadOnly',\n 'isReadonly',\n];\n\n// Fields that should be readonly\nconst readonlyFields: string[] = ['attributes', 'id', 'isReadOnly', 'ouId', 'username', 'sub'];\n\nconst BaseUserProfile: FC<BaseUserProfileProps> = ({\n fallback = null,\n className = '',\n cardLayout = true,\n profile,\n flattenedProfile,\n userSchema,\n mode = 'inline',\n title,\n attributeMapping = {},\n editable = true,\n onOpenChange,\n onUpdate,\n open = false,\n error = null,\n isLoading = false,\n preferences,\n showFields = [],\n hideFields = [],\n displayNameAttributes = [],\n}: BaseUserProfileProps): ReactElement | null => {\n const {theme, colorScheme} = useTheme();\n const [editedUser, setEditedUser] = useState(flattenedProfile || profile);\n const [editingFields, setEditingFields] = useState<Record<string, boolean>>({});\n const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({});\n const {t} = useTranslation(preferences?.i18n);\n\n useEffect(() => {\n const nextUser = flattenedProfile ?? profile;\n if (!nextUser) return;\n\n setEditedUser((prev: any) => {\n if (!prev) return nextUser;\n\n const updated = {...nextUser};\n Object.keys(prev).forEach((key) => {\n if (editingFields[key]) {\n updated[key] = prev[key];\n }\n });\n return updated;\n });\n }, [flattenedProfile, profile, editingFields]);\n\n /**\n * Determines if a field should be visible based on showFields, hideFields, and fallback fieldsToSkip arrays.\n * When isSchemaBased is true, fieldsToSkip is bypassed so schema-defined fields render dynamically.\n */\n const shouldShowField = useCallback(\n (fieldName: string, isSchemaBased: boolean = false): boolean => {\n // For fallback without schema metadata, skip internal system fields\n if (!isSchemaBased && fieldsToSkip.includes(fieldName)) {\n return false;\n }\n\n // If hideFields is provided and contains this field, hide it\n if (hideFields.length > 0 && hideFields.includes(fieldName)) {\n return false;\n }\n\n // If showFields is provided and not empty, only show fields in that array\n if (showFields.length > 0) {\n return showFields.includes(fieldName);\n }\n\n return true;\n },\n [showFields, hideFields],\n );\n\n const PencilIcon = (): any => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z\" />\n </svg>\n );\n\n const toggleFieldEdit: any = useCallback((fieldName: string) => {\n setEditingFields((prev: any) => ({\n ...prev,\n [fieldName]: !prev[fieldName],\n }));\n }, []);\n\n const getFieldPlaceholder: any = useCallback(\n (schema: Schema): string => {\n const {type, displayName, description, name} = schema;\n\n const fieldLabel: any = displayName || description || name || 'value';\n\n switch (type) {\n case 'DATE_TIME':\n case 'STRING':\n default:\n return t('elements.fields.generic.placeholder', {field: fieldLabel.toLowerCase()});\n }\n },\n [t],\n );\n\n const formatLabel: any = useCallback(\n (key: string): string =>\n key\n .split(/(?=[A-Z])|_/)\n .map((word: any) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(' '),\n [],\n );\n\n const styles: any = useStyles(theme, colorScheme);\n\n const ObjectDisplay: FC<{data: unknown}> = ({data}: {data: unknown}): ReactElement | null => {\n if (!data || typeof data !== 'object') return null;\n\n return (\n <table className={styles.value}>\n <tbody>\n {Object.entries(data).map(([key, value]: any) => (\n <tr key={key}>\n <td className={styles.objectKey}>\n <strong>{formatLabel(key)}:</strong>\n </td>\n <td className={styles.objectValue}>\n {typeof value === 'object' ? <ObjectDisplay data={value} /> : String(value)}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n };\n\n function set(obj: Record<string, any>, path: string, value: any): void {\n const keys: any = path.split('.');\n let current: any = obj;\n\n for (let i: any = 0; i < keys.length; i += 1) {\n const key: any = keys[i];\n\n if (i === keys.length - 1) {\n current[key] = value;\n } else {\n if (!current[key] || typeof current[key] !== 'object') {\n current[key] = {};\n }\n current = current[key];\n }\n }\n }\n\n const handleFieldSave: any = useCallback(\n (schema: Schema): void => {\n if (!onUpdate || !schema.name) return;\n\n const fieldName: string = schema.name;\n const currentUser: any = flattenedProfile || profile;\n let fieldValue: any;\n if (editedUser && fieldName && editedUser[fieldName] !== undefined) {\n fieldValue = editedUser[fieldName];\n } else if (currentUser?.attributes?.[fieldName] !== undefined) {\n fieldValue = currentUser.attributes[fieldName];\n } else if (flattenedProfile?.[fieldName] !== undefined) {\n fieldValue = flattenedProfile[fieldName];\n } else {\n fieldValue = '';\n }\n\n if (Array.isArray(fieldValue)) {\n fieldValue = fieldValue.filter((v: any) => v !== undefined && v !== null && v !== '');\n }\n\n const strVal = String(fieldValue ?? '').trim();\n const fieldLabel = schema.displayName || (schema.name ? startCase(schema.name) : 'Field');\n\n // 1. Required validation\n if (schema.required && !strVal) {\n setFieldErrors((prev: Record<string, string>) => ({\n ...prev,\n [fieldName]: t('validations.required.field.error'),\n }));\n return;\n }\n\n // 2. Regex validation\n if (schema.regex && strVal) {\n try {\n const reg = new RegExp(schema.regex);\n if (!reg.test(strVal)) {\n setFieldErrors((prev: Record<string, string>) => ({\n ...prev,\n [fieldName]: t('validation.pattern.invalid'),\n }));\n return;\n }\n } catch (e) {\n // ignore invalid regex syntax safely\n }\n }\n\n // Clear field error if valid\n setFieldErrors((prev: Record<string, string>) => {\n const next = {...prev};\n delete next[fieldName];\n return next;\n });\n\n let payload: Record<string, any> = {};\n set(payload, fieldName, fieldValue);\n\n onUpdate(payload);\n\n toggleFieldEdit(fieldName);\n },\n [editedUser, flattenedProfile, profile, onUpdate, toggleFieldEdit, t],\n );\n\n const handleFieldCancel: any = useCallback(\n (fieldName: string) => {\n const currentUser: any = flattenedProfile || profile;\n const initialVal = currentUser?.attributes?.[fieldName] ?? currentUser?.[fieldName];\n setEditedUser((prev: any) => ({\n ...prev,\n [fieldName]: initialVal,\n }));\n setFieldErrors((prev: Record<string, string>) => {\n const next = {...prev};\n delete next[fieldName];\n return next;\n });\n toggleFieldEdit(fieldName);\n },\n [flattenedProfile, profile, toggleFieldEdit],\n );\n\n const defaultAttributeMappings: Record<string, string | string[]> = {\n email: ['emails', 'email'],\n firstName: ['name.givenName', 'given_name'],\n lastName: ['name.familyName', 'family_name'],\n picture: ['profile', 'profileUrl', 'picture', 'URL'],\n username: ['userName', 'username', 'user_name'],\n };\n\n const mergedMappings: Record<string, string | string[]> = Object.fromEntries(\n Object.entries({...defaultAttributeMappings, ...attributeMapping}).filter(\n (entry): entry is [string, string | string[]] => entry[1] !== undefined,\n ),\n );\n\n const renderSchemaField = (\n schema: Schema,\n isEditing: boolean,\n onEditValue?: (value: any) => void,\n onStartEdit?: () => void,\n ): ReactElement | null => {\n if (!schema) return null;\n const {value, displayName, description, name, type, required, mutability, subAttributes, multiValued} = schema;\n const label: any = displayName || description || (name ? startCase(name) : '');\n\n if (subAttributes && Array.isArray(subAttributes)) {\n return (\n <>\n {subAttributes.map((subAttr: any, index: any) => {\n let displayValue: string;\n if (Array.isArray(subAttr.value)) {\n displayValue = subAttr.value\n .map((item: any) => (typeof item === 'object' ? JSON.stringify(item) : String(item)))\n .join(', ');\n } else if (typeof subAttr.value === 'object') {\n displayValue = JSON.stringify(subAttr.value);\n } else {\n displayValue = String(subAttr.value);\n }\n\n return (\n <div key={index} className={styles.field}>\n <span className={styles.label}>{subAttr.displayName || subAttr.description || ''}</span>\n <div className={styles.value}>{displayValue}</div>\n </div>\n );\n })}\n </>\n );\n }\n\n if (Array.isArray(value) || multiValued) {\n const hasValues: any = Array.isArray(value)\n ? value.length > 0\n : value !== undefined && value !== null && value !== '';\n const isEditable: any = editable && mutability !== 'READ_ONLY' && !readonlyFields.includes(name || '');\n\n if (isEditing && onEditValue && isEditable) {\n let currentValue: any;\n if (editedUser && name && editedUser[name] !== undefined) {\n currentValue = editedUser[name];\n } else if (flattenedProfile && name && flattenedProfile[name] !== undefined) {\n currentValue = flattenedProfile[name];\n } else {\n currentValue = value;\n }\n\n let fieldValues: string[];\n if (Array.isArray(currentValue)) {\n fieldValues = currentValue.map(String);\n } else if (currentValue !== undefined && currentValue !== null && currentValue !== '') {\n fieldValues = [String(currentValue)];\n } else {\n fieldValues = [];\n }\n\n return (\n <>\n <span className={styles.label}>{label}</span>\n <div className={styles.value}>\n <MultiInput\n values={fieldValues}\n onChange={(newValues: any): void => {\n if (multiValued || Array.isArray(currentValue)) {\n onEditValue(newValues);\n } else {\n onEditValue(newValues[0] || '');\n }\n }}\n placeholder={getFieldPlaceholder(schema)}\n fieldType={type as 'STRING' | 'DATE_TIME' | 'BOOLEAN'}\n type={type === 'DATE_TIME' ? 'date' : 'text'}\n required={required}\n />\n </div>\n </>\n );\n }\n\n let displayValue: string;\n if (hasValues) {\n if (Array.isArray(value)) {\n displayValue = value\n .map((item: any) => (typeof item === 'object' ? JSON.stringify(item) : String(item)))\n .join(', ');\n } else {\n displayValue = String(value);\n }\n } else if (isEditable) {\n displayValue = getFieldPlaceholder(schema);\n } else {\n displayValue = '-';\n }\n\n return (\n <>\n <span className={styles.label}>{label}</span>\n <div className={cx(styles.value, !hasValues ? styles.valuePlaceholder : '')}>\n {!hasValues && isEditable && onStartEdit ? (\n <Button\n onClick={onStartEdit}\n variant=\"text\"\n color=\"secondary\"\n size=\"small\"\n title=\"Click to edit\"\n className={styles.editButton}\n >\n {displayValue}\n </Button>\n ) : (\n displayValue\n )}\n </div>\n </>\n );\n }\n if (type === 'COMPLEX' && typeof value === 'object') {\n return <ObjectDisplay data={value} />;\n }\n\n if (isEditing && onEditValue && mutability !== 'READ_ONLY' && !readonlyFields.includes(name || '')) {\n let fieldValue: any;\n if (editedUser && name && editedUser[name] !== undefined) {\n fieldValue = editedUser[name];\n } else if (flattenedProfile && name && flattenedProfile[name] !== undefined) {\n fieldValue = flattenedProfile[name];\n } else {\n fieldValue = value || '';\n }\n\n const commonProps: any = {\n label: undefined,\n onChange: (e: any) => onEditValue(e.target ? e.target.value : e),\n placeholder: getFieldPlaceholder(schema),\n required,\n value: fieldValue,\n // Removed inline style, use .styles.ts for marginBottom if needed\n };\n let field: ReactElement;\n switch (type) {\n case 'STRING':\n field = <TextField {...commonProps} />;\n break;\n case 'DATE_TIME':\n field = <DatePicker {...commonProps} />;\n break;\n case 'BOOLEAN':\n field = (\n <Checkbox\n {...commonProps}\n checked={!!fieldValue}\n onChange={(e: any): void => {\n onEditValue(e.target.checked);\n }}\n />\n );\n break;\n case 'COMPLEX':\n field = (\n <textarea\n value={fieldValue}\n onChange={(e: any): void => onEditValue(e.target.value)}\n placeholder={getFieldPlaceholder(schema)}\n required={required}\n className={styles.complexTextarea}\n />\n );\n break;\n default:\n field = <TextField {...commonProps} />;\n }\n return (\n <>\n <span className={styles.label}>{label}</span>\n <div className={styles.value}>{field}</div>\n </>\n );\n }\n\n const hasValue: any = value !== undefined && value !== null && value !== '';\n const isEditable: any = editable && mutability !== 'READ_ONLY' && !readonlyFields.includes(name || '');\n\n let displayValue: string;\n if (hasValue) {\n displayValue = String(value);\n } else if (isEditable) {\n displayValue = getFieldPlaceholder(schema);\n } else {\n displayValue = '-';\n }\n\n return (\n <>\n <span className={styles.label}>{label}</span>\n <div className={cx(styles.value, !hasValue ? styles.valuePlaceholder : '')}>\n {!hasValue && isEditable && onStartEdit ? (\n <Button\n onClick={onStartEdit}\n variant=\"text\"\n color=\"secondary\"\n size=\"small\"\n title=\"Click to edit\"\n className={styles.editButton}\n >\n {displayValue}\n </Button>\n ) : (\n displayValue\n )}\n </div>\n </>\n );\n };\n\n const renderUserInfo = (schema: Schema): any => {\n if (!schema?.name) return null;\n\n const hasValue: any = schema.value !== undefined && schema.value !== '' && schema.value !== null;\n const isFieldEditing: any = editingFields[schema.name];\n const isReadonlyField: any = readonlyFields.includes(schema.name);\n\n const shouldShow: any = hasValue || isFieldEditing || (editable && schema.mutability === 'READ_WRITE');\n\n if (!shouldShow) {\n return null;\n }\n\n return (\n <div className={styles.field}>\n <div className={styles.fieldInner}>\n {renderSchemaField(\n schema,\n isFieldEditing,\n (value: any) => {\n const tempEditedUser: any = {...editedUser};\n tempEditedUser[schema.name!] = value;\n setEditedUser(tempEditedUser);\n },\n () => toggleFieldEdit(schema.name),\n )}\n {fieldErrors[schema.name] && (\n <div style={{color: '#d32f2f', fontSize: '0.8rem', marginTop: '4px', fontWeight: 500}}>\n {fieldErrors[schema.name]}\n </div>\n )}\n </div>\n {editable && schema.mutability !== 'READ_ONLY' && !isReadonlyField && (\n <div className={styles.fieldActions}>\n {isFieldEditing && (\n <>\n <Button size=\"small\" color=\"primary\" variant=\"solid\" onClick={(): any => handleFieldSave(schema)}>\n Save\n </Button>\n <Button\n size=\"small\"\n color=\"secondary\"\n variant=\"solid\"\n onClick={(): any => handleFieldCancel(schema.name)}\n >\n Cancel\n </Button>\n </>\n )}\n {!isFieldEditing && hasValue && (\n <Button\n size=\"small\"\n color=\"tertiary\"\n variant=\"icon\"\n onClick={(): any => toggleFieldEdit(schema.name)}\n title=\"Edit\"\n className={styles.editButton}\n >\n <PencilIcon />\n </Button>\n )}\n </div>\n )}\n </div>\n );\n };\n\n if (!profile && !flattenedProfile) {\n return fallback;\n }\n\n const containerClasses: any = cx(\n styles.root,\n cardLayout ? styles.card : '',\n withVendorCSSClassPrefix('user-profile'),\n className,\n );\n\n const currentUser: any = flattenedProfile || profile;\n\n const renderProfileContent = (): any => {\n if (!currentUser) return null;\n\n const displayName: any = getDisplayName(mergedMappings, profile!, displayNameAttributes);\n\n let schemaItems: Schema[] = [];\n\n if (userSchema && typeof userSchema === 'object' && Object.keys(userSchema).length > 0) {\n schemaItems = Object.entries(userSchema)\n .filter(([key, metaAttr]: [string, AttributeSchema]) => {\n if (metaAttr?.credential) return false;\n return shouldShowField(key, true);\n })\n .map(([key, metaAttr]: [string, AttributeSchema]) => {\n const val = editedUser?.[key] ?? currentUser?.attributes?.[key] ?? currentUser?.[key] ?? '';\n\n const isReadonly =\n metaAttr.readOnly === true || metaAttr.mutability === 'READ_ONLY' || readonlyFields.includes(key);\n\n return {\n name: key,\n displayName: metaAttr.displayName ?? (key ? startCase(key) : ''),\n type: (metaAttr.type ?? 'STRING').toUpperCase(),\n regex: metaAttr.regex,\n required: !!metaAttr.required,\n mutability: isReadonly ? 'READ_ONLY' : 'READ_WRITE',\n value: val,\n };\n });\n } else {\n const profileEntries: any = Object.entries(currentUser)\n .filter(([key, value]: [string, any]) => {\n if (!shouldShowField(key)) return false;\n\n return value !== undefined && value !== '' && value !== null;\n })\n .sort(([a]: [string, ...any[]], [b]: [string, ...any[]]) => a.localeCompare(b));\n\n schemaItems = profileEntries.map(([key, value]: any) => {\n const isReadonly = readonlyFields.includes(key);\n return {\n name: key,\n displayName: startCase(key),\n mutability: isReadonly ? 'READ_ONLY' : 'READ_WRITE',\n value,\n };\n });\n }\n\n return (\n <>\n <div className={styles.profileSummary}>\n <Avatar\n imageUrl={getMappedUserProfileValue('picture', mergedMappings, currentUser)}\n name={displayName}\n size={70}\n alt={`${displayName}'s avatar`}\n isLoading={isLoading}\n />\n <Typography variant=\"h3\" fontWeight=\"medium\">\n {displayName}\n </Typography>\n {getMappedUserProfileValue('email', mergedMappings, currentUser) && (\n <Typography variant=\"body2\" color=\"textSecondary\">\n {getMappedUserProfileValue('email', mergedMappings, currentUser)}\n </Typography>\n )}\n </div>\n <Divider />\n {schemaItems.map((schemaWithValue: Schema) => (\n <div key={schemaWithValue.name} className={styles.info}>\n {renderUserInfo(schemaWithValue)}\n </div>\n ))}\n </>\n );\n };\n\n const profileContent: any = (\n <CardPrimitive className={containerClasses}>\n {error && (\n <AlertPrimitive\n variant=\"error\"\n className={cx(withVendorCSSClassPrefix(bem('user-profile', 'alert')), styles.alert)}\n >\n <AlertPrimitive.Title>{t('errors.heading') || 'Error'}</AlertPrimitive.Title>\n <AlertPrimitive.Description>{error}</AlertPrimitive.Description>\n </AlertPrimitive>\n )}\n <div className={styles.infoContainer}>{renderProfileContent()}</div>\n </CardPrimitive>\n );\n\n if (mode === 'popup') {\n return (\n <DialogPrimitive open={open} onOpenChange={onOpenChange}>\n <DialogPrimitive.Content>\n <DialogPrimitive.Heading>{title ?? t('user.profile.heading')}</DialogPrimitive.Heading>\n <div className={styles.popup}>{profileContent}</div>\n </DialogPrimitive.Content>\n </DialogPrimitive>\n );\n }\n\n return profileContent;\n};\n\nexport default BaseUserProfile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,MAAMA,eAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAGD,MAAMC,iBAA2B;CAAC;CAAc;CAAM;CAAc;CAAQ;CAAY;CAAM;AAE9F,MAAMC,mBAA6C,EACjD,WAAW,MACX,YAAY,IACZ,aAAa,MACb,SACA,kBACA,YACA,OAAO,UACP,OACA,mBAAmB,EAAE,EACrB,WAAW,MACX,cACA,UACA,OAAO,OACP,QAAQ,MACR,YAAY,OACZ,aACA,aAAa,EAAE,EACf,aAAa,EAAE,EACf,wBAAwB,EAAE,OACqB;CAC/C,MAAM,EAAC,OAAO,gBAAeC,0BAAU;CACvC,MAAM,CAAC,YAAY,qCAA0B,oBAAoB,QAAQ;CACzE,MAAM,CAAC,eAAe,wCAAsD,EAAE,CAAC;CAC/E,MAAM,CAAC,aAAa,sCAAmD,EAAE,CAAC;CAC1E,MAAM,EAAC,MAAKC,+BAAe,aAAa,KAAK;AAE7C,4BAAgB;EACd,MAAM,WAAW,oBAAoB;AACrC,MAAI,CAAC,SAAU;AAEf,iBAAe,SAAc;AAC3B,OAAI,CAAC,KAAM,QAAO;GAElB,MAAM,UAAU,EAAC,GAAG,UAAS;AAC7B,UAAO,KAAK,KAAK,CAAC,SAAS,Q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;MADxB,gBAAgB,KAEpB,CACN;MACD;;CAIP,MAAMC,iBACJ,4CAACC;EAAc,WAAW;aACvB,SACC,4CAACC;GACC,SAAQ;GACR,WAAWrB,kGAAgC,gBAAgB,QAAQ,CAAC,EAAE,OAAO,MAAM;cAEnF,2CAACqB,sBAAe,mBAAO,EAAE,iBAAiB,IAAI,UAA+B,EAC7E,2CAACA,sBAAe,yBAAa,QAAmC;IACjD,EAEnB,2CAAC;GAAI,WAAW,OAAO;aAAgB,sBAAsB;IAAO;GACtD;AAGlB,KAAI,SAAS,QACX,QACE,2CAACC;EAAsB;EAAoB;YACzC,4CAACA,uBAAgB,sBACf,2CAACA,uBAAgB,qBAAS,SAAS,EAAE,uBAAuB,GAA2B,EACvF,2CAAC;GAAI,WAAW,OAAO;aAAQ;IAAqB,IAC5B;GACV;AAItB,QAAO;;AAGT,8BAAe"}
@@ -46,8 +46,8 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
46
46
  * ```
47
47
  */
48
48
  const UserProfile = ({ preferences, editable = true,...rest }) => {
49
- const { baseUrl, instanceId, preferences: contextPreferences } = require_useThunderID.default();
50
- const { profile, flattenedProfile, onUpdateProfile } = require_useUser.default();
49
+ const { baseUrl, endpoints, instanceId, preferences: contextPreferences } = require_useThunderID.default();
50
+ const { profile, flattenedProfile, onUpdateProfile, userSchema } = require_useUser.default();
51
51
  const resolvedPreferences = {
52
52
  ...contextPreferences,
53
53
  ...preferences,
@@ -68,6 +68,7 @@ const UserProfile = ({ preferences, editable = true,...rest }) => {
68
68
  });
69
69
  onUpdateProfile(await require_updateMeProfile.default({
70
70
  baseUrl,
71
+ url: (0, __thunderid_browser.resolveResourceEndpoint)("usersMe", { endpoints }),
71
72
  instanceId,
72
73
  payload: updatedAttributes
73
74
  }));
@@ -80,6 +81,7 @@ const UserProfile = ({ preferences, editable = true,...rest }) => {
80
81
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_BaseUserProfile.default, {
81
82
  profile: profile ?? void 0,
82
83
  flattenedProfile: flattenedProfile ?? void 0,
84
+ userSchema: userSchema ?? void 0,
83
85
  editable: isEditableProfile,
84
86
  onUpdate: isEditableProfile ? handleProfileUpdate : void 0,
85
87
  error,
@@ -1 +1 @@
1
- {"version":3,"file":"UserProfile.cjs","names":["UserProfile: FC<UserProfileProps>","useThunderID","useUser","useTranslation","isEditableProfile: boolean","updatedAttributes: Record<string, unknown>","updateMeProfile","caughtError: unknown","message: string","ThunderIDError","BaseUserProfile"],"sources":["../../../../../src/components/presentation/UserProfile/UserProfile.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {ThunderIDError, User, deepMerge} from '@thunderid/browser';\nimport {FC, ReactElement, useState} from 'react';\n// eslint-disable-next-line import/no-named-as-default\nimport BaseUserProfile, {BaseUserProfileProps} from './BaseUserProfile';\nimport updateMeProfile from '../../../api/updateMeProfile';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\nimport useUser from '../../../contexts/User/useUser';\nimport useTranslation from '../../../hooks/useTranslation';\n\n/**\n * Props for the UserProfile component.\n * Extends BaseUserProfileProps but makes the user prop optional since it will be obtained from useThunderID\n */\nexport type UserProfileProps = Omit<BaseUserProfileProps, 'user' | 'profile' | 'flattenedProfile'>;\n\n/**\n * UserProfile component displays the authenticated user's profile information in a\n * structured and styled format. It shows user details such as display name, email,\n * username, and other available profile information from ThunderID.\n *\n * This component is the React-specific implementation that uses the BaseUserProfile\n * and automatically retrieves the user data from ThunderID context if not provided.\n *\n * @example\n * ```tsx\n * // Basic usage - will use user from ThunderID context\n * <UserProfile />\n *\n * // With explicit user data\n * <UserProfile user={specificUser} />\n *\n * // With card layout and custom fallback\n * <UserProfile\n * cardLayout={true}\n * fallback={<div>Please sign in to view your profile</div>}\n * />\n *\n * // With field filtering - only show specific fields\n * <UserProfile\n * showFields={['name.givenName', 'name.familyName', 'emails']}\n * />\n *\n * // With field hiding - hide specific fields\n * <UserProfile\n * hideFields={['phoneNumbers', 'addresses']}\n * />\n * ```\n */\nconst UserProfile: FC<UserProfileProps> = ({preferences, editable = true, ...rest}: UserProfileProps): ReactElement => {\n const {baseUrl, instanceId, preferences: contextPreferences} = useThunderID();\n const {profile, flattenedProfile, onUpdateProfile} = useUser();\n const resolvedPreferences = {\n ...contextPreferences,\n ...preferences,\n user: {\n ...contextPreferences?.user,\n ...preferences?.user,\n },\n };\n const {t} = useTranslation(resolvedPreferences?.i18n);\n const isEditableProfile: boolean = resolvedPreferences?.user?.fetchUserProfile === false ? false : editable;\n\n const [error, setError] = useState<string | null>(null);\n\n const handleProfileUpdate = async (payload: Record<string, unknown>): Promise<void> => {\n setError(null);\n\n try {\n const updatedAttributes: Record<string, unknown> = deepMerge(\n (profile?.['attributes'] as Record<string, unknown>) ?? {},\n payload,\n );\n\n Object.keys(updatedAttributes).forEach((key) => {\n if (updatedAttributes[key] === undefined || updatedAttributes[key] === null) {\n delete updatedAttributes[key];\n }\n });\n\n const response: User = await updateMeProfile({baseUrl, instanceId, payload: updatedAttributes});\n onUpdateProfile(response);\n } catch (caughtError: unknown) {\n let message: string = t('user.profile.update.generic.error');\n\n if (caughtError instanceof ThunderIDError) {\n message = caughtError?.message;\n }\n\n setError(message);\n }\n };\n\n return (\n <BaseUserProfile\n profile={profile ?? undefined}\n flattenedProfile={flattenedProfile ?? undefined}\n editable={isEditableProfile}\n onUpdate={isEditableProfile ? handleProfileUpdate : undefined}\n error={error}\n preferences={resolvedPreferences}\n {...rest}\n />\n );\n};\n\nexport default UserProfile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAMA,eAAqC,EAAC,aAAa,WAAW,KAAM,GAAG,WAA0C;CACrH,MAAM,EAAC,SAAS,YAAY,aAAa,uBAAsBC,8BAAc;CAC7E,MAAM,EAAC,SAAS,kBAAkB,oBAAmBC,yBAAS;CAC9D,MAAM,sBAAsB;EAC1B,GAAG;EACH,GAAG;EACH,MAAM;GACJ,GAAG,oBAAoB;GACvB,GAAG,aAAa;GACjB;EACF;CACD,MAAM,EAAC,MAAKC,+BAAe,qBAAqB,KAAK;CACrD,MAAMC,oBAA6B,qBAAqB,MAAM,qBAAqB,QAAQ,QAAQ;CAEnG,MAAM,CAAC,OAAO,gCAAoC,KAAK;CAEvD,MAAM,sBAAsB,OAAO,YAAoD;AACrF,WAAS,KAAK;AAEd,MAAI;GACF,MAAMC,uDACH,UAAU,iBAA6C,EAAE,EAC1D,QACD;AAED,UAAO,KAAK,kBAAkB,CAAC,SAAS,QAAQ;AAC9C,QAAI,kBAAkB,SAAS,UAAa,kBAAkB,SAAS,KACrE,QAAO,kBAAkB;KAE3B;AAGF,mBADuB,MAAMC,gCAAgB;IAAC;IAAS;IAAY,SAAS;IAAkB,CAAC,CACtE;WAClBC,aAAsB;GAC7B,IAAIC,UAAkB,EAAE,oCAAoC;AAE5D,OAAI,uBAAuBC,mCACzB,WAAU,aAAa;AAGzB,YAAS,QAAQ;;;AAIrB,QACE,2CAACC;EACC,SAAS,WAAW;EACpB,kBAAkB,oBAAoB;EACtC,UAAU;EACV,UAAU,oBAAoB,sBAAsB;EAC7C;EACP,aAAa;EACb,GAAI;GACJ;;AAIN,0BAAe"}
1
+ {"version":3,"file":"UserProfile.cjs","names":["UserProfile: FC<UserProfileProps>","useThunderID","useUser","useTranslation","isEditableProfile: boolean","updatedAttributes: Record<string, unknown>","updateMeProfile","caughtError: unknown","message: string","ThunderIDError","BaseUserProfile"],"sources":["../../../../../src/components/presentation/UserProfile/UserProfile.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {ThunderIDError, User, deepMerge, resolveResourceEndpoint} from '@thunderid/browser';\nimport {FC, ReactElement, useState} from 'react';\n// eslint-disable-next-line import/no-named-as-default\nimport BaseUserProfile, {BaseUserProfileProps} from './BaseUserProfile';\nimport updateMeProfile from '../../../api/updateMeProfile';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\nimport useUser from '../../../contexts/User/useUser';\nimport useTranslation from '../../../hooks/useTranslation';\n\n/**\n * Props for the UserProfile component.\n * Extends BaseUserProfileProps but makes the user prop optional since it will be obtained from useThunderID\n */\nexport type UserProfileProps = Omit<BaseUserProfileProps, 'user' | 'profile' | 'flattenedProfile'>;\n\n/**\n * UserProfile component displays the authenticated user's profile information in a\n * structured and styled format. It shows user details such as display name, email,\n * username, and other available profile information from ThunderID.\n *\n * This component is the React-specific implementation that uses the BaseUserProfile\n * and automatically retrieves the user data from ThunderID context if not provided.\n *\n * @example\n * ```tsx\n * // Basic usage - will use user from ThunderID context\n * <UserProfile />\n *\n * // With explicit user data\n * <UserProfile user={specificUser} />\n *\n * // With card layout and custom fallback\n * <UserProfile\n * cardLayout={true}\n * fallback={<div>Please sign in to view your profile</div>}\n * />\n *\n * // With field filtering - only show specific fields\n * <UserProfile\n * showFields={['name.givenName', 'name.familyName', 'emails']}\n * />\n *\n * // With field hiding - hide specific fields\n * <UserProfile\n * hideFields={['phoneNumbers', 'addresses']}\n * />\n * ```\n */\nconst UserProfile: FC<UserProfileProps> = ({preferences, editable = true, ...rest}: UserProfileProps): ReactElement => {\n const {baseUrl, endpoints, instanceId, preferences: contextPreferences} = useThunderID();\n const {profile, flattenedProfile, onUpdateProfile, userSchema} = useUser();\n const resolvedPreferences = {\n ...contextPreferences,\n ...preferences,\n user: {\n ...contextPreferences?.user,\n ...preferences?.user,\n },\n };\n const {t} = useTranslation(resolvedPreferences?.i18n);\n const isEditableProfile: boolean = resolvedPreferences?.user?.fetchUserProfile === false ? false : editable;\n\n const [error, setError] = useState<string | null>(null);\n\n const handleProfileUpdate = async (payload: Record<string, unknown>): Promise<void> => {\n setError(null);\n\n try {\n const updatedAttributes: Record<string, unknown> = deepMerge(\n (profile?.['attributes'] as Record<string, unknown>) ?? {},\n payload,\n );\n\n Object.keys(updatedAttributes).forEach((key) => {\n if (updatedAttributes[key] === undefined || updatedAttributes[key] === null) {\n delete updatedAttributes[key];\n }\n });\n\n const response: User = await updateMeProfile({\n baseUrl,\n url: resolveResourceEndpoint('usersMe', {endpoints}),\n instanceId,\n payload: updatedAttributes,\n });\n onUpdateProfile(response);\n } catch (caughtError: unknown) {\n let message: string = t('user.profile.update.generic.error');\n\n if (caughtError instanceof ThunderIDError) {\n message = caughtError?.message;\n }\n\n setError(message);\n }\n };\n\n return (\n <BaseUserProfile\n profile={profile ?? undefined}\n flattenedProfile={flattenedProfile ?? undefined}\n userSchema={userSchema ?? undefined}\n editable={isEditableProfile}\n onUpdate={isEditableProfile ? handleProfileUpdate : undefined}\n error={error}\n preferences={resolvedPreferences}\n {...rest}\n />\n );\n};\n\nexport default UserProfile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAMA,eAAqC,EAAC,aAAa,WAAW,KAAM,GAAG,WAA0C;CACrH,MAAM,EAAC,SAAS,WAAW,YAAY,aAAa,uBAAsBC,8BAAc;CACxF,MAAM,EAAC,SAAS,kBAAkB,iBAAiB,eAAcC,yBAAS;CAC1E,MAAM,sBAAsB;EAC1B,GAAG;EACH,GAAG;EACH,MAAM;GACJ,GAAG,oBAAoB;GACvB,GAAG,aAAa;GACjB;EACF;CACD,MAAM,EAAC,MAAKC,+BAAe,qBAAqB,KAAK;CACrD,MAAMC,oBAA6B,qBAAqB,MAAM,qBAAqB,QAAQ,QAAQ;CAEnG,MAAM,CAAC,OAAO,gCAAoC,KAAK;CAEvD,MAAM,sBAAsB,OAAO,YAAoD;AACrF,WAAS,KAAK;AAEd,MAAI;GACF,MAAMC,uDACH,UAAU,iBAA6C,EAAE,EAC1D,QACD;AAED,UAAO,KAAK,kBAAkB,CAAC,SAAS,QAAQ;AAC9C,QAAI,kBAAkB,SAAS,UAAa,kBAAkB,SAAS,KACrE,QAAO,kBAAkB;KAE3B;AAQF,mBANuB,MAAMC,gCAAgB;IAC3C;IACA,sDAA6B,WAAW,EAAC,WAAU,CAAC;IACpD;IACA,SAAS;IACV,CAAC,CACuB;WAClBC,aAAsB;GAC7B,IAAIC,UAAkB,EAAE,oCAAoC;AAE5D,OAAI,uBAAuBC,mCACzB,WAAU,aAAa;AAGzB,YAAS,QAAQ;;;AAIrB,QACE,2CAACC;EACC,SAAS,WAAW;EACpB,kBAAkB,oBAAoB;EACtC,YAAY,cAAc;EAC1B,UAAU;EACV,UAAU,oBAAoB,sBAAsB;EAC7C;EACP,aAAa;EACb,GAAI;GACJ;;AAIN,0BAAe"}
@@ -209,12 +209,17 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
209
209
  const identifier = component.ref;
210
210
  const value = formValues[identifier] || "";
211
211
  const error = touchedFields[identifier] || false ? formErrors[identifier] : void 0;
212
+ const reportedLength = Number(options.additionalData?.["otpLength"]);
213
+ const otpLength = Number.isInteger(reportedLength) && reportedLength > 0 ? reportedLength : void 0;
214
+ const numericOnly = options.additionalData?.["otpNumericOnly"] !== "false";
212
215
  return (0, react.cloneElement)(require_FieldFactory.createField({
213
216
  className: require_emotion.cx(options.inputClassName, component.classes),
214
217
  error,
215
218
  id: component.id,
216
219
  label: resolve(component.label) || "",
220
+ length: otpLength,
217
221
  name: identifier,
222
+ numericOnly,
218
223
  onBlur: () => options.onInputBlur?.(identifier),
219
224
  onChange: (newValue) => onInputChange(identifier, newValue),
220
225
  placeholder: resolve(component.placeholder) || "",