react-unified-auth 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4064,19 +4064,14 @@ function useDynamicForm(formId) {
4064
4064
  }
4065
4065
 
4066
4066
  function Button({ variant = 'primary', size = 'md', loading = false, fullWidth = false, children, disabled, className = '', ...props }) {
4067
- const baseStyles = 'inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed';
4068
- const variantStyles = {
4069
- primary: 'bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500',
4070
- secondary: 'bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500',
4071
- outline: 'border-2 border-blue-600 text-blue-600 hover:bg-blue-50 focus:ring-blue-500',
4072
- };
4073
- const sizeStyles = {
4074
- sm: 'px-3 py-1.5 text-sm',
4075
- md: 'px-4 py-2 text-base',
4076
- lg: 'px-6 py-3 text-lg',
4077
- };
4078
- const widthStyles = fullWidth ? 'w-full' : '';
4079
- return (jsxRuntime.jsxs("button", { className: `${baseStyles} ${variantStyles[variant]} ${sizeStyles[size]} ${widthStyles} ${className}`, disabled: disabled || loading, ...props, children: [loading && (jsxRuntime.jsxs("svg", { className: "animate-spin -ml-1 mr-2 h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [jsxRuntime.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), jsxRuntime.jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] })), children] }));
4067
+ const buttonClasses = [
4068
+ 'usa-button',
4069
+ `usa-button--${variant}`,
4070
+ `usa-button--${size}`,
4071
+ fullWidth ? 'usa-button--full-width' : '',
4072
+ className
4073
+ ].filter(Boolean).join(' ');
4074
+ return (jsxRuntime.jsxs("button", { className: buttonClasses, disabled: disabled || loading, ...props, children: [loading && (jsxRuntime.jsxs("svg", { className: "usa-loading-spinner", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [jsxRuntime.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), jsxRuntime.jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] })), children] }));
4080
4075
  }
4081
4076
 
4082
4077
  function validateField(field, value) {
@@ -4165,8 +4160,8 @@ function DynamicForm({ fields, onSubmit, submitText = 'Submit', submitVariant =
4165
4160
  const renderField = (field) => {
4166
4161
  const error = touched[field.name] ? errors[field.name] : '';
4167
4162
  const hasError = !!error;
4168
- const baseInputStyles = 'w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 transition-colors';
4169
- const errorStyles = hasError ? 'border-red-500 focus:ring-red-500' : 'border-gray-300 focus:ring-blue-500';
4163
+ const baseInputStyles = 'usa-form__input';
4164
+ const errorStyles = hasError ? 'usa-form__input--error' : '';
4170
4165
  switch (field.type) {
4171
4166
  case 'text':
4172
4167
  case 'email':
@@ -4174,18 +4169,18 @@ function DynamicForm({ fields, onSubmit, submitText = 'Submit', submitVariant =
4174
4169
  case 'number':
4175
4170
  return (jsxRuntime.jsx("input", { type: field.type, name: field.name, value: values[field.name] || '', onChange: (e) => handleChange(field.name, e.target.value), onBlur: () => handleBlur(field.name), placeholder: field.placeholder, className: `${baseInputStyles} ${errorStyles}`, disabled: loading }));
4176
4171
  case 'textarea':
4177
- return (jsxRuntime.jsx("textarea", { name: field.name, value: values[field.name] || '', onChange: (e) => handleChange(field.name, e.target.value), onBlur: () => handleBlur(field.name), placeholder: field.placeholder, rows: 4, className: `${baseInputStyles} ${errorStyles}`, disabled: loading }));
4172
+ return (jsxRuntime.jsx("textarea", { name: field.name, value: values[field.name] || '', onChange: (e) => handleChange(field.name, e.target.value), onBlur: () => handleBlur(field.name), placeholder: field.placeholder, rows: 4, className: "usa-form__textarea", disabled: loading }));
4178
4173
  case 'select':
4179
- return (jsxRuntime.jsxs("select", { name: field.name, value: values[field.name] || '', onChange: (e) => handleChange(field.name, e.target.value), onBlur: () => handleBlur(field.name), className: `${baseInputStyles} ${errorStyles}`, disabled: loading, children: [jsxRuntime.jsx("option", { value: "", children: "Select an option" }), field.options?.map((option) => (jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value)))] }));
4174
+ return (jsxRuntime.jsxs("select", { name: field.name, value: values[field.name] || '', onChange: (e) => handleChange(field.name, e.target.value), onBlur: () => handleBlur(field.name), className: "usa-form__select", disabled: loading, children: [jsxRuntime.jsx("option", { value: "", children: "Select an option" }), field.options?.map((option) => (jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value)))] }));
4180
4175
  case 'checkbox':
4181
- return (jsxRuntime.jsx("input", { type: "checkbox", name: field.name, checked: values[field.name] || false, onChange: (e) => handleChange(field.name, e.target.checked), onBlur: () => handleBlur(field.name), className: "w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500", disabled: loading }));
4176
+ return (jsxRuntime.jsx("input", { type: "checkbox", name: field.name, checked: values[field.name] || false, onChange: (e) => handleChange(field.name, e.target.checked), onBlur: () => handleBlur(field.name), className: "usa-form__checkbox", disabled: loading }));
4182
4177
  case 'radio':
4183
- return (jsxRuntime.jsx("div", { className: "space-y-2", children: field.options?.map((option) => (jsxRuntime.jsxs("label", { className: "flex items-center space-x-2", children: [jsxRuntime.jsx("input", { type: "radio", name: field.name, value: option.value, checked: values[field.name] === option.value, onChange: (e) => handleChange(field.name, e.target.value), onBlur: () => handleBlur(field.name), className: "w-4 h-4 text-blue-600 border-gray-300 focus:ring-blue-500", disabled: loading }), jsxRuntime.jsx("span", { children: option.label })] }, option.value))) }));
4178
+ return (jsxRuntime.jsx("div", { className: "usa-form__radio-group", children: field.options?.map((option) => (jsxRuntime.jsxs("label", { className: "usa-form__radio-label", children: [jsxRuntime.jsx("input", { type: "radio", name: field.name, value: option.value, checked: values[field.name] === option.value, onChange: (e) => handleChange(field.name, e.target.value), onBlur: () => handleBlur(field.name), className: "usa-form__radio", disabled: loading }), jsxRuntime.jsx("span", { children: option.label })] }, option.value))) }));
4184
4179
  default:
4185
4180
  return null;
4186
4181
  }
4187
4182
  };
4188
- return (jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [fields.map((field) => (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: [field.label, field.required && jsxRuntime.jsx("span", { className: "text-red-500 ml-1", children: "*" })] }), renderField(field), touched[field.name] && errors[field.name] && (jsxRuntime.jsx("p", { className: "mt-1 text-sm text-red-600", children: errors[field.name] }))] }, field.name))), jsxRuntime.jsx(Button, { type: "submit", variant: submitVariant, loading: loading, fullWidth: true, children: submitText })] }));
4183
+ return (jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "usa-form", children: [fields.map((field) => (jsxRuntime.jsxs("div", { className: "usa-form__field-group", children: [jsxRuntime.jsx("label", { className: `usa-form__label ${field.required ? 'usa-form__label--required' : ''}`, children: field.label }), renderField(field), touched[field.name] && errors[field.name] && (jsxRuntime.jsx("p", { className: "usa-form__error", children: errors[field.name] }))] }, field.name))), jsxRuntime.jsx(Button, { type: "submit", variant: submitVariant, loading: loading, fullWidth: true, children: submitText })] }));
4189
4184
  }
