@kenlo/kdls-design-system 2.10.1 → 2.12.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 +6 -5
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/Input/phone.d.ts +28 -0
- package/dist/components/Pill/Pill.d.ts +2 -0
- package/dist/index.cjs +3 -3
- package/dist/index.css +1 -1
- package/dist/index.js +3597 -3498
- package/kdls-manifest.json +17 -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 = {
|
|
@@ -38,6 +35,8 @@ type BaseInputProps = {
|
|
|
38
35
|
iconRight?: IconElement;
|
|
39
36
|
/** Callback when clicking iconRight — makes the icon interactive with stopPropagation */
|
|
40
37
|
onClickIconRight?: () => void;
|
|
38
|
+
/** Accessible name of iconRight when it is clickable — say what the click does (e.g. "Buscar" for a magnifier that applies the search). Default: "Limpar" */
|
|
39
|
+
iconRightLabel?: string;
|
|
41
40
|
/** Count badge shown before the right icon (used as a Popover Trigger) */
|
|
42
41
|
notificationCount?: number;
|
|
43
42
|
/** Shows a custom incrementer (+/−) for type="number". The browser's native spinner is always hidden via CSS. */
|
|
@@ -80,6 +79,8 @@ type BaseInputProps = {
|
|
|
80
79
|
excludeCountries?: string[];
|
|
81
80
|
/** Called when the user selects a country */
|
|
82
81
|
onCountryChange?: (country: PhoneCountry) => void;
|
|
82
|
+
/** 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 */
|
|
83
|
+
onPhoneChange?: (phone: PhoneValue) => void;
|
|
83
84
|
/** Disables algorithm validation for type='cpf', 'cnpj', 'cpf-cnpj'. When false, only validates whether the mask is complete */
|
|
84
85
|
validateDocument?: boolean;
|
|
85
86
|
};
|
|
@@ -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;
|
|
@@ -14,6 +14,8 @@ interface PillBase {
|
|
|
14
14
|
width?: 'hug' | 'fill';
|
|
15
15
|
/** @internal Callback fired when clicking iconRight — prevents propagation to onClick */
|
|
16
16
|
onClickIconRight?: () => void;
|
|
17
|
+
/** @internal Accessible name of iconRight when onClickIconRight is set — say what the click does. Default: "Limpar" */
|
|
18
|
+
iconRightLabel?: string;
|
|
17
19
|
/** @internal Shows a notification badge (size 24px) */
|
|
18
20
|
showNotification?: boolean;
|
|
19
21
|
/** @internal Number shown in the notification badge (requires showNotification=true) */
|