@aspprev/versi-ds 0.4.0 → 0.4.2
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/README.md +7 -0
- package/dist/charts.js +1 -2
- package/dist/{chunk-ATWH3MA6.js → chunk-2XXVEFFY.js} +18 -35
- package/dist/{chunk-ATWH3MA6.js.map → chunk-2XXVEFFY.js.map} +1 -1
- package/dist/{chunk-V66QL3TD.js → chunk-5MRS4PDD.js} +200 -211
- package/dist/{chunk-V66QL3TD.js.map → chunk-5MRS4PDD.js.map} +1 -1
- package/dist/{chunk-LPLXAKPJ.js → chunk-6NVJWI5B.js} +551 -603
- package/dist/chunk-6NVJWI5B.js.map +1 -0
- package/dist/chunk-7IY43S3Y.js +2833 -0
- package/dist/chunk-7IY43S3Y.js.map +1 -0
- package/dist/{chunk-LTW323JQ.js → chunk-JGCZAVYV.js} +420 -594
- package/dist/{chunk-LTW323JQ.js.map → chunk-JGCZAVYV.js.map} +1 -1
- package/dist/{chunk-FTRF27XF.js → chunk-MMTKCHRP.js} +7 -17
- package/dist/{chunk-FTRF27XF.js.map → chunk-MMTKCHRP.js.map} +1 -1
- package/dist/{chunk-7JI5637G.js → chunk-YIUITJ4V.js} +45 -77
- package/dist/{chunk-7JI5637G.js.map → chunk-YIUITJ4V.js.map} +1 -1
- package/dist/{chunk-WOD44OEH.js → chunk-ZPY72ILO.js} +41 -58
- package/dist/{chunk-WOD44OEH.js.map → chunk-ZPY72ILO.js.map} +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +3 -4
- package/dist/countries-browser.d.ts +11 -0
- package/dist/countries-browser.js +294 -0
- package/dist/countries-browser.js.map +1 -0
- package/dist/countries.d.ts +6 -46
- package/dist/countries.js +280 -7
- package/dist/countries.js.map +1 -1
- package/dist/country-metadata-DOgzawAc.d.ts +27 -0
- package/dist/documents.js +2 -3
- package/dist/flags-00-MPU4ISEM.js +85 -0
- package/dist/flags-00-MPU4ISEM.js.map +1 -0
- package/dist/flags-01-PWC64NSQ.js +13 -0
- package/dist/flags-01-PWC64NSQ.js.map +1 -0
- package/dist/flags-02-GNF7X6MP.js +10 -0
- package/dist/flags-02-GNF7X6MP.js.map +1 -0
- package/dist/flags-03-STVDA6UG.js +82 -0
- package/dist/flags-03-STVDA6UG.js.map +1 -0
- package/dist/flags-04-Z6AHZIWG.js +31 -0
- package/dist/flags-04-Z6AHZIWG.js.map +1 -0
- package/dist/flags-05-QBADBC6C.js +13 -0
- package/dist/flags-05-QBADBC6C.js.map +1 -0
- package/dist/flags-06-O55E67OI.js +28 -0
- package/dist/flags-06-O55E67OI.js.map +1 -0
- package/dist/flags-07-RSWJQIRW.js +64 -0
- package/dist/flags-07-RSWJQIRW.js.map +1 -0
- package/dist/flags-08-HHXIPTKX.js +31 -0
- package/dist/flags-08-HHXIPTKX.js.map +1 -0
- package/dist/flags-09-OEZBQ62G.js +64 -0
- package/dist/flags-09-OEZBQ62G.js.map +1 -0
- package/dist/flags-10-XJY5UMQR.js +73 -0
- package/dist/flags-10-XJY5UMQR.js.map +1 -0
- package/dist/flags-11-7M75OPUJ.js +34 -0
- package/dist/flags-11-7M75OPUJ.js.map +1 -0
- package/dist/flags-12-JY22PFQH.js +31 -0
- package/dist/flags-12-JY22PFQH.js.map +1 -0
- package/dist/flags-13-BERDGZCT.js +52 -0
- package/dist/flags-13-BERDGZCT.js.map +1 -0
- package/dist/flags-14-XVPM2GQ2.js +31 -0
- package/dist/flags-14-XVPM2GQ2.js.map +1 -0
- package/dist/flags-15-WESIXIDR.js +64 -0
- package/dist/flags-15-WESIXIDR.js.map +1 -0
- package/dist/flags-16-PTNHBPYG.js +40 -0
- package/dist/flags-16-PTNHBPYG.js.map +1 -0
- package/dist/flags-17-UYXBV5BH.js +10 -0
- package/dist/flags-17-UYXBV5BH.js.map +1 -0
- package/dist/flags-18-VMKDO7W4.js +91 -0
- package/dist/flags-18-VMKDO7W4.js.map +1 -0
- package/dist/flags-19-635PQOEQ.js +43 -0
- package/dist/flags-19-635PQOEQ.js.map +1 -0
- package/dist/forms.d.ts +2 -2
- package/dist/forms.js +3 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -9
- package/dist/manifest.json +32 -10
- package/dist/overlays.js +1 -2
- package/package.json +4 -2
- package/dist/chunk-2NMEKWO5.js +0 -38
- package/dist/chunk-2NMEKWO5.js.map +0 -1
- package/dist/chunk-LPLXAKPJ.js.map +0 -1
- package/dist/chunk-YCW3REQK.js +0 -3102
- package/dist/chunk-YCW3REQK.js.map +0 -1
|
@@ -2,18 +2,12 @@ import {
|
|
|
2
2
|
Tooltip_default,
|
|
3
3
|
getFloatingLayerClass,
|
|
4
4
|
mergeAriaDescribedBy
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-MMTKCHRP.js";
|
|
6
6
|
import {
|
|
7
7
|
COUNTRY_OPTIONS,
|
|
8
8
|
PHONE_COUNTRY_OPTIONS,
|
|
9
|
-
filterCountryOptions
|
|
10
|
-
|
|
11
|
-
} from "./chunk-YCW3REQK.js";
|
|
12
|
-
import {
|
|
13
|
-
__objRest,
|
|
14
|
-
__spreadProps,
|
|
15
|
-
__spreadValues
|
|
16
|
-
} from "./chunk-2NMEKWO5.js";
|
|
9
|
+
filterCountryOptions
|
|
10
|
+
} from "./chunk-7IY43S3Y.js";
|
|
17
11
|
|
|
18
12
|
// src/components/input/Input.tsx
|
|
19
13
|
import React, { useRef, useCallback, useId, useState } from "react";
|
|
@@ -39,38 +33,26 @@ var FIELD_INPUT_CLASS = "w-full border-none bg-transparent text-field-content ou
|
|
|
39
33
|
// src/components/field/FieldFrame.tsx
|
|
40
34
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
41
35
|
var FieldFrame = forwardRef(
|
|
42
|
-
function FieldFrame2(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"children",
|
|
57
|
-
"label",
|
|
58
|
-
"labelFor",
|
|
59
|
-
"labelId",
|
|
60
|
-
"labelAdornment",
|
|
61
|
-
"description",
|
|
62
|
-
"descriptionId",
|
|
63
|
-
"message",
|
|
64
|
-
"messageId",
|
|
65
|
-
"invalid",
|
|
66
|
-
"className"
|
|
67
|
-
]);
|
|
36
|
+
function FieldFrame2({
|
|
37
|
+
children,
|
|
38
|
+
label,
|
|
39
|
+
labelFor,
|
|
40
|
+
labelId,
|
|
41
|
+
labelAdornment,
|
|
42
|
+
description,
|
|
43
|
+
descriptionId,
|
|
44
|
+
message,
|
|
45
|
+
messageId,
|
|
46
|
+
invalid = false,
|
|
47
|
+
className,
|
|
48
|
+
...rest
|
|
49
|
+
}, ref) {
|
|
68
50
|
return /* @__PURE__ */ jsxs(
|
|
69
51
|
"div",
|
|
70
|
-
|
|
52
|
+
{
|
|
71
53
|
ref,
|
|
72
|
-
className: classNames(FIELD_ROOT_CLASS, className)
|
|
73
|
-
|
|
54
|
+
className: classNames(FIELD_ROOT_CLASS, className),
|
|
55
|
+
...rest,
|
|
74
56
|
children: [
|
|
75
57
|
(label || labelAdornment) && /* @__PURE__ */ jsxs("div", { className: "field-label-slot flex flex-row items-end justify-between", children: [
|
|
76
58
|
label && /* @__PURE__ */ jsx(
|
|
@@ -97,7 +79,7 @@ var FieldFrame = forwardRef(
|
|
|
97
79
|
}
|
|
98
80
|
)
|
|
99
81
|
]
|
|
100
|
-
}
|
|
82
|
+
}
|
|
101
83
|
);
|
|
102
84
|
}
|
|
103
85
|
);
|
|
@@ -108,10 +90,11 @@ var FieldFrame_default = FieldFrame;
|
|
|
108
90
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
109
91
|
var BaseInput = React.forwardRef((props, ref) => /* @__PURE__ */ jsx2(
|
|
110
92
|
"input",
|
|
111
|
-
|
|
93
|
+
{
|
|
94
|
+
...props,
|
|
112
95
|
ref,
|
|
113
96
|
className: classNames2(FIELD_INPUT_CLASS, props.className)
|
|
114
|
-
}
|
|
97
|
+
}
|
|
115
98
|
));
|
|
116
99
|
BaseInput.displayName = "BaseInput";
|
|
117
100
|
function normalizeCurrencyDigits(value) {
|
|
@@ -159,39 +142,23 @@ function formatContaValue(value) {
|
|
|
159
142
|
}
|
|
160
143
|
return `${compactDigits.slice(0, 12)}-${compactDigits.slice(12, 13)}`;
|
|
161
144
|
}
|
|
162
|
-
var Input = (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
"name",
|
|
180
|
-
"label",
|
|
181
|
-
"helperText",
|
|
182
|
-
"placeholder",
|
|
183
|
-
"prefix",
|
|
184
|
-
"suffix",
|
|
185
|
-
"mask",
|
|
186
|
-
"disabled",
|
|
187
|
-
"error",
|
|
188
|
-
"disallowSpaces",
|
|
189
|
-
"leadIcon",
|
|
190
|
-
"endIcon",
|
|
191
|
-
"type",
|
|
192
|
-
"className"
|
|
193
|
-
]);
|
|
194
|
-
var _a2;
|
|
145
|
+
var Input = ({
|
|
146
|
+
name,
|
|
147
|
+
label,
|
|
148
|
+
helperText,
|
|
149
|
+
placeholder,
|
|
150
|
+
prefix,
|
|
151
|
+
suffix,
|
|
152
|
+
mask,
|
|
153
|
+
disabled,
|
|
154
|
+
error,
|
|
155
|
+
disallowSpaces,
|
|
156
|
+
leadIcon: LeadIcon,
|
|
157
|
+
endIcon: EndIcon,
|
|
158
|
+
type,
|
|
159
|
+
className,
|
|
160
|
+
...rest
|
|
161
|
+
}) => {
|
|
195
162
|
const [field, meta, helpers] = useField(name);
|
|
196
163
|
const inputRef = useRef(null);
|
|
197
164
|
const iconRef = useRef(null);
|
|
@@ -200,7 +167,7 @@ var Input = (_a) => {
|
|
|
200
167
|
const [showPassword, setShowPassword] = useState(false);
|
|
201
168
|
const currentType = isPasswordType ? showPassword ? "text" : "password" : type;
|
|
202
169
|
const hasError = Boolean(meta.touched && meta.error || error);
|
|
203
|
-
const inputId =
|
|
170
|
+
const inputId = rest.id ?? name;
|
|
204
171
|
const errorId = `${inputId}-error`;
|
|
205
172
|
const ariaDescribedBy = mergeAriaDescribedBy(
|
|
206
173
|
rest["aria-describedby"],
|
|
@@ -221,16 +188,15 @@ var Input = (_a) => {
|
|
|
221
188
|
);
|
|
222
189
|
const handlePasteFormik = useCallback(
|
|
223
190
|
(e) => {
|
|
224
|
-
var _a3, _b2;
|
|
225
191
|
if (!disallowSpaces) {
|
|
226
|
-
|
|
192
|
+
rest.onPaste?.(e);
|
|
227
193
|
return;
|
|
228
194
|
}
|
|
229
195
|
e.preventDefault();
|
|
230
196
|
const pastedText = e.clipboardData.getData("text");
|
|
231
197
|
const sanitizedValue = sanitizeValue(pastedText);
|
|
232
198
|
helpers.setValue(sanitizedValue);
|
|
233
|
-
|
|
199
|
+
rest.onPaste?.(e);
|
|
234
200
|
},
|
|
235
201
|
[disallowSpaces, helpers, rest, sanitizeValue]
|
|
236
202
|
);
|
|
@@ -247,12 +213,14 @@ var Input = (_a) => {
|
|
|
247
213
|
);
|
|
248
214
|
helpers.setValue(formattedCurrencyValue);
|
|
249
215
|
if (rest.onChange) {
|
|
250
|
-
const event =
|
|
251
|
-
|
|
252
|
-
|
|
216
|
+
const event = {
|
|
217
|
+
...e,
|
|
218
|
+
target: { ...e.target, value: formattedCurrencyValue },
|
|
219
|
+
currentTarget: {
|
|
220
|
+
...e.currentTarget,
|
|
253
221
|
value: formattedCurrencyValue
|
|
254
|
-
}
|
|
255
|
-
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
256
224
|
rest.onChange(event);
|
|
257
225
|
}
|
|
258
226
|
},
|
|
@@ -284,7 +252,9 @@ var Input = (_a) => {
|
|
|
284
252
|
const rawCurrencyValue = typeof field.value === "string" || typeof field.value === "number" ? field.value : "";
|
|
285
253
|
return /* @__PURE__ */ jsx2(
|
|
286
254
|
"input",
|
|
287
|
-
|
|
255
|
+
{
|
|
256
|
+
...rest,
|
|
257
|
+
...accessibilityProps,
|
|
288
258
|
name,
|
|
289
259
|
ref: inputRef,
|
|
290
260
|
type: "text",
|
|
@@ -296,55 +266,58 @@ var Input = (_a) => {
|
|
|
296
266
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
297
267
|
autoComplete: autoCompleteValue,
|
|
298
268
|
disabled
|
|
299
|
-
}
|
|
269
|
+
}
|
|
300
270
|
);
|
|
301
271
|
}
|
|
302
272
|
if (mask === "specialChars") {
|
|
303
273
|
return /* @__PURE__ */ jsx2(
|
|
304
274
|
"input",
|
|
305
|
-
|
|
275
|
+
{
|
|
276
|
+
...rest,
|
|
277
|
+
...accessibilityProps,
|
|
278
|
+
...field,
|
|
306
279
|
name,
|
|
307
280
|
ref: inputRef,
|
|
308
281
|
placeholder,
|
|
309
282
|
type: inputType === "date" ? "text" : inputType,
|
|
310
283
|
value: String(safeValue(field.value)),
|
|
311
284
|
onKeyDown: (e) => {
|
|
312
|
-
var _a3;
|
|
313
285
|
if (disallowSpaces && e.key === " ") {
|
|
314
286
|
e.preventDefault();
|
|
315
287
|
}
|
|
316
|
-
|
|
288
|
+
rest.onKeyDown?.(e);
|
|
317
289
|
},
|
|
318
290
|
onPaste: handlePasteFormik,
|
|
319
291
|
onChange: (e) => {
|
|
320
|
-
var _a3;
|
|
321
292
|
const cleanedValue = cleanSpecialChars(e.target.value);
|
|
322
293
|
const sanitizedValue = sanitizeValue(cleanedValue);
|
|
323
294
|
helpers.setValue(sanitizedValue);
|
|
324
|
-
|
|
295
|
+
rest.onChange?.(e);
|
|
325
296
|
},
|
|
326
297
|
autoComplete: autoCompleteValue,
|
|
327
298
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
328
299
|
disabled
|
|
329
|
-
}
|
|
300
|
+
}
|
|
330
301
|
);
|
|
331
302
|
}
|
|
332
303
|
if (mask === "datePicker") {
|
|
333
304
|
const dateValue = field.value ? typeof field.value === "string" ? field.value : field.value instanceof Date ? field.value.toLocaleDateString("pt-BR") : String(field.value) : "";
|
|
334
305
|
return /* @__PURE__ */ jsx2(
|
|
335
306
|
"input",
|
|
336
|
-
|
|
307
|
+
{
|
|
308
|
+
...rest,
|
|
309
|
+
...accessibilityProps,
|
|
310
|
+
...field,
|
|
337
311
|
name,
|
|
338
312
|
ref: inputRef,
|
|
339
313
|
placeholder,
|
|
340
314
|
type: inputType,
|
|
341
315
|
value: dateValue,
|
|
342
316
|
onKeyDown: (e) => {
|
|
343
|
-
var _a3;
|
|
344
317
|
if (disallowSpaces && e.key === " ") {
|
|
345
318
|
e.preventDefault();
|
|
346
319
|
}
|
|
347
|
-
|
|
320
|
+
rest.onKeyDown?.(e);
|
|
348
321
|
},
|
|
349
322
|
onPaste: handlePasteFormik,
|
|
350
323
|
onChange: (e) => {
|
|
@@ -355,13 +328,15 @@ var Input = (_a) => {
|
|
|
355
328
|
autoComplete: autoCompleteValue,
|
|
356
329
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
357
330
|
disabled
|
|
358
|
-
}
|
|
331
|
+
}
|
|
359
332
|
);
|
|
360
333
|
}
|
|
361
334
|
if (mask === "conta") {
|
|
362
335
|
return /* @__PURE__ */ jsx2(
|
|
363
336
|
"input",
|
|
364
|
-
|
|
337
|
+
{
|
|
338
|
+
...rest,
|
|
339
|
+
...accessibilityProps,
|
|
365
340
|
name,
|
|
366
341
|
ref: inputRef,
|
|
367
342
|
placeholder,
|
|
@@ -370,7 +345,6 @@ var Input = (_a) => {
|
|
|
370
345
|
disabled,
|
|
371
346
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
372
347
|
onKeyDown: (e) => {
|
|
373
|
-
var _a3;
|
|
374
348
|
if (disallowSpaces && e.key === " ") {
|
|
375
349
|
e.preventDefault();
|
|
376
350
|
}
|
|
@@ -382,26 +356,28 @@ var Input = (_a) => {
|
|
|
382
356
|
helpers.setValue(nextValue);
|
|
383
357
|
return;
|
|
384
358
|
}
|
|
385
|
-
|
|
359
|
+
rest.onKeyDown?.(e);
|
|
386
360
|
},
|
|
387
361
|
onPaste: handlePasteFormik,
|
|
388
362
|
onChange: (e) => {
|
|
389
|
-
var _a3;
|
|
390
363
|
const val = sanitizeValue(formatContaValue(e.target.value));
|
|
391
364
|
e.target.value = val;
|
|
392
365
|
e.currentTarget.value = val;
|
|
393
366
|
helpers.setValue(val);
|
|
394
|
-
|
|
367
|
+
rest.onChange?.(e);
|
|
395
368
|
},
|
|
396
369
|
autoComplete: autoCompleteValue
|
|
397
|
-
}
|
|
370
|
+
}
|
|
398
371
|
);
|
|
399
372
|
}
|
|
400
373
|
if (mask && patternMasks[mask]) {
|
|
401
374
|
const patternValue = typeof field.value === "string" || typeof field.value === "number" ? field.value : "";
|
|
402
375
|
return /* @__PURE__ */ jsx2(
|
|
403
376
|
PatternFormat,
|
|
404
|
-
|
|
377
|
+
{
|
|
378
|
+
...rest,
|
|
379
|
+
...accessibilityProps,
|
|
380
|
+
...field,
|
|
405
381
|
name,
|
|
406
382
|
value: patternValue,
|
|
407
383
|
defaultValue: "",
|
|
@@ -415,35 +391,36 @@ var Input = (_a) => {
|
|
|
415
391
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
416
392
|
autoComplete: autoCompleteValue,
|
|
417
393
|
disabled
|
|
418
|
-
}
|
|
394
|
+
}
|
|
419
395
|
);
|
|
420
396
|
}
|
|
421
397
|
return /* @__PURE__ */ jsx2(
|
|
422
398
|
"input",
|
|
423
|
-
|
|
399
|
+
{
|
|
400
|
+
...rest,
|
|
401
|
+
...accessibilityProps,
|
|
402
|
+
...field,
|
|
424
403
|
name,
|
|
425
404
|
ref: inputRef,
|
|
426
405
|
placeholder,
|
|
427
406
|
type: inputType === "date" ? "text" : inputType,
|
|
428
407
|
value: String(safeValue(field.value)),
|
|
429
408
|
onKeyDown: (e) => {
|
|
430
|
-
var _a3;
|
|
431
409
|
if (disallowSpaces && e.key === " ") {
|
|
432
410
|
e.preventDefault();
|
|
433
411
|
}
|
|
434
|
-
|
|
412
|
+
rest.onKeyDown?.(e);
|
|
435
413
|
},
|
|
436
414
|
onPaste: handlePasteFormik,
|
|
437
415
|
onChange: (e) => {
|
|
438
|
-
var _a3;
|
|
439
416
|
const sanitizedValue = sanitizeValue(e.target.value);
|
|
440
417
|
helpers.setValue(sanitizedValue);
|
|
441
|
-
|
|
418
|
+
rest.onChange?.(e);
|
|
442
419
|
},
|
|
443
420
|
autoComplete: autoCompleteValue,
|
|
444
421
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
445
422
|
disabled
|
|
446
|
-
}
|
|
423
|
+
}
|
|
447
424
|
);
|
|
448
425
|
};
|
|
449
426
|
return /* @__PURE__ */ jsx2(
|
|
@@ -464,7 +441,7 @@ var Input = (_a) => {
|
|
|
464
441
|
onFocus: () => setHovered(true),
|
|
465
442
|
onBlur: () => setHovered(false),
|
|
466
443
|
type: "button",
|
|
467
|
-
"aria-label": `Mais informa\xE7\xF5es sobre ${label
|
|
444
|
+
"aria-label": `Mais informa\xE7\xF5es sobre ${label ?? name}`,
|
|
468
445
|
className: "rounded-sm pb-[3px] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-1",
|
|
469
446
|
children: /* @__PURE__ */ jsx2(MdInfoOutline, { "aria-hidden": "true", className: "mr-0 text-content-muted" })
|
|
470
447
|
}
|
|
@@ -548,8 +525,7 @@ var Input = (_a) => {
|
|
|
548
525
|
};
|
|
549
526
|
var Input_default = Input;
|
|
550
527
|
var InputStandalone = (props) => {
|
|
551
|
-
|
|
552
|
-
const _a = props, {
|
|
528
|
+
const {
|
|
553
529
|
label,
|
|
554
530
|
helperText,
|
|
555
531
|
prefix,
|
|
@@ -562,22 +538,9 @@ var InputStandalone = (props) => {
|
|
|
562
538
|
leadIcon: LeadIcon,
|
|
563
539
|
endIcon: EndIcon,
|
|
564
540
|
type,
|
|
565
|
-
className
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
"helperText",
|
|
569
|
-
"prefix",
|
|
570
|
-
"suffix",
|
|
571
|
-
"mask",
|
|
572
|
-
"disabled",
|
|
573
|
-
"error",
|
|
574
|
-
"errorText",
|
|
575
|
-
"disallowSpaces",
|
|
576
|
-
"leadIcon",
|
|
577
|
-
"endIcon",
|
|
578
|
-
"type",
|
|
579
|
-
"className"
|
|
580
|
-
]);
|
|
541
|
+
className,
|
|
542
|
+
...rest
|
|
543
|
+
} = props;
|
|
581
544
|
const inputRef = useRef(null);
|
|
582
545
|
const iconRef = useRef(null);
|
|
583
546
|
const [hovered, setHovered] = useState(false);
|
|
@@ -586,7 +549,7 @@ var InputStandalone = (props) => {
|
|
|
586
549
|
const currentType = isPasswordType ? showPassword ? "text" : "password" : type;
|
|
587
550
|
const hasError = Boolean(error);
|
|
588
551
|
const generatedInputId = useId();
|
|
589
|
-
const inputId =
|
|
552
|
+
const inputId = rest.id ?? generatedInputId;
|
|
590
553
|
const errorId = `${inputId}-error`;
|
|
591
554
|
const ariaDescribedBy = mergeAriaDescribedBy(
|
|
592
555
|
rest["aria-describedby"],
|
|
@@ -607,24 +570,26 @@ var InputStandalone = (props) => {
|
|
|
607
570
|
);
|
|
608
571
|
const handlePasteStandalone = useCallback(
|
|
609
572
|
(e) => {
|
|
610
|
-
var _a2, _b2, _c2;
|
|
611
573
|
if (!disallowSpaces) {
|
|
612
|
-
|
|
574
|
+
rest.onPaste?.(e);
|
|
613
575
|
return;
|
|
614
576
|
}
|
|
615
577
|
e.preventDefault();
|
|
616
578
|
const pastedText = e.clipboardData.getData("text");
|
|
617
579
|
const sanitizedValue = sanitizeValue(pastedText);
|
|
618
|
-
const syntheticEvent =
|
|
619
|
-
|
|
580
|
+
const syntheticEvent = {
|
|
581
|
+
...e,
|
|
582
|
+
target: {
|
|
583
|
+
...e.target,
|
|
620
584
|
value: sanitizedValue
|
|
621
|
-
}
|
|
622
|
-
currentTarget:
|
|
585
|
+
},
|
|
586
|
+
currentTarget: {
|
|
587
|
+
...e.currentTarget,
|
|
623
588
|
value: sanitizedValue
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
rest.onChange?.(syntheticEvent);
|
|
592
|
+
rest.onPaste?.(e);
|
|
628
593
|
},
|
|
629
594
|
[disallowSpaces, rest, sanitizeValue]
|
|
630
595
|
);
|
|
@@ -654,7 +619,9 @@ var InputStandalone = (props) => {
|
|
|
654
619
|
const rawCurrencyValue = typeof rest.value === "string" || typeof rest.value === "number" ? rest.value : "";
|
|
655
620
|
return /* @__PURE__ */ jsx2(
|
|
656
621
|
"input",
|
|
657
|
-
|
|
622
|
+
{
|
|
623
|
+
...rest,
|
|
624
|
+
...accessibilityProps,
|
|
658
625
|
ref: inputRef,
|
|
659
626
|
type: "text",
|
|
660
627
|
inputMode: "numeric",
|
|
@@ -675,72 +642,74 @@ var InputStandalone = (props) => {
|
|
|
675
642
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
676
643
|
autoComplete: autoCompleteValue,
|
|
677
644
|
disabled
|
|
678
|
-
}
|
|
645
|
+
}
|
|
679
646
|
);
|
|
680
647
|
}
|
|
681
648
|
if (mask === "specialChars") {
|
|
682
649
|
return /* @__PURE__ */ jsx2(
|
|
683
650
|
"input",
|
|
684
|
-
|
|
651
|
+
{
|
|
652
|
+
...rest,
|
|
653
|
+
...accessibilityProps,
|
|
685
654
|
ref: inputRef,
|
|
686
655
|
placeholder: rest.placeholder,
|
|
687
656
|
type: inputType === "date" ? "text" : inputType,
|
|
688
657
|
value: String(safeValue(rest.value)),
|
|
689
658
|
onKeyDown: (e) => {
|
|
690
|
-
var _a2;
|
|
691
659
|
if (disallowSpaces && e.key === " ") {
|
|
692
660
|
e.preventDefault();
|
|
693
661
|
}
|
|
694
|
-
|
|
662
|
+
rest.onKeyDown?.(e);
|
|
695
663
|
},
|
|
696
664
|
onPaste: handlePasteStandalone,
|
|
697
665
|
onChange: (e) => {
|
|
698
|
-
var _a2;
|
|
699
666
|
const cleaned = cleanSpecialChars(e.target.value);
|
|
700
667
|
const sanitizedValue = sanitizeValue(cleaned);
|
|
701
668
|
e.target.value = sanitizedValue;
|
|
702
|
-
|
|
669
|
+
rest.onChange?.(e);
|
|
703
670
|
},
|
|
704
671
|
autoComplete: autoCompleteValue,
|
|
705
672
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
706
673
|
disabled
|
|
707
|
-
}
|
|
674
|
+
}
|
|
708
675
|
);
|
|
709
676
|
}
|
|
710
677
|
if (mask === "datePicker") {
|
|
711
678
|
const dateValue = rest.value ? typeof rest.value === "string" ? rest.value : rest.value instanceof Date ? rest.value.toLocaleDateString("pt-BR") : String(rest.value) : "";
|
|
712
679
|
return /* @__PURE__ */ jsx2(
|
|
713
680
|
"input",
|
|
714
|
-
|
|
681
|
+
{
|
|
682
|
+
...rest,
|
|
683
|
+
...accessibilityProps,
|
|
715
684
|
ref: inputRef,
|
|
716
685
|
placeholder: rest.placeholder,
|
|
717
686
|
type: inputType,
|
|
718
687
|
value: dateValue,
|
|
719
688
|
onKeyDown: (e) => {
|
|
720
|
-
var _a2;
|
|
721
689
|
if (disallowSpaces && e.key === " ") {
|
|
722
690
|
e.preventDefault();
|
|
723
691
|
}
|
|
724
|
-
|
|
692
|
+
rest.onKeyDown?.(e);
|
|
725
693
|
},
|
|
726
694
|
onPaste: handlePasteStandalone,
|
|
727
695
|
onChange: (e) => {
|
|
728
|
-
var _a2;
|
|
729
696
|
const cleaned = cleanSpecialChars(e.target.value);
|
|
730
697
|
const sanitizedValue = sanitizeValue(cleaned);
|
|
731
698
|
e.target.value = sanitizedValue;
|
|
732
|
-
|
|
699
|
+
rest.onChange?.(e);
|
|
733
700
|
},
|
|
734
701
|
autoComplete: autoCompleteValue,
|
|
735
702
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
736
703
|
disabled
|
|
737
|
-
}
|
|
704
|
+
}
|
|
738
705
|
);
|
|
739
706
|
}
|
|
740
707
|
if (mask === "conta") {
|
|
741
708
|
return /* @__PURE__ */ jsx2(
|
|
742
709
|
"input",
|
|
743
|
-
|
|
710
|
+
{
|
|
711
|
+
...rest,
|
|
712
|
+
...accessibilityProps,
|
|
744
713
|
ref: inputRef,
|
|
745
714
|
placeholder: rest.placeholder,
|
|
746
715
|
maxLength: 14,
|
|
@@ -748,7 +717,6 @@ var InputStandalone = (props) => {
|
|
|
748
717
|
disabled,
|
|
749
718
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
750
719
|
onKeyDown: (e) => {
|
|
751
|
-
var _a2;
|
|
752
720
|
if (disallowSpaces && e.key === " ") {
|
|
753
721
|
e.preventDefault();
|
|
754
722
|
}
|
|
@@ -767,24 +735,25 @@ var InputStandalone = (props) => {
|
|
|
767
735
|
}
|
|
768
736
|
return;
|
|
769
737
|
}
|
|
770
|
-
|
|
738
|
+
rest.onKeyDown?.(e);
|
|
771
739
|
},
|
|
772
740
|
onPaste: handlePasteStandalone,
|
|
773
741
|
onChange: (e) => {
|
|
774
|
-
var _a2;
|
|
775
742
|
const val = sanitizeValue(formatContaValue(e.target.value));
|
|
776
743
|
e.target.value = val;
|
|
777
|
-
|
|
744
|
+
rest.onChange?.(e);
|
|
778
745
|
},
|
|
779
746
|
autoComplete: autoCompleteValue
|
|
780
|
-
}
|
|
747
|
+
}
|
|
781
748
|
);
|
|
782
749
|
}
|
|
783
750
|
if (mask && patternMasks[mask]) {
|
|
784
751
|
const patternValue = typeof rest.value === "string" || typeof rest.value === "number" ? rest.value : "";
|
|
785
752
|
return /* @__PURE__ */ jsx2(
|
|
786
753
|
PatternFormat,
|
|
787
|
-
|
|
754
|
+
{
|
|
755
|
+
...rest,
|
|
756
|
+
...accessibilityProps,
|
|
788
757
|
value: patternValue,
|
|
789
758
|
defaultValue: "",
|
|
790
759
|
getInputRef: inputRef,
|
|
@@ -804,34 +773,34 @@ var InputStandalone = (props) => {
|
|
|
804
773
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
805
774
|
autoComplete: autoCompleteValue,
|
|
806
775
|
disabled
|
|
807
|
-
}
|
|
776
|
+
}
|
|
808
777
|
);
|
|
809
778
|
}
|
|
810
779
|
return /* @__PURE__ */ jsx2(
|
|
811
780
|
"input",
|
|
812
|
-
|
|
781
|
+
{
|
|
782
|
+
...rest,
|
|
783
|
+
...accessibilityProps,
|
|
813
784
|
ref: inputRef,
|
|
814
785
|
placeholder: rest.placeholder,
|
|
815
786
|
type: inputType === "date" ? "text" : inputType,
|
|
816
787
|
value: String(safeValue(rest.value)),
|
|
817
788
|
onKeyDown: (e) => {
|
|
818
|
-
var _a2;
|
|
819
789
|
if (disallowSpaces && e.key === " ") {
|
|
820
790
|
e.preventDefault();
|
|
821
791
|
}
|
|
822
|
-
|
|
792
|
+
rest.onKeyDown?.(e);
|
|
823
793
|
},
|
|
824
794
|
onPaste: handlePasteStandalone,
|
|
825
795
|
onChange: (e) => {
|
|
826
|
-
var _a2;
|
|
827
796
|
const sanitizedValue = sanitizeValue(e.target.value);
|
|
828
797
|
e.target.value = sanitizedValue;
|
|
829
|
-
|
|
798
|
+
rest.onChange?.(e);
|
|
830
799
|
},
|
|
831
800
|
autoComplete: autoCompleteValue,
|
|
832
801
|
className: classNames2(FIELD_INPUT_CLASS, className),
|
|
833
802
|
disabled
|
|
834
|
-
}
|
|
803
|
+
}
|
|
835
804
|
);
|
|
836
805
|
};
|
|
837
806
|
return /* @__PURE__ */ jsx2(
|
|
@@ -852,7 +821,7 @@ var InputStandalone = (props) => {
|
|
|
852
821
|
onFocus: () => setHovered(true),
|
|
853
822
|
onBlur: () => setHovered(false),
|
|
854
823
|
type: "button",
|
|
855
|
-
"aria-label": `Mais informa\xE7\xF5es sobre ${
|
|
824
|
+
"aria-label": `Mais informa\xE7\xF5es sobre ${label ?? rest.name ?? "este campo"}`,
|
|
856
825
|
className: "rounded-sm pb-[3px] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-1",
|
|
857
826
|
children: /* @__PURE__ */ jsx2(MdInfoOutline, { "aria-hidden": "true", className: "mr-0 text-content-muted" })
|
|
858
827
|
}
|
|
@@ -870,7 +839,7 @@ var InputStandalone = (props) => {
|
|
|
870
839
|
children: /* @__PURE__ */ jsxs2(
|
|
871
840
|
"div",
|
|
872
841
|
{
|
|
873
|
-
"data-has-value": String(safeValue(
|
|
842
|
+
"data-has-value": String(safeValue(rest.value ?? rest.defaultValue)).length > 0,
|
|
874
843
|
className: classNames2(
|
|
875
844
|
FIELD_CONTROL_CLASS,
|
|
876
845
|
{
|
|
@@ -987,51 +956,30 @@ import {
|
|
|
987
956
|
MdSearch
|
|
988
957
|
} from "react-icons/md";
|
|
989
958
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
990
|
-
var InputSelect = (
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
"label",
|
|
1015
|
-
"helperText",
|
|
1016
|
-
"placeholder",
|
|
1017
|
-
"defaultValue",
|
|
1018
|
-
"options",
|
|
1019
|
-
"prefix",
|
|
1020
|
-
"suffix",
|
|
1021
|
-
"disabled",
|
|
1022
|
-
"error",
|
|
1023
|
-
"leadIcon",
|
|
1024
|
-
"endIcon",
|
|
1025
|
-
"searchable",
|
|
1026
|
-
"searchPlaceholder",
|
|
1027
|
-
"noOptionsText",
|
|
1028
|
-
"renderOption",
|
|
1029
|
-
"renderValue",
|
|
1030
|
-
"searchAccessor",
|
|
1031
|
-
"className",
|
|
1032
|
-
"onChange"
|
|
1033
|
-
]);
|
|
1034
|
-
const isSearchable = searchable != null ? searchable : options.length > 10;
|
|
959
|
+
var InputSelect = ({
|
|
960
|
+
name,
|
|
961
|
+
label,
|
|
962
|
+
helperText,
|
|
963
|
+
placeholder,
|
|
964
|
+
defaultValue,
|
|
965
|
+
options,
|
|
966
|
+
prefix,
|
|
967
|
+
suffix,
|
|
968
|
+
disabled,
|
|
969
|
+
error,
|
|
970
|
+
leadIcon: LeadIcon,
|
|
971
|
+
endIcon: EndIcon,
|
|
972
|
+
searchable,
|
|
973
|
+
searchPlaceholder = "Pesquisar...",
|
|
974
|
+
noOptionsText = "Nenhuma op\xE7\xE3o encontrada",
|
|
975
|
+
renderOption,
|
|
976
|
+
renderValue,
|
|
977
|
+
searchAccessor,
|
|
978
|
+
className,
|
|
979
|
+
onChange,
|
|
980
|
+
...rest
|
|
981
|
+
}) => {
|
|
982
|
+
const isSearchable = searchable ?? options.length > 10;
|
|
1035
983
|
const normalizeSearchText2 = (value) => value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
1036
984
|
const [field, meta, helpers] = useField2(name);
|
|
1037
985
|
const inputRef = useRef2(null);
|
|
@@ -1075,17 +1023,16 @@ var InputSelect = (_a) => {
|
|
|
1075
1023
|
}
|
|
1076
1024
|
}, [open]);
|
|
1077
1025
|
useEffect(() => {
|
|
1078
|
-
var _a2, _b2, _c, _d;
|
|
1079
1026
|
if (!open) return;
|
|
1080
1027
|
if (isSearchable) {
|
|
1081
|
-
|
|
1028
|
+
searchInputRef.current?.focus({ preventScroll: true });
|
|
1082
1029
|
return;
|
|
1083
1030
|
}
|
|
1084
|
-
const selectedOptionElement =
|
|
1031
|
+
const selectedOptionElement = dropdownRef.current?.querySelector(
|
|
1085
1032
|
'[role="option"][aria-selected="true"]'
|
|
1086
1033
|
);
|
|
1087
|
-
const firstOptionElement =
|
|
1088
|
-
(
|
|
1034
|
+
const firstOptionElement = dropdownRef.current?.querySelector('[role="option"]');
|
|
1035
|
+
(selectedOptionElement ?? firstOptionElement)?.focus({
|
|
1089
1036
|
preventScroll: true
|
|
1090
1037
|
});
|
|
1091
1038
|
}, [isSearchable, open]);
|
|
@@ -1119,16 +1066,14 @@ var InputSelect = (_a) => {
|
|
|
1119
1066
|
window.removeEventListener("resize", scheduleDropdownPosition);
|
|
1120
1067
|
};
|
|
1121
1068
|
}, [open, updateDropdownPosition]);
|
|
1122
|
-
const selectedOption = options.find((o) => o.value === (field.value ||
|
|
1069
|
+
const selectedOption = options.find((o) => o.value === (field.value || defaultValue?.value)) || null;
|
|
1123
1070
|
const closeDropdown = useCallback2((restoreFocus = false) => {
|
|
1124
|
-
var _a2;
|
|
1125
1071
|
setOpen(false);
|
|
1126
1072
|
if (restoreFocus) {
|
|
1127
|
-
|
|
1073
|
+
inputRef.current?.focus({ preventScroll: true });
|
|
1128
1074
|
}
|
|
1129
1075
|
}, []);
|
|
1130
1076
|
const moveFocusFromTrigger = useCallback2((backward) => {
|
|
1131
|
-
var _a2;
|
|
1132
1077
|
const trigger = inputRef.current;
|
|
1133
1078
|
if (!trigger) return;
|
|
1134
1079
|
const focusableElements = Array.from(
|
|
@@ -1136,14 +1081,11 @@ var InputSelect = (_a) => {
|
|
|
1136
1081
|
'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
1137
1082
|
)
|
|
1138
1083
|
).filter(
|
|
1139
|
-
(element) =>
|
|
1140
|
-
var _a3;
|
|
1141
|
-
return !((_a3 = dropdownRef.current) == null ? void 0 : _a3.contains(element)) && element.getAttribute("aria-hidden") !== "true" && element.getClientRects().length > 0;
|
|
1142
|
-
}
|
|
1084
|
+
(element) => !dropdownRef.current?.contains(element) && element.getAttribute("aria-hidden") !== "true" && element.getClientRects().length > 0
|
|
1143
1085
|
);
|
|
1144
1086
|
const triggerIndex = focusableElements.indexOf(trigger);
|
|
1145
1087
|
const targetIndex = triggerIndex + (backward ? -1 : 1);
|
|
1146
|
-
|
|
1088
|
+
focusableElements[targetIndex]?.focus({ preventScroll: true });
|
|
1147
1089
|
}, []);
|
|
1148
1090
|
const handleSelect = (value) => {
|
|
1149
1091
|
const option = options.find((candidate) => candidate.value === value);
|
|
@@ -1185,7 +1127,7 @@ var InputSelect = (_a) => {
|
|
|
1185
1127
|
const label2 = normalizeSearchText2(String(option.label || ""));
|
|
1186
1128
|
const value = normalizeSearchText2(String(option.value || ""));
|
|
1187
1129
|
const extraSearch = normalizeSearchText2(
|
|
1188
|
-
String(
|
|
1130
|
+
String(searchAccessor?.(option) || "")
|
|
1189
1131
|
);
|
|
1190
1132
|
return label2.includes(normalizedSearch) || value.includes(normalizedSearch) || extraSearch.includes(normalizedSearch);
|
|
1191
1133
|
}) : options;
|
|
@@ -1196,21 +1138,19 @@ var InputSelect = (_a) => {
|
|
|
1196
1138
|
hasError ? errorId : void 0
|
|
1197
1139
|
].filter(Boolean).join(" ");
|
|
1198
1140
|
const focusOption = (position) => {
|
|
1199
|
-
var _a2, _b2;
|
|
1200
1141
|
const optionElements = Array.from(
|
|
1201
|
-
|
|
1142
|
+
dropdownRef.current?.querySelectorAll(
|
|
1202
1143
|
'[role="option"]'
|
|
1203
|
-
)
|
|
1144
|
+
) ?? []
|
|
1204
1145
|
);
|
|
1205
1146
|
const option = position === "first" ? optionElements[0] : optionElements[optionElements.length - 1];
|
|
1206
|
-
option
|
|
1147
|
+
option?.focus({ preventScroll: true });
|
|
1207
1148
|
};
|
|
1208
1149
|
const handleOptionKeyDown = (event) => {
|
|
1209
|
-
var _a2, _b2, _c, _d, _e;
|
|
1210
1150
|
const optionElements = Array.from(
|
|
1211
|
-
|
|
1151
|
+
dropdownRef.current?.querySelectorAll(
|
|
1212
1152
|
'[role="option"]'
|
|
1213
|
-
)
|
|
1153
|
+
) ?? []
|
|
1214
1154
|
);
|
|
1215
1155
|
const currentIndex = optionElements.indexOf(event.currentTarget);
|
|
1216
1156
|
if (event.key === "Escape") {
|
|
@@ -1230,18 +1170,18 @@ var InputSelect = (_a) => {
|
|
|
1230
1170
|
}
|
|
1231
1171
|
event.preventDefault();
|
|
1232
1172
|
if (event.key === "Home") {
|
|
1233
|
-
|
|
1173
|
+
optionElements[0]?.focus({ preventScroll: true });
|
|
1234
1174
|
return;
|
|
1235
1175
|
}
|
|
1236
1176
|
if (event.key === "End") {
|
|
1237
|
-
|
|
1177
|
+
optionElements[optionElements.length - 1]?.focus({
|
|
1238
1178
|
preventScroll: true
|
|
1239
1179
|
});
|
|
1240
1180
|
return;
|
|
1241
1181
|
}
|
|
1242
1182
|
const direction = event.key === "ArrowDown" ? 1 : -1;
|
|
1243
1183
|
const nextIndex = (currentIndex + direction + optionElements.length) % optionElements.length;
|
|
1244
|
-
|
|
1184
|
+
optionElements[nextIndex]?.focus({ preventScroll: true });
|
|
1245
1185
|
};
|
|
1246
1186
|
const selectedValueContent = renderValue ? renderValue(selectedOption, placeholder) : /* @__PURE__ */ jsx3(
|
|
1247
1187
|
"span",
|
|
@@ -1289,7 +1229,7 @@ var InputSelect = (_a) => {
|
|
|
1289
1229
|
focusOption("last");
|
|
1290
1230
|
}
|
|
1291
1231
|
},
|
|
1292
|
-
"aria-label": `Pesquisar op\xE7\xF5es de ${label
|
|
1232
|
+
"aria-label": `Pesquisar op\xE7\xF5es de ${label ?? name}`,
|
|
1293
1233
|
"aria-controls": listboxId,
|
|
1294
1234
|
"aria-describedby": resultsId,
|
|
1295
1235
|
placeholder: searchPlaceholder,
|
|
@@ -1319,7 +1259,7 @@ var InputSelect = (_a) => {
|
|
|
1319
1259
|
{
|
|
1320
1260
|
type: "button",
|
|
1321
1261
|
role: "option",
|
|
1322
|
-
"aria-selected":
|
|
1262
|
+
"aria-selected": selectedOption?.value === opc.value,
|
|
1323
1263
|
tabIndex: -1,
|
|
1324
1264
|
onMouseDown: (e) => {
|
|
1325
1265
|
e.preventDefault();
|
|
@@ -1339,7 +1279,7 @@ var InputSelect = (_a) => {
|
|
|
1339
1279
|
) : null;
|
|
1340
1280
|
return /* @__PURE__ */ jsxs3(
|
|
1341
1281
|
FieldFrame_default,
|
|
1342
|
-
|
|
1282
|
+
{
|
|
1343
1283
|
className,
|
|
1344
1284
|
label,
|
|
1345
1285
|
labelFor: selectId,
|
|
@@ -1357,7 +1297,7 @@ var InputSelect = (_a) => {
|
|
|
1357
1297
|
onFocus: () => setHovered(true),
|
|
1358
1298
|
onBlur: () => setHovered(false),
|
|
1359
1299
|
type: "button",
|
|
1360
|
-
"aria-label": `Mais informa\xE7\xF5es sobre ${label
|
|
1300
|
+
"aria-label": `Mais informa\xE7\xF5es sobre ${label ?? name}`,
|
|
1361
1301
|
className: "rounded-sm pb-[3px] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-1",
|
|
1362
1302
|
children: /* @__PURE__ */ jsx3(
|
|
1363
1303
|
MdInfoOutline2,
|
|
@@ -1377,8 +1317,8 @@ var InputSelect = (_a) => {
|
|
|
1377
1317
|
preferredPosition: "bottom"
|
|
1378
1318
|
}
|
|
1379
1319
|
)
|
|
1380
|
-
] }) : void 0
|
|
1381
|
-
|
|
1320
|
+
] }) : void 0,
|
|
1321
|
+
...rest,
|
|
1382
1322
|
children: [
|
|
1383
1323
|
/* @__PURE__ */ jsxs3(
|
|
1384
1324
|
"button",
|
|
@@ -1393,7 +1333,7 @@ var InputSelect = (_a) => {
|
|
|
1393
1333
|
"aria-expanded": open,
|
|
1394
1334
|
"aria-haspopup": "listbox",
|
|
1395
1335
|
"aria-labelledby": label ? labelId : void 0,
|
|
1396
|
-
"aria-label": label ? void 0 : placeholder
|
|
1336
|
+
"aria-label": label ? void 0 : placeholder ?? name,
|
|
1397
1337
|
"aria-invalid": Boolean(hasError) || void 0,
|
|
1398
1338
|
"aria-describedby": triggerDescribedBy,
|
|
1399
1339
|
disabled,
|
|
@@ -1503,7 +1443,7 @@ var InputSelect = (_a) => {
|
|
|
1503
1443
|
),
|
|
1504
1444
|
isMounted && dropdownContent ? createPortal(dropdownContent, document.body) : null
|
|
1505
1445
|
]
|
|
1506
|
-
}
|
|
1446
|
+
}
|
|
1507
1447
|
);
|
|
1508
1448
|
};
|
|
1509
1449
|
var InputSelect_default = InputSelect;
|
|
@@ -1513,29 +1453,18 @@ import { useRef as useRef3 } from "react";
|
|
|
1513
1453
|
import classNames4 from "classnames";
|
|
1514
1454
|
import { useField as useField3 } from "formik";
|
|
1515
1455
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1516
|
-
var TextArea = (
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
"name",
|
|
1529
|
-
"label",
|
|
1530
|
-
"helperText",
|
|
1531
|
-
"className",
|
|
1532
|
-
"placeholder",
|
|
1533
|
-
"prefix",
|
|
1534
|
-
"suffix",
|
|
1535
|
-
"disabled",
|
|
1536
|
-
"icon"
|
|
1537
|
-
]);
|
|
1538
|
-
var _a2;
|
|
1456
|
+
var TextArea = ({
|
|
1457
|
+
name,
|
|
1458
|
+
label,
|
|
1459
|
+
helperText,
|
|
1460
|
+
className,
|
|
1461
|
+
placeholder,
|
|
1462
|
+
prefix,
|
|
1463
|
+
suffix,
|
|
1464
|
+
disabled,
|
|
1465
|
+
icon: Icon,
|
|
1466
|
+
...rest
|
|
1467
|
+
}) => {
|
|
1539
1468
|
const [field, meta] = useField3(name);
|
|
1540
1469
|
const componentRef = useRef3(null);
|
|
1541
1470
|
const hasError = meta.touched && meta.error;
|
|
@@ -1559,7 +1488,7 @@ var TextArea = (_a) => {
|
|
|
1559
1488
|
children: /* @__PURE__ */ jsxs4(
|
|
1560
1489
|
"div",
|
|
1561
1490
|
{
|
|
1562
|
-
"data-has-value": String(
|
|
1491
|
+
"data-has-value": String(field.value ?? "").length > 0,
|
|
1563
1492
|
className: classNames4(
|
|
1564
1493
|
`${FIELD_CONTROL_CLASS} py-1`,
|
|
1565
1494
|
{
|
|
@@ -1572,7 +1501,9 @@ var TextArea = (_a) => {
|
|
|
1572
1501
|
prefix && /* @__PURE__ */ jsx4("span", { children: prefix }),
|
|
1573
1502
|
/* @__PURE__ */ jsx4(
|
|
1574
1503
|
"textarea",
|
|
1575
|
-
|
|
1504
|
+
{
|
|
1505
|
+
...field,
|
|
1506
|
+
...rest,
|
|
1576
1507
|
id: name,
|
|
1577
1508
|
"aria-invalid": Boolean(hasError) || void 0,
|
|
1578
1509
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -1580,7 +1511,7 @@ var TextArea = (_a) => {
|
|
|
1580
1511
|
placeholder,
|
|
1581
1512
|
disabled,
|
|
1582
1513
|
className: classNames4(FIELD_INPUT_CLASS, className)
|
|
1583
|
-
}
|
|
1514
|
+
}
|
|
1584
1515
|
),
|
|
1585
1516
|
suffix && /* @__PURE__ */ jsx4("span", { children: suffix })
|
|
1586
1517
|
]
|
|
@@ -1594,7 +1525,7 @@ var TextArea_default = TextArea;
|
|
|
1594
1525
|
// src/components/inputPhone/InputPhone.tsx
|
|
1595
1526
|
import classNames5 from "classnames";
|
|
1596
1527
|
import { useField as useField4 } from "formik";
|
|
1597
|
-
import { useCallback as useCallback3, useEffect as
|
|
1528
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useMemo, useRef as useRef4, useState as useState4 } from "react";
|
|
1598
1529
|
import {
|
|
1599
1530
|
MdOutlineKeyboardArrowDown as MdOutlineKeyboardArrowDown2,
|
|
1600
1531
|
MdOutlineKeyboardArrowUp as MdOutlineKeyboardArrowUp2,
|
|
@@ -1602,7 +1533,99 @@ import {
|
|
|
1602
1533
|
} from "react-icons/md";
|
|
1603
1534
|
import { PatternFormat as PatternFormat2 } from "react-number-format";
|
|
1604
1535
|
import { createPortal as createPortal2 } from "react-dom";
|
|
1605
|
-
|
|
1536
|
+
|
|
1537
|
+
// src/components/countryFlag/CountryFlag.tsx
|
|
1538
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
1539
|
+
|
|
1540
|
+
// src/data/country-flags-runtime.ts
|
|
1541
|
+
var countryFlags = null;
|
|
1542
|
+
var countryFlagsPromise = null;
|
|
1543
|
+
function getLoadedCountryFlagUrl(cca2) {
|
|
1544
|
+
const code = String(cca2 || "").trim().toLowerCase();
|
|
1545
|
+
return code && countryFlags ? countryFlags[code] || "" : "";
|
|
1546
|
+
}
|
|
1547
|
+
function loadCountryFlags() {
|
|
1548
|
+
if (countryFlags) return Promise.resolve(countryFlags);
|
|
1549
|
+
if (!countryFlagsPromise) {
|
|
1550
|
+
countryFlagsPromise = Promise.all([
|
|
1551
|
+
import("./flags-00-MPU4ISEM.js"),
|
|
1552
|
+
import("./flags-01-PWC64NSQ.js"),
|
|
1553
|
+
import("./flags-02-GNF7X6MP.js"),
|
|
1554
|
+
import("./flags-03-STVDA6UG.js"),
|
|
1555
|
+
import("./flags-04-Z6AHZIWG.js"),
|
|
1556
|
+
import("./flags-05-QBADBC6C.js"),
|
|
1557
|
+
import("./flags-06-O55E67OI.js"),
|
|
1558
|
+
import("./flags-07-RSWJQIRW.js"),
|
|
1559
|
+
import("./flags-08-HHXIPTKX.js"),
|
|
1560
|
+
import("./flags-09-OEZBQ62G.js"),
|
|
1561
|
+
import("./flags-10-XJY5UMQR.js"),
|
|
1562
|
+
import("./flags-11-7M75OPUJ.js"),
|
|
1563
|
+
import("./flags-12-JY22PFQH.js"),
|
|
1564
|
+
import("./flags-13-BERDGZCT.js"),
|
|
1565
|
+
import("./flags-14-XVPM2GQ2.js"),
|
|
1566
|
+
import("./flags-15-WESIXIDR.js"),
|
|
1567
|
+
import("./flags-16-PTNHBPYG.js"),
|
|
1568
|
+
import("./flags-17-UYXBV5BH.js"),
|
|
1569
|
+
import("./flags-18-VMKDO7W4.js"),
|
|
1570
|
+
import("./flags-19-635PQOEQ.js")
|
|
1571
|
+
]).then((modules) => {
|
|
1572
|
+
const mergedFlags = Object.assign(
|
|
1573
|
+
{},
|
|
1574
|
+
...modules.map((module) => module.default)
|
|
1575
|
+
);
|
|
1576
|
+
countryFlags = mergedFlags;
|
|
1577
|
+
return mergedFlags;
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
return countryFlagsPromise;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
// src/components/countryFlag/CountryFlag.tsx
|
|
1584
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1585
|
+
function CountryFlag({
|
|
1586
|
+
cca2,
|
|
1587
|
+
src,
|
|
1588
|
+
alt = "",
|
|
1589
|
+
className,
|
|
1590
|
+
loading = "lazy"
|
|
1591
|
+
}) {
|
|
1592
|
+
const normalizedSrc = src?.trim() || "";
|
|
1593
|
+
const [loadedSrc, setLoadedSrc] = useState3(
|
|
1594
|
+
() => normalizedSrc || getLoadedCountryFlagUrl(cca2)
|
|
1595
|
+
);
|
|
1596
|
+
useEffect2(() => {
|
|
1597
|
+
const immediateSrc = normalizedSrc || getLoadedCountryFlagUrl(cca2);
|
|
1598
|
+
if (immediateSrc) {
|
|
1599
|
+
setLoadedSrc(immediateSrc);
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
setLoadedSrc("");
|
|
1603
|
+
let mounted = true;
|
|
1604
|
+
void loadCountryFlags().then(() => {
|
|
1605
|
+
if (mounted) setLoadedSrc(getLoadedCountryFlagUrl(cca2));
|
|
1606
|
+
});
|
|
1607
|
+
return () => {
|
|
1608
|
+
mounted = false;
|
|
1609
|
+
};
|
|
1610
|
+
}, [cca2, normalizedSrc]);
|
|
1611
|
+
if (!loadedSrc) {
|
|
1612
|
+
return /* @__PURE__ */ jsx5("span", { "aria-hidden": "true", className: "h-5 w-7 shrink-0 rounded-sm bg-surface-muted" });
|
|
1613
|
+
}
|
|
1614
|
+
return /* @__PURE__ */ jsx5(
|
|
1615
|
+
"img",
|
|
1616
|
+
{
|
|
1617
|
+
src: loadedSrc,
|
|
1618
|
+
alt,
|
|
1619
|
+
"aria-hidden": alt ? void 0 : true,
|
|
1620
|
+
className,
|
|
1621
|
+
loading,
|
|
1622
|
+
referrerPolicy: "no-referrer"
|
|
1623
|
+
}
|
|
1624
|
+
);
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
// src/components/inputPhone/InputPhone.tsx
|
|
1628
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1606
1629
|
var DEFAULT_BRAZIL_DDI = 55;
|
|
1607
1630
|
var DEFAULT_BRAZIL_CCA2 = "BR";
|
|
1608
1631
|
var phoneMasksByDdi = {
|
|
@@ -1617,21 +1640,20 @@ var phoneMasksByDdi = {
|
|
|
1617
1640
|
"351": "### ### ###"
|
|
1618
1641
|
};
|
|
1619
1642
|
function normalizeDigits(value) {
|
|
1620
|
-
return String(value
|
|
1643
|
+
return String(value ?? "").replace(/\D/g, "");
|
|
1621
1644
|
}
|
|
1622
1645
|
function normalizeSearchText(value) {
|
|
1623
1646
|
return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
1624
1647
|
}
|
|
1625
1648
|
function toPhoneValue(value) {
|
|
1626
1649
|
return {
|
|
1627
|
-
ddi: Number(normalizeDigits(value
|
|
1628
|
-
ddd: normalizeDigits(value
|
|
1629
|
-
numero: normalizeDigits(value
|
|
1650
|
+
ddi: Number(normalizeDigits(value?.ddi) || DEFAULT_BRAZIL_DDI),
|
|
1651
|
+
ddd: normalizeDigits(value?.ddd),
|
|
1652
|
+
numero: normalizeDigits(value?.numero)
|
|
1630
1653
|
};
|
|
1631
1654
|
}
|
|
1632
1655
|
function getMaskForDdi(ddi) {
|
|
1633
|
-
|
|
1634
|
-
return (_a = phoneMasksByDdi[normalizeDigits(ddi)]) != null ? _a : null;
|
|
1656
|
+
return phoneMasksByDdi[normalizeDigits(ddi)] ?? null;
|
|
1635
1657
|
}
|
|
1636
1658
|
function getAreaCodeLength(mask) {
|
|
1637
1659
|
if (!mask) return 0;
|
|
@@ -1653,8 +1675,7 @@ function splitNationalNumber(localNumber, mask) {
|
|
|
1653
1675
|
};
|
|
1654
1676
|
}
|
|
1655
1677
|
function getDialDigits(country) {
|
|
1656
|
-
|
|
1657
|
-
return normalizeDigits((_a = country == null ? void 0 : country.idd) == null ? void 0 : _a.display);
|
|
1678
|
+
return normalizeDigits(country?.idd?.display);
|
|
1658
1679
|
}
|
|
1659
1680
|
function getCountryByDdi(countries, ddi) {
|
|
1660
1681
|
const normalizedDdi = Number(normalizeDigits(ddi));
|
|
@@ -1704,18 +1725,20 @@ function parseStoredPhoneValue(rawValue, countries) {
|
|
|
1704
1725
|
localDigits2,
|
|
1705
1726
|
getMaskForDdi(Number(dialDigits2))
|
|
1706
1727
|
);
|
|
1707
|
-
return
|
|
1708
|
-
ddi: Number(dialDigits2)
|
|
1709
|
-
|
|
1728
|
+
return {
|
|
1729
|
+
ddi: Number(dialDigits2),
|
|
1730
|
+
...local2
|
|
1731
|
+
};
|
|
1710
1732
|
}
|
|
1711
1733
|
if (digits.length <= 11) {
|
|
1712
1734
|
const local2 = splitNationalNumber(
|
|
1713
1735
|
digits,
|
|
1714
1736
|
getMaskForDdi(DEFAULT_BRAZIL_DDI)
|
|
1715
1737
|
);
|
|
1716
|
-
return
|
|
1717
|
-
ddi: DEFAULT_BRAZIL_DDI
|
|
1718
|
-
|
|
1738
|
+
return {
|
|
1739
|
+
ddi: DEFAULT_BRAZIL_DDI,
|
|
1740
|
+
...local2
|
|
1741
|
+
};
|
|
1719
1742
|
}
|
|
1720
1743
|
const optionsByDialLength = getCountriesByDialLength(countries);
|
|
1721
1744
|
const matchedCountry = optionsByDialLength.find((country) => {
|
|
@@ -1727,9 +1750,10 @@ function parseStoredPhoneValue(rawValue, countries) {
|
|
|
1727
1750
|
digits,
|
|
1728
1751
|
getMaskForDdi(DEFAULT_BRAZIL_DDI)
|
|
1729
1752
|
);
|
|
1730
|
-
return
|
|
1731
|
-
ddi: DEFAULT_BRAZIL_DDI
|
|
1732
|
-
|
|
1753
|
+
return {
|
|
1754
|
+
ddi: DEFAULT_BRAZIL_DDI,
|
|
1755
|
+
...local2
|
|
1756
|
+
};
|
|
1733
1757
|
}
|
|
1734
1758
|
const dialDigits = getDialDigits(matchedCountry);
|
|
1735
1759
|
const localDigits = digits.slice(dialDigits.length);
|
|
@@ -1737,9 +1761,10 @@ function parseStoredPhoneValue(rawValue, countries) {
|
|
|
1737
1761
|
localDigits,
|
|
1738
1762
|
getMaskForDdi(Number(dialDigits))
|
|
1739
1763
|
);
|
|
1740
|
-
return
|
|
1741
|
-
ddi: Number(dialDigits)
|
|
1742
|
-
|
|
1764
|
+
return {
|
|
1765
|
+
ddi: Number(dialDigits),
|
|
1766
|
+
...local
|
|
1767
|
+
};
|
|
1743
1768
|
}
|
|
1744
1769
|
function buildPhonePayload(phoneValue) {
|
|
1745
1770
|
const normalized = toPhoneValue(phoneValue);
|
|
@@ -1756,22 +1781,13 @@ function parsePhonePayload(rawValue, countries = PHONE_COUNTRY_OPTIONS) {
|
|
|
1756
1781
|
return parseStoredPhoneValue(rawValue, countries);
|
|
1757
1782
|
}
|
|
1758
1783
|
function renderFlag(option) {
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
((_b = (_a = option == null ? void 0 : option.flags) == null ? void 0 : _a.svg) == null ? void 0 : _b.trim()) || getCountryFlagUrl(option == null ? void 0 : option.cca2)
|
|
1762
|
-
).trim();
|
|
1763
|
-
if (!svgSrc) {
|
|
1764
|
-
return /* @__PURE__ */ jsx5("span", { className: "h-5 w-7 shrink-0 rounded-sm bg-surface-muted" });
|
|
1765
|
-
}
|
|
1766
|
-
return /* @__PURE__ */ jsx5(
|
|
1767
|
-
"img",
|
|
1784
|
+
return /* @__PURE__ */ jsx6(
|
|
1785
|
+
CountryFlag,
|
|
1768
1786
|
{
|
|
1769
|
-
|
|
1787
|
+
cca2: option?.cca2,
|
|
1788
|
+
src: option?.flags?.svg,
|
|
1770
1789
|
alt: "",
|
|
1771
|
-
"
|
|
1772
|
-
className: "h-5 w-7 shrink-0 object-contain",
|
|
1773
|
-
loading: "lazy",
|
|
1774
|
-
referrerPolicy: "no-referrer"
|
|
1790
|
+
className: "h-5 w-7 shrink-0 object-contain"
|
|
1775
1791
|
}
|
|
1776
1792
|
);
|
|
1777
1793
|
}
|
|
@@ -1797,10 +1813,10 @@ function InputPhone({
|
|
|
1797
1813
|
const dropdownRef = useRef4(null);
|
|
1798
1814
|
const searchInputRef = useRef4(null);
|
|
1799
1815
|
const initializedRef = useRef4(false);
|
|
1800
|
-
const [open, setOpen] =
|
|
1801
|
-
const [selectedCountryCode, setSelectedCountryCode] =
|
|
1802
|
-
const [searchTerm, setSearchTerm] =
|
|
1803
|
-
const [dropdownPosition, setDropdownPosition] =
|
|
1816
|
+
const [open, setOpen] = useState4(false);
|
|
1817
|
+
const [selectedCountryCode, setSelectedCountryCode] = useState4();
|
|
1818
|
+
const [searchTerm, setSearchTerm] = useState4("");
|
|
1819
|
+
const [dropdownPosition, setDropdownPosition] = useState4(null);
|
|
1804
1820
|
const value = useMemo(() => toPhoneValue(field.value), [field.value]);
|
|
1805
1821
|
const selectedCountry = useMemo(
|
|
1806
1822
|
() => availableCountries.find((country) => country.cca2 === selectedCountryCode && Number(getDialDigits(country)) === value.ddi) || getCountryByDdi(availableCountries, value.ddi),
|
|
@@ -1848,7 +1864,7 @@ function InputPhone({
|
|
|
1848
1864
|
},
|
|
1849
1865
|
panel: {
|
|
1850
1866
|
width: 220,
|
|
1851
|
-
height: Math.min(
|
|
1867
|
+
height: Math.min(dropdown?.scrollHeight || 320, 320)
|
|
1852
1868
|
},
|
|
1853
1869
|
viewport: {
|
|
1854
1870
|
width: window.innerWidth,
|
|
@@ -1857,7 +1873,7 @@ function InputPhone({
|
|
|
1857
1873
|
});
|
|
1858
1874
|
setDropdownPosition(panelRect);
|
|
1859
1875
|
}, [open]);
|
|
1860
|
-
|
|
1876
|
+
useEffect3(() => {
|
|
1861
1877
|
if (!open) {
|
|
1862
1878
|
setSearchTerm("");
|
|
1863
1879
|
setDropdownPosition(null);
|
|
@@ -1865,16 +1881,15 @@ function InputPhone({
|
|
|
1865
1881
|
}
|
|
1866
1882
|
updateDropdownPosition();
|
|
1867
1883
|
}, [open, updateDropdownPosition]);
|
|
1868
|
-
|
|
1869
|
-
var _a;
|
|
1884
|
+
useEffect3(() => {
|
|
1870
1885
|
if (open && isDropdownPositioned) {
|
|
1871
|
-
|
|
1886
|
+
searchInputRef.current?.focus({ preventScroll: true });
|
|
1872
1887
|
}
|
|
1873
1888
|
}, [isDropdownPositioned, open]);
|
|
1874
|
-
|
|
1889
|
+
useEffect3(() => {
|
|
1875
1890
|
if (disabled) setOpen(false);
|
|
1876
1891
|
}, [disabled]);
|
|
1877
|
-
|
|
1892
|
+
useEffect3(() => {
|
|
1878
1893
|
if (!open) return;
|
|
1879
1894
|
const scheduleDropdownPosition = () => updateDropdownPosition();
|
|
1880
1895
|
window.addEventListener("resize", scheduleDropdownPosition);
|
|
@@ -1884,7 +1899,7 @@ function InputPhone({
|
|
|
1884
1899
|
window.removeEventListener("scroll", scheduleDropdownPosition, true);
|
|
1885
1900
|
};
|
|
1886
1901
|
}, [open, updateDropdownPosition]);
|
|
1887
|
-
|
|
1902
|
+
useEffect3(() => {
|
|
1888
1903
|
if (initializedRef.current || availableCountries.length === 0) return;
|
|
1889
1904
|
const parsed = parseStoredPhoneValue(
|
|
1890
1905
|
field.value,
|
|
@@ -1893,11 +1908,10 @@ function InputPhone({
|
|
|
1893
1908
|
helpers.setValue(parsed);
|
|
1894
1909
|
initializedRef.current = true;
|
|
1895
1910
|
}, [availableCountries, field.value, helpers]);
|
|
1896
|
-
|
|
1911
|
+
useEffect3(() => {
|
|
1897
1912
|
if (!open) return;
|
|
1898
1913
|
const handleClickOutside = (event) => {
|
|
1899
|
-
|
|
1900
|
-
if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(event.target)) && !((_b = dropdownRef.current) == null ? void 0 : _b.contains(event.target))) {
|
|
1914
|
+
if (!wrapperRef.current?.contains(event.target) && !dropdownRef.current?.contains(event.target)) {
|
|
1901
1915
|
setOpen(false);
|
|
1902
1916
|
helpers.setTouched(true);
|
|
1903
1917
|
}
|
|
@@ -1908,21 +1922,22 @@ function InputPhone({
|
|
|
1908
1922
|
};
|
|
1909
1923
|
}, [helpers, open]);
|
|
1910
1924
|
const setPhoneValue = (nextValue) => {
|
|
1911
|
-
|
|
1912
|
-
|
|
1925
|
+
helpers.setValue({
|
|
1926
|
+
...value,
|
|
1927
|
+
...nextValue,
|
|
1913
1928
|
ddi: Number(
|
|
1914
|
-
normalizeDigits(
|
|
1929
|
+
normalizeDigits(nextValue.ddi ?? value.ddi) || DEFAULT_BRAZIL_DDI
|
|
1915
1930
|
),
|
|
1916
|
-
ddd: normalizeDigits(
|
|
1917
|
-
numero: normalizeDigits(
|
|
1918
|
-
})
|
|
1931
|
+
ddd: normalizeDigits(nextValue.ddd ?? value.ddd),
|
|
1932
|
+
numero: normalizeDigits(nextValue.numero ?? value.numero)
|
|
1933
|
+
});
|
|
1919
1934
|
};
|
|
1920
1935
|
const dropdownLayerClass = getFloatingLayerClass(
|
|
1921
1936
|
countryButtonRef.current,
|
|
1922
1937
|
"popover"
|
|
1923
1938
|
);
|
|
1924
1939
|
const dropdownZClass = dropdownLayerClass === "z-popover" ? "z-menu" : dropdownLayerClass;
|
|
1925
|
-
return /* @__PURE__ */
|
|
1940
|
+
return /* @__PURE__ */ jsx6(
|
|
1926
1941
|
FieldFrame_default,
|
|
1927
1942
|
{
|
|
1928
1943
|
className,
|
|
@@ -1954,7 +1969,7 @@ function InputPhone({
|
|
|
1954
1969
|
{
|
|
1955
1970
|
ref: countryButtonRef,
|
|
1956
1971
|
type: "button",
|
|
1957
|
-
"aria-label": `Selecionar pa\xEDs de ${label || name}: ${
|
|
1972
|
+
"aria-label": `Selecionar pa\xEDs de ${label || name}: ${selectedCountry?.label || ""} ${selectedCountry?.idd.display || `+${value.ddi}`}`,
|
|
1958
1973
|
"aria-haspopup": "dialog",
|
|
1959
1974
|
"aria-expanded": open && !disabled,
|
|
1960
1975
|
"aria-controls": open && !disabled ? dropdownId : void 0,
|
|
@@ -1977,8 +1992,8 @@ function InputPhone({
|
|
|
1977
1992
|
),
|
|
1978
1993
|
children: [
|
|
1979
1994
|
renderFlag(selectedCountry),
|
|
1980
|
-
/* @__PURE__ */
|
|
1981
|
-
open ? /* @__PURE__ */
|
|
1995
|
+
/* @__PURE__ */ jsx6("span", { className: "text-sm", children: selectedCountry?.idd.display || `+${value.ddi}` }),
|
|
1996
|
+
open ? /* @__PURE__ */ jsx6(
|
|
1982
1997
|
MdOutlineKeyboardArrowUp2,
|
|
1983
1998
|
{
|
|
1984
1999
|
className: classNames5("h-4 w-4 shrink-0", {
|
|
@@ -1986,7 +2001,7 @@ function InputPhone({
|
|
|
1986
2001
|
"text-field-content": !hasError
|
|
1987
2002
|
})
|
|
1988
2003
|
}
|
|
1989
|
-
) : /* @__PURE__ */
|
|
2004
|
+
) : /* @__PURE__ */ jsx6(
|
|
1990
2005
|
MdOutlineKeyboardArrowDown2,
|
|
1991
2006
|
{
|
|
1992
2007
|
className: classNames5("h-4 w-4 shrink-0", {
|
|
@@ -1999,7 +2014,7 @@ function InputPhone({
|
|
|
1999
2014
|
]
|
|
2000
2015
|
}
|
|
2001
2016
|
),
|
|
2002
|
-
/* @__PURE__ */
|
|
2017
|
+
/* @__PURE__ */ jsx6("div", { className: "min-w-0 flex-1 pl-1 pr-3", children: phoneMask ? /* @__PURE__ */ jsx6(
|
|
2003
2018
|
PatternFormat2,
|
|
2004
2019
|
{
|
|
2005
2020
|
id: name,
|
|
@@ -2026,7 +2041,7 @@ function InputPhone({
|
|
|
2026
2041
|
});
|
|
2027
2042
|
}
|
|
2028
2043
|
}
|
|
2029
|
-
) : /* @__PURE__ */
|
|
2044
|
+
) : /* @__PURE__ */ jsx6(
|
|
2030
2045
|
"input",
|
|
2031
2046
|
{
|
|
2032
2047
|
id: name,
|
|
@@ -2056,23 +2071,22 @@ function InputPhone({
|
|
|
2056
2071
|
role: "dialog",
|
|
2057
2072
|
"aria-label": `Selecionar pa\xEDs de ${label || name}`,
|
|
2058
2073
|
onKeyDown: (event) => {
|
|
2059
|
-
var _a, _b, _c, _d;
|
|
2060
2074
|
if (event.key === "Escape" || event.key === "Tab") {
|
|
2061
2075
|
event.preventDefault();
|
|
2062
2076
|
setOpen(false);
|
|
2063
2077
|
helpers.setTouched(true);
|
|
2064
|
-
if (event.key === "Escape" || event.shiftKey)
|
|
2065
|
-
else
|
|
2078
|
+
if (event.key === "Escape" || event.shiftKey) countryButtonRef.current?.focus();
|
|
2079
|
+
else document.getElementById(name)?.focus();
|
|
2066
2080
|
return;
|
|
2067
2081
|
}
|
|
2068
2082
|
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
|
|
2069
2083
|
if (event.target === searchInputRef.current && ["Home", "End"].includes(event.key)) return;
|
|
2070
|
-
const options = Array.from(
|
|
2084
|
+
const options = Array.from(dropdownRef.current?.querySelectorAll("button") || []);
|
|
2071
2085
|
if (!options.length) return;
|
|
2072
2086
|
event.preventDefault();
|
|
2073
2087
|
const index = options.indexOf(document.activeElement);
|
|
2074
2088
|
const next = event.key === "Home" ? 0 : event.key === "End" ? options.length - 1 : event.key === "ArrowDown" ? (index + 1) % options.length : (index <= 0 ? options.length : index) - 1;
|
|
2075
|
-
|
|
2089
|
+
options[next]?.focus();
|
|
2076
2090
|
},
|
|
2077
2091
|
style: {
|
|
2078
2092
|
top: dropdownPosition.top,
|
|
@@ -2086,8 +2100,8 @@ function InputPhone({
|
|
|
2086
2100
|
),
|
|
2087
2101
|
children: [
|
|
2088
2102
|
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 border-b border-field-border-default bg-field-surface p-2", children: [
|
|
2089
|
-
/* @__PURE__ */
|
|
2090
|
-
/* @__PURE__ */
|
|
2103
|
+
/* @__PURE__ */ jsx6(MdSearch2, { className: "h-4 w-4 text-field-icon" }),
|
|
2104
|
+
/* @__PURE__ */ jsx6(
|
|
2091
2105
|
"input",
|
|
2092
2106
|
{
|
|
2093
2107
|
ref: searchInputRef,
|
|
@@ -2100,24 +2114,23 @@ function InputPhone({
|
|
|
2100
2114
|
}
|
|
2101
2115
|
)
|
|
2102
2116
|
] }),
|
|
2103
|
-
/* @__PURE__ */
|
|
2117
|
+
/* @__PURE__ */ jsx6("div", { className: "max-h-60 overflow-y-auto", children: filteredCountries.length === 0 ? /* @__PURE__ */ jsx6("div", { role: "status", className: "px-3 py-2 text-sm text-content-muted", children: "Nenhum DDI encontrado" }) : filteredCountries.map((country) => /* @__PURE__ */ jsxs5(
|
|
2104
2118
|
"button",
|
|
2105
2119
|
{
|
|
2106
2120
|
type: "button",
|
|
2107
|
-
"aria-pressed":
|
|
2121
|
+
"aria-pressed": selectedCountry?.cca2 === country.cca2,
|
|
2108
2122
|
onClick: () => {
|
|
2109
|
-
var _a;
|
|
2110
2123
|
setSelectedCountryCode(country.cca2);
|
|
2111
2124
|
setPhoneValue({ ddi: Number(getDialDigits(country)) });
|
|
2112
2125
|
helpers.setTouched(true);
|
|
2113
2126
|
setOpen(false);
|
|
2114
|
-
|
|
2127
|
+
countryButtonRef.current?.focus();
|
|
2115
2128
|
},
|
|
2116
2129
|
className: "flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface-muted focus-visible:bg-surface-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus-ring",
|
|
2117
2130
|
children: [
|
|
2118
2131
|
renderFlag(country),
|
|
2119
|
-
/* @__PURE__ */
|
|
2120
|
-
/* @__PURE__ */
|
|
2132
|
+
/* @__PURE__ */ jsx6("span", { className: "min-w-0 flex-1 truncate text-field-content", children: country.label }),
|
|
2133
|
+
/* @__PURE__ */ jsx6("span", { className: "shrink-0 text-content-muted", children: country.idd.display })
|
|
2121
2134
|
]
|
|
2122
2135
|
},
|
|
2123
2136
|
`${country.cca2}-${country.idd.display}`
|
|
@@ -2161,15 +2174,15 @@ import { ptBR } from "date-fns/locale/pt-BR";
|
|
|
2161
2174
|
import { FormikContext, getIn } from "formik";
|
|
2162
2175
|
import {
|
|
2163
2176
|
useContext,
|
|
2164
|
-
useEffect as
|
|
2177
|
+
useEffect as useEffect4,
|
|
2165
2178
|
useId as useId3,
|
|
2166
2179
|
useMemo as useMemo2,
|
|
2167
2180
|
useRef as useRef5,
|
|
2168
|
-
useState as
|
|
2181
|
+
useState as useState5
|
|
2169
2182
|
} from "react";
|
|
2170
2183
|
import { createPortal as createPortal3 } from "react-dom";
|
|
2171
2184
|
import { MdCalendarMonth, MdChevronLeft, MdChevronRight } from "react-icons/md";
|
|
2172
|
-
import { jsx as
|
|
2185
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2173
2186
|
var WEEKDAYS = ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"];
|
|
2174
2187
|
var CALENDAR_WIDTH = 256;
|
|
2175
2188
|
var VIEWPORT_MARGIN = 8;
|
|
@@ -2251,47 +2264,45 @@ var UnifiedDatePicker = ({
|
|
|
2251
2264
|
const formikError = hasFormikField && formik ? getIn(formik.errors, name) : void 0;
|
|
2252
2265
|
const isFieldDisabled = disabled || isDisabled;
|
|
2253
2266
|
const resolvedPlaceholder = selectionMode === "year" ? "aaaa" : placeholder;
|
|
2254
|
-
const [isOpen, setIsOpen] =
|
|
2255
|
-
const [isEditing, setIsEditing] =
|
|
2256
|
-
const [draftValue, setDraftValue] =
|
|
2267
|
+
const [isOpen, setIsOpen] = useState5(false);
|
|
2268
|
+
const [isEditing, setIsEditing] = useState5(false);
|
|
2269
|
+
const [draftValue, setDraftValue] = useState5(
|
|
2257
2270
|
formatDateForInput(selectedDate, selectionMode)
|
|
2258
2271
|
);
|
|
2259
|
-
const [viewDate, setViewDate] =
|
|
2260
|
-
const [mode, setMode] =
|
|
2261
|
-
const [inputError, setInputError] =
|
|
2272
|
+
const [viewDate, setViewDate] = useState5(getSafeViewDate(selectedDate));
|
|
2273
|
+
const [mode, setMode] = useState5(defaultView);
|
|
2274
|
+
const [inputError, setInputError] = useState5(null);
|
|
2262
2275
|
const containerRef = useRef5(null);
|
|
2263
2276
|
const inputRef = useRef5(null);
|
|
2264
2277
|
const dropdownRef = useRef5(null);
|
|
2265
2278
|
const calendarId = `date-picker-${useId3()}`;
|
|
2266
2279
|
const wasOpenRef = useRef5(false);
|
|
2267
2280
|
const rafRef = useRef5(null);
|
|
2268
|
-
const [isMounted, setIsMounted] =
|
|
2269
|
-
const [panelNeedsScroll, setPanelNeedsScroll] =
|
|
2270
|
-
const [dropdownStyle, setDropdownStyle] =
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
(_b = inputRef.current) == null ? void 0 : _b.focus();
|
|
2281
|
+
const [isMounted, setIsMounted] = useState5(false);
|
|
2282
|
+
const [panelNeedsScroll, setPanelNeedsScroll] = useState5(false);
|
|
2283
|
+
const [dropdownStyle, setDropdownStyle] = useState5({});
|
|
2284
|
+
useEffect4(() => {
|
|
2285
|
+
if (wasOpenRef.current && !isOpen && dropdownRef.current?.contains(document.activeElement)) {
|
|
2286
|
+
inputRef.current?.focus();
|
|
2275
2287
|
}
|
|
2276
2288
|
wasOpenRef.current = isOpen;
|
|
2277
2289
|
}, [isOpen]);
|
|
2278
|
-
|
|
2290
|
+
useEffect4(() => {
|
|
2279
2291
|
setIsMounted(true);
|
|
2280
2292
|
}, []);
|
|
2281
|
-
|
|
2293
|
+
useEffect4(() => {
|
|
2282
2294
|
if (!isEditing) {
|
|
2283
2295
|
setDraftValue(formatDateForInput(selectedDate, selectionMode));
|
|
2284
2296
|
}
|
|
2285
2297
|
setViewDate(getSafeViewDate(selectedDate));
|
|
2286
2298
|
}, [isEditing, selectedDate, selectionMode]);
|
|
2287
|
-
|
|
2299
|
+
useEffect4(() => {
|
|
2288
2300
|
if (!isOpen) return;
|
|
2289
2301
|
setMode(
|
|
2290
2302
|
selectionMode === "year" ? "years" : selectionMode === "month" ? "months" : navigationVariant === "dropdown" ? "days" : defaultView
|
|
2291
2303
|
);
|
|
2292
2304
|
const onMouseDown = (event) => {
|
|
2293
|
-
|
|
2294
|
-
if (!((_a = containerRef.current) == null ? void 0 : _a.contains(event.target)) && !((_b = dropdownRef.current) == null ? void 0 : _b.contains(event.target))) {
|
|
2305
|
+
if (!containerRef.current?.contains(event.target) && !dropdownRef.current?.contains(event.target)) {
|
|
2295
2306
|
setIsOpen(false);
|
|
2296
2307
|
}
|
|
2297
2308
|
};
|
|
@@ -2305,19 +2316,18 @@ var UnifiedDatePicker = ({
|
|
|
2305
2316
|
document.removeEventListener("keydown", onKeyDown);
|
|
2306
2317
|
};
|
|
2307
2318
|
}, [defaultView, isOpen, navigationVariant, selectionMode]);
|
|
2308
|
-
|
|
2319
|
+
useEffect4(() => {
|
|
2309
2320
|
if (!isOpen) return;
|
|
2310
2321
|
const updateDropdownPosition = () => {
|
|
2311
|
-
var _a;
|
|
2312
2322
|
if (!containerRef.current) return;
|
|
2313
|
-
const rect = (
|
|
2323
|
+
const rect = (inputRef.current ?? containerRef.current).getBoundingClientRect();
|
|
2314
2324
|
const isOutOfViewport = rect.bottom <= 0 || rect.top >= window.innerHeight || rect.right <= 0 || rect.left >= window.innerWidth;
|
|
2315
2325
|
if (isOutOfViewport) {
|
|
2316
2326
|
setIsOpen(false);
|
|
2317
2327
|
return;
|
|
2318
2328
|
}
|
|
2319
2329
|
const dropdown = dropdownRef.current;
|
|
2320
|
-
const panelHeight =
|
|
2330
|
+
const panelHeight = dropdown?.scrollHeight || 320;
|
|
2321
2331
|
const panelRect = calculateFloatingPanelRect({
|
|
2322
2332
|
trigger: rect,
|
|
2323
2333
|
panel: {
|
|
@@ -2364,7 +2374,7 @@ var UnifiedDatePicker = ({
|
|
|
2364
2374
|
if (hasFormikField && formik) {
|
|
2365
2375
|
formik.setFieldValue(name, nextDate);
|
|
2366
2376
|
}
|
|
2367
|
-
onChange
|
|
2377
|
+
onChange?.(nextDate);
|
|
2368
2378
|
};
|
|
2369
2379
|
const touchField = () => {
|
|
2370
2380
|
if (hasFormikField && formik) {
|
|
@@ -2372,15 +2382,13 @@ var UnifiedDatePicker = ({
|
|
|
2372
2382
|
}
|
|
2373
2383
|
};
|
|
2374
2384
|
const openCalendar = () => {
|
|
2375
|
-
var _a;
|
|
2376
2385
|
if (isFieldDisabled) return;
|
|
2377
2386
|
setIsOpen(true);
|
|
2378
|
-
|
|
2387
|
+
inputRef.current?.focus();
|
|
2379
2388
|
};
|
|
2380
2389
|
const closeCalendar = () => {
|
|
2381
|
-
var _a;
|
|
2382
2390
|
setIsOpen(false);
|
|
2383
|
-
|
|
2391
|
+
inputRef.current?.focus();
|
|
2384
2392
|
};
|
|
2385
2393
|
const getDaysInView = () => {
|
|
2386
2394
|
const start = startOfWeek(startOfMonth(viewDate), { weekStartsOn: 0 });
|
|
@@ -2460,7 +2468,6 @@ var UnifiedDatePicker = ({
|
|
|
2460
2468
|
});
|
|
2461
2469
|
};
|
|
2462
2470
|
const moveCalendarFocus = (event, columns) => {
|
|
2463
|
-
var _a, _b;
|
|
2464
2471
|
const movement = {
|
|
2465
2472
|
ArrowLeft: -1,
|
|
2466
2473
|
ArrowRight: 1,
|
|
@@ -2468,9 +2475,9 @@ var UnifiedDatePicker = ({
|
|
|
2468
2475
|
ArrowDown: columns
|
|
2469
2476
|
};
|
|
2470
2477
|
const buttons = Array.from(
|
|
2471
|
-
|
|
2478
|
+
dropdownRef.current?.querySelectorAll(
|
|
2472
2479
|
'[data-calendar-option="true"]:not(:disabled)'
|
|
2473
|
-
)
|
|
2480
|
+
) ?? []
|
|
2474
2481
|
);
|
|
2475
2482
|
const currentIndex = buttons.indexOf(event.currentTarget);
|
|
2476
2483
|
if (currentIndex < 0) return;
|
|
@@ -2587,13 +2594,13 @@ var UnifiedDatePicker = ({
|
|
|
2587
2594
|
className
|
|
2588
2595
|
),
|
|
2589
2596
|
children: [
|
|
2590
|
-
/* @__PURE__ */
|
|
2597
|
+
/* @__PURE__ */ jsx7(
|
|
2591
2598
|
"input",
|
|
2592
2599
|
{
|
|
2593
2600
|
ref: inputRef,
|
|
2594
2601
|
id: name,
|
|
2595
2602
|
name,
|
|
2596
|
-
"aria-label": ariaLabel
|
|
2603
|
+
"aria-label": ariaLabel ?? (!label ? "Data" : void 0),
|
|
2597
2604
|
role: "combobox",
|
|
2598
2605
|
"aria-invalid": hasError || void 0,
|
|
2599
2606
|
"aria-describedby": mergeAriaDescribedBy(
|
|
@@ -2629,7 +2636,7 @@ var UnifiedDatePicker = ({
|
|
|
2629
2636
|
onBlur: (event) => {
|
|
2630
2637
|
setIsEditing(false);
|
|
2631
2638
|
commitDraftValue(event.target.value);
|
|
2632
|
-
onBlur
|
|
2639
|
+
onBlur?.(event);
|
|
2633
2640
|
},
|
|
2634
2641
|
onKeyDown: (event) => {
|
|
2635
2642
|
if (event.key === "Enter") {
|
|
@@ -2640,7 +2647,7 @@ var UnifiedDatePicker = ({
|
|
|
2640
2647
|
className: FIELD_INPUT_CLASS
|
|
2641
2648
|
}
|
|
2642
2649
|
),
|
|
2643
|
-
/* @__PURE__ */
|
|
2650
|
+
/* @__PURE__ */ jsx7(
|
|
2644
2651
|
"button",
|
|
2645
2652
|
{
|
|
2646
2653
|
type: "button",
|
|
@@ -2648,7 +2655,7 @@ var UnifiedDatePicker = ({
|
|
|
2648
2655
|
onClick: openCalendar,
|
|
2649
2656
|
className: "flex items-center justify-center disabled:cursor-not-allowed",
|
|
2650
2657
|
"aria-label": "Abrir calendario",
|
|
2651
|
-
children: /* @__PURE__ */
|
|
2658
|
+
children: /* @__PURE__ */ jsx7(
|
|
2652
2659
|
MdCalendarMonth,
|
|
2653
2660
|
{
|
|
2654
2661
|
className: classNames6("h-5 w-5", {
|
|
@@ -2678,7 +2685,7 @@ var UnifiedDatePicker = ({
|
|
|
2678
2685
|
),
|
|
2679
2686
|
children: [
|
|
2680
2687
|
/* @__PURE__ */ jsxs6("div", { className: "mb-1 flex items-center justify-between px-1", children: [
|
|
2681
|
-
/* @__PURE__ */
|
|
2688
|
+
/* @__PURE__ */ jsx7(
|
|
2682
2689
|
"button",
|
|
2683
2690
|
{
|
|
2684
2691
|
type: "button",
|
|
@@ -2694,18 +2701,18 @@ var UnifiedDatePicker = ({
|
|
|
2694
2701
|
return nextDate;
|
|
2695
2702
|
}),
|
|
2696
2703
|
className: "rounded-sm p-1 text-primary-1 transition-colors hover:bg-primary-1/10 disabled:cursor-not-allowed disabled:text-content-disabled",
|
|
2697
|
-
children: /* @__PURE__ */
|
|
2704
|
+
children: /* @__PURE__ */ jsx7(MdChevronLeft, { "aria-hidden": "true", className: "h-5 w-5" })
|
|
2698
2705
|
}
|
|
2699
2706
|
),
|
|
2700
2707
|
navigationVariant === "dropdown" ? /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-[6px]", children: [
|
|
2701
|
-
/* @__PURE__ */
|
|
2708
|
+
/* @__PURE__ */ jsx7(
|
|
2702
2709
|
"select",
|
|
2703
2710
|
{
|
|
2704
2711
|
"aria-label": "Selecionar m\xEAs do calend\xE1rio",
|
|
2705
2712
|
value: viewDate.getMonth(),
|
|
2706
2713
|
onChange: (event) => handleMonthChange(Number(event.target.value)),
|
|
2707
2714
|
className: "h-6 w-24 rounded-sm border-2 border-border-default bg-field-surface px-0.5 text-xs leading-3 text-field-content focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring",
|
|
2708
|
-
children: MONTHS.map((month, monthIndex) => /* @__PURE__ */
|
|
2715
|
+
children: MONTHS.map((month, monthIndex) => /* @__PURE__ */ jsx7(
|
|
2709
2716
|
"option",
|
|
2710
2717
|
{
|
|
2711
2718
|
value: monthIndex,
|
|
@@ -2716,17 +2723,17 @@ var UnifiedDatePicker = ({
|
|
|
2716
2723
|
))
|
|
2717
2724
|
}
|
|
2718
2725
|
),
|
|
2719
|
-
/* @__PURE__ */
|
|
2726
|
+
/* @__PURE__ */ jsx7(
|
|
2720
2727
|
"select",
|
|
2721
2728
|
{
|
|
2722
2729
|
"aria-label": "Selecionar ano do calend\xE1rio",
|
|
2723
2730
|
value: viewDate.getFullYear(),
|
|
2724
2731
|
onChange: (event) => handleYearChange(Number(event.target.value)),
|
|
2725
2732
|
className: "h-6 w-[58px] rounded-sm border-2 border-border-default bg-field-surface px-0.5 text-xs leading-3 text-field-content focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring",
|
|
2726
|
-
children: selectableYears.map((year) => /* @__PURE__ */
|
|
2733
|
+
children: selectableYears.map((year) => /* @__PURE__ */ jsx7("option", { value: year, children: year }, year))
|
|
2727
2734
|
}
|
|
2728
2735
|
)
|
|
2729
|
-
] }) : /* @__PURE__ */
|
|
2736
|
+
] }) : /* @__PURE__ */ jsx7(
|
|
2730
2737
|
"button",
|
|
2731
2738
|
{
|
|
2732
2739
|
type: "button",
|
|
@@ -2737,7 +2744,7 @@ var UnifiedDatePicker = ({
|
|
|
2737
2744
|
children: headerLabel
|
|
2738
2745
|
}
|
|
2739
2746
|
),
|
|
2740
|
-
/* @__PURE__ */
|
|
2747
|
+
/* @__PURE__ */ jsx7(
|
|
2741
2748
|
"button",
|
|
2742
2749
|
{
|
|
2743
2750
|
type: "button",
|
|
@@ -2753,12 +2760,12 @@ var UnifiedDatePicker = ({
|
|
|
2753
2760
|
return nextDate;
|
|
2754
2761
|
}),
|
|
2755
2762
|
className: "rounded-sm p-1 text-primary-1 transition-colors hover:bg-primary-1/10 disabled:cursor-not-allowed disabled:text-content-disabled",
|
|
2756
|
-
children: /* @__PURE__ */
|
|
2763
|
+
children: /* @__PURE__ */ jsx7(MdChevronRight, { "aria-hidden": "true", className: "h-5 w-5" })
|
|
2757
2764
|
}
|
|
2758
2765
|
)
|
|
2759
2766
|
] }),
|
|
2760
2767
|
mode === "days" && /* @__PURE__ */ jsxs6("div", { className: "px-3", children: [
|
|
2761
|
-
/* @__PURE__ */
|
|
2768
|
+
/* @__PURE__ */ jsx7("div", { className: "grid grid-cols-7 gap-x-1", role: "row", children: WEEKDAYS.map((weekday) => /* @__PURE__ */ jsx7(
|
|
2762
2769
|
"div",
|
|
2763
2770
|
{
|
|
2764
2771
|
role: "columnheader",
|
|
@@ -2767,7 +2774,7 @@ var UnifiedDatePicker = ({
|
|
|
2767
2774
|
},
|
|
2768
2775
|
weekday
|
|
2769
2776
|
)) }),
|
|
2770
|
-
/* @__PURE__ */
|
|
2777
|
+
/* @__PURE__ */ jsx7(
|
|
2771
2778
|
"div",
|
|
2772
2779
|
{
|
|
2773
2780
|
className: "grid grid-cols-7 gap-x-1",
|
|
@@ -2779,7 +2786,7 @@ var UnifiedDatePicker = ({
|
|
|
2779
2786
|
const inMonth = isSameMonth(day, viewDate);
|
|
2780
2787
|
const dayDisabled = isBefore(day, startOfDay(minDate)) || isAfter(day, startOfDay(maxDate));
|
|
2781
2788
|
if (!showAdjacentDays && !inMonth) {
|
|
2782
|
-
return /* @__PURE__ */
|
|
2789
|
+
return /* @__PURE__ */ jsx7(
|
|
2783
2790
|
"span",
|
|
2784
2791
|
{
|
|
2785
2792
|
"aria-hidden": "true",
|
|
@@ -2788,7 +2795,7 @@ var UnifiedDatePicker = ({
|
|
|
2788
2795
|
`${day.toISOString()}-${index}`
|
|
2789
2796
|
);
|
|
2790
2797
|
}
|
|
2791
|
-
return /* @__PURE__ */
|
|
2798
|
+
return /* @__PURE__ */ jsx7(
|
|
2792
2799
|
"button",
|
|
2793
2800
|
{
|
|
2794
2801
|
type: "button",
|
|
@@ -2806,7 +2813,7 @@ var UnifiedDatePicker = ({
|
|
|
2806
2813
|
"cursor-pointer": !dayDisabled
|
|
2807
2814
|
}
|
|
2808
2815
|
),
|
|
2809
|
-
children: /* @__PURE__ */
|
|
2816
|
+
children: /* @__PURE__ */ jsx7(
|
|
2810
2817
|
"span",
|
|
2811
2818
|
{
|
|
2812
2819
|
className: classNames6(
|
|
@@ -2828,7 +2835,7 @@ var UnifiedDatePicker = ({
|
|
|
2828
2835
|
}
|
|
2829
2836
|
)
|
|
2830
2837
|
] }),
|
|
2831
|
-
mode === "months" && /* @__PURE__ */
|
|
2838
|
+
mode === "months" && /* @__PURE__ */ jsx7(
|
|
2832
2839
|
"div",
|
|
2833
2840
|
{
|
|
2834
2841
|
className: "grid grid-cols-3 gap-1 px-3",
|
|
@@ -2838,7 +2845,7 @@ var UnifiedDatePicker = ({
|
|
|
2838
2845
|
const selected = index === viewDate.getMonth();
|
|
2839
2846
|
const monthDate = new Date(viewDate.getFullYear(), index, 1);
|
|
2840
2847
|
const monthDisabled = isBefore(endOfMonth(monthDate), startOfDay(minDate)) || isAfter(startOfMonth(monthDate), startOfDay(maxDate));
|
|
2841
|
-
return /* @__PURE__ */
|
|
2848
|
+
return /* @__PURE__ */ jsx7(
|
|
2842
2849
|
"button",
|
|
2843
2850
|
{
|
|
2844
2851
|
type: "button",
|
|
@@ -2861,7 +2868,7 @@ var UnifiedDatePicker = ({
|
|
|
2861
2868
|
})
|
|
2862
2869
|
}
|
|
2863
2870
|
),
|
|
2864
|
-
mode === "years" && /* @__PURE__ */
|
|
2871
|
+
mode === "years" && /* @__PURE__ */ jsx7(
|
|
2865
2872
|
"div",
|
|
2866
2873
|
{
|
|
2867
2874
|
className: "grid grid-cols-3 gap-1 px-3",
|
|
@@ -2870,7 +2877,7 @@ var UnifiedDatePicker = ({
|
|
|
2870
2877
|
children: years.map((year) => {
|
|
2871
2878
|
const selected = year === viewDate.getFullYear();
|
|
2872
2879
|
const yearDisabled = year < minYear || year > maxYear;
|
|
2873
|
-
return /* @__PURE__ */
|
|
2880
|
+
return /* @__PURE__ */ jsx7(
|
|
2874
2881
|
"button",
|
|
2875
2882
|
{
|
|
2876
2883
|
type: "button",
|
|
@@ -2912,16 +2919,16 @@ var datePicker_default = DatePicker;
|
|
|
2912
2919
|
// src/components/selectMulti/SelectMultiView.tsx
|
|
2913
2920
|
import cs from "classnames";
|
|
2914
2921
|
import {
|
|
2915
|
-
useEffect as
|
|
2922
|
+
useEffect as useEffect5,
|
|
2916
2923
|
useId as useId4,
|
|
2917
2924
|
useRef as useRef6,
|
|
2918
|
-
useState as
|
|
2925
|
+
useState as useState6
|
|
2919
2926
|
} from "react";
|
|
2920
2927
|
import { MdClose, MdKeyboardArrowDown } from "react-icons/md";
|
|
2921
|
-
import { jsx as
|
|
2928
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2922
2929
|
function SelectMultiView(props) {
|
|
2923
2930
|
const { options, error, label, checkedList = [], onClear, disabled } = props;
|
|
2924
|
-
const [isOpened, setIsOpened] =
|
|
2931
|
+
const [isOpened, setIsOpened] = useState6(false);
|
|
2925
2932
|
const containerRef = useRef6(null);
|
|
2926
2933
|
const triggerRef = useRef6(null);
|
|
2927
2934
|
const groupRef = useRef6(null);
|
|
@@ -2940,19 +2947,16 @@ function SelectMultiView(props) {
|
|
|
2940
2947
|
);
|
|
2941
2948
|
const menuLayerClass = floatingLayerClass === "z-popover" ? "z-menu" : floatingLayerClass;
|
|
2942
2949
|
const closeAndFocusTrigger = () => {
|
|
2943
|
-
var _a;
|
|
2944
2950
|
setIsOpened(false);
|
|
2945
|
-
|
|
2951
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
2946
2952
|
};
|
|
2947
|
-
|
|
2948
|
-
var _a, _b;
|
|
2953
|
+
useEffect5(() => {
|
|
2949
2954
|
if (!isOpened) return;
|
|
2950
|
-
|
|
2955
|
+
groupRef.current?.querySelector('input[type="checkbox"]')?.focus({ preventScroll: true });
|
|
2951
2956
|
}, [isOpened]);
|
|
2952
|
-
|
|
2957
|
+
useEffect5(() => {
|
|
2953
2958
|
function handleClickOutside(event) {
|
|
2954
|
-
|
|
2955
|
-
if (!((_a = containerRef.current) == null ? void 0 : _a.contains(event.target))) {
|
|
2959
|
+
if (!containerRef.current?.contains(event.target)) {
|
|
2956
2960
|
setIsOpened(false);
|
|
2957
2961
|
}
|
|
2958
2962
|
}
|
|
@@ -2963,15 +2967,14 @@ function SelectMultiView(props) {
|
|
|
2963
2967
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
2964
2968
|
};
|
|
2965
2969
|
}, [isOpened]);
|
|
2966
|
-
|
|
2970
|
+
useEffect5(() => {
|
|
2967
2971
|
if (disabled) setIsOpened(false);
|
|
2968
2972
|
}, [disabled]);
|
|
2969
2973
|
const handleOptionKeyDown = (event) => {
|
|
2970
|
-
var _a, _b, _c, _d, _e;
|
|
2971
2974
|
const checkboxes = Array.from(
|
|
2972
|
-
|
|
2975
|
+
groupRef.current?.querySelectorAll(
|
|
2973
2976
|
'input[type="checkbox"]:not([disabled])'
|
|
2974
|
-
)
|
|
2977
|
+
) ?? []
|
|
2975
2978
|
);
|
|
2976
2979
|
const currentIndex = checkboxes.indexOf(event.currentTarget);
|
|
2977
2980
|
if (event.key === "Escape") {
|
|
@@ -2989,18 +2992,18 @@ function SelectMultiView(props) {
|
|
|
2989
2992
|
}
|
|
2990
2993
|
event.preventDefault();
|
|
2991
2994
|
if (event.key === "Home") {
|
|
2992
|
-
|
|
2995
|
+
checkboxes[0]?.focus({ preventScroll: true });
|
|
2993
2996
|
return;
|
|
2994
2997
|
}
|
|
2995
2998
|
if (event.key === "End") {
|
|
2996
|
-
|
|
2999
|
+
checkboxes[checkboxes.length - 1]?.focus({ preventScroll: true });
|
|
2997
3000
|
return;
|
|
2998
3001
|
}
|
|
2999
3002
|
const direction = event.key === "ArrowDown" ? 1 : -1;
|
|
3000
3003
|
const nextIndex = (currentIndex + direction + checkboxes.length) % checkboxes.length;
|
|
3001
|
-
|
|
3004
|
+
checkboxes[nextIndex]?.focus({ preventScroll: true });
|
|
3002
3005
|
};
|
|
3003
|
-
return /* @__PURE__ */
|
|
3006
|
+
return /* @__PURE__ */ jsx8(
|
|
3004
3007
|
FieldFrame_default,
|
|
3005
3008
|
{
|
|
3006
3009
|
ref: containerRef,
|
|
@@ -3049,7 +3052,7 @@ function SelectMultiView(props) {
|
|
|
3049
3052
|
disabled && "cursor-not-allowed border-field-border-default bg-field-surface-disabled text-field-content-disabled"
|
|
3050
3053
|
),
|
|
3051
3054
|
children: [
|
|
3052
|
-
/* @__PURE__ */
|
|
3055
|
+
/* @__PURE__ */ jsx8(
|
|
3053
3056
|
"span",
|
|
3054
3057
|
{
|
|
3055
3058
|
className: cs(
|
|
@@ -3062,7 +3065,7 @@ function SelectMultiView(props) {
|
|
|
3062
3065
|
children: "Selecione"
|
|
3063
3066
|
}
|
|
3064
3067
|
),
|
|
3065
|
-
/* @__PURE__ */
|
|
3068
|
+
/* @__PURE__ */ jsx8(
|
|
3066
3069
|
MdKeyboardArrowDown,
|
|
3067
3070
|
{
|
|
3068
3071
|
"aria-hidden": "true",
|
|
@@ -3080,8 +3083,8 @@ function SelectMultiView(props) {
|
|
|
3080
3083
|
]
|
|
3081
3084
|
}
|
|
3082
3085
|
),
|
|
3083
|
-
/* @__PURE__ */
|
|
3084
|
-
isOpened && /* @__PURE__ */
|
|
3086
|
+
/* @__PURE__ */ jsx8("span", { id: summaryId, className: "sr-only", children: selectedSummary }),
|
|
3087
|
+
isOpened && /* @__PURE__ */ jsx8(
|
|
3085
3088
|
"div",
|
|
3086
3089
|
{
|
|
3087
3090
|
id: groupId,
|
|
@@ -3106,7 +3109,7 @@ function SelectMultiView(props) {
|
|
|
3106
3109
|
disabled && "cursor-not-allowed"
|
|
3107
3110
|
),
|
|
3108
3111
|
children: [
|
|
3109
|
-
/* @__PURE__ */
|
|
3112
|
+
/* @__PURE__ */ jsx8(
|
|
3110
3113
|
"input",
|
|
3111
3114
|
{
|
|
3112
3115
|
id: `${baseId}-option-${index}`,
|
|
@@ -3122,7 +3125,7 @@ function SelectMultiView(props) {
|
|
|
3122
3125
|
disabled
|
|
3123
3126
|
}
|
|
3124
3127
|
),
|
|
3125
|
-
/* @__PURE__ */
|
|
3128
|
+
/* @__PURE__ */ jsx8("span", { "aria-hidden": "true", className: "checkbox-control-proxy" }),
|
|
3126
3129
|
option.label
|
|
3127
3130
|
]
|
|
3128
3131
|
},
|
|
@@ -3135,13 +3138,13 @@ function SelectMultiView(props) {
|
|
|
3135
3138
|
"button",
|
|
3136
3139
|
{
|
|
3137
3140
|
type: "button",
|
|
3138
|
-
"aria-label": `Limpar sele\xE7\xE3o de ${label
|
|
3141
|
+
"aria-label": `Limpar sele\xE7\xE3o de ${label ?? "op\xE7\xF5es"}`,
|
|
3139
3142
|
disabled,
|
|
3140
3143
|
onClick: onClear,
|
|
3141
3144
|
className: "absolute right-9 top-1/2 flex min-h-6 min-w-6 -translate-y-1/2 touch-manipulation items-center justify-center gap-1 rounded-full bg-action-primary px-2 text-xs text-action-primary-content focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring disabled:cursor-not-allowed",
|
|
3142
3145
|
children: [
|
|
3143
|
-
/* @__PURE__ */
|
|
3144
|
-
/* @__PURE__ */
|
|
3146
|
+
/* @__PURE__ */ jsx8("span", { "aria-hidden": "true", children: selectedCount }),
|
|
3147
|
+
/* @__PURE__ */ jsx8(MdClose, { "aria-hidden": "true", size: 10 })
|
|
3145
3148
|
]
|
|
3146
3149
|
}
|
|
3147
3150
|
)
|
|
@@ -3154,48 +3157,34 @@ function SelectMultiView(props) {
|
|
|
3154
3157
|
var SelectMultiView_default = SelectMultiView;
|
|
3155
3158
|
|
|
3156
3159
|
// src/components/selectMulti/SelectMulti.tsx
|
|
3157
|
-
import { jsx as
|
|
3160
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
3158
3161
|
function SelectMulti(props) {
|
|
3159
|
-
return /* @__PURE__ */
|
|
3162
|
+
return /* @__PURE__ */ jsx9(
|
|
3160
3163
|
SelectMultiView_default,
|
|
3161
|
-
|
|
3164
|
+
{
|
|
3165
|
+
...props,
|
|
3162
3166
|
checkedList: props.value,
|
|
3163
3167
|
onClear: props.onReset
|
|
3164
|
-
}
|
|
3168
|
+
}
|
|
3165
3169
|
);
|
|
3166
3170
|
}
|
|
3167
3171
|
var MultiSelect = SelectMulti;
|
|
3168
3172
|
var SelectMulti_default = SelectMulti;
|
|
3169
3173
|
|
|
3170
3174
|
// src/components/selectCountry/SelectCountry.tsx
|
|
3171
|
-
import { jsx as
|
|
3175
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3172
3176
|
function renderFlag2(option) {
|
|
3173
|
-
|
|
3174
|
-
const svgSrc = String(
|
|
3175
|
-
((_b = (_a = option.flags) == null ? void 0 : _a.svg) == null ? void 0 : _b.trim()) || getCountryFlagUrl(option.cca2)
|
|
3176
|
-
).trim();
|
|
3177
|
-
if (!svgSrc) {
|
|
3178
|
-
return /* @__PURE__ */ jsx9(
|
|
3179
|
-
"span",
|
|
3180
|
-
{
|
|
3181
|
-
"aria-hidden": "true",
|
|
3182
|
-
className: "h-5 w-7 shrink-0 rounded-sm bg-surface-muted"
|
|
3183
|
-
}
|
|
3184
|
-
);
|
|
3185
|
-
}
|
|
3186
|
-
return /* @__PURE__ */ jsx9(
|
|
3177
|
+
return /* @__PURE__ */ jsx10(
|
|
3187
3178
|
"span",
|
|
3188
3179
|
{
|
|
3189
3180
|
"aria-hidden": "true",
|
|
3190
3181
|
className: "flex h-5 w-7 shrink-0 items-center justify-center",
|
|
3191
|
-
children: /* @__PURE__ */
|
|
3192
|
-
|
|
3182
|
+
children: /* @__PURE__ */ jsx10(
|
|
3183
|
+
CountryFlag,
|
|
3193
3184
|
{
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
className: "h-full w-full object-contain"
|
|
3197
|
-
loading: "lazy",
|
|
3198
|
-
referrerPolicy: "no-referrer"
|
|
3185
|
+
cca2: option.cca2,
|
|
3186
|
+
src: option.flags?.svg,
|
|
3187
|
+
className: "h-full w-full object-contain"
|
|
3199
3188
|
}
|
|
3200
3189
|
)
|
|
3201
3190
|
}
|
|
@@ -3203,40 +3192,32 @@ function renderFlag2(option) {
|
|
|
3203
3192
|
}
|
|
3204
3193
|
function renderCountryContent(option, placeholder) {
|
|
3205
3194
|
if (!option) {
|
|
3206
|
-
return /* @__PURE__ */
|
|
3195
|
+
return /* @__PURE__ */ jsx10("span", { className: "block w-full truncate overflow-hidden text-content-muted", children: placeholder });
|
|
3207
3196
|
}
|
|
3208
3197
|
return /* @__PURE__ */ jsxs8("span", { className: "flex w-full min-w-0 items-center gap-2", children: [
|
|
3209
3198
|
renderFlag2(option),
|
|
3210
|
-
/* @__PURE__ */
|
|
3199
|
+
/* @__PURE__ */ jsx10("span", { className: "block truncate overflow-hidden", children: option.label })
|
|
3211
3200
|
] });
|
|
3212
3201
|
}
|
|
3213
|
-
function SelectCountry(
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
"options",
|
|
3225
|
-
"countryList",
|
|
3226
|
-
"searchable",
|
|
3227
|
-
"searchPlaceholder",
|
|
3228
|
-
"noOptionsText",
|
|
3229
|
-
"defaultValue",
|
|
3230
|
-
"onChange",
|
|
3231
|
-
"className"
|
|
3232
|
-
]);
|
|
3202
|
+
function SelectCountry({
|
|
3203
|
+
options,
|
|
3204
|
+
countryList,
|
|
3205
|
+
searchable = true,
|
|
3206
|
+
searchPlaceholder = "Busque um pa\xEDs",
|
|
3207
|
+
noOptionsText = "Nenhum pa\xEDs encontrado",
|
|
3208
|
+
defaultValue,
|
|
3209
|
+
onChange,
|
|
3210
|
+
className,
|
|
3211
|
+
...props
|
|
3212
|
+
}) {
|
|
3233
3213
|
const availableOptions = filterCountryOptions(
|
|
3234
3214
|
options || COUNTRY_OPTIONS,
|
|
3235
3215
|
countryList
|
|
3236
3216
|
);
|
|
3237
|
-
return /* @__PURE__ */
|
|
3217
|
+
return /* @__PURE__ */ jsx10(
|
|
3238
3218
|
InputSelect_default,
|
|
3239
|
-
|
|
3219
|
+
{
|
|
3220
|
+
...props,
|
|
3240
3221
|
className,
|
|
3241
3222
|
defaultValue,
|
|
3242
3223
|
onChange,
|
|
@@ -3246,7 +3227,7 @@ function SelectCountry(_a) {
|
|
|
3246
3227
|
noOptionsText,
|
|
3247
3228
|
renderOption: (option) => renderCountryContent(option),
|
|
3248
3229
|
renderValue: (option, placeholder) => renderCountryContent(option, placeholder)
|
|
3249
|
-
}
|
|
3230
|
+
}
|
|
3250
3231
|
);
|
|
3251
3232
|
}
|
|
3252
3233
|
var CountrySelect = SelectCountry;
|
|
@@ -3255,53 +3236,49 @@ var SelectCountry_default = SelectCountry;
|
|
|
3255
3236
|
// src/components/radio-group/radio-group.tsx
|
|
3256
3237
|
import { useField as useField5 } from "formik";
|
|
3257
3238
|
import { useId as useId5 } from "react";
|
|
3258
|
-
import { jsx as
|
|
3259
|
-
function RadioGroup(
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
"name",
|
|
3267
|
-
"label",
|
|
3268
|
-
"options",
|
|
3269
|
-
"className"
|
|
3270
|
-
]);
|
|
3239
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3240
|
+
function RadioGroup({
|
|
3241
|
+
name,
|
|
3242
|
+
label,
|
|
3243
|
+
options,
|
|
3244
|
+
className,
|
|
3245
|
+
...rest
|
|
3246
|
+
}) {
|
|
3271
3247
|
const [field, meta] = useField5(name);
|
|
3272
3248
|
const hasError = Boolean(meta.touched && meta.error);
|
|
3273
3249
|
const errorId = `${useId5()}-error`;
|
|
3274
3250
|
return /* @__PURE__ */ jsxs9(
|
|
3275
3251
|
"fieldset",
|
|
3276
3252
|
{
|
|
3277
|
-
className: `${FIELD_ROOT_CLASS} ${className
|
|
3253
|
+
className: `${FIELD_ROOT_CLASS} ${className ?? ""}`,
|
|
3278
3254
|
"aria-describedby": hasError ? errorId : void 0,
|
|
3279
3255
|
"aria-invalid": hasError || void 0,
|
|
3280
3256
|
children: [
|
|
3281
|
-
label && /* @__PURE__ */
|
|
3282
|
-
/* @__PURE__ */
|
|
3257
|
+
label && /* @__PURE__ */ jsx11("legend", { className: FIELD_LABEL_CLASS, children: label }),
|
|
3258
|
+
/* @__PURE__ */ jsx11("div", { className: "field-control-slot mt-4xs mb-[4px] flex min-h-control-md flex-wrap items-center gap-x-6 gap-y-2", children: options.map((option) => /* @__PURE__ */ jsxs9(
|
|
3283
3259
|
"label",
|
|
3284
3260
|
{
|
|
3285
3261
|
className: "flex min-h-7 cursor-pointer items-center gap-2",
|
|
3286
3262
|
children: [
|
|
3287
|
-
/* @__PURE__ */
|
|
3263
|
+
/* @__PURE__ */ jsx11(
|
|
3288
3264
|
"input",
|
|
3289
|
-
|
|
3290
|
-
type: "radio"
|
|
3291
|
-
|
|
3265
|
+
{
|
|
3266
|
+
type: "radio",
|
|
3267
|
+
...rest,
|
|
3268
|
+
...field,
|
|
3292
3269
|
value: option.value,
|
|
3293
3270
|
checked: field.value === option.value,
|
|
3294
3271
|
"aria-describedby": hasError ? errorId : void 0,
|
|
3295
3272
|
"data-invalid": hasError || void 0,
|
|
3296
3273
|
className: "radio-control"
|
|
3297
|
-
}
|
|
3274
|
+
}
|
|
3298
3275
|
),
|
|
3299
|
-
/* @__PURE__ */
|
|
3276
|
+
/* @__PURE__ */ jsx11("span", { className: "text-content-secondary", children: option.label })
|
|
3300
3277
|
]
|
|
3301
3278
|
},
|
|
3302
3279
|
option.value
|
|
3303
3280
|
)) }),
|
|
3304
|
-
hasError && /* @__PURE__ */
|
|
3281
|
+
hasError && /* @__PURE__ */ jsx11(
|
|
3305
3282
|
"span",
|
|
3306
3283
|
{
|
|
3307
3284
|
id: errorId,
|
|
@@ -3323,9 +3300,9 @@ import {
|
|
|
3323
3300
|
useContext as useContext2,
|
|
3324
3301
|
useId as useId6,
|
|
3325
3302
|
useMemo as useMemo3,
|
|
3326
|
-
useState as
|
|
3303
|
+
useState as useState7
|
|
3327
3304
|
} from "react";
|
|
3328
|
-
import { jsx as
|
|
3305
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3329
3306
|
var isFormikContext = (context) => Boolean(context && typeof context.setFieldValue === "function");
|
|
3330
3307
|
function RadioCardGroup({
|
|
3331
3308
|
name,
|
|
@@ -3346,19 +3323,18 @@ function RadioCardGroup({
|
|
|
3346
3323
|
);
|
|
3347
3324
|
const generatedName = useId6();
|
|
3348
3325
|
const errorId = `${generatedName}-error`;
|
|
3349
|
-
const [internalValue, setInternalValue] =
|
|
3326
|
+
const [internalValue, setInternalValue] = useState7(defaultValue);
|
|
3350
3327
|
const hasFormikBinding = Boolean(name) && isFormikContext(formikContext);
|
|
3351
|
-
const fieldName = name
|
|
3328
|
+
const fieldName = name ?? generatedName;
|
|
3352
3329
|
const fieldValue = useMemo3(() => {
|
|
3353
|
-
var _a;
|
|
3354
3330
|
if (hasFormikBinding && name) {
|
|
3355
|
-
return String(
|
|
3331
|
+
return String(getIn2(formikContext.values, name) ?? "");
|
|
3356
3332
|
}
|
|
3357
3333
|
if (value !== void 0) {
|
|
3358
3334
|
return value;
|
|
3359
3335
|
}
|
|
3360
3336
|
return internalValue;
|
|
3361
|
-
}, [formikContext
|
|
3337
|
+
}, [formikContext?.values, hasFormikBinding, internalValue, name, value]);
|
|
3362
3338
|
const fieldTouched = hasFormikBinding && name ? Boolean(getIn2(formikContext.touched, name)) : Boolean(touched);
|
|
3363
3339
|
const fieldError = hasFormikBinding && name ? getIn2(formikContext.errors, name) : error;
|
|
3364
3340
|
const hasError = Boolean(fieldTouched && fieldError);
|
|
@@ -3370,7 +3346,7 @@ function RadioCardGroup({
|
|
|
3370
3346
|
} else if (value === void 0) {
|
|
3371
3347
|
setInternalValue(nextValue);
|
|
3372
3348
|
}
|
|
3373
|
-
onChange
|
|
3349
|
+
onChange?.(nextValue, event);
|
|
3374
3350
|
};
|
|
3375
3351
|
return /* @__PURE__ */ jsxs10(
|
|
3376
3352
|
"fieldset",
|
|
@@ -3379,12 +3355,12 @@ function RadioCardGroup({
|
|
|
3379
3355
|
"aria-describedby": helperText ? errorId : void 0,
|
|
3380
3356
|
"aria-invalid": hasError || void 0,
|
|
3381
3357
|
children: [
|
|
3382
|
-
label && /* @__PURE__ */
|
|
3383
|
-
/* @__PURE__ */
|
|
3358
|
+
label && /* @__PURE__ */ jsx12("legend", { className: "mb-2 px-0.5 text-[16px] tracking-wide", children: label }),
|
|
3359
|
+
/* @__PURE__ */ jsx12("div", { className: classNames7("grid gap-3", columnsClassName), children: options.map((option) => {
|
|
3384
3360
|
const optionId = `${fieldName}-${option.value}`;
|
|
3385
3361
|
const checked = fieldValue === option.value;
|
|
3386
3362
|
const optionDisabled = disabled || Boolean(option.disabled);
|
|
3387
|
-
return /* @__PURE__ */
|
|
3363
|
+
return /* @__PURE__ */ jsx12(
|
|
3388
3364
|
"label",
|
|
3389
3365
|
{
|
|
3390
3366
|
htmlFor: optionId,
|
|
@@ -3396,7 +3372,7 @@ function RadioCardGroup({
|
|
|
3396
3372
|
optionClassName
|
|
3397
3373
|
),
|
|
3398
3374
|
children: /* @__PURE__ */ jsxs10("div", { className: "flex items-start gap-3", children: [
|
|
3399
|
-
/* @__PURE__ */
|
|
3375
|
+
/* @__PURE__ */ jsx12(
|
|
3400
3376
|
"input",
|
|
3401
3377
|
{
|
|
3402
3378
|
id: optionId,
|
|
@@ -3416,15 +3392,15 @@ function RadioCardGroup({
|
|
|
3416
3392
|
}
|
|
3417
3393
|
),
|
|
3418
3394
|
/* @__PURE__ */ jsxs10("div", { className: "min-w-0 flex-1", children: [
|
|
3419
|
-
/* @__PURE__ */
|
|
3420
|
-
option.description && /* @__PURE__ */
|
|
3395
|
+
/* @__PURE__ */ jsx12("div", { className: "font-bold text-content-primary", children: option.title }),
|
|
3396
|
+
option.description && /* @__PURE__ */ jsx12("div", { className: "mt-1 text-content-primary", children: option.description })
|
|
3421
3397
|
] })
|
|
3422
3398
|
] })
|
|
3423
3399
|
},
|
|
3424
3400
|
option.value
|
|
3425
3401
|
);
|
|
3426
3402
|
}) }),
|
|
3427
|
-
helperText && /* @__PURE__ */
|
|
3403
|
+
helperText && /* @__PURE__ */ jsx12(
|
|
3428
3404
|
"span",
|
|
3429
3405
|
{
|
|
3430
3406
|
id: errorId,
|
|
@@ -3443,13 +3419,13 @@ function RadioCardGroup({
|
|
|
3443
3419
|
import classNames8 from "classnames";
|
|
3444
3420
|
import {
|
|
3445
3421
|
forwardRef as forwardRef2,
|
|
3446
|
-
useEffect as
|
|
3422
|
+
useEffect as useEffect6,
|
|
3447
3423
|
useId as useId7,
|
|
3448
3424
|
useImperativeHandle,
|
|
3449
3425
|
useRef as useRef7,
|
|
3450
|
-
useState as
|
|
3426
|
+
useState as useState8
|
|
3451
3427
|
} from "react";
|
|
3452
|
-
import { jsx as
|
|
3428
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
3453
3429
|
import { createElement } from "react";
|
|
3454
3430
|
var normalizeMask = (value, mask) => {
|
|
3455
3431
|
if (typeof mask === "function") return mask(value).slice(0, 1);
|
|
@@ -3461,64 +3437,42 @@ var normalizeMask = (value, mask) => {
|
|
|
3461
3437
|
return value.replace(/\D/g, "").slice(0, 1);
|
|
3462
3438
|
};
|
|
3463
3439
|
var normalizeValues = (source, length, mask) => {
|
|
3464
|
-
const values = Array.isArray(source) ? source : Array.from(source
|
|
3465
|
-
return Array.from({ length }, (_, index) =>
|
|
3466
|
-
var _a;
|
|
3467
|
-
return normalizeMask((_a = values[index]) != null ? _a : "", mask);
|
|
3468
|
-
});
|
|
3440
|
+
const values = Array.isArray(source) ? source : Array.from(source ?? "");
|
|
3441
|
+
return Array.from({ length }, (_, index) => normalizeMask(values[index] ?? "", mask));
|
|
3469
3442
|
};
|
|
3470
3443
|
var OtpCodeInput = forwardRef2(
|
|
3471
|
-
function OtpCodeInput2(
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
"length",
|
|
3493
|
-
"value",
|
|
3494
|
-
"values",
|
|
3495
|
-
"onChange",
|
|
3496
|
-
"onComplete",
|
|
3497
|
-
"onPaste",
|
|
3498
|
-
"autoFocus",
|
|
3499
|
-
"disabled",
|
|
3500
|
-
"error",
|
|
3501
|
-
"errorText",
|
|
3502
|
-
"helperText",
|
|
3503
|
-
"label",
|
|
3504
|
-
"inputMode",
|
|
3505
|
-
"mask",
|
|
3506
|
-
"name",
|
|
3507
|
-
"onFocus",
|
|
3508
|
-
"onKeyDown",
|
|
3509
|
-
"className"
|
|
3510
|
-
]);
|
|
3444
|
+
function OtpCodeInput2({
|
|
3445
|
+
length = 6,
|
|
3446
|
+
value,
|
|
3447
|
+
values,
|
|
3448
|
+
onChange,
|
|
3449
|
+
onComplete,
|
|
3450
|
+
onPaste,
|
|
3451
|
+
autoFocus = false,
|
|
3452
|
+
disabled = false,
|
|
3453
|
+
error = false,
|
|
3454
|
+
errorText,
|
|
3455
|
+
helperText,
|
|
3456
|
+
label = "C\xF3digo de uso \xFAnico",
|
|
3457
|
+
inputMode = "numeric",
|
|
3458
|
+
mask = "numeric",
|
|
3459
|
+
name,
|
|
3460
|
+
onFocus: onInputFocus,
|
|
3461
|
+
onKeyDown: onInputKeyDown,
|
|
3462
|
+
className,
|
|
3463
|
+
...inputProps
|
|
3464
|
+
}, ref) {
|
|
3511
3465
|
const safeLength = Math.max(1, Number.isFinite(length) ? Math.floor(length) : 6);
|
|
3512
3466
|
const groupId = useId7();
|
|
3513
3467
|
const errorId = `${groupId}-error`;
|
|
3514
3468
|
const helperId = `${groupId}-helper`;
|
|
3515
3469
|
const inputRefs = useRef7([]);
|
|
3516
3470
|
const isControlled = value !== void 0 || values !== void 0;
|
|
3517
|
-
const [internalValues, setInternalValues] =
|
|
3518
|
-
() => normalizeValues(values
|
|
3471
|
+
const [internalValues, setInternalValues] = useState8(
|
|
3472
|
+
() => normalizeValues(values ?? value, safeLength, mask)
|
|
3519
3473
|
);
|
|
3520
|
-
const currentValues = isControlled ? normalizeValues(values
|
|
3521
|
-
|
|
3474
|
+
const currentValues = isControlled ? normalizeValues(values ?? value, safeLength, mask) : internalValues;
|
|
3475
|
+
useEffect6(() => {
|
|
3522
3476
|
if (!isControlled) {
|
|
3523
3477
|
setInternalValues((previous) => {
|
|
3524
3478
|
const normalized = normalizeValues(previous, safeLength, mask);
|
|
@@ -3529,36 +3483,30 @@ var OtpCodeInput = forwardRef2(
|
|
|
3529
3483
|
}
|
|
3530
3484
|
}, [isControlled, mask, safeLength]);
|
|
3531
3485
|
useImperativeHandle(ref, () => ({
|
|
3532
|
-
focus: (index = 0) =>
|
|
3533
|
-
var _a2;
|
|
3534
|
-
return (_a2 = inputRefs.current[Math.min(Math.max(index, 0), safeLength - 1)]) == null ? void 0 : _a2.focus();
|
|
3535
|
-
},
|
|
3486
|
+
focus: (index = 0) => inputRefs.current[Math.min(Math.max(index, 0), safeLength - 1)]?.focus(),
|
|
3536
3487
|
clear: () => {
|
|
3537
|
-
var _a2;
|
|
3538
3488
|
const next = Array.from({ length: safeLength }, () => "");
|
|
3539
3489
|
if (!isControlled) setInternalValues(next);
|
|
3540
|
-
onChange
|
|
3541
|
-
|
|
3490
|
+
onChange?.("", next);
|
|
3491
|
+
inputRefs.current[0]?.focus();
|
|
3542
3492
|
}
|
|
3543
3493
|
}), [isControlled, onChange, safeLength]);
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
if (autoFocus) (_a2 = inputRefs.current[0]) == null ? void 0 : _a2.focus();
|
|
3494
|
+
useEffect6(() => {
|
|
3495
|
+
if (autoFocus) inputRefs.current[0]?.focus();
|
|
3547
3496
|
}, [autoFocus]);
|
|
3548
3497
|
const emit = (next, focusIndex) => {
|
|
3549
|
-
var _a2;
|
|
3550
3498
|
const normalized = normalizeValues(next, safeLength, mask);
|
|
3551
3499
|
if (!isControlled) setInternalValues(normalized);
|
|
3552
3500
|
const nextValue = normalized.join("");
|
|
3553
3501
|
const wasComplete = currentValues.every(Boolean) && currentValues.length === safeLength;
|
|
3554
|
-
onChange
|
|
3502
|
+
onChange?.(nextValue, normalized);
|
|
3555
3503
|
if (!wasComplete && normalized.every(Boolean) && nextValue.length === safeLength) {
|
|
3556
|
-
onComplete
|
|
3504
|
+
onComplete?.(nextValue);
|
|
3557
3505
|
}
|
|
3558
|
-
if (focusIndex !== void 0)
|
|
3506
|
+
if (focusIndex !== void 0) inputRefs.current[focusIndex]?.focus();
|
|
3559
3507
|
};
|
|
3560
3508
|
const handlePaste = (event, index) => {
|
|
3561
|
-
onPaste
|
|
3509
|
+
onPaste?.(event);
|
|
3562
3510
|
if (event.defaultPrevented) return;
|
|
3563
3511
|
event.preventDefault();
|
|
3564
3512
|
const pasted = Array.from(event.clipboardData.getData("text")).map((item) => normalizeMask(item, mask)).filter(Boolean).slice(0, safeLength - index);
|
|
@@ -3570,13 +3518,12 @@ var OtpCodeInput = forwardRef2(
|
|
|
3570
3518
|
emit(next, Math.min(index + pasted.length, safeLength - 1));
|
|
3571
3519
|
};
|
|
3572
3520
|
const handleKeyDown = (event, index) => {
|
|
3573
|
-
var _a2, _b2, _c, _d;
|
|
3574
3521
|
if (event.key === "ArrowLeft" && index > 0) {
|
|
3575
3522
|
event.preventDefault();
|
|
3576
|
-
|
|
3523
|
+
inputRefs.current[index - 1]?.focus();
|
|
3577
3524
|
} else if (event.key === "ArrowRight" && index < safeLength - 1) {
|
|
3578
3525
|
event.preventDefault();
|
|
3579
|
-
|
|
3526
|
+
inputRefs.current[index + 1]?.focus();
|
|
3580
3527
|
} else if (event.key === "Backspace") {
|
|
3581
3528
|
if (currentValues[index]) {
|
|
3582
3529
|
const next = [...currentValues];
|
|
@@ -3594,15 +3541,15 @@ var OtpCodeInput = forwardRef2(
|
|
|
3594
3541
|
emit(next);
|
|
3595
3542
|
} else if (event.key === "Home") {
|
|
3596
3543
|
event.preventDefault();
|
|
3597
|
-
|
|
3544
|
+
inputRefs.current[0]?.focus();
|
|
3598
3545
|
} else if (event.key === "End") {
|
|
3599
3546
|
event.preventDefault();
|
|
3600
|
-
|
|
3547
|
+
inputRefs.current[safeLength - 1]?.focus();
|
|
3601
3548
|
}
|
|
3602
3549
|
};
|
|
3603
3550
|
const hasError = Boolean(error || errorText);
|
|
3604
3551
|
const describedBy = [helperText ? helperId : "", hasError && errorText ? errorId : ""].filter(Boolean).join(" ") || void 0;
|
|
3605
|
-
return /* @__PURE__ */
|
|
3552
|
+
return /* @__PURE__ */ jsx13(
|
|
3606
3553
|
FieldFrame_default,
|
|
3607
3554
|
{
|
|
3608
3555
|
label,
|
|
@@ -3614,7 +3561,7 @@ var OtpCodeInput = forwardRef2(
|
|
|
3614
3561
|
descriptionId: helperId,
|
|
3615
3562
|
invalid: hasError,
|
|
3616
3563
|
className,
|
|
3617
|
-
children: /* @__PURE__ */
|
|
3564
|
+
children: /* @__PURE__ */ jsx13(
|
|
3618
3565
|
"div",
|
|
3619
3566
|
{
|
|
3620
3567
|
role: "group",
|
|
@@ -3624,7 +3571,8 @@ var OtpCodeInput = forwardRef2(
|
|
|
3624
3571
|
className: "mt-1 flex flex-wrap gap-2",
|
|
3625
3572
|
children: Array.from({ length: safeLength }, (_, index) => /* @__PURE__ */ createElement(
|
|
3626
3573
|
"input",
|
|
3627
|
-
|
|
3574
|
+
{
|
|
3575
|
+
...inputProps,
|
|
3628
3576
|
key: index,
|
|
3629
3577
|
ref: (element) => {
|
|
3630
3578
|
inputRefs.current[index] = element;
|
|
@@ -3648,18 +3596,18 @@ var OtpCodeInput = forwardRef2(
|
|
|
3648
3596
|
},
|
|
3649
3597
|
onPaste: (event) => handlePaste(event, index),
|
|
3650
3598
|
onKeyDown: (event) => {
|
|
3651
|
-
onInputKeyDown
|
|
3599
|
+
onInputKeyDown?.(event);
|
|
3652
3600
|
if (!event.defaultPrevented) handleKeyDown(event, index);
|
|
3653
3601
|
},
|
|
3654
3602
|
onFocus: (event) => {
|
|
3655
|
-
onInputFocus
|
|
3603
|
+
onInputFocus?.(event);
|
|
3656
3604
|
if (!event.defaultPrevented) event.currentTarget.select();
|
|
3657
3605
|
},
|
|
3658
3606
|
className: classNames8(
|
|
3659
3607
|
"h-11 w-11 rounded-sm border bg-field-surface text-center text-lg font-bold text-field-content outline-none transition-colors focus-visible:border-field-border-active focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring disabled:cursor-not-allowed disabled:bg-field-surface-disabled",
|
|
3660
3608
|
hasError ? "border-field-border-error" : "border-field-border-default"
|
|
3661
3609
|
)
|
|
3662
|
-
}
|
|
3610
|
+
}
|
|
3663
3611
|
))
|
|
3664
3612
|
}
|
|
3665
3613
|
)
|
|
@@ -3689,4 +3637,4 @@ export {
|
|
|
3689
3637
|
RadioCardGroup,
|
|
3690
3638
|
OtpCodeInput_default
|
|
3691
3639
|
};
|
|
3692
|
-
//# sourceMappingURL=chunk-
|
|
3640
|
+
//# sourceMappingURL=chunk-6NVJWI5B.js.map
|