4190
4185
 
4191
4186
  function LoginForm({ formId, onSuccess, onError }) {
@@ -4218,32 +4213,32 @@ function LoginForm({ formId, onSuccess, onError }) {
4218
4213
  }
4219
4214
  };
4220
4215
  if (formLoading) {
4221
- return (jsxRuntime.jsx("div", { className: "flex items-center justify-center p-8", children: jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600" }) }));
4216
+ return (jsxRuntime.jsx("div", { className: "usa-login-form__loading", children: jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600" }) }));
4222
4217
  }
4223
4218
  if (formError) {
4224
- return (jsxRuntime.jsx("div", { className: "p-4 bg-red-50 border border-red-200 rounded-lg", children: jsxRuntime.jsx("p", { className: "text-red-600", children: formError }) }));
4219
+ return (jsxRuntime.jsx("div", { className: "usa-login-form__error", children: jsxRuntime.jsx("p", { className: "text-red-600", children: formError }) }));
4225
4220
  }
4226
4221
  if (!formConfig) {
4227
4222
  return null;
4228
4223
  }
4229
- return (jsxRuntime.jsx("div", { className: "w-full", children: jsxRuntime.jsx(DynamicForm, { fields: formConfig.fields, onSubmit: handleSubmit, submitText: formConfig.submitButton?.text || 'Login', submitVariant: formConfig.submitButton?.variant || 'primary', loading: submitting }) }));
4224
+ return (jsxRuntime.jsx("div", { className: "usa-login-form", children: jsxRuntime.jsx(DynamicForm, { fields: formConfig.fields, onSubmit: handleSubmit, submitText: formConfig.submitButton?.text || 'Login', submitVariant: formConfig.submitButton?.variant || 'primary', loading: submitting }) }));
4230
4225
  }
4231
4226
 
4232
4227
  function UserInfoBox({ user, onLogout, loading = false, className = '' }) {
4233
- return (jsxRuntime.jsxs("div", { className: `bg-white rounded-lg shadow-md p-6 ${className}`, children: [jsxRuntime.jsxs("div", { className: "flex items-center space-x-4", children: [user.avatar && (jsxRuntime.jsx("img", { src: user.avatar, alt: user.name, className: "w-16 h-16 rounded-full object-cover" })), jsxRuntime.jsxs("div", { className: "flex-1", children: [jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-gray-900", children: user.name }), user.email && (jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: user.email }))] })] }), onLogout && (jsxRuntime.jsx("div", { className: "mt-4", children: jsxRuntime.jsx(Button, { variant: "outline", size: "sm", onClick: onLogout, loading: loading, fullWidth: true, children: "Logout" }) }))] }));
4228
+ return (jsxRuntime.jsxs("div", { className: `usa-user-info-box ${className}`, children: [jsxRuntime.jsxs("div", { className: "usa-user-info-box__header", children: [user.avatar && (jsxRuntime.jsx("img", { src: user.avatar, alt: user.name, className: "usa-user-info-box__avatar" })), jsxRuntime.jsxs("div", { className: "usa-user-info-box__details", children: [jsxRuntime.jsx("h3", { className: "usa-user-info-box__name", children: user.name }), user.email && (jsxRuntime.jsx("p", { className: "usa-user-info-box__email", children: user.email }))] })] }), onLogout && (jsxRuntime.jsx("div", { className: "mt-4", children: jsxRuntime.jsx(Button, { variant: "outline", size: "sm", onClick: onLogout, loading: loading, fullWidth: true, children: "Logout" }) }))] }));
4234
4229
  }
4235
4230
 
4236
4231
  function SocialLoginButton({ provider, onClick, loading = false, className = '' }) {
4237
4232
  const handleClick = () => {
4238
4233
  onClick(provider);
4239
4234
  };
4240
- return (jsxRuntime.jsxs(Button, { variant: "outline", onClick: handleClick, loading: loading, fullWidth: true, className: `flex items-center justify-center space-x-2 ${className}`, children: [provider.icon && (jsxRuntime.jsx("img", { src: provider.icon, alt: provider.name, className: "w-5 h-5" })), jsxRuntime.jsxs("span", { children: ["Continue with ", provider.name] })] }));
4235
+ return (jsxRuntime.jsxs(Button, { variant: "outline", onClick: handleClick, loading: loading, fullWidth: true, className: `usa-social-login-button ${className}`, children: [provider.icon && (jsxRuntime.jsx("img", { src: provider.icon, alt: provider.name, className: "usa-social-login-button__icon" })), jsxRuntime.jsxs("span", { children: ["Continue with ", provider.name] })] }));
4241
4236
  }
4242
4237
  function SocialLogin({ providers, onLogin, loading = false, className = '' }) {
4243
4238
  if (providers.length === 0) {
4244
4239
  return null;
4245
4240
  }
4246
- return (jsxRuntime.jsx("div", { className: `space-y-3 ${className}`, children: providers.map((provider) => (jsxRuntime.jsx(SocialLoginButton, { provider: provider, onClick: onLogin, loading: loading }, provider.id))) }));
4241
+ return (jsxRuntime.jsx("div", { className: `usa-social-login ${className}`, children: providers.map((provider) => (jsxRuntime.jsx(SocialLoginButton, { provider: provider, onClick: onLogin, loading: loading }, provider.id))) }));
4247
4242
  }
4248
4243
 
4249
4244
  exports.ApiClient = ApiClient;