@ttoss/forms 0.35.2 → 0.35.3
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/package.json +11 -11
- package/dist/Brazil/index.d.ts +0 -25
- package/dist/FormFieldPatternFormat-D5CI6eUA.d.ts +0 -59
- package/dist/MultistepForm/index.d.ts +0 -65
- package/dist/esm/Brazil/index.js +0 -128
- package/dist/esm/MultistepForm/index.js +0 -2482
- package/dist/esm/chunk-QJQFXN4B.js +0 -442
- package/dist/esm/chunk-YXYTHWIU.js +0 -971
- package/dist/esm/index.js +0 -4
- package/dist/index.d.ts +0 -120
- package/dist/typings.d-BZ6kUiQ4.d.ts +0 -13
|
@@ -1,971 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { FormErrorMessage, FormField, FormFieldPatternFormat, __name, isCnpjValid, isCpfValid } from "./chunk-QJQFXN4B.js";
|
|
4
|
-
|
|
5
|
-
// src/Form.tsx
|
|
6
|
-
import { Box } from "@ttoss/ui";
|
|
7
|
-
import * as React2 from "react";
|
|
8
|
-
import { FormProvider } from "react-hook-form";
|
|
9
|
-
var Form = /* @__PURE__ */__name(({
|
|
10
|
-
children,
|
|
11
|
-
onSubmit,
|
|
12
|
-
sx,
|
|
13
|
-
...formMethods
|
|
14
|
-
}) => {
|
|
15
|
-
return /* @__PURE__ */React2.createElement(FormProvider, formMethods, /* @__PURE__ */React2.createElement(Box, {
|
|
16
|
-
as: "form",
|
|
17
|
-
variant: "forms.form",
|
|
18
|
-
onSubmit: formMethods.handleSubmit(data => {
|
|
19
|
-
return onSubmit?.(data);
|
|
20
|
-
}),
|
|
21
|
-
sx
|
|
22
|
-
}, children));
|
|
23
|
-
}, "Form");
|
|
24
|
-
|
|
25
|
-
// src/FormFieldCheckbox.tsx
|
|
26
|
-
import { Checkbox } from "@ttoss/ui";
|
|
27
|
-
var FormFieldCheckbox = /* @__PURE__ */__name(({
|
|
28
|
-
defaultValue = false,
|
|
29
|
-
disabled,
|
|
30
|
-
...props
|
|
31
|
-
}) => {
|
|
32
|
-
const {
|
|
33
|
-
label,
|
|
34
|
-
name,
|
|
35
|
-
labelTooltip,
|
|
36
|
-
warning,
|
|
37
|
-
sx,
|
|
38
|
-
css,
|
|
39
|
-
rules,
|
|
40
|
-
id,
|
|
41
|
-
onBlur,
|
|
42
|
-
onChange,
|
|
43
|
-
...checkboxProps
|
|
44
|
-
} = props;
|
|
45
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
46
|
-
id,
|
|
47
|
-
label,
|
|
48
|
-
name,
|
|
49
|
-
labelTooltip,
|
|
50
|
-
warning,
|
|
51
|
-
sx,
|
|
52
|
-
css,
|
|
53
|
-
defaultValue,
|
|
54
|
-
rules,
|
|
55
|
-
disabled,
|
|
56
|
-
render: /* @__PURE__ */__name(({
|
|
57
|
-
field,
|
|
58
|
-
fieldState
|
|
59
|
-
}) => {
|
|
60
|
-
const {
|
|
61
|
-
value,
|
|
62
|
-
...fieldWithoutValue
|
|
63
|
-
} = field;
|
|
64
|
-
return /* @__PURE__ */React.createElement(Checkbox, {
|
|
65
|
-
...checkboxProps,
|
|
66
|
-
...fieldWithoutValue,
|
|
67
|
-
onBlur: /* @__PURE__ */__name(e => {
|
|
68
|
-
field.onBlur();
|
|
69
|
-
onBlur?.(e);
|
|
70
|
-
}, "onBlur"),
|
|
71
|
-
onChange: /* @__PURE__ */__name(e => {
|
|
72
|
-
field.onChange(e);
|
|
73
|
-
onChange?.(e);
|
|
74
|
-
}, "onChange"),
|
|
75
|
-
checked: value,
|
|
76
|
-
disabled: disabled ?? field.disabled,
|
|
77
|
-
"aria-invalid": !!fieldState.error
|
|
78
|
-
});
|
|
79
|
-
}, "render")
|
|
80
|
-
});
|
|
81
|
-
}, "FormFieldCheckbox");
|
|
82
|
-
|
|
83
|
-
// src/FormFieldCreditCardNumber.tsx
|
|
84
|
-
var FormFieldCreditCardNumber = /* @__PURE__ */__name(({
|
|
85
|
-
format = "#### #### #### ####",
|
|
86
|
-
placeholder = "1234 1234 1234 1234",
|
|
87
|
-
...formFieldPatternFormatProps
|
|
88
|
-
}) => {
|
|
89
|
-
return /* @__PURE__ */React.createElement(FormFieldPatternFormat, {
|
|
90
|
-
format,
|
|
91
|
-
placeholder,
|
|
92
|
-
...formFieldPatternFormatProps
|
|
93
|
-
});
|
|
94
|
-
}, "FormFieldCreditCardNumber");
|
|
95
|
-
|
|
96
|
-
// src/FormFieldCurrencyInput.tsx
|
|
97
|
-
import { defineMessages, useI18n } from "@ttoss/react-i18n";
|
|
98
|
-
|
|
99
|
-
// src/FormFieldNumericFormat.tsx
|
|
100
|
-
import { Input } from "@ttoss/ui";
|
|
101
|
-
import { NumericFormat } from "react-number-format";
|
|
102
|
-
var FormFieldNumericFormat = /* @__PURE__ */__name(({
|
|
103
|
-
disabled,
|
|
104
|
-
...props
|
|
105
|
-
}) => {
|
|
106
|
-
const {
|
|
107
|
-
label,
|
|
108
|
-
name,
|
|
109
|
-
labelTooltip,
|
|
110
|
-
warning,
|
|
111
|
-
sx,
|
|
112
|
-
css,
|
|
113
|
-
rules,
|
|
114
|
-
id,
|
|
115
|
-
defaultValue,
|
|
116
|
-
leadingIcon,
|
|
117
|
-
trailingIcon,
|
|
118
|
-
auxiliaryCheckbox,
|
|
119
|
-
onBlur,
|
|
120
|
-
onValueChange,
|
|
121
|
-
...numericFormatProps
|
|
122
|
-
} = props;
|
|
123
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
124
|
-
id,
|
|
125
|
-
label,
|
|
126
|
-
name,
|
|
127
|
-
labelTooltip,
|
|
128
|
-
warning,
|
|
129
|
-
sx,
|
|
130
|
-
css,
|
|
131
|
-
defaultValue,
|
|
132
|
-
rules,
|
|
133
|
-
disabled,
|
|
134
|
-
auxiliaryCheckbox,
|
|
135
|
-
render: /* @__PURE__ */__name(({
|
|
136
|
-
field
|
|
137
|
-
}) => {
|
|
138
|
-
return /* @__PURE__ */React.createElement(NumericFormat, {
|
|
139
|
-
...numericFormatProps,
|
|
140
|
-
name: field.name,
|
|
141
|
-
value: field.value,
|
|
142
|
-
onBlur: /* @__PURE__ */__name(e => {
|
|
143
|
-
field.onBlur();
|
|
144
|
-
onBlur?.(e);
|
|
145
|
-
}, "onBlur"),
|
|
146
|
-
onValueChange: /* @__PURE__ */__name((values, sourceInfo) => {
|
|
147
|
-
field.onChange(values.floatValue);
|
|
148
|
-
onValueChange?.(values, sourceInfo);
|
|
149
|
-
}, "onValueChange"),
|
|
150
|
-
customInput: Input,
|
|
151
|
-
leadingIcon,
|
|
152
|
-
trailingIcon,
|
|
153
|
-
disabled: disabled ?? field.disabled
|
|
154
|
-
});
|
|
155
|
-
}, "render")
|
|
156
|
-
});
|
|
157
|
-
}, "FormFieldNumericFormat");
|
|
158
|
-
|
|
159
|
-
// src/FormFieldCurrencyInput.tsx
|
|
160
|
-
var messages = defineMessages({
|
|
161
|
-
decimalSeparator: {
|
|
162
|
-
id: "JnCaDG",
|
|
163
|
-
defaultMessage: [{
|
|
164
|
-
"type": 0,
|
|
165
|
-
"value": "."
|
|
166
|
-
}]
|
|
167
|
-
},
|
|
168
|
-
thousandSeparator: {
|
|
169
|
-
id: "0+4wTp",
|
|
170
|
-
defaultMessage: [{
|
|
171
|
-
"type": 0,
|
|
172
|
-
"value": ","
|
|
173
|
-
}]
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
var FormFieldCurrencyInput = /* @__PURE__ */__name(({
|
|
177
|
-
prefix,
|
|
178
|
-
decimalSeparator,
|
|
179
|
-
thousandSeparator,
|
|
180
|
-
...formFieldNumericFormatProps
|
|
181
|
-
}) => {
|
|
182
|
-
const {
|
|
183
|
-
intl
|
|
184
|
-
} = useI18n();
|
|
185
|
-
const finalDecimalSeparator = decimalSeparator ?? intl.formatMessage(messages.decimalSeparator);
|
|
186
|
-
const finalThousandSeparator = thousandSeparator ?? intl.formatMessage(messages.thousandSeparator);
|
|
187
|
-
return /* @__PURE__ */React.createElement(FormFieldNumericFormat, {
|
|
188
|
-
fixedDecimalScale: true,
|
|
189
|
-
decimalScale: 2,
|
|
190
|
-
prefix,
|
|
191
|
-
decimalSeparator: finalDecimalSeparator,
|
|
192
|
-
thousandSeparator: finalThousandSeparator,
|
|
193
|
-
placeholder: `${prefix} 0${finalDecimalSeparator}00`,
|
|
194
|
-
allowNegative: false,
|
|
195
|
-
...formFieldNumericFormatProps
|
|
196
|
-
});
|
|
197
|
-
}, "FormFieldCurrencyInput");
|
|
198
|
-
|
|
199
|
-
// src/FormFieldDatePicker.tsx
|
|
200
|
-
import { DatePicker } from "@ttoss/components/DatePicker";
|
|
201
|
-
var FormFieldDatePicker = /* @__PURE__ */__name(({
|
|
202
|
-
disabled,
|
|
203
|
-
...props
|
|
204
|
-
}) => {
|
|
205
|
-
const {
|
|
206
|
-
label,
|
|
207
|
-
name,
|
|
208
|
-
labelTooltip,
|
|
209
|
-
warning,
|
|
210
|
-
sx,
|
|
211
|
-
css,
|
|
212
|
-
rules,
|
|
213
|
-
id,
|
|
214
|
-
defaultValue,
|
|
215
|
-
presets,
|
|
216
|
-
...datePickerProps
|
|
217
|
-
} = props;
|
|
218
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
219
|
-
id,
|
|
220
|
-
label,
|
|
221
|
-
name,
|
|
222
|
-
labelTooltip,
|
|
223
|
-
warning,
|
|
224
|
-
sx,
|
|
225
|
-
css,
|
|
226
|
-
defaultValue,
|
|
227
|
-
rules,
|
|
228
|
-
disabled,
|
|
229
|
-
render: /* @__PURE__ */__name(({
|
|
230
|
-
field
|
|
231
|
-
}) => {
|
|
232
|
-
return /* @__PURE__ */React.createElement(DatePicker, {
|
|
233
|
-
...datePickerProps,
|
|
234
|
-
value: field.value,
|
|
235
|
-
onChange: /* @__PURE__ */__name(range => {
|
|
236
|
-
field.onChange(range);
|
|
237
|
-
}, "onChange"),
|
|
238
|
-
presets
|
|
239
|
-
});
|
|
240
|
-
}, "render")
|
|
241
|
-
});
|
|
242
|
-
}, "FormFieldDatePicker");
|
|
243
|
-
|
|
244
|
-
// src/FormFieldInput.tsx
|
|
245
|
-
import { Input as Input2 } from "@ttoss/ui";
|
|
246
|
-
var FormFieldInput = /* @__PURE__ */__name(({
|
|
247
|
-
defaultValue = "",
|
|
248
|
-
disabled,
|
|
249
|
-
...props
|
|
250
|
-
}) => {
|
|
251
|
-
const {
|
|
252
|
-
label,
|
|
253
|
-
name,
|
|
254
|
-
labelTooltip,
|
|
255
|
-
warning,
|
|
256
|
-
sx,
|
|
257
|
-
css,
|
|
258
|
-
rules,
|
|
259
|
-
id,
|
|
260
|
-
leadingIcon,
|
|
261
|
-
trailingIcon,
|
|
262
|
-
auxiliaryCheckbox,
|
|
263
|
-
onBlur,
|
|
264
|
-
onChange,
|
|
265
|
-
...inputProps
|
|
266
|
-
} = props;
|
|
267
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
268
|
-
id,
|
|
269
|
-
label,
|
|
270
|
-
name,
|
|
271
|
-
labelTooltip,
|
|
272
|
-
warning,
|
|
273
|
-
sx,
|
|
274
|
-
css,
|
|
275
|
-
defaultValue,
|
|
276
|
-
rules,
|
|
277
|
-
disabled,
|
|
278
|
-
auxiliaryCheckbox,
|
|
279
|
-
render: /* @__PURE__ */__name(({
|
|
280
|
-
field,
|
|
281
|
-
fieldState
|
|
282
|
-
}) => {
|
|
283
|
-
return /* @__PURE__ */React.createElement(Input2, {
|
|
284
|
-
...inputProps,
|
|
285
|
-
...field,
|
|
286
|
-
onBlur: /* @__PURE__ */__name(e => {
|
|
287
|
-
field.onBlur();
|
|
288
|
-
onBlur?.(e);
|
|
289
|
-
}, "onBlur"),
|
|
290
|
-
onChange: /* @__PURE__ */__name(e => {
|
|
291
|
-
field.onChange(e);
|
|
292
|
-
onChange?.(e);
|
|
293
|
-
}, "onChange"),
|
|
294
|
-
leadingIcon,
|
|
295
|
-
trailingIcon,
|
|
296
|
-
disabled: disabled ?? field.disabled,
|
|
297
|
-
"aria-invalid": fieldState.error ? "true" : void 0
|
|
298
|
-
});
|
|
299
|
-
}, "render")
|
|
300
|
-
});
|
|
301
|
-
}, "FormFieldInput");
|
|
302
|
-
|
|
303
|
-
// src/FormFieldPassword.tsx
|
|
304
|
-
import { InputPassword } from "@ttoss/ui";
|
|
305
|
-
var FormFieldPassword = /* @__PURE__ */__name(({
|
|
306
|
-
defaultValue = "",
|
|
307
|
-
disabled,
|
|
308
|
-
...props
|
|
309
|
-
}) => {
|
|
310
|
-
const {
|
|
311
|
-
label,
|
|
312
|
-
name,
|
|
313
|
-
labelTooltip,
|
|
314
|
-
warning,
|
|
315
|
-
sx,
|
|
316
|
-
css,
|
|
317
|
-
rules,
|
|
318
|
-
id,
|
|
319
|
-
leadingIcon,
|
|
320
|
-
auxiliaryCheckbox,
|
|
321
|
-
onBlur,
|
|
322
|
-
onChange,
|
|
323
|
-
...inputProps
|
|
324
|
-
} = props;
|
|
325
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
326
|
-
id,
|
|
327
|
-
label,
|
|
328
|
-
name,
|
|
329
|
-
labelTooltip,
|
|
330
|
-
warning,
|
|
331
|
-
sx,
|
|
332
|
-
css,
|
|
333
|
-
defaultValue,
|
|
334
|
-
rules,
|
|
335
|
-
disabled,
|
|
336
|
-
auxiliaryCheckbox,
|
|
337
|
-
render: /* @__PURE__ */__name(({
|
|
338
|
-
field,
|
|
339
|
-
fieldState
|
|
340
|
-
}) => {
|
|
341
|
-
return /* @__PURE__ */React.createElement(InputPassword, {
|
|
342
|
-
...inputProps,
|
|
343
|
-
...field,
|
|
344
|
-
onBlur: /* @__PURE__ */__name(e => {
|
|
345
|
-
field.onBlur();
|
|
346
|
-
onBlur?.(e);
|
|
347
|
-
}, "onBlur"),
|
|
348
|
-
onChange: /* @__PURE__ */__name(e => {
|
|
349
|
-
field.onChange(e);
|
|
350
|
-
onChange?.(e);
|
|
351
|
-
}, "onChange"),
|
|
352
|
-
leadingIcon,
|
|
353
|
-
disabled: disabled ?? field.disabled,
|
|
354
|
-
"aria-invalid": fieldState.error ? "true" : void 0
|
|
355
|
-
});
|
|
356
|
-
}, "render")
|
|
357
|
-
});
|
|
358
|
-
}, "FormFieldPassword");
|
|
359
|
-
|
|
360
|
-
// src/FormFieldRadio.tsx
|
|
361
|
-
import { Flex, Label, Radio } from "@ttoss/ui";
|
|
362
|
-
var FormFieldRadio = /* @__PURE__ */__name(({
|
|
363
|
-
disabled,
|
|
364
|
-
options,
|
|
365
|
-
...props
|
|
366
|
-
}) => {
|
|
367
|
-
const {
|
|
368
|
-
label,
|
|
369
|
-
name,
|
|
370
|
-
labelTooltip,
|
|
371
|
-
warning,
|
|
372
|
-
sx,
|
|
373
|
-
css,
|
|
374
|
-
rules,
|
|
375
|
-
id,
|
|
376
|
-
defaultValue,
|
|
377
|
-
onBlur,
|
|
378
|
-
onChange,
|
|
379
|
-
...radioProps
|
|
380
|
-
} = props;
|
|
381
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
382
|
-
id,
|
|
383
|
-
label,
|
|
384
|
-
name,
|
|
385
|
-
labelTooltip,
|
|
386
|
-
warning,
|
|
387
|
-
sx,
|
|
388
|
-
css,
|
|
389
|
-
defaultValue,
|
|
390
|
-
rules,
|
|
391
|
-
disabled,
|
|
392
|
-
render: /* @__PURE__ */__name(({
|
|
393
|
-
field
|
|
394
|
-
}) => {
|
|
395
|
-
return /* @__PURE__ */React.createElement(Flex, {
|
|
396
|
-
sx: {
|
|
397
|
-
flexDirection: "column",
|
|
398
|
-
gap: "1"
|
|
399
|
-
}
|
|
400
|
-
}, options.map(option => {
|
|
401
|
-
const key = `form-field-radio-${name}-${option.value}`;
|
|
402
|
-
return /* @__PURE__ */React.createElement(Label, {
|
|
403
|
-
key,
|
|
404
|
-
sx: {
|
|
405
|
-
fontSize: "md"
|
|
406
|
-
}
|
|
407
|
-
}, /* @__PURE__ */React.createElement(Radio, {
|
|
408
|
-
ref: field.ref,
|
|
409
|
-
onChange: /* @__PURE__ */__name(e => {
|
|
410
|
-
field.onChange(e);
|
|
411
|
-
onChange?.(e);
|
|
412
|
-
}, "onChange"),
|
|
413
|
-
onBlur: /* @__PURE__ */__name(e => {
|
|
414
|
-
field.onBlur();
|
|
415
|
-
onBlur?.(e);
|
|
416
|
-
}, "onBlur"),
|
|
417
|
-
value: option.value,
|
|
418
|
-
checked: field.value === option.value,
|
|
419
|
-
name,
|
|
420
|
-
disabled: disabled ?? field.disabled,
|
|
421
|
-
...radioProps
|
|
422
|
-
}), option.label);
|
|
423
|
-
}));
|
|
424
|
-
}, "render")
|
|
425
|
-
});
|
|
426
|
-
}, "FormFieldRadio");
|
|
427
|
-
|
|
428
|
-
// src/FormFieldRadioCard.tsx
|
|
429
|
-
import { Box as Box2, Flex as Flex2, Label as Label2, Radio as Radio2, Text } from "@ttoss/ui";
|
|
430
|
-
var FormFieldRadioCard = /* @__PURE__ */__name(({
|
|
431
|
-
disabled,
|
|
432
|
-
...props
|
|
433
|
-
}) => {
|
|
434
|
-
const {
|
|
435
|
-
label,
|
|
436
|
-
name,
|
|
437
|
-
labelTooltip,
|
|
438
|
-
warning,
|
|
439
|
-
sx,
|
|
440
|
-
css,
|
|
441
|
-
rules,
|
|
442
|
-
id,
|
|
443
|
-
defaultValue,
|
|
444
|
-
options,
|
|
445
|
-
direction = "column",
|
|
446
|
-
width = "full",
|
|
447
|
-
onBlur,
|
|
448
|
-
onChange,
|
|
449
|
-
...radioProps
|
|
450
|
-
} = props;
|
|
451
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
452
|
-
id,
|
|
453
|
-
label,
|
|
454
|
-
name,
|
|
455
|
-
labelTooltip,
|
|
456
|
-
warning,
|
|
457
|
-
sx,
|
|
458
|
-
css,
|
|
459
|
-
defaultValue,
|
|
460
|
-
rules,
|
|
461
|
-
disabled,
|
|
462
|
-
render: /* @__PURE__ */__name(({
|
|
463
|
-
field
|
|
464
|
-
}) => {
|
|
465
|
-
return /* @__PURE__ */React.createElement(Flex2, {
|
|
466
|
-
sx: {
|
|
467
|
-
flexDirection: direction,
|
|
468
|
-
gap: "4"
|
|
469
|
-
}
|
|
470
|
-
}, options.map(option => {
|
|
471
|
-
const key = `form-field-radio-${name}-${option.value}`;
|
|
472
|
-
return /* @__PURE__ */React.createElement(Box2, {
|
|
473
|
-
key,
|
|
474
|
-
sx: {
|
|
475
|
-
gap: "2",
|
|
476
|
-
width,
|
|
477
|
-
border: "md",
|
|
478
|
-
borderColor: "display.border.muted.default",
|
|
479
|
-
borderRadius: "md"
|
|
480
|
-
}
|
|
481
|
-
}, /* @__PURE__ */React.createElement(Label2, {
|
|
482
|
-
sx: {
|
|
483
|
-
fontSize: "md",
|
|
484
|
-
width: "100%",
|
|
485
|
-
padding: "4"
|
|
486
|
-
}
|
|
487
|
-
}, /* @__PURE__ */React.createElement(Radio2, {
|
|
488
|
-
...radioProps,
|
|
489
|
-
ref: field.ref,
|
|
490
|
-
onChange: /* @__PURE__ */__name(e => {
|
|
491
|
-
field.onChange(e);
|
|
492
|
-
onChange?.(e);
|
|
493
|
-
}, "onChange"),
|
|
494
|
-
onBlur: /* @__PURE__ */__name(e => {
|
|
495
|
-
field.onBlur();
|
|
496
|
-
onBlur?.(e);
|
|
497
|
-
}, "onBlur"),
|
|
498
|
-
value: option.value,
|
|
499
|
-
checked: field.value === option.value,
|
|
500
|
-
name,
|
|
501
|
-
disabled: disabled ?? field.disabled
|
|
502
|
-
}), /* @__PURE__ */React.createElement(Flex2, {
|
|
503
|
-
sx: {
|
|
504
|
-
flexDirection: "column",
|
|
505
|
-
gap: "1"
|
|
506
|
-
}
|
|
507
|
-
}, option.label && /* @__PURE__ */React.createElement(Text, null, option.label), option.description && /* @__PURE__ */React.createElement(Text, {
|
|
508
|
-
sx: {
|
|
509
|
-
fontSize: "sm"
|
|
510
|
-
}
|
|
511
|
-
}, option.description))));
|
|
512
|
-
}));
|
|
513
|
-
}, "render")
|
|
514
|
-
});
|
|
515
|
-
}, "FormFieldRadioCard");
|
|
516
|
-
|
|
517
|
-
// src/FormFieldRadioCardIcony.tsx
|
|
518
|
-
import { Box as Box3, Flex as Flex3, Tag, Text as Text2 } from "@ttoss/ui";
|
|
519
|
-
import * as React3 from "react";
|
|
520
|
-
var FormFieldRadioCardIcony = /* @__PURE__ */__name(({
|
|
521
|
-
disabled,
|
|
522
|
-
...props
|
|
523
|
-
}) => {
|
|
524
|
-
const {
|
|
525
|
-
label,
|
|
526
|
-
name,
|
|
527
|
-
labelTooltip,
|
|
528
|
-
warning,
|
|
529
|
-
sx,
|
|
530
|
-
css,
|
|
531
|
-
rules,
|
|
532
|
-
id,
|
|
533
|
-
defaultValue,
|
|
534
|
-
options,
|
|
535
|
-
direction = "row",
|
|
536
|
-
width = "full"
|
|
537
|
-
} = props;
|
|
538
|
-
return /* @__PURE__ */React3.createElement(FormField, {
|
|
539
|
-
id,
|
|
540
|
-
label,
|
|
541
|
-
name,
|
|
542
|
-
labelTooltip,
|
|
543
|
-
warning,
|
|
544
|
-
sx,
|
|
545
|
-
css,
|
|
546
|
-
defaultValue,
|
|
547
|
-
rules,
|
|
548
|
-
disabled,
|
|
549
|
-
render: /* @__PURE__ */__name(({
|
|
550
|
-
field
|
|
551
|
-
}) => {
|
|
552
|
-
const isDisabled = disabled ?? field.disabled;
|
|
553
|
-
const handleOptionClick = /* @__PURE__ */__name(optionValue => {
|
|
554
|
-
if (!isDisabled) {
|
|
555
|
-
field.onChange(optionValue);
|
|
556
|
-
field.onBlur();
|
|
557
|
-
}
|
|
558
|
-
}, "handleOptionClick");
|
|
559
|
-
return /* @__PURE__ */React3.createElement(Flex3, {
|
|
560
|
-
sx: {
|
|
561
|
-
flexDirection: direction,
|
|
562
|
-
gap: "4"
|
|
563
|
-
}
|
|
564
|
-
}, options.map(option => {
|
|
565
|
-
const key = `form-field-radio-card-${name}-${option.value}`;
|
|
566
|
-
const isSelected = field.value === option.value;
|
|
567
|
-
const IconComponent = option.icon;
|
|
568
|
-
const tag = option.tag;
|
|
569
|
-
return /* @__PURE__ */React3.createElement(Box3, {
|
|
570
|
-
key,
|
|
571
|
-
onClick: /* @__PURE__ */__name(() => {
|
|
572
|
-
return handleOptionClick(option.value);
|
|
573
|
-
}, "onClick"),
|
|
574
|
-
sx: {
|
|
575
|
-
width,
|
|
576
|
-
padding: "6",
|
|
577
|
-
border: isSelected ? "lg" : "md",
|
|
578
|
-
borderColor: isSelected ? "input.background.accent.default" : "input.border.muted.default",
|
|
579
|
-
borderRadius: "md",
|
|
580
|
-
backgroundColor: isSelected ? "feedback.background.positive.default" : "transparent",
|
|
581
|
-
display: "flex",
|
|
582
|
-
flexDirection: "column",
|
|
583
|
-
alignItems: "center",
|
|
584
|
-
justifyContent: "center",
|
|
585
|
-
textAlign: "center",
|
|
586
|
-
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
587
|
-
opacity: isDisabled ? 0.5 : 1,
|
|
588
|
-
transition: "all 0.2s ease-in-out"
|
|
589
|
-
}
|
|
590
|
-
}, IconComponent && /* @__PURE__ */React3.createElement(Box3, {
|
|
591
|
-
sx: {
|
|
592
|
-
marginBottom: "2",
|
|
593
|
-
color: "text.primary"
|
|
594
|
-
}
|
|
595
|
-
}, /* @__PURE__ */React3.createElement(IconComponent, {
|
|
596
|
-
size: 24
|
|
597
|
-
})), /* @__PURE__ */React3.createElement(Flex3, {
|
|
598
|
-
sx: {
|
|
599
|
-
flexDirection: "column",
|
|
600
|
-
gap: "1"
|
|
601
|
-
}
|
|
602
|
-
}, option.label && /* @__PURE__ */React3.createElement(Text2, {
|
|
603
|
-
sx: {
|
|
604
|
-
fontSize: "lg",
|
|
605
|
-
fontWeight: "semibold",
|
|
606
|
-
color: "text.primary"
|
|
607
|
-
}
|
|
608
|
-
}, option.label), option.description && /* @__PURE__ */React3.createElement(Text2, {
|
|
609
|
-
sx: {
|
|
610
|
-
fontSize: "md",
|
|
611
|
-
color: "text.secondary"
|
|
612
|
-
}
|
|
613
|
-
}, option.description)), tag?.label && /* @__PURE__ */React3.createElement(Tag, {
|
|
614
|
-
variant: tag?.variant,
|
|
615
|
-
sx: {
|
|
616
|
-
px: "3",
|
|
617
|
-
mt: "2",
|
|
618
|
-
fontSize: "sm",
|
|
619
|
-
...tag?.sx
|
|
620
|
-
}
|
|
621
|
-
}, tag.label));
|
|
622
|
-
}));
|
|
623
|
-
}, "render")
|
|
624
|
-
});
|
|
625
|
-
}, "FormFieldRadioCardIcony");
|
|
626
|
-
|
|
627
|
-
// src/FormFieldSelect.tsx
|
|
628
|
-
import { Select } from "@ttoss/ui";
|
|
629
|
-
var FormFieldSelect = /* @__PURE__ */__name(({
|
|
630
|
-
disabled,
|
|
631
|
-
...props
|
|
632
|
-
}) => {
|
|
633
|
-
const {
|
|
634
|
-
label,
|
|
635
|
-
name,
|
|
636
|
-
labelTooltip,
|
|
637
|
-
warning,
|
|
638
|
-
sx,
|
|
639
|
-
css,
|
|
640
|
-
rules,
|
|
641
|
-
id,
|
|
642
|
-
defaultValue,
|
|
643
|
-
onBlur,
|
|
644
|
-
onChange,
|
|
645
|
-
...selectProps
|
|
646
|
-
} = props;
|
|
647
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
648
|
-
id,
|
|
649
|
-
label,
|
|
650
|
-
name,
|
|
651
|
-
labelTooltip,
|
|
652
|
-
warning,
|
|
653
|
-
sx,
|
|
654
|
-
css,
|
|
655
|
-
defaultValue,
|
|
656
|
-
rules,
|
|
657
|
-
disabled,
|
|
658
|
-
render: /* @__PURE__ */__name(({
|
|
659
|
-
field,
|
|
660
|
-
fieldState
|
|
661
|
-
}) => {
|
|
662
|
-
return /* @__PURE__ */React.createElement(Select, {
|
|
663
|
-
...selectProps,
|
|
664
|
-
...field,
|
|
665
|
-
onBlur: /* @__PURE__ */__name(e => {
|
|
666
|
-
field.onBlur();
|
|
667
|
-
onBlur?.(e);
|
|
668
|
-
}, "onBlur"),
|
|
669
|
-
onChange: /* @__PURE__ */__name(newValue => {
|
|
670
|
-
field.onChange(newValue);
|
|
671
|
-
onChange?.(newValue);
|
|
672
|
-
}, "onChange"),
|
|
673
|
-
isDisabled: disabled ?? field.disabled,
|
|
674
|
-
"aria-invalid": fieldState.error ? "true" : void 0
|
|
675
|
-
});
|
|
676
|
-
}, "render")
|
|
677
|
-
});
|
|
678
|
-
}, "FormFieldSelect");
|
|
679
|
-
|
|
680
|
-
// src/FormFieldSwitch.tsx
|
|
681
|
-
import { Switch } from "@ttoss/ui";
|
|
682
|
-
var FormFieldSwitch = /* @__PURE__ */__name(({
|
|
683
|
-
disabled,
|
|
684
|
-
...props
|
|
685
|
-
}) => {
|
|
686
|
-
const {
|
|
687
|
-
label,
|
|
688
|
-
name,
|
|
689
|
-
labelTooltip,
|
|
690
|
-
warning,
|
|
691
|
-
sx,
|
|
692
|
-
css,
|
|
693
|
-
rules,
|
|
694
|
-
id,
|
|
695
|
-
defaultValue,
|
|
696
|
-
onBlur,
|
|
697
|
-
onChange,
|
|
698
|
-
...switchProps
|
|
699
|
-
} = props;
|
|
700
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
701
|
-
id,
|
|
702
|
-
label,
|
|
703
|
-
name,
|
|
704
|
-
labelTooltip,
|
|
705
|
-
warning,
|
|
706
|
-
sx,
|
|
707
|
-
css,
|
|
708
|
-
defaultValue,
|
|
709
|
-
rules,
|
|
710
|
-
disabled,
|
|
711
|
-
render: /* @__PURE__ */__name(({
|
|
712
|
-
field,
|
|
713
|
-
fieldState
|
|
714
|
-
}) => {
|
|
715
|
-
return /* @__PURE__ */React.createElement(Switch, {
|
|
716
|
-
...switchProps,
|
|
717
|
-
...field,
|
|
718
|
-
onBlur: /* @__PURE__ */__name(e => {
|
|
719
|
-
field.onBlur();
|
|
720
|
-
onBlur?.(e);
|
|
721
|
-
}, "onBlur"),
|
|
722
|
-
onChange: /* @__PURE__ */__name(e => {
|
|
723
|
-
field.onChange(e);
|
|
724
|
-
onChange?.(e);
|
|
725
|
-
}, "onChange"),
|
|
726
|
-
disabled: disabled ?? field.disabled,
|
|
727
|
-
"aria-invalid": !!fieldState.error
|
|
728
|
-
});
|
|
729
|
-
}, "render")
|
|
730
|
-
});
|
|
731
|
-
}, "FormFieldSwitch");
|
|
732
|
-
|
|
733
|
-
// src/FormFieldTextarea.tsx
|
|
734
|
-
import { Textarea } from "@ttoss/ui";
|
|
735
|
-
var FormFieldTextarea = /* @__PURE__ */__name(({
|
|
736
|
-
defaultValue = "",
|
|
737
|
-
disabled,
|
|
738
|
-
...props
|
|
739
|
-
}) => {
|
|
740
|
-
const {
|
|
741
|
-
label,
|
|
742
|
-
name,
|
|
743
|
-
labelTooltip,
|
|
744
|
-
warning,
|
|
745
|
-
sx,
|
|
746
|
-
css,
|
|
747
|
-
rules,
|
|
748
|
-
id,
|
|
749
|
-
auxiliaryCheckbox,
|
|
750
|
-
onBlur,
|
|
751
|
-
onChange,
|
|
752
|
-
...textareaProps
|
|
753
|
-
} = props;
|
|
754
|
-
return /* @__PURE__ */React.createElement(FormField, {
|
|
755
|
-
id,
|
|
756
|
-
label,
|
|
757
|
-
name,
|
|
758
|
-
labelTooltip,
|
|
759
|
-
warning,
|
|
760
|
-
sx,
|
|
761
|
-
css,
|
|
762
|
-
defaultValue,
|
|
763
|
-
rules,
|
|
764
|
-
disabled,
|
|
765
|
-
auxiliaryCheckbox,
|
|
766
|
-
render: /* @__PURE__ */__name(({
|
|
767
|
-
field,
|
|
768
|
-
fieldState
|
|
769
|
-
}) => {
|
|
770
|
-
return /* @__PURE__ */React.createElement(Textarea, {
|
|
771
|
-
...textareaProps,
|
|
772
|
-
...field,
|
|
773
|
-
onBlur: /* @__PURE__ */__name(e => {
|
|
774
|
-
field.onBlur();
|
|
775
|
-
onBlur?.(e);
|
|
776
|
-
}, "onBlur"),
|
|
777
|
-
onChange: /* @__PURE__ */__name(e => {
|
|
778
|
-
field.onChange(e);
|
|
779
|
-
onChange?.(e);
|
|
780
|
-
}, "onChange"),
|
|
781
|
-
disabled: disabled ?? field.disabled,
|
|
782
|
-
"aria-invalid": fieldState.error ? "true" : void 0
|
|
783
|
-
});
|
|
784
|
-
}, "render")
|
|
785
|
-
});
|
|
786
|
-
}, "FormFieldTextarea");
|
|
787
|
-
|
|
788
|
-
// src/FormGroup.tsx
|
|
789
|
-
import { Box as Box4, Flex as Flex4, Text as Text3 } from "@ttoss/ui";
|
|
790
|
-
import * as React4 from "react";
|
|
791
|
-
var FormGroupLevelsManagerContext = /* @__PURE__ */React4.createContext({
|
|
792
|
-
levelsLength: 1,
|
|
793
|
-
registerChild: /* @__PURE__ */__name(() => {
|
|
794
|
-
return null;
|
|
795
|
-
}, "registerChild")
|
|
796
|
-
});
|
|
797
|
-
var FormGroupLevelsManager = /* @__PURE__ */__name(({
|
|
798
|
-
children
|
|
799
|
-
}) => {
|
|
800
|
-
const [levelsLength, setLevelsLength] = React4.useState(0);
|
|
801
|
-
const registerChild = React4.useCallback(level => {
|
|
802
|
-
if (level + 1 > levelsLength) {
|
|
803
|
-
setLevelsLength(level + 1);
|
|
804
|
-
}
|
|
805
|
-
}, [levelsLength]);
|
|
806
|
-
return /* @__PURE__ */React4.createElement(FormGroupLevelsManagerContext.Provider, {
|
|
807
|
-
value: {
|
|
808
|
-
levelsLength,
|
|
809
|
-
registerChild
|
|
810
|
-
}
|
|
811
|
-
}, children);
|
|
812
|
-
}, "FormGroupLevelsManager");
|
|
813
|
-
var FormGroupContext = /* @__PURE__ */React4.createContext({});
|
|
814
|
-
var useFormGroup = /* @__PURE__ */__name(() => {
|
|
815
|
-
const {
|
|
816
|
-
parentLevel
|
|
817
|
-
} = React4.useContext(FormGroupContext);
|
|
818
|
-
const {
|
|
819
|
-
levelsLength
|
|
820
|
-
} = React4.useContext(FormGroupLevelsManagerContext);
|
|
821
|
-
return {
|
|
822
|
-
level: parentLevel,
|
|
823
|
-
levelsLength
|
|
824
|
-
};
|
|
825
|
-
}, "useFormGroup");
|
|
826
|
-
var FormGroupWrapper = /* @__PURE__ */__name(({
|
|
827
|
-
title,
|
|
828
|
-
direction,
|
|
829
|
-
children,
|
|
830
|
-
name,
|
|
831
|
-
...boxProps
|
|
832
|
-
}) => {
|
|
833
|
-
const {
|
|
834
|
-
level
|
|
835
|
-
} = useFormGroup();
|
|
836
|
-
const {
|
|
837
|
-
registerChild
|
|
838
|
-
} = React4.useContext(FormGroupLevelsManagerContext);
|
|
839
|
-
React4.useEffect(() => {
|
|
840
|
-
if (typeof level === "number") {
|
|
841
|
-
registerChild(level);
|
|
842
|
-
}
|
|
843
|
-
}, [level, registerChild]);
|
|
844
|
-
const childrenContainerSx = {
|
|
845
|
-
flexDirection: direction || "column",
|
|
846
|
-
gap: "1",
|
|
847
|
-
width: "100%"
|
|
848
|
-
};
|
|
849
|
-
return /* @__PURE__ */React4.createElement(Box4, {
|
|
850
|
-
"aria-level": level,
|
|
851
|
-
...boxProps,
|
|
852
|
-
sx: {
|
|
853
|
-
marginTop: level === 0 ? "none" : "4",
|
|
854
|
-
marginBottom: "4",
|
|
855
|
-
...boxProps.sx
|
|
856
|
-
}
|
|
857
|
-
}, title && /* @__PURE__ */React4.createElement(Box4, {
|
|
858
|
-
sx: {
|
|
859
|
-
marginBottom: "2"
|
|
860
|
-
}
|
|
861
|
-
}, /* @__PURE__ */React4.createElement(Text3, {
|
|
862
|
-
sx: {
|
|
863
|
-
fontSize: "2xl",
|
|
864
|
-
fontWeight: "bold"
|
|
865
|
-
}
|
|
866
|
-
}, title)), /* @__PURE__ */React4.createElement(Flex4, {
|
|
867
|
-
sx: childrenContainerSx
|
|
868
|
-
}, children), name && /* @__PURE__ */React4.createElement(FormErrorMessage, {
|
|
869
|
-
name
|
|
870
|
-
}));
|
|
871
|
-
}, "FormGroupWrapper");
|
|
872
|
-
var FormGroup = /* @__PURE__ */__name(props => {
|
|
873
|
-
const {
|
|
874
|
-
level
|
|
875
|
-
} = useFormGroup();
|
|
876
|
-
const currentLevel = level === void 0 ? 0 : level + 1;
|
|
877
|
-
return /* @__PURE__ */React4.createElement(FormGroupContext.Provider, {
|
|
878
|
-
value: {
|
|
879
|
-
parentLevel: currentLevel
|
|
880
|
-
}
|
|
881
|
-
}, currentLevel === 0 ? /* @__PURE__ */React4.createElement(FormGroupLevelsManager, null, /* @__PURE__ */React4.createElement(FormGroupWrapper, props)) : /* @__PURE__ */React4.createElement(FormGroupWrapper, props));
|
|
882
|
-
}, "FormGroup");
|
|
883
|
-
|
|
884
|
-
// src/yup/i18n.ts
|
|
885
|
-
import { defineMessage } from "@ttoss/react-i18n";
|
|
886
|
-
import { setLocale } from "yup";
|
|
887
|
-
setLocale({
|
|
888
|
-
mixed: {
|
|
889
|
-
required: defineMessage({
|
|
890
|
-
id: "MfWGyg",
|
|
891
|
-
defaultMessage: [{
|
|
892
|
-
"type": 0,
|
|
893
|
-
"value": "Field is required"
|
|
894
|
-
}]
|
|
895
|
-
}),
|
|
896
|
-
notType: /* @__PURE__ */__name(({
|
|
897
|
-
type
|
|
898
|
-
}) => {
|
|
899
|
-
return {
|
|
900
|
-
...defineMessage({
|
|
901
|
-
id: "ZhaPt0",
|
|
902
|
-
defaultMessage: [{
|
|
903
|
-
"type": 0,
|
|
904
|
-
"value": "Invalid Value for Field of type "
|
|
905
|
-
}, {
|
|
906
|
-
"type": 1,
|
|
907
|
-
"value": "type"
|
|
908
|
-
}]
|
|
909
|
-
}),
|
|
910
|
-
values: {
|
|
911
|
-
type
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
|
-
}, "notType")
|
|
915
|
-
},
|
|
916
|
-
string: {
|
|
917
|
-
min: /* @__PURE__ */__name(({
|
|
918
|
-
min
|
|
919
|
-
}) => {
|
|
920
|
-
return {
|
|
921
|
-
...defineMessage({
|
|
922
|
-
id: "D1C6fR",
|
|
923
|
-
defaultMessage: [{
|
|
924
|
-
"type": 0,
|
|
925
|
-
"value": "Field must be at least "
|
|
926
|
-
}, {
|
|
927
|
-
"type": 1,
|
|
928
|
-
"value": "min"
|
|
929
|
-
}, {
|
|
930
|
-
"type": 0,
|
|
931
|
-
"value": " characters"
|
|
932
|
-
}]
|
|
933
|
-
}),
|
|
934
|
-
values: {
|
|
935
|
-
min
|
|
936
|
-
}
|
|
937
|
-
};
|
|
938
|
-
}, "min")
|
|
939
|
-
}
|
|
940
|
-
});
|
|
941
|
-
|
|
942
|
-
// src/yup/schema.ts
|
|
943
|
-
import * as yup from "yup";
|
|
944
|
-
yup.addMethod(yup.string, "cnpj", function () {
|
|
945
|
-
return this.test("valid-cnpj", "Invalid CNPJ", value => {
|
|
946
|
-
return isCnpjValid(value);
|
|
947
|
-
});
|
|
948
|
-
});
|
|
949
|
-
yup.addMethod(yup.string, "cpf", function () {
|
|
950
|
-
return this.test("valid-cpf", "Invalid CPF", value => {
|
|
951
|
-
return isCpfValid(value);
|
|
952
|
-
});
|
|
953
|
-
});
|
|
954
|
-
yup.addMethod(yup.string, "password", function ({
|
|
955
|
-
required
|
|
956
|
-
} = {}) {
|
|
957
|
-
const schema = this.trim();
|
|
958
|
-
if (required) {
|
|
959
|
-
schema.required("Password is required");
|
|
960
|
-
}
|
|
961
|
-
return schema.min(8, "Password must be at least 8 characters long");
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
// src/yup/yup.ts
|
|
965
|
-
import * as yup2 from "yup";
|
|
966
|
-
|
|
967
|
-
// src/index.ts
|
|
968
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
969
|
-
import { Controller, FormProvider as FormProvider2, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from "react-hook-form";
|
|
970
|
-
export * from "react-hook-form";
|
|
971
|
-
export { Form, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldNumericFormat, FormFieldCurrencyInput, FormFieldDatePicker, FormFieldInput, FormFieldPassword, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, useFormGroup, FormGroup, yup2 as yup, yupResolver, Controller, FormProvider2 as FormProvider, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };
|