@kenlo/kdls-design-system 2.10.0 → 2.11.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/components/Input/Input.d.ts +4 -5
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/Input/phone.d.ts +28 -0
- package/dist/components/Modal/useDialogFocus.d.ts +7 -0
- package/dist/index.cjs +3 -3
- package/dist/index.css +1 -1
- package/dist/index.js +3896 -3753
- package/kdls-manifest.json +10 -3
- package/package.json +3 -2
|
@@ -3,17 +3,14 @@ import { IconElement } from '../Icon/Icon';
|
|
|
3
3
|
import './Input.css';
|
|
4
4
|
import '../../foundations/Scrollbar/Scrollbar.css';
|
|
5
5
|
import type { FormValidateOn } from '../Form/Form';
|
|
6
|
+
import { type PhoneCountry, type PhoneValue } from './phone';
|
|
7
|
+
export type { PhoneCountry, PhoneValue } from './phone';
|
|
6
8
|
export interface InputRule {
|
|
7
9
|
/** Message shown as a hint when the rule fails */
|
|
8
10
|
message: string;
|
|
9
11
|
/** Receives the current value and returns true when the rule passes */
|
|
10
12
|
valid: (value: string) => boolean;
|
|
11
13
|
}
|
|
12
|
-
export interface PhoneCountry {
|
|
13
|
-
code: string;
|
|
14
|
-
ddi: string;
|
|
15
|
-
name: string;
|
|
16
|
-
}
|
|
17
14
|
export type InputFeedback = 'none' | 'success' | 'alert' | 'error';
|
|
18
15
|
export type InputState = 'enabled' | 'hover' | 'filled' | 'focused' | 'disabled';
|
|
19
16
|
type BaseInputProps = {
|
|
@@ -80,6 +77,8 @@ type BaseInputProps = {
|
|
|
80
77
|
excludeCountries?: string[];
|
|
81
78
|
/** Called when the user selects a country */
|
|
82
79
|
onCountryChange?: (country: PhoneCountry) => void;
|
|
80
|
+
/** Called on every change of a phone with country: the country, the national digits, the E.164 form when valid, and whether it is valid */
|
|
81
|
+
onPhoneChange?: (phone: PhoneValue) => void;
|
|
83
82
|
/** Disables algorithm validation for type='cpf', 'cnpj', 'cpf-cnpj'. When false, only validates whether the mask is complete */
|
|
84
83
|
validateDocument?: boolean;
|
|
85
84
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Input } from './Input';
|
|
2
|
-
export type { InputProps, InputFeedback, InputState, InputRule, PhoneCountry } from './Input';
|
|
2
|
+
export type { InputProps, InputFeedback, InputState, InputRule, PhoneCountry, PhoneValue } from './Input';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type * as PhoneLibModule from 'libphonenumber-js';
|
|
2
|
+
export type PhoneLib = typeof PhoneLibModule;
|
|
3
|
+
export interface PhoneCountry {
|
|
4
|
+
code: string;
|
|
5
|
+
ddi: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PhoneValue {
|
|
9
|
+
country: PhoneCountry;
|
|
10
|
+
national: string;
|
|
11
|
+
e164: string | null;
|
|
12
|
+
valid: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const BRAZIL: PhoneCountry;
|
|
15
|
+
export declare function loadPhoneLib(): Promise<PhoneLib>;
|
|
16
|
+
export declare function usePhoneLib(enabled: boolean): PhoneLib | null;
|
|
17
|
+
export declare function phoneCountries(lib: PhoneLib | null): PhoneCountry[];
|
|
18
|
+
export declare function searchCountries(list: PhoneCountry[], query: string): PhoneCountry[];
|
|
19
|
+
export declare function applyBrazilMask(raw: string): string;
|
|
20
|
+
export declare function capPhoneDigits(raw: string, country: PhoneCountry, lib: PhoneLib | null): string;
|
|
21
|
+
export declare function formatPhone(raw: string, country: PhoneCountry, lib: PhoneLib | null): string;
|
|
22
|
+
export declare function isValidPhoneFor(raw: string, country: PhoneCountry, lib: PhoneLib | null, kind: 'tel' | 'cel'): boolean;
|
|
23
|
+
export declare function phoneValue(raw: string, country: PhoneCountry, lib: PhoneLib | null, kind: 'tel' | 'cel'): PhoneValue;
|
|
24
|
+
export declare function readInternational(typed: string, lib: PhoneLib): {
|
|
25
|
+
country: string;
|
|
26
|
+
national: string;
|
|
27
|
+
} | null;
|
|
28
|
+
export declare function formatInternationalDraft(typed: string, lib: PhoneLib | null): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modal dialog focus, for Drawer and Modal: on open, focus moves inside (the first control of
|
|
3
|
+
* the body, else the first control of the panel, else the panel itself); Tab and Shift+Tab wrap
|
|
4
|
+
* inside the panel, and come back to it from a floating list the dialog opened; on close, focus
|
|
5
|
+
* returns to the element that had it when the dialog opened, when it is still on the page.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useDialogFocus(open: boolean, panelRef: React.RefObject<HTMLElement | null>, bodySelector: string): void;
|