finform-react-builder 1.15.0 → 1.16.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.
@@ -6,5 +6,6 @@ export { CustomButtons } from './CustomButtons';
6
6
  export { generateSchema } from './generateSchema';
7
7
  export { fetchApiData, hasApiConfig, getApiConfig, shouldShowField, useApiData } from './apiUtils';
8
8
  export * from './inputs';
9
- export type { FieldConfig, AutomationFieldConfig, ValidationRule, FormButton, ButtonGroup, FormTitle, FormTheme, FinFormProps, ApiConfig, } from './types';
9
+ export * from './utils/phoneUtils';
10
+ export type { FieldConfig, MobileField, AutomationFieldConfig, ValidationRule, FormButton, ButtonGroup, FormTitle, FormTheme, FinFormProps, ApiConfig, } from './types';
10
11
  export { buildFinformTestIds, resolveFieldTestIds } from './testIds';
@@ -0,0 +1,31 @@
1
+ import { default as React } from 'react';
2
+ import { DialCodeOption } from '../utils/phoneUtils';
3
+ export type FinMobileFieldProps = {
4
+ id?: string;
5
+ value?: any;
6
+ onChange?: (val: string) => void;
7
+ onBlur?: () => void;
8
+ labelText?: string;
9
+ label?: string;
10
+ labelVariant?: 'caption' | 'body2' | 'subtitle2' | 'h6';
11
+ placeholder?: string;
12
+ disabled?: boolean;
13
+ hasError?: boolean;
14
+ helperText?: string;
15
+ dialCodes?: DialCodeOption[];
16
+ defaultDialCode?: string;
17
+ mobilePrefixes?: string[];
18
+ storeFormat?: string;
19
+ phoneExamples?: string[];
20
+ name?: string;
21
+ inputTestId?: string;
22
+ labelTestId?: string;
23
+ errorTestId?: string;
24
+ };
25
+ /**
26
+ * Mobile phone field: dial-code select + national number.
27
+ * Visual tokens match FinTextField (8px radius, outlined, theme input tokens).
28
+ * Stored value is national store-format string (not E.164).
29
+ */
30
+ export declare const FinMobileField: React.FC<FinMobileFieldProps>;
31
+ export default FinMobileField;
@@ -1,4 +1,5 @@
1
1
  export * from './FinTextField';
2
+ export * from './FinMobileField';
2
3
  export * from './FinSelect';
3
4
  export * from './FinAutocomplete';
4
5
  export * from './FinCheckbox';
