@archbase/components 4.0.3 → 4.0.17
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/archbase-components-4.0.17.tgz +0 -0
- package/dist/editors/index.d.ts +0 -2
- package/dist/index.js +3857 -3981
- package/package.json +20 -20
- package/src/editors/index.tsx +0 -3
- package/dist/archbase-components-4.0.3.tgz +0 -0
- package/dist/editors/ArchbasePhoneInput.d.ts +0 -52
- package/src/editors/ArchbasePhoneInput.tsx +0 -355
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archbase/components",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.17",
|
|
4
4
|
"description": "UI Components for Archbase React v3 - Form editors, data visualization, and business components",
|
|
5
5
|
"author": "Edson Martins <edsonmartins2005@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@fortune-sheet/core": "^1.0.4",
|
|
42
42
|
"@fortune-sheet/react": "^1.0.4",
|
|
43
|
-
"@pdfme/ui": "^5.3.6",
|
|
44
|
-
"@pdfme/common": "^5.3.6",
|
|
45
|
-
"@pdfme/schemas": "^5.3.6",
|
|
46
|
-
"@pdfme/generator": "^5.3.6",
|
|
47
43
|
"@gfazioli/mantine-list-view-table": "^2.2.0",
|
|
48
44
|
"@mui/x-data-grid": "^7.28.3",
|
|
45
|
+
"@pdfme/common": "^5.3.6",
|
|
46
|
+
"@pdfme/generator": "^5.3.6",
|
|
47
|
+
"@pdfme/schemas": "^5.3.6",
|
|
48
|
+
"@pdfme/ui": "^5.3.6",
|
|
49
49
|
"@rehooks/component-size": "^1.0.3",
|
|
50
50
|
"ajv": "^8.16.0",
|
|
51
51
|
"cep-promise": "^4.4.0",
|
|
@@ -67,11 +67,13 @@
|
|
|
67
67
|
"is-hotkey": "^0.2.0",
|
|
68
68
|
"js-beautify": "^1.15.1",
|
|
69
69
|
"js-cookie": "^3.0.5",
|
|
70
|
+
"jsbarcode": "^3.11.6",
|
|
70
71
|
"jspdf": "^2.5.1",
|
|
71
72
|
"jspdf-autotable": "^3.8.2",
|
|
72
73
|
"jwt-decode": "^3.1.2",
|
|
73
74
|
"libphonenumber-js": "^1.11.3",
|
|
74
75
|
"lodash": "^4.17.21",
|
|
76
|
+
"mantine-contextmenu": "^7.14.0",
|
|
75
77
|
"markdown-it": "^14.1.0",
|
|
76
78
|
"overlayscrollbars": "^2.8.3",
|
|
77
79
|
"pdfjs-dist": "^4.0.379",
|
|
@@ -85,45 +87,43 @@
|
|
|
85
87
|
"react-frame-component": "^5.2.7",
|
|
86
88
|
"react-hook-form": "^7.54.2",
|
|
87
89
|
"react-i18next": "^13.5.0",
|
|
90
|
+
"react-image-picker-editor": "^1.1.1",
|
|
88
91
|
"react-imask": "^7.6.1",
|
|
89
92
|
"react-inspector": "^9.0.0",
|
|
90
|
-
"react-json-view-lite": "^2.1.0",
|
|
91
93
|
"react-intersection-observer": "^9.10.3",
|
|
94
|
+
"react-json-view-lite": "^2.1.0",
|
|
92
95
|
"react-markdown": "^9.0.1",
|
|
93
96
|
"react-markdown-editor-lite": "^1.3.5",
|
|
97
|
+
"react-mentions": "^4.4.10",
|
|
94
98
|
"react-modal": "^3.16.1",
|
|
95
|
-
"react-phone-number-input": "^3.4.0",
|
|
96
99
|
"react-multi-date-picker": "4.1.2",
|
|
97
100
|
"react-multi-email": "^1.0.24",
|
|
98
101
|
"react-pdf": "^9.1.0",
|
|
102
|
+
"react-photo-album": "^3.0.0",
|
|
103
|
+
"react-pro-sidebar": "^1.1.0",
|
|
99
104
|
"react-router": "^6.22.0",
|
|
100
|
-
"react-signature-canvas": "^1.0.7",
|
|
101
105
|
"react-router-dom": "^6.22.0",
|
|
106
|
+
"react-signature-canvas": "^1.0.7",
|
|
102
107
|
"react-speech-recognition": "^3.10.0",
|
|
103
108
|
"react-thermal-printer": "^0.22.0",
|
|
104
109
|
"react-use-audio-player": "^2.2.0",
|
|
105
110
|
"rehype-external-links": "^3.0.0",
|
|
106
111
|
"rehype-raw": "^7.0.0",
|
|
107
112
|
"remark-gfm": "^4.0.0",
|
|
113
|
+
"sheet-happens": "^0.0.57",
|
|
108
114
|
"suneditor": "^2.46.3",
|
|
109
115
|
"suneditor-react": "^3.6.1",
|
|
116
|
+
"unified": "^11.0.5",
|
|
110
117
|
"use-debounce": "^10.0.1",
|
|
111
118
|
"usehooks-ts": "^3.1.1",
|
|
112
119
|
"uuid": "^9.0.1",
|
|
113
120
|
"validator": "^13.12.0",
|
|
114
121
|
"vis-timeline": "^7.7.3",
|
|
115
122
|
"xlsx": "^0.18.5",
|
|
116
|
-
"react-mentions": "^4.4.10",
|
|
117
|
-
"sheet-happens": "^0.0.57",
|
|
118
|
-
"mantine-contextmenu": "^7.14.0",
|
|
119
|
-
"jsbarcode": "^3.11.6",
|
|
120
123
|
"yet-another-react-lightbox": "^3.21.0",
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"@archbase/core": "4.0.3",
|
|
125
|
-
"@archbase/layout": "4.0.3",
|
|
126
|
-
"@archbase/data": "4.0.3"
|
|
124
|
+
"@archbase/core": "4.0.17",
|
|
125
|
+
"@archbase/data": "4.0.17",
|
|
126
|
+
"@archbase/layout": "4.0.17"
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
129
|
"@types/d3": "^7.4.3",
|
|
@@ -131,6 +131,7 @@
|
|
|
131
131
|
"@types/node": "^22.16.1",
|
|
132
132
|
"@types/react": "^19.0.6",
|
|
133
133
|
"@types/react-dom": "^19.0.2",
|
|
134
|
+
"@types/react-mentions": "^4.1.13",
|
|
134
135
|
"@types/react-signature-canvas": "^1.0.5",
|
|
135
136
|
"@vitejs/plugin-react": "^4.3.4",
|
|
136
137
|
"react": "^19.2.3",
|
|
@@ -139,8 +140,7 @@
|
|
|
139
140
|
"typescript": "~5.7.2",
|
|
140
141
|
"vite": "^6.0.3",
|
|
141
142
|
"vite-plugin-dts": "^4.5.4",
|
|
142
|
-
"vitest": "^2.1.8"
|
|
143
|
-
"@types/react-mentions": "^4.1.13"
|
|
143
|
+
"vitest": "^2.1.8"
|
|
144
144
|
},
|
|
145
145
|
"publishConfig": {
|
|
146
146
|
"registry": "http://192.168.100.5:4873"
|
package/src/editors/index.tsx
CHANGED
|
@@ -126,9 +126,6 @@ export type { ArchbaseAvatarEditProps } from './ArchbaseAvatarEdit'
|
|
|
126
126
|
export { ArchbaseTagInput } from './ArchbaseTagInput'
|
|
127
127
|
export type { ArchbaseTagInputProps } from './ArchbaseTagInput'
|
|
128
128
|
|
|
129
|
-
export { ArchbasePhoneInput } from './ArchbasePhoneInput'
|
|
130
|
-
export type { ArchbasePhoneInputProps } from './ArchbasePhoneInput'
|
|
131
|
-
|
|
132
129
|
export { ArchbaseMultiEmail } from './ArchbaseMultiEmail'
|
|
133
130
|
export type { ArchbaseMultiEmailProps } from './ArchbaseMultiEmail'
|
|
134
131
|
|
|
Binary file
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { MantineSize } from '@mantine/core';
|
|
2
|
-
import { CSSProperties, FocusEventHandler, default as React } from 'react';
|
|
3
|
-
import { IArchbaseDataSourceBase } from '@archbase/data';
|
|
4
|
-
import { CountryCode } from 'libphonenumber-js';
|
|
5
|
-
export interface ArchbasePhoneInputProps<T, ID> {
|
|
6
|
-
/** Fonte de dados onde será atribuído o valor do phone input (V1 ou V2) */
|
|
7
|
-
dataSource?: IArchbaseDataSourceBase<T>;
|
|
8
|
-
/** Campo onde deverá ser atribuído o valor do phone input na fonte de dados */
|
|
9
|
-
dataField?: string;
|
|
10
|
-
/** Valor controlado do phone input (modo standalone) */
|
|
11
|
-
value?: string;
|
|
12
|
-
/** Valor padrão do phone input (modo standalone) */
|
|
13
|
-
defaultValue?: string;
|
|
14
|
-
/** País padrão selecionado no seletor de bandeiras */
|
|
15
|
-
defaultCountry?: CountryCode;
|
|
16
|
-
/** Se true, exibe o número em formato internacional (+55 ...) */
|
|
17
|
-
international?: boolean;
|
|
18
|
-
/** Título/label do phone input */
|
|
19
|
-
label?: string;
|
|
20
|
-
/** Descrição exibida abaixo do label */
|
|
21
|
-
description?: string;
|
|
22
|
-
/** Mensagem de erro a ser exibida */
|
|
23
|
-
error?: string;
|
|
24
|
-
/** Texto de placeholder do phone input */
|
|
25
|
-
placeholder?: string;
|
|
26
|
-
/** Indicador se o preenchimento é obrigatório */
|
|
27
|
-
required?: boolean;
|
|
28
|
-
/** Indicador se o phone input está desabilitado */
|
|
29
|
-
disabled?: boolean;
|
|
30
|
-
/** Indicador se o phone input é somente leitura. Obs: usado em conjunto com o status da fonte de dados */
|
|
31
|
-
readOnly?: boolean;
|
|
32
|
-
/** Evento quando o valor do phone input é alterado */
|
|
33
|
-
onChangeValue?: (value: string | undefined) => void;
|
|
34
|
-
/** Evento quando o phone input recebe o foco */
|
|
35
|
-
onFocusEnter?: FocusEventHandler<HTMLInputElement> | undefined;
|
|
36
|
-
/** Evento quando o foco sai do phone input */
|
|
37
|
-
onFocusExit?: FocusEventHandler<HTMLInputElement> | undefined;
|
|
38
|
-
/** Referência para o componente interno */
|
|
39
|
-
innerRef?: React.RefObject<HTMLInputElement> | undefined;
|
|
40
|
-
/** Estilo CSS customizado aplicado ao wrapper */
|
|
41
|
-
style?: CSSProperties;
|
|
42
|
-
/** Classe CSS customizada aplicada ao wrapper */
|
|
43
|
-
className?: string;
|
|
44
|
-
/** Largura do componente */
|
|
45
|
-
width?: string | number;
|
|
46
|
-
/** Tamanho do componente seguindo o padrão Mantine */
|
|
47
|
-
size?: MantineSize;
|
|
48
|
-
}
|
|
49
|
-
export declare function ArchbasePhoneInput<T, ID>({ dataSource, dataField, value: valueProp, defaultValue, defaultCountry, international, label, description, error, placeholder, required, disabled, readOnly, onChangeValue, onFocusEnter, onFocusExit, innerRef, style, className, width, size, }: ArchbasePhoneInputProps<T, ID>): import("react/jsx-runtime").JSX.Element;
|
|
50
|
-
export declare namespace ArchbasePhoneInput {
|
|
51
|
-
var displayName: string;
|
|
52
|
-
}
|
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ArchbasePhoneInput — input de telefone internacional integrado ao DataSource (v1/v2)
|
|
3
|
-
* com suporte a validação, estado controlado e seleção de país.
|
|
4
|
-
* @status stable
|
|
5
|
-
*/
|
|
6
|
-
import { Input, MantineSize, useMantineColorScheme, useMantineTheme } from '@mantine/core';
|
|
7
|
-
import { useForceUpdate } from '@mantine/hooks';
|
|
8
|
-
import type { CSSProperties, FocusEventHandler } from 'react';
|
|
9
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
10
|
-
import PhoneInput from 'react-phone-number-input';
|
|
11
|
-
import 'react-phone-number-input/style.css';
|
|
12
|
-
import type { DataSourceEvent, IArchbaseDataSourceBase } from '@archbase/data';
|
|
13
|
-
import { DataSourceEventNames, useArchbaseDidUpdate, useArchbaseV1V2Compatibility } from '@archbase/data';
|
|
14
|
-
import { useValidationErrors } from '@archbase/core';
|
|
15
|
-
import type { CountryCode } from 'libphonenumber-js';
|
|
16
|
-
|
|
17
|
-
export interface ArchbasePhoneInputProps<T, ID> {
|
|
18
|
-
/** Fonte de dados onde será atribuído o valor do phone input (V1 ou V2) */
|
|
19
|
-
dataSource?: IArchbaseDataSourceBase<T>;
|
|
20
|
-
/** Campo onde deverá ser atribuído o valor do phone input na fonte de dados */
|
|
21
|
-
dataField?: string;
|
|
22
|
-
/** Valor controlado do phone input (modo standalone) */
|
|
23
|
-
value?: string;
|
|
24
|
-
/** Valor padrão do phone input (modo standalone) */
|
|
25
|
-
defaultValue?: string;
|
|
26
|
-
/** País padrão selecionado no seletor de bandeiras */
|
|
27
|
-
defaultCountry?: CountryCode;
|
|
28
|
-
/** Se true, exibe o número em formato internacional (+55 ...) */
|
|
29
|
-
international?: boolean;
|
|
30
|
-
/** Título/label do phone input */
|
|
31
|
-
label?: string;
|
|
32
|
-
/** Descrição exibida abaixo do label */
|
|
33
|
-
description?: string;
|
|
34
|
-
/** Mensagem de erro a ser exibida */
|
|
35
|
-
error?: string;
|
|
36
|
-
/** Texto de placeholder do phone input */
|
|
37
|
-
placeholder?: string;
|
|
38
|
-
/** Indicador se o preenchimento é obrigatório */
|
|
39
|
-
required?: boolean;
|
|
40
|
-
/** Indicador se o phone input está desabilitado */
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
/** Indicador se o phone input é somente leitura. Obs: usado em conjunto com o status da fonte de dados */
|
|
43
|
-
readOnly?: boolean;
|
|
44
|
-
/** Evento quando o valor do phone input é alterado */
|
|
45
|
-
onChangeValue?: (value: string | undefined) => void;
|
|
46
|
-
/** Evento quando o phone input recebe o foco */
|
|
47
|
-
onFocusEnter?: FocusEventHandler<HTMLInputElement> | undefined;
|
|
48
|
-
/** Evento quando o foco sai do phone input */
|
|
49
|
-
onFocusExit?: FocusEventHandler<HTMLInputElement> | undefined;
|
|
50
|
-
/** Referência para o componente interno */
|
|
51
|
-
innerRef?: React.RefObject<HTMLInputElement> | undefined;
|
|
52
|
-
/** Estilo CSS customizado aplicado ao wrapper */
|
|
53
|
-
style?: CSSProperties;
|
|
54
|
-
/** Classe CSS customizada aplicada ao wrapper */
|
|
55
|
-
className?: string;
|
|
56
|
-
/** Largura do componente */
|
|
57
|
-
width?: string | number;
|
|
58
|
-
/** Tamanho do componente seguindo o padrão Mantine */
|
|
59
|
-
size?: MantineSize;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function ArchbasePhoneInput<T, ID>({
|
|
63
|
-
dataSource,
|
|
64
|
-
dataField,
|
|
65
|
-
value: valueProp,
|
|
66
|
-
defaultValue = '',
|
|
67
|
-
defaultCountry = 'BR',
|
|
68
|
-
international = true,
|
|
69
|
-
label,
|
|
70
|
-
description,
|
|
71
|
-
error,
|
|
72
|
-
placeholder,
|
|
73
|
-
required,
|
|
74
|
-
disabled = false,
|
|
75
|
-
readOnly = false,
|
|
76
|
-
onChangeValue,
|
|
77
|
-
onFocusEnter,
|
|
78
|
-
onFocusExit,
|
|
79
|
-
innerRef,
|
|
80
|
-
style,
|
|
81
|
-
className,
|
|
82
|
-
width,
|
|
83
|
-
size = 'sm',
|
|
84
|
-
}: ArchbasePhoneInputProps<T, ID>) {
|
|
85
|
-
// Hook de compatibilidade V1/V2
|
|
86
|
-
const v1v2Compatibility = useArchbaseV1V2Compatibility<string>(
|
|
87
|
-
'ArchbasePhoneInput',
|
|
88
|
-
dataSource,
|
|
89
|
-
dataField,
|
|
90
|
-
'',
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const innerComponentRef = innerRef || useRef<any>(null);
|
|
94
|
-
const [currentValue, setCurrentValue] = useState<string>(valueProp || defaultValue || '');
|
|
95
|
-
const forceUpdate = useForceUpdate();
|
|
96
|
-
const [internalError, setInternalError] = useState<string | undefined>(error);
|
|
97
|
-
const theme = useMantineTheme();
|
|
98
|
-
const { colorScheme } = useMantineColorScheme();
|
|
99
|
-
|
|
100
|
-
// Contexto de validação (opcional - pode não existir)
|
|
101
|
-
const validationContext = useValidationErrors();
|
|
102
|
-
|
|
103
|
-
// Chave única para o field
|
|
104
|
-
const fieldKey = `${dataField}`;
|
|
105
|
-
|
|
106
|
-
// Recuperar erro do contexto se existir
|
|
107
|
-
const contextError = validationContext?.getError(fieldKey);
|
|
108
|
-
|
|
109
|
-
// Detecta automaticamente se é DataSource V2
|
|
110
|
-
const isDataSourceV2 =
|
|
111
|
-
dataSource &&
|
|
112
|
-
('appendToFieldArray' in dataSource || 'updateFieldArrayItem' in dataSource);
|
|
113
|
-
|
|
114
|
-
// Para V2: estado otimizado (sem re-renders desnecessários)
|
|
115
|
-
const [v2Value, setV2Value] = useState<string>('');
|
|
116
|
-
|
|
117
|
-
// Apenas atualizar se o prop error vier definido
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
if (error !== undefined && error !== internalError) {
|
|
120
|
-
setInternalError(error);
|
|
121
|
-
}
|
|
122
|
-
}, [error]);
|
|
123
|
-
|
|
124
|
-
const loadDataSourceFieldValue = () => {
|
|
125
|
-
let initialValue: any = valueProp || defaultValue || '';
|
|
126
|
-
|
|
127
|
-
if (dataSource && dataField) {
|
|
128
|
-
initialValue = dataSource.getFieldValue(dataField);
|
|
129
|
-
if (!initialValue) {
|
|
130
|
-
initialValue = '';
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (isDataSourceV2) {
|
|
135
|
-
setV2Value(initialValue);
|
|
136
|
-
} else {
|
|
137
|
-
setCurrentValue(initialValue);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const fieldChangedListener = useCallback(() => {
|
|
142
|
-
loadDataSourceFieldValue();
|
|
143
|
-
}, []);
|
|
144
|
-
|
|
145
|
-
const dataSourceEvent = useCallback(
|
|
146
|
-
(event: DataSourceEvent<T>) => {
|
|
147
|
-
if (dataSource && dataField) {
|
|
148
|
-
if (
|
|
149
|
-
event.type === DataSourceEventNames.dataChanged ||
|
|
150
|
-
event.type === DataSourceEventNames.recordChanged ||
|
|
151
|
-
event.type === DataSourceEventNames.afterScroll ||
|
|
152
|
-
event.type === DataSourceEventNames.afterCancel ||
|
|
153
|
-
event.type === DataSourceEventNames.afterEdit
|
|
154
|
-
) {
|
|
155
|
-
loadDataSourceFieldValue();
|
|
156
|
-
if (!isDataSourceV2) {
|
|
157
|
-
forceUpdate();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
event.type === DataSourceEventNames.onFieldError &&
|
|
163
|
-
event.fieldName === dataField
|
|
164
|
-
) {
|
|
165
|
-
setInternalError(event.error);
|
|
166
|
-
validationContext?.setError(fieldKey, event.error);
|
|
167
|
-
if (!isDataSourceV2) {
|
|
168
|
-
forceUpdate();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
[isDataSourceV2, dataSource, dataField, validationContext, fieldKey],
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
// Ref para manter callback sempre atualizado (corrige problema de closure desatualizada)
|
|
177
|
-
const dataSourceEventRef = useRef(dataSourceEvent);
|
|
178
|
-
useEffect(() => {
|
|
179
|
-
dataSourceEventRef.current = dataSourceEvent;
|
|
180
|
-
}, [dataSourceEvent]);
|
|
181
|
-
|
|
182
|
-
// Wrapper estável que delega para ref - nunca muda, então o listener permanece consistente
|
|
183
|
-
const stableDataSourceEvent = useCallback((event: DataSourceEvent<T>) => {
|
|
184
|
-
dataSourceEventRef.current(event);
|
|
185
|
-
}, []);
|
|
186
|
-
|
|
187
|
-
// Registrar listeners com cleanup apropriado
|
|
188
|
-
useEffect(() => {
|
|
189
|
-
loadDataSourceFieldValue();
|
|
190
|
-
if (dataSource && dataField) {
|
|
191
|
-
const hasFieldListener =
|
|
192
|
-
typeof (dataSource as any).addFieldChangeListener === 'function';
|
|
193
|
-
dataSource.addListener(stableDataSourceEvent);
|
|
194
|
-
if (hasFieldListener) {
|
|
195
|
-
(dataSource as any).addFieldChangeListener(dataField, fieldChangedListener);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return () => {
|
|
199
|
-
dataSource.removeListener(stableDataSourceEvent);
|
|
200
|
-
if (hasFieldListener) {
|
|
201
|
-
(dataSource as any).removeFieldChangeListener(dataField, fieldChangedListener);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
}, [dataSource, dataField, stableDataSourceEvent, fieldChangedListener]);
|
|
206
|
-
|
|
207
|
-
useArchbaseDidUpdate(() => {
|
|
208
|
-
loadDataSourceFieldValue();
|
|
209
|
-
}, []);
|
|
210
|
-
|
|
211
|
-
const handleChange = (newValue: string | undefined) => {
|
|
212
|
-
const changedValue = newValue || '';
|
|
213
|
-
|
|
214
|
-
// Limpa erro quando usuário edita o campo
|
|
215
|
-
const hasError = internalError || contextError;
|
|
216
|
-
if (hasError) {
|
|
217
|
-
setInternalError(undefined);
|
|
218
|
-
validationContext?.clearError(fieldKey);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (isDataSourceV2) {
|
|
222
|
-
setV2Value(changedValue);
|
|
223
|
-
if (
|
|
224
|
-
dataSource &&
|
|
225
|
-
!dataSource.isBrowsing() &&
|
|
226
|
-
dataField &&
|
|
227
|
-
dataSource.getFieldValue(dataField) !== changedValue
|
|
228
|
-
) {
|
|
229
|
-
dataSource.setFieldValue(dataField, changedValue);
|
|
230
|
-
}
|
|
231
|
-
} else {
|
|
232
|
-
setCurrentValue(changedValue);
|
|
233
|
-
if (
|
|
234
|
-
dataSource &&
|
|
235
|
-
!dataSource.isBrowsing() &&
|
|
236
|
-
dataField &&
|
|
237
|
-
dataSource.getFieldValue(dataField) !== changedValue
|
|
238
|
-
) {
|
|
239
|
-
dataSource.setFieldValue(dataField, changedValue);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (onChangeValue) {
|
|
244
|
-
onChangeValue(newValue);
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const handleOnFocusExit = (event: React.FocusEvent<HTMLInputElement>) => {
|
|
249
|
-
if (onFocusExit) {
|
|
250
|
-
onFocusExit(event);
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
const handleOnFocusEnter = (event: React.FocusEvent<HTMLInputElement>) => {
|
|
255
|
-
if (onFocusEnter) {
|
|
256
|
-
onFocusEnter(event);
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
const isReadOnly = (): boolean => {
|
|
261
|
-
return readOnly || v1v2Compatibility.isReadOnly;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
// Erro a ser exibido: local ou do contexto
|
|
265
|
-
const displayError = internalError || contextError;
|
|
266
|
-
|
|
267
|
-
const isDark = colorScheme === 'dark';
|
|
268
|
-
|
|
269
|
-
// Mantine-compatible sizing
|
|
270
|
-
const inputHeight =
|
|
271
|
-
size === 'xs'
|
|
272
|
-
? 30
|
|
273
|
-
: size === 'sm'
|
|
274
|
-
? 36
|
|
275
|
-
: size === 'md'
|
|
276
|
-
? 42
|
|
277
|
-
: size === 'lg'
|
|
278
|
-
? 50
|
|
279
|
-
: size === 'xl'
|
|
280
|
-
? 60
|
|
281
|
-
: 36;
|
|
282
|
-
|
|
283
|
-
const fontSize =
|
|
284
|
-
size === 'xs'
|
|
285
|
-
? 12
|
|
286
|
-
: size === 'sm'
|
|
287
|
-
? 14
|
|
288
|
-
: size === 'md'
|
|
289
|
-
? 16
|
|
290
|
-
: size === 'lg'
|
|
291
|
-
? 18
|
|
292
|
-
: size === 'xl'
|
|
293
|
-
? 20
|
|
294
|
-
: 14;
|
|
295
|
-
|
|
296
|
-
return (
|
|
297
|
-
<Input.Wrapper
|
|
298
|
-
label={label}
|
|
299
|
-
description={description}
|
|
300
|
-
error={displayError}
|
|
301
|
-
required={required}
|
|
302
|
-
size={size}
|
|
303
|
-
style={{ width, ...style }}
|
|
304
|
-
className={className}
|
|
305
|
-
>
|
|
306
|
-
<PhoneInput
|
|
307
|
-
ref={innerComponentRef}
|
|
308
|
-
international={international}
|
|
309
|
-
defaultCountry={defaultCountry}
|
|
310
|
-
value={isDataSourceV2 ? v2Value : currentValue}
|
|
311
|
-
onChange={handleChange}
|
|
312
|
-
onFocus={handleOnFocusEnter}
|
|
313
|
-
onBlur={handleOnFocusExit}
|
|
314
|
-
disabled={disabled}
|
|
315
|
-
readOnly={isReadOnly()}
|
|
316
|
-
placeholder={placeholder}
|
|
317
|
-
style={{
|
|
318
|
-
'--PhoneInputCountryFlag-height': '1em',
|
|
319
|
-
'--PhoneInputCountrySelectArrow-color': isDark
|
|
320
|
-
? theme.colors.dark[1]
|
|
321
|
-
: theme.colors.gray[6],
|
|
322
|
-
'--PhoneInput-color--focus': theme.colors[theme.primaryColor][isDark ? 4 : 6],
|
|
323
|
-
} as React.CSSProperties}
|
|
324
|
-
numberInputProps={{
|
|
325
|
-
style: {
|
|
326
|
-
height: inputHeight,
|
|
327
|
-
fontSize,
|
|
328
|
-
backgroundColor: isDark ? theme.colors.dark[6] : theme.white,
|
|
329
|
-
color: isDark ? theme.colors.dark[0] : theme.black,
|
|
330
|
-
border: `1px solid ${
|
|
331
|
-
displayError
|
|
332
|
-
? theme.colors.red[isDark ? 4 : 6]
|
|
333
|
-
: isDark
|
|
334
|
-
? theme.colors.dark[4]
|
|
335
|
-
: theme.colors.gray[4]
|
|
336
|
-
}`,
|
|
337
|
-
borderRadius: theme.radius.sm,
|
|
338
|
-
paddingLeft: 8,
|
|
339
|
-
paddingRight: 8,
|
|
340
|
-
outline: 'none',
|
|
341
|
-
width: '100%',
|
|
342
|
-
},
|
|
343
|
-
}}
|
|
344
|
-
countrySelectProps={{
|
|
345
|
-
style: {
|
|
346
|
-
backgroundColor: isDark ? theme.colors.dark[6] : theme.white,
|
|
347
|
-
color: isDark ? theme.colors.dark[0] : theme.black,
|
|
348
|
-
},
|
|
349
|
-
}}
|
|
350
|
-
/>
|
|
351
|
-
</Input.Wrapper>
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
ArchbasePhoneInput.displayName = 'ArchbasePhoneInput';
|