@ews-admin/global-design-system 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import React, { forwardRef, createElement, useState, useRef, useEffect, useId, useCallback, createContext, useContext } from 'react';
3
3
 
4
- function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
4
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
5
5
 
6
6
  const LOCAL_PORTS = {
7
7
  bff: 8082,
8
8
  loginBff: 8080,
9
9
  app: 3000,
10
- login: 3001,
10
+ login: 4001,
11
11
  dashboard: 3002,
12
12
  admin: 3008,
13
13
  };
@@ -62,7 +62,7 @@ function createEnvConfig(env, overrides) {
62
62
  * Available country codes supported by the platform
63
63
  */
64
64
  const COUNTRY_CODES = [
65
- { code: "+221", country: "SN" }, // Senegal
65
+ { code: "+221", country: "SN" },
66
66
  { code: "+235", country: "TD" }, // Chad
67
67
  ];
68
68
  /**
@@ -32543,7 +32543,7 @@ const UserIcon = ({ size = 24, color = "currentColor", className = "", ...props
32543
32543
  return jsx(User, { size: size, color: color, className: className, ...props });
32544
32544
  };
32545
32545
 
32546
- const Input = React.forwardRef(({ className, variant = "default", size = "md", label, helperText, error, leftIcon, rightIcon, fullWidth = false, showPasswordToggle = false, required = false, countryCodeSelect, leftAddon, rightAddon, id, type = "text", ...props }, ref) => {
32546
+ const Input = React.forwardRef(({ className, variant = "default", size = "md", label, helperText, error, leftIcon, rightIcon, fullWidth = false, showPasswordToggle = false, required = false, countryCodeSelect, leftAddon, rightAddon, id, type = "text", onChange, onBlur, ...props }, ref) => {
32547
32547
  const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
32548
32548
  const hasError = Boolean(error);
32549
32549
  const actualVariant = hasError ? "error" : variant;
@@ -32552,6 +32552,24 @@ const Input = React.forwardRef(({ className, variant = "default", size = "md", l
32552
32552
  const isPasswordInput = type === "password";
32553
32553
  const shouldShowPasswordToggle = showPasswordToggle && isPasswordInput;
32554
32554
  const actualType = isPasswordInput && showPassword ? "text" : type;
32555
+ // Normalize spaces for text-like inputs
32556
+ const shouldNormalize = type !== "password" && type !== "number" && type !== "checkbox";
32557
+ const handleChange = (e) => {
32558
+ if (shouldNormalize) {
32559
+ e.target.value = e.target.value.replace(/^\s+/, "").replace(/\s{2,}/g, " ");
32560
+ }
32561
+ onChange?.(e);
32562
+ };
32563
+ const handleBlur = (e) => {
32564
+ if (shouldNormalize && onChange) {
32565
+ const trimmed = e.target.value.replace(/\s+$/, "");
32566
+ if (trimmed !== e.target.value) {
32567
+ e.target.value = trimmed;
32568
+ onChange(e);
32569
+ }
32570
+ }
32571
+ onBlur?.(e);
32572
+ };
32555
32573
  // Country code dropdown state
32556
32574
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
32557
32575
  const dropdownRef = useRef(null);
@@ -32602,7 +32620,7 @@ const Input = React.forwardRef(({ className, variant = "default", size = "md", l
32602
32620
  countryCodeSelect.onChange(item.code);
32603
32621
  setIsDropdownOpen(false);
32604
32622
  }, className: cn("px-3 py-2 text-sm cursor-pointer transition-colors", isSelected && "bg-ews-primary text-white", !isSelected && "hover:bg-ews-gray-50"), children: [jsx("span", { className: "font-medium", children: item.code }), item.country && (jsx("span", { className: cn("ml-2 text-xs", isSelected ? "text-white/80" : "text-ews-gray-500"), children: item.country }))] }, item.code));
32605
- }) }))] }) })), leftIcon && !countryCodeSelect && !leftAddon && (jsx("div", { className: "flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none", children: jsx("span", { className: cn("text-ews-gray-400", iconSizes[size]), children: leftIcon }) })), leftAddon && !countryCodeSelect && !leftIcon && (jsx("div", { className: "flex absolute inset-y-0 left-0 items-center pointer-events-none overflow-hidden rounded-l-md", children: jsx("span", { className: "flex items-center h-full px-3 text-sm font-medium whitespace-nowrap bg-ews-gray-50 border-r border-ews-gray-300 text-ews-gray-600", children: leftAddon }) })), jsx("input", { id: inputId, type: actualType, className: cn(baseStyles, variants[actualVariant], sizes[size], countryCodeSelect && "pl-24", leftIcon && !countryCodeSelect && !leftAddon && "pl-10", leftAddon && !countryCodeSelect && !leftIcon && "pl-16", (rightIcon || shouldShowPasswordToggle) && "pr-10", rightAddon && !rightIcon && !shouldShowPasswordToggle && "pr-16", className), ref: ref, ...props }), rightAddon && !rightIcon && !shouldShowPasswordToggle && (jsx("div", { className: "flex absolute inset-y-0 right-0 items-center pr-3 pointer-events-none", children: jsx("span", { className: "text-sm font-medium text-ews-gray-500", children: rightAddon }) })), rightIcon && !shouldShowPasswordToggle && (jsx("div", { className: "flex absolute inset-y-0 right-0 items-center pr-3 pointer-events-none", children: jsx("span", { className: cn("text-ews-gray-400", iconSizes[size]), children: rightIcon }) })), shouldShowPasswordToggle && (jsx("button", { type: "button", className: "flex absolute inset-y-0 right-0 items-center pr-3", onClick: () => setShowPassword(!showPassword), tabIndex: -1, children: jsx("span", { className: cn("transition-colors text-ews-gray-400 hover:text-ews-gray-600", iconSizes[size]), children: showPassword ? jsx(EyeOff, { size: 16 }) : jsx(Eye, { size: 16 }) }) }))] }), (error || helperText) && (jsx("p", { className: cn("text-sm", error ? "text-ews-error" : "text-ews-gray-500"), children: error || helperText }))] }));
32623
+ }) }))] }) })), leftIcon && !countryCodeSelect && !leftAddon && (jsx("div", { className: "flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none", children: jsx("span", { className: cn("text-ews-gray-400", iconSizes[size]), children: leftIcon }) })), leftAddon && !countryCodeSelect && !leftIcon && (jsx("div", { className: "flex absolute inset-y-0 left-0 items-center pointer-events-none overflow-hidden rounded-l-md", children: jsx("span", { className: "flex items-center h-full px-3 text-sm font-medium whitespace-nowrap bg-ews-gray-50 border-r border-ews-gray-300 text-ews-gray-600", children: leftAddon }) })), jsx("input", { id: inputId, type: actualType, className: cn(baseStyles, variants[actualVariant], sizes[size], countryCodeSelect && "pl-24", leftIcon && !countryCodeSelect && !leftAddon && "pl-10", leftAddon && !countryCodeSelect && !leftIcon && "pl-16", (rightIcon || shouldShowPasswordToggle) && "pr-10", rightAddon && !rightIcon && !shouldShowPasswordToggle && "pr-16", className), ref: ref, onChange: handleChange, onBlur: handleBlur, ...props }), rightAddon && !rightIcon && !shouldShowPasswordToggle && (jsx("div", { className: "flex absolute inset-y-0 right-0 items-center pr-3 pointer-events-none", children: jsx("span", { className: "text-sm font-medium text-ews-gray-500", children: rightAddon }) })), rightIcon && !shouldShowPasswordToggle && (jsx("div", { className: "flex absolute inset-y-0 right-0 items-center pr-3 pointer-events-none", children: jsx("span", { className: cn("text-ews-gray-400", iconSizes[size]), children: rightIcon }) })), shouldShowPasswordToggle && (jsx("button", { type: "button", className: "flex absolute inset-y-0 right-0 items-center pr-3", onClick: () => setShowPassword(!showPassword), tabIndex: -1, children: jsx("span", { className: cn("transition-colors text-ews-gray-400 hover:text-ews-gray-600", iconSizes[size]), children: showPassword ? jsx(EyeOff, { size: 16 }) : jsx(Eye, { size: 16 }) }) }))] }), (error || helperText) && (jsx("p", { className: cn("text-sm", error ? "text-ews-error" : "text-ews-gray-500"), children: error || helperText }))] }));
32606
32624
  });
32607
32625
  Input.displayName = "Input";
32608
32626
 
@@ -32919,23 +32937,29 @@ var isWeb = typeof window !== 'undefined' &&
32919
32937
  typeof document !== 'undefined';
32920
32938
 
32921
32939
  function cloneObject(data) {
32940
+ let copy;
32941
+ const isArray = Array.isArray(data);
32942
+ const isFileListInstance = typeof FileList !== 'undefined' ? data instanceof FileList : false;
32922
32943
  if (data instanceof Date) {
32923
- return new Date(data);
32944
+ copy = new Date(data);
32924
32945
  }
32925
- const isFileListInstance = typeof FileList !== 'undefined' && data instanceof FileList;
32926
- if (isWeb && (data instanceof Blob || isFileListInstance)) {
32927
- return data;
32946
+ else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
32947
+ (isArray || isObject(data))) {
32948
+ copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
32949
+ if (!isArray && !isPlainObject(data)) {
32950
+ copy = data;
32951
+ }
32952
+ else {
32953
+ for (const key in data) {
32954
+ if (data.hasOwnProperty(key)) {
32955
+ copy[key] = cloneObject(data[key]);
32956
+ }
32957
+ }
32958
+ }
32928
32959
  }
32929
- const isArray = Array.isArray(data);
32930
- if (!isArray && !(isObject(data) && isPlainObject(data))) {
32960
+ else {
32931
32961
  return data;
32932
32962
  }
32933
- const copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
32934
- for (const key in data) {
32935
- if (Object.prototype.hasOwnProperty.call(data, key)) {
32936
- copy[key] = cloneObject(data[key]);
32937
- }
32938
- }
32939
32963
  return copy;
32940
32964
  }
32941
32965
 
@@ -32961,8 +32985,6 @@ var get = (object, path, defaultValue) => {
32961
32985
 
32962
32986
  var isBoolean = (value) => typeof value === 'boolean';
32963
32987
 
32964
- var isFunction = (value) => typeof value === 'function';
32965
-
32966
32988
  var set = (object, path, value) => {
32967
32989
  let index = -1;
32968
32990
  const tempPath = isKey(path) ? [path] : stringToPath(path);
@@ -32990,21 +33012,50 @@ var set = (object, path, value) => {
32990
33012
 
32991
33013
  const EVENTS = {
32992
33014
  BLUR: 'blur',
32993
- CHANGE: 'change'};
33015
+ FOCUS_OUT: 'focusout',
33016
+ CHANGE: 'change',
33017
+ };
32994
33018
  const VALIDATION_MODE = {
33019
+ onBlur: 'onBlur',
33020
+ onChange: 'onChange',
33021
+ onSubmit: 'onSubmit',
33022
+ onTouched: 'onTouched',
32995
33023
  all: 'all',
32996
33024
  };
32997
33025
 
33026
+ const HookFormContext = React.createContext(null);
33027
+ HookFormContext.displayName = 'HookFormContext';
32998
33028
  /**
32999
- * Separate context for `control` to prevent unnecessary rerenders.
33000
- * Internal hooks that only need control use this instead of full form context.
33001
- */
33002
- const HookFormControlContext = React.createContext(null);
33003
- HookFormControlContext.displayName = 'HookFormControlContext';
33004
- /**
33005
- * @internal Internal hook to access only control from context.
33029
+ * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
33030
+ *
33031
+ * @remarks
33032
+ * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
33033
+ *
33034
+ * @returns return all useForm methods
33035
+ *
33036
+ * @example
33037
+ * ```tsx
33038
+ * function App() {
33039
+ * const methods = useForm();
33040
+ * const onSubmit = data => console.log(data);
33041
+ *
33042
+ * return (
33043
+ * <FormProvider {...methods} >
33044
+ * <form onSubmit={methods.handleSubmit(onSubmit)}>
33045
+ * <NestedInput />
33046
+ * <input type="submit" />
33047
+ * </form>
33048
+ * </FormProvider>
33049
+ * );
33050
+ * }
33051
+ *
33052
+ * function NestedInput() {
33053
+ * const { register } = useFormContext(); // retrieve all hook methods
33054
+ * return <input {...register("test")} />;
33055
+ * }
33056
+ * ```
33006
33057
  */
33007
- const useFormControlContext = () => React.useContext(HookFormControlContext);
33058
+ const useFormContext = () => React.useContext(HookFormContext);
33008
33059
 
33009
33060
  var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
33010
33061
  const result = {
@@ -33058,8 +33109,8 @@ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayou
33058
33109
  * ```
33059
33110
  */
33060
33111
  function useFormState(props) {
33061
- const formControl = useFormControlContext();
33062
- const { control = formControl, disabled, name, exact } = props || {};
33112
+ const methods = useFormContext();
33113
+ const { control = methods.control, disabled, name, exact } = props || {};
33063
33114
  const [formState, updateFormState] = React.useState(control._formState);
33064
33115
  const _localProxyFormState = React.useRef({
33065
33116
  isDirty: false,
@@ -33093,11 +33144,14 @@ var isString = (value) => typeof value === 'string';
33093
33144
 
33094
33145
  var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
33095
33146
  if (isString(names)) {
33147
+ isGlobal && _names.watch.add(names);
33096
33148
  return get(formValues, names, defaultValue);
33097
33149
  }
33098
33150
  if (Array.isArray(names)) {
33099
- return names.map((fieldName) => (get(formValues, fieldName)));
33151
+ return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName),
33152
+ get(formValues, fieldName)));
33100
33153
  }
33154
+ isGlobal && (_names.watchAll = true);
33101
33155
  return formValues;
33102
33156
  };
33103
33157
 
@@ -33105,10 +33159,10 @@ var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
33105
33159
 
33106
33160
  function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
33107
33161
  if (isPrimitive(object1) || isPrimitive(object2)) {
33108
- return Object.is(object1, object2);
33162
+ return object1 === object2;
33109
33163
  }
33110
33164
  if (isDateObject(object1) && isDateObject(object2)) {
33111
- return Object.is(object1.getTime(), object2.getTime());
33165
+ return object1.getTime() === object2.getTime();
33112
33166
  }
33113
33167
  const keys1 = Object.keys(object1);
33114
33168
  const keys2 = Object.keys(object2);
@@ -33131,7 +33185,7 @@ function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
33131
33185
  (isObject(val1) && isObject(val2)) ||
33132
33186
  (Array.isArray(val1) && Array.isArray(val2))
33133
33187
  ? !deepEqual(val1, val2, _internal_visited)
33134
- : !Object.is(val1, val2)) {
33188
+ : val1 !== val2) {
33135
33189
  return false;
33136
33190
  }
33137
33191
  }
@@ -33156,73 +33210,38 @@ function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
33156
33210
  * ```
33157
33211
  */
33158
33212
  function useWatch(props) {
33159
- const formControl = useFormControlContext();
33160
- const { control = formControl, name, defaultValue, disabled, exact, compute, } = props || {};
33213
+ const methods = useFormContext();
33214
+ const { control = methods.control, name, defaultValue, disabled, exact, compute, } = props || {};
33161
33215
  const _defaultValue = React.useRef(defaultValue);
33162
33216
  const _compute = React.useRef(compute);
33163
33217
  const _computeFormValues = React.useRef(undefined);
33164
- const _prevControl = React.useRef(control);
33165
- const _prevName = React.useRef(name);
33166
33218
  _compute.current = compute;
33167
- const [value, updateValue] = React.useState(() => {
33168
- const defaultValue = control._getWatch(name, _defaultValue.current);
33169
- return _compute.current ? _compute.current(defaultValue) : defaultValue;
33170
- });
33171
- const getCurrentOutput = React.useCallback((values) => {
33172
- const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
33173
- return _compute.current ? _compute.current(formValues) : formValues;
33174
- }, [control._formValues, control._names, name]);
33175
- const refreshValue = React.useCallback((values) => {
33176
- if (!disabled) {
33177
- const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
33178
- if (_compute.current) {
33179
- const computedFormValues = _compute.current(formValues);
33180
- if (!deepEqual(computedFormValues, _computeFormValues.current)) {
33181
- updateValue(computedFormValues);
33182
- _computeFormValues.current = computedFormValues;
33219
+ const defaultValueMemo = React.useMemo(() => control._getWatch(name, _defaultValue.current), [control, name]);
33220
+ const [value, updateValue] = React.useState(_compute.current ? _compute.current(defaultValueMemo) : defaultValueMemo);
33221
+ useIsomorphicLayoutEffect(() => control._subscribe({
33222
+ name,
33223
+ formState: {
33224
+ values: true,
33225
+ },
33226
+ exact,
33227
+ callback: (formState) => {
33228
+ if (!disabled) {
33229
+ const formValues = generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current);
33230
+ if (_compute.current) {
33231
+ const computedFormValues = _compute.current(formValues);
33232
+ if (!deepEqual(computedFormValues, _computeFormValues.current)) {
33233
+ updateValue(computedFormValues);
33234
+ _computeFormValues.current = computedFormValues;
33235
+ }
33236
+ }
33237
+ else {
33238
+ updateValue(formValues);
33183
33239
  }
33184
33240
  }
33185
- else {
33186
- updateValue(formValues);
33187
- }
33188
- }
33189
- }, [control._formValues, control._names, disabled, name]);
33190
- useIsomorphicLayoutEffect(() => {
33191
- if (_prevControl.current !== control ||
33192
- !deepEqual(_prevName.current, name)) {
33193
- _prevControl.current = control;
33194
- _prevName.current = name;
33195
- refreshValue();
33196
- }
33197
- return control._subscribe({
33198
- name,
33199
- formState: {
33200
- values: true,
33201
- },
33202
- exact,
33203
- callback: (formState) => {
33204
- refreshValue(formState.values);
33205
- },
33206
- });
33207
- }, [control, exact, name, refreshValue]);
33241
+ },
33242
+ }), [control, disabled, name, exact]);
33208
33243
  React.useEffect(() => control._removeUnmounted());
33209
- // If name or control changed for this render, synchronously reflect the
33210
- // latest value so callers (like useController) see the correct value
33211
- // immediately on the same render.
33212
- // Optimize: Check control reference first before expensive deepEqual
33213
- const controlChanged = _prevControl.current !== control;
33214
- const prevName = _prevName.current;
33215
- // Cache the computed output to avoid duplicate calls within the same render
33216
- // We include shouldReturnImmediate in deps to ensure proper recomputation
33217
- const computedOutput = React.useMemo(() => {
33218
- if (disabled) {
33219
- return null;
33220
- }
33221
- const nameChanged = !controlChanged && !deepEqual(prevName, name);
33222
- const shouldReturnImmediate = controlChanged || nameChanged;
33223
- return shouldReturnImmediate ? getCurrentOutput() : null;
33224
- }, [disabled, controlChanged, name, prevName, getCurrentOutput]);
33225
- return computedOutput !== null ? computedOutput : value;
33244
+ return value;
33226
33245
  }
33227
33246
 
33228
33247
  /**
@@ -33250,20 +33269,20 @@ function useWatch(props) {
33250
33269
  * ```
33251
33270
  */
33252
33271
  function useController(props) {
33253
- const formControl = useFormControlContext();
33254
- const { name, disabled, control = formControl, shouldUnregister, defaultValue, exact = true, } = props;
33272
+ const methods = useFormContext();
33273
+ const { name, disabled, control = methods.control, shouldUnregister, defaultValue, } = props;
33255
33274
  const isArrayField = isNameInFieldArray(control._names.array, name);
33256
33275
  const defaultValueMemo = React.useMemo(() => get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [control, name, defaultValue]);
33257
33276
  const value = useWatch({
33258
33277
  control,
33259
33278
  name,
33260
33279
  defaultValue: defaultValueMemo,
33261
- exact,
33280
+ exact: true,
33262
33281
  });
33263
33282
  const formState = useFormState({
33264
33283
  control,
33265
33284
  name,
33266
- exact,
33285
+ exact: true,
33267
33286
  });
33268
33287
  const _props = React.useRef(props);
33269
33288
  const _previousNameRef = React.useRef(undefined);
@@ -33311,12 +33330,12 @@ function useController(props) {
33311
33330
  }), [name, control._formValues]);
33312
33331
  const ref = React.useCallback((elm) => {
33313
33332
  const field = get(control._fields, name);
33314
- if (field && field._f && elm) {
33333
+ if (field && elm) {
33315
33334
  field._f.ref = {
33316
- focus: () => isFunction(elm.focus) && elm.focus(),
33317
- select: () => isFunction(elm.select) && elm.select(),
33318
- setCustomValidity: (message) => isFunction(elm.setCustomValidity) && elm.setCustomValidity(message),
33319
- reportValidity: () => isFunction(elm.reportValidity) && elm.reportValidity(),
33335
+ focus: () => elm.focus && elm.focus(),
33336
+ select: () => elm.select && elm.select(),
33337
+ setCustomValidity: (message) => elm.setCustomValidity(message),
33338
+ reportValidity: () => elm.reportValidity(),
33320
33339
  };
33321
33340
  }
33322
33341
  }, [control._fields, name]);
@@ -33350,7 +33369,7 @@ function useController(props) {
33350
33369
  };
33351
33370
  updateMounted(name, true);
33352
33371
  if (_shouldUnregisterField) {
33353
- const value = cloneObject(get(control._options.defaultValues, name, _props.current.defaultValue));
33372
+ const value = cloneObject(get(control._options.defaultValues, name));
33354
33373
  set(control._defaultValues, name, value);
33355
33374
  if (isUndefined(get(control._formValues, name))) {
33356
33375
  set(control._formValues, name, value);
@@ -33423,9 +33442,6 @@ function useController(props) {
33423
33442
  */
33424
33443
  const Controller = (props) => props.render(useController(props));
33425
33444
 
33426
- const HookFormContext = React.createContext(null);
33427
- HookFormContext.displayName = 'HookFormContext';
33428
-
33429
33445
  function useSelectField({ name, control, options: _options, rules, defaultValue, }) {
33430
33446
  const { field, fieldState: { error, invalid }, } = useController({
33431
33447
  name,
@@ -33949,7 +33965,14 @@ const PhoneInput = React.forwardRef(({ countryCode, onCountryCodeChange, onChang
33949
33965
  // when the user changes the dropdown without retyping the number.
33950
33966
  const el = nativeRef.current;
33951
33967
  if (el && onChange) {
33952
- const numeric = formatNumeric(el.value);
33968
+ let numeric = formatNumeric(el.value);
33969
+ // Strip new country code digits if already present at the start
33970
+ // (e.g. local part "221778384499" when switching to +221).
33971
+ const newCodeDigits = formatNumeric(newCode);
33972
+ if (newCodeDigits && numeric.startsWith(newCodeDigits)) {
33973
+ numeric = numeric.slice(newCodeDigits.length);
33974
+ el.value = numeric;
33975
+ }
33953
33976
  const fullValue = numeric ? `${newCode}${numeric}` : "";
33954
33977
  // Pass the value string directly — RHF's Controller field.onChange
33955
33978
  // accepts raw values, avoiding unreliable fake-event parsing.
@@ -33967,7 +33990,14 @@ const PhoneInput = React.forwardRef(({ countryCode, onCountryCodeChange, onChang
33967
33990
  }, [value]);
33968
33991
  const handleChange = (e) => {
33969
33992
  // Enforce digits-only in the displayed field.
33970
- const numeric = formatNumeric(e.target.value);
33993
+ let numeric = formatNumeric(e.target.value);
33994
+ // Strip country code digits if user typed or pasted the full number
33995
+ // (e.g. typed "+221778384499" → formatNumeric gives "221778384499"
33996
+ // which would produce "+221221778384499" without this guard).
33997
+ const codeDigits = formatNumeric(activeCode);
33998
+ if (codeDigits && numeric.startsWith(codeDigits)) {
33999
+ numeric = numeric.slice(codeDigits.length);
34000
+ }
33971
34001
  if (e.target.value !== numeric) {
33972
34002
  e.target.value = numeric;
33973
34003
  }
@@ -34075,8 +34105,8 @@ const PROMED_THEME = {
34075
34105
  const MED_THEME = {
34076
34106
  name: "MED",
34077
34107
  colors: {
34078
- primary: "#3BA1A1", // Teal for patients (calming, trustworthy)
34079
- secondary: "#6B73FF", // Soft purple-blue (suggested secondary for MED)
34108
+ primary: "#3BA1A1",
34109
+ secondary: "#6B73FF",
34080
34110
  primaryHover: "#308181",
34081
34111
  secondaryHover: "#5a61e6",
34082
34112
  primaryLight: "#a8d5d5",