@@ -35,7 +35,7 @@ export interface BaseField {
35
35
  title?: string;
36
36
  name: string;
37
37
  label: string;
38
- type: 'text' | 'email' | 'password' | 'number' | 'tel' | 'select' | 'checkbox' | 'checkboxGroup' | 'toggle' | 'radio' | 'switch' | 'autocomplete' | 'date' | 'textarea' | 'image' | 'title' | 'section' | 'component' | 'finuiHeader' | 'tabs' | 'grid' | 'listcards' | 'dragdroplist';
38
+ type: 'text' | 'email' | 'password' | 'number' | 'tel' | 'mobile' | 'select' | 'checkbox' | 'checkboxGroup' | 'toggle' | 'radio' | 'switch' | 'autocomplete' | 'date' | 'textarea' | 'image' | 'title' | 'section' | 'component' | 'finuiHeader' | 'tabs' | 'grid' | 'listcards' | 'dragdroplist';
39
39
  placeholder?: string;
40
40
  labelPosition?: 'inner' | 'top' | 'none';
41
41
  labelVariant?: 'caption' | 'body2' | 'subtitle2' | 'h6';
@@ -80,6 +80,27 @@ export interface NumberField extends BaseField {
80
80
  min?: number;
81
81
  max?: number;
82
82
  }
83
+ /** Mobile phone with dial-code dropdown; store value is national store-format string (not E.164). */
84
+ export interface MobileField extends BaseField {
85
+ type: 'mobile';
86
+ minLength?: number;
87
+ maxLength?: number;
88
+ pattern?: string;
89
+ /** Dial-code options (digits without "+"), e.g. [{ dial_code: "260", label: "ZM" }] */
90
+ dialCodes?: Array<{
91
+ dial_code: string;
92
+ label?: string;
93
+ iso?: string;
94
+ }>;
95
+ /** Default dial code digits without "+" */
96
+ defaultDialCode?: string;
97
+ /** Optional national prefix allowlist */
98
+ mobilePrefixes?: string[];
99
+ /** Expected store shape, e.g. "0XXXXXXXXX" */
100
+ storeFormat?: string;
101
+ /** Example strings for helper / paste hints */
102
+ phoneExamples?: string[];
103
+ }
83
104
  export interface SelectField extends BaseField {
84
105
  type: 'select';
85
106
  options?: Array<{
@@ -342,7 +363,7 @@ export interface DragDropListField extends Omit<BaseField, 'helperText'> {
342
363
  helperText?: React.ReactNode | string;
343
364
  sx?: any;
344
365
  }
345
- export type FieldConfig = TextField | NumberField | SelectField | CheckboxField | CheckboxGroupField | ToggleField | RadioField | SwitchField | AutocompleteField | DateField | ImageField | TitleField | SectionField | ComponentField | FinUiHeaderField | TabsField | GridField | ListCardsField | DragDropListField;
366
+ export type FieldConfig = TextField | NumberField | MobileField | SelectField | CheckboxField | CheckboxGroupField | ToggleField | RadioField | SwitchField | AutocompleteField | DateField | ImageField | TitleField | SectionField | ComponentField | FinUiHeaderField | TabsField | GridField | ListCardsField | DragDropListField;
346
367
  export type AutomationFieldConfig = FieldConfig & {
347
368
  testId?: string;
348
369
  automation?: {
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Generic phone normalize / display helpers for FinMobileField.
3
+ * Country rules come from field props — no country hardcoding.
4
+ */
5
+ export type DialCodeOption = {
6
+ dial_code: string;
7
+ label?: string;
8
+ iso?: string;
9
+ };
10
+ export type PhoneNormalizeOptions = {
11
+ dialCode?: string;
12
+ storeFormat?: string;
13
+ prefixes?: string[];
14
+ };
15
+ export type PhoneDisplayParts = {
16
+ dialCode: string;
17
+ national: string;
18
+ };
19
+ /** Digits only. */
20
+ export declare function digitsOnly(value: unknown): string;
21
+ /** Strip leading zeros from a dial code string ("0260" → "260", "+260" → "260"). */
22
+ export declare function normalizeDialCode(dialCode: unknown): string;
23
+ /**
24
+ * Parse storeFormat like "0XXXXXXXXX":
25
+ * - leadingDigits: literal digit prefix ("0")
26
+ * - xCount: number of X placeholders (9)
27
+ * - totalLen: expected national length (10)
28
+ */
29
+ export declare function parseStoreFormat(storeFormat?: string): {
30
+ leadingDigits: string;
31
+ xCount: number;
32
+ totalLen: number;
33
+ };
34
+ /**
35
+ * Normalize any common input shape into the national store format.
36
+ * Accepts: "+260971234567", "0971234567", "971234567", with spaces/dashes.
37
+ */
38
+ export declare function normalizePhoneToStoreFormat(raw: unknown, options?: PhoneNormalizeOptions): string;
39
+ /**
40
+ * Split a stored national value for UI: dial code + national digits.
41
+ */
42
+ export declare function parsePhoneDisplayParts(stored: unknown, options?: {
43
+ dialCode?: string;
44
+ dialCodes?: DialCodeOption[];
45
+ }): PhoneDisplayParts;
46
+ /**
47
+ * Validate a store-format national number.
48
+ */
49
+ export declare function validatePhone(storeValue: unknown, options?: {
50
+ pattern?: string | RegExp;
51
+ prefixes?: string[];
52
+ message?: string;
53
+ }): {
54
+ valid: boolean;
55
+ message?: string;
56
+ };