@ews-admin/global-design-system 1.1.26 → 1.1.27
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/components/PhoneInput/PhoneInput.d.ts +19 -0
- package/dist/components/PhoneInput/PhoneInput.d.ts.map +1 -0
- package/dist/components/PhoneInput/index.d.ts +3 -0
- package/dist/components/PhoneInput/index.d.ts.map +1 -0
- package/dist/index.d.ts +71 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +156 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +160 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/phone.d.ts +48 -0
- package/dist/utils/phone.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/PhoneInput/PhoneInput.tsx +127 -0
- package/src/components/PhoneInput/index.ts +2 -0
- package/src/index.ts +14 -1
- package/src/utils/index.ts +7 -0
- package/src/utils/phone.ts +109 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { InputProps } from "../Input/Input";
|
|
3
|
+
export interface PhoneInputProps extends Omit<InputProps, "countryCodeSelect" | "leftIcon" | "type"> {
|
|
4
|
+
/** Currently selected country code (controlled). Defaults to +221 if omitted. */
|
|
5
|
+
countryCode?: string;
|
|
6
|
+
/** Called when the user changes the country code dropdown. */
|
|
7
|
+
onCountryCodeChange?: (code: string) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Phone number input with integrated country code selector.
|
|
11
|
+
*
|
|
12
|
+
* The component stores the **full** phone number (e.g. "+22177123456") as its
|
|
13
|
+
* form value so that the country code prefix is always preserved on save.
|
|
14
|
+
* The text field displays only the local part ("77123456") for a clean UX.
|
|
15
|
+
*
|
|
16
|
+
* Works with React Hook Form via `Controller` — no extra setup needed.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PhoneInput: React.ForwardRefExoticComponent<PhoneInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
19
|
+
//# sourceMappingURL=PhoneInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/components/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqE,MAAM,OAAO,CAAC;AAO1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,GAAG,MAAM,CAAC;IACnE,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,0FAgGtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PhoneInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,15 +34,15 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
34
34
|
}
|
|
35
35
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
36
36
|
|
|
37
|
-
interface CountryCodeOption {
|
|
37
|
+
interface CountryCodeOption$1 {
|
|
38
38
|
code: string;
|
|
39
39
|
country: string;
|
|
40
40
|
}
|
|
41
|
-
interface CountryCodeSelectProps {
|
|
41
|
+
interface CountryCodeSelectProps$1 {
|
|
42
42
|
/**
|
|
43
43
|
* Array of country code options
|
|
44
44
|
*/
|
|
45
|
-
options: CountryCodeOption[];
|
|
45
|
+
options: CountryCodeOption$1[];
|
|
46
46
|
/**
|
|
47
47
|
* Currently selected country code
|
|
48
48
|
*/
|
|
@@ -104,7 +104,7 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
|
|
104
104
|
/**
|
|
105
105
|
* Country code dropdown configuration for phone inputs
|
|
106
106
|
*/
|
|
107
|
-
countryCodeSelect?: CountryCodeSelectProps;
|
|
107
|
+
countryCodeSelect?: CountryCodeSelectProps$1;
|
|
108
108
|
}
|
|
109
109
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
110
110
|
|
|
@@ -379,6 +379,23 @@ interface DropdownMultiSelectProps<T extends FieldValues, TValue> {
|
|
|
379
379
|
}
|
|
380
380
|
declare const DropdownMultiSelect: <T extends FieldValues, TValue extends string | number | object>({ options, name, control, placeholder, searchPlaceholder, onChange, value: controlledValue, defaultValue, onValidate, disabled, error, label, className, }: DropdownMultiSelectProps<T, TValue>) => react_jsx_runtime.JSX.Element;
|
|
381
381
|
|
|
382
|
+
interface PhoneInputProps extends Omit<InputProps, "countryCodeSelect" | "leftIcon" | "type"> {
|
|
383
|
+
/** Currently selected country code (controlled). Defaults to +221 if omitted. */
|
|
384
|
+
countryCode?: string;
|
|
385
|
+
/** Called when the user changes the country code dropdown. */
|
|
386
|
+
onCountryCodeChange?: (code: string) => void;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Phone number input with integrated country code selector.
|
|
390
|
+
*
|
|
391
|
+
* The component stores the **full** phone number (e.g. "+22177123456") as its
|
|
392
|
+
* form value so that the country code prefix is always preserved on save.
|
|
393
|
+
* The text field displays only the local part ("77123456") for a clean UX.
|
|
394
|
+
*
|
|
395
|
+
* Works with React Hook Form via `Controller` — no extra setup needed.
|
|
396
|
+
*/
|
|
397
|
+
declare const PhoneInput: React.ForwardRefExoticComponent<PhoneInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
398
|
+
|
|
382
399
|
type LogoSize = "sm" | "md" | "lg" | "xl";
|
|
383
400
|
type LogoVariant = "normal" | "white" | "fullWhite" | "favicon";
|
|
384
401
|
interface LogoProps {
|
|
@@ -522,6 +539,54 @@ interface EnvConfig {
|
|
|
522
539
|
*/
|
|
523
540
|
declare function createEnvConfig(env: string, overrides?: EnvConfigOverrides): EnvConfig;
|
|
524
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Country code option for phone number selection
|
|
544
|
+
*/
|
|
545
|
+
interface CountryCodeOption {
|
|
546
|
+
code: string;
|
|
547
|
+
country: string;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Props for country code select component
|
|
551
|
+
*/
|
|
552
|
+
interface CountryCodeSelectProps {
|
|
553
|
+
options: CountryCodeOption[];
|
|
554
|
+
value: string;
|
|
555
|
+
onChange: (code: string) => void;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Available country codes supported by the platform
|
|
559
|
+
*/
|
|
560
|
+
declare const COUNTRY_CODES: CountryCodeOption[];
|
|
561
|
+
/**
|
|
562
|
+
* Determines the default country code based on phone number prefix or country ISO code.
|
|
563
|
+
* Falls back to "+221" (Senegal) when no match is found.
|
|
564
|
+
*/
|
|
565
|
+
declare function getDefaultCountryCode(phoneNumber?: string, country?: string): string;
|
|
566
|
+
/**
|
|
567
|
+
* Extracts the country code prefix from a phone number and returns both
|
|
568
|
+
* the detected country code and the local number without the prefix.
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* extractCountryCodeFromPhoneNumber("+22177123456") // { countryCode: "+221", cleanedPhoneNumber: "77123456" }
|
|
572
|
+
* extractCountryCodeFromPhoneNumber("77123456") // { countryCode: "+221", cleanedPhoneNumber: "77123456" }
|
|
573
|
+
*/
|
|
574
|
+
declare function extractCountryCodeFromPhoneNumber(phoneNumber: string, country?: string): {
|
|
575
|
+
countryCode: string;
|
|
576
|
+
cleanedPhoneNumber: string;
|
|
577
|
+
};
|
|
578
|
+
/**
|
|
579
|
+
* Formats a phone number by prepending the country code if not already present.
|
|
580
|
+
* If the number already starts with a known country code it is returned as-is.
|
|
581
|
+
* Leading zeros, spaces and dashes are stripped from the local part before formatting.
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* formatPhoneNumberWithCountryCode("77123456", "+221") // "+22177123456"
|
|
585
|
+
* formatPhoneNumberWithCountryCode("+22177123456", "+221") // "+22177123456" (unchanged)
|
|
586
|
+
* formatPhoneNumberWithCountryCode("077123456", "+221") // "+22177123456" (leading 0 stripped)
|
|
587
|
+
*/
|
|
588
|
+
declare function formatPhoneNumberWithCountryCode(phoneNumber: string, countryCode?: string): string;
|
|
589
|
+
|
|
525
590
|
/**
|
|
526
591
|
* Utility function to merge class names
|
|
527
592
|
* @param inputs - Class values to merge
|
|
@@ -647,5 +712,5 @@ interface ThemeProviderProps {
|
|
|
647
712
|
declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
648
713
|
declare const useTheme: () => ThemeContextType;
|
|
649
714
|
|
|
650
|
-
export { BLOOD_TYPES, BloodType, Button, DoctorIcon, DropdownMultiSelect, Icon, Input, Logo, Modal, MultiSearchAutocomplete, PatientIcon, ProfileImageUpload, SearchAutocomplete, Select, SpecialtySearchAutocomplete, ThemeDebugger, ThemeProvider, ThemeToggle, UserIcon, cn, createEnvConfig, debounce, formatCurrency, formatDate, formatNumeric, generateId, isValidPhoneNumber, useDebounce, useDebouncedCallback, useSelectField, useTheme };
|
|
651
|
-
export type { ButtonProps, DropdownMultiSelectProps, EnvConfig, EnvConfigOverrides, Environment, ErrorField, ErrorObject, IconProps, InputProps, LogoProps, ModalProps, ProfileImageUploadProps, SearchableEntity, SelectOption, SelectProps, SimpleIconProps, Specialty, SpecialtySearchAutocompleteProps, Theme, ThemeConfig, ThemeContextType, ThemeDebuggerProps, ThemeToggleProps, UseSelectFieldProps };
|
|
715
|
+
export { BLOOD_TYPES, BloodType, Button, COUNTRY_CODES, DoctorIcon, DropdownMultiSelect, Icon, Input, Logo, Modal, MultiSearchAutocomplete, PatientIcon, PhoneInput, ProfileImageUpload, SearchAutocomplete, Select, SpecialtySearchAutocomplete, ThemeDebugger, ThemeProvider, ThemeToggle, UserIcon, cn, createEnvConfig, debounce, extractCountryCodeFromPhoneNumber, formatCurrency, formatDate, formatNumeric, formatPhoneNumberWithCountryCode, generateId, getDefaultCountryCode, isValidPhoneNumber, useDebounce, useDebouncedCallback, useSelectField, useTheme };
|
|
716
|
+
export type { ButtonProps, CountryCodeOption, CountryCodeSelectProps, DropdownMultiSelectProps, EnvConfig, EnvConfigOverrides, Environment, ErrorField, ErrorObject, IconProps, InputProps, LogoProps, ModalProps, PhoneInputProps, ProfileImageUploadProps, SearchableEntity, SelectOption, SelectProps, SimpleIconProps, Specialty, SpecialtySearchAutocompleteProps, Theme, ThemeConfig, ThemeContextType, ThemeDebuggerProps, ThemeToggleProps, UseSelectFieldProps };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;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