@ttoss/forms 0.18.6 → 0.18.8
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 +1 -1
- package/dist/esm/index.js +5 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +23 -22
- package/package.json +11 -11
- package/src/FormFieldInput.tsx +2 -7
- package/src/FormFieldSelect.tsx +2 -1
package/README.md
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -236,7 +236,7 @@ var FormFieldCheckbox = ({
|
|
|
236
236
|
};
|
|
237
237
|
|
|
238
238
|
// src/FormFieldInput.tsx
|
|
239
|
-
import { Input } from "@ttoss/ui";
|
|
239
|
+
import { Input } from "@ttoss/ui/src";
|
|
240
240
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
241
241
|
var FormFieldInput = ({
|
|
242
242
|
label,
|
|
@@ -263,8 +263,7 @@ var FormFieldInput = ({
|
|
|
263
263
|
return /* @__PURE__ */jsx5(Input, {
|
|
264
264
|
...inputProps,
|
|
265
265
|
...field,
|
|
266
|
-
"aria-invalid": hasError.valueOf()
|
|
267
|
-
trailingIcon: hasError ? "warning-alt" : void 0
|
|
266
|
+
"aria-invalid": hasError.valueOf()
|
|
268
267
|
});
|
|
269
268
|
}
|
|
270
269
|
});
|
|
@@ -414,7 +413,8 @@ var FormFieldSelect = ({
|
|
|
414
413
|
sx,
|
|
415
414
|
defaultValue: checkedDefaultValue,
|
|
416
415
|
render: ({
|
|
417
|
-
field
|
|
416
|
+
field,
|
|
417
|
+
fieldState
|
|
418
418
|
}) => {
|
|
419
419
|
return /* @__PURE__ */jsx8(Select, {
|
|
420
420
|
...selectProps,
|
|
@@ -423,6 +423,7 @@ var FormFieldSelect = ({
|
|
|
423
423
|
...selectProps,
|
|
424
424
|
defaultValue: void 0
|
|
425
425
|
},
|
|
426
|
+
"aria-invalid": fieldState.error ? "true" : void 0,
|
|
426
427
|
children: options.map(option => {
|
|
427
428
|
return /* @__PURE__ */jsx8("option", {
|
|
428
429
|
value: option.value,
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ import * as yup from 'yup';
|
|
|
6
6
|
export { yup };
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import * as React from 'react';
|
|
9
|
-
import { BoxProps, FlexProps, CheckboxProps,
|
|
9
|
+
import { BoxProps, FlexProps, CheckboxProps, InputPasswordProps, RadioProps, SelectProps, TextareaProps } from '@ttoss/ui';
|
|
10
|
+
import { InputProps } from '@ttoss/ui/src';
|
|
10
11
|
|
|
11
12
|
declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children, onSubmit, sx, ...formMethods }: {
|
|
12
13
|
children?: React.ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -272,7 +272,7 @@ var FormFieldCheckbox = ({
|
|
|
272
272
|
};
|
|
273
273
|
|
|
274
274
|
// src/FormFieldInput.tsx
|
|
275
|
-
var
|
|
275
|
+
var import_src = require("@ttoss/ui/src");
|
|
276
276
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
277
277
|
var FormFieldInput = ({
|
|
278
278
|
label,
|
|
@@ -296,18 +296,17 @@ var FormFieldInput = ({
|
|
|
296
296
|
formState
|
|
297
297
|
}) => {
|
|
298
298
|
const hasError = !!formState.errors[name]?.message;
|
|
299
|
-
return /* @__PURE__ */(0, import_jsx_runtime5.jsx)(
|
|
299
|
+
return /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_src.Input, {
|
|
300
300
|
...inputProps,
|
|
301
301
|
...field,
|
|
302
|
-
"aria-invalid": hasError.valueOf()
|
|
303
|
-
trailingIcon: hasError ? "warning-alt" : void 0
|
|
302
|
+
"aria-invalid": hasError.valueOf()
|
|
304
303
|
});
|
|
305
304
|
}
|
|
306
305
|
});
|
|
307
306
|
};
|
|
308
307
|
|
|
309
308
|
// src/FormFieldPassword.tsx
|
|
310
|
-
var
|
|
309
|
+
var import_ui5 = require("@ttoss/ui");
|
|
311
310
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
312
311
|
var FormFieldPassword = ({
|
|
313
312
|
label,
|
|
@@ -331,7 +330,7 @@ var FormFieldPassword = ({
|
|
|
331
330
|
formState
|
|
332
331
|
}) => {
|
|
333
332
|
const hasError = !!formState.errors[name]?.message;
|
|
334
|
-
return /* @__PURE__ */(0, import_jsx_runtime6.jsx)(
|
|
333
|
+
return /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_ui5.InputPassword, {
|
|
335
334
|
...inputProps,
|
|
336
335
|
...field,
|
|
337
336
|
"aria-invalid": hasError.valueOf()
|
|
@@ -341,7 +340,7 @@ var FormFieldPassword = ({
|
|
|
341
340
|
};
|
|
342
341
|
|
|
343
342
|
// src/FormFieldRadio.tsx
|
|
344
|
-
var
|
|
343
|
+
var import_ui6 = require("@ttoss/ui");
|
|
345
344
|
var import_react_hook_form5 = require("react-hook-form");
|
|
346
345
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
347
346
|
var FormFieldRadio = ({
|
|
@@ -362,23 +361,23 @@ var FormFieldRadio = ({
|
|
|
362
361
|
name,
|
|
363
362
|
defaultValue: ""
|
|
364
363
|
});
|
|
365
|
-
return /* @__PURE__ */(0, import_jsx_runtime7.jsxs)(
|
|
364
|
+
return /* @__PURE__ */(0, import_jsx_runtime7.jsxs)(import_ui6.Flex, {
|
|
366
365
|
sx: {
|
|
367
366
|
flexDirection: "column",
|
|
368
367
|
width: "100%",
|
|
369
368
|
...sx
|
|
370
369
|
},
|
|
371
|
-
children: [label && /* @__PURE__ */(0, import_jsx_runtime7.jsx)(
|
|
370
|
+
children: [label && /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_ui6.Label, {
|
|
372
371
|
sx: {
|
|
373
372
|
marginBottom: "md"
|
|
374
373
|
},
|
|
375
374
|
children: label
|
|
376
|
-
}), /* @__PURE__ */(0, import_jsx_runtime7.jsx)(
|
|
375
|
+
}), /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_ui6.Box, {
|
|
377
376
|
children: options.map(option => {
|
|
378
377
|
const id = `form-field-radio-${name}-${option.value}`;
|
|
379
|
-
return /* @__PURE__ */(0, import_jsx_runtime7.jsxs)(
|
|
378
|
+
return /* @__PURE__ */(0, import_jsx_runtime7.jsxs)(import_ui6.Label, {
|
|
380
379
|
htmlFor: id,
|
|
381
|
-
children: [/* @__PURE__ */(0, import_jsx_runtime7.jsx)(
|
|
380
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_ui6.Radio, {
|
|
382
381
|
ref,
|
|
383
382
|
onChange,
|
|
384
383
|
onBlur,
|
|
@@ -397,7 +396,7 @@ var FormFieldRadio = ({
|
|
|
397
396
|
};
|
|
398
397
|
|
|
399
398
|
// src/FormFieldSelect.tsx
|
|
400
|
-
var
|
|
399
|
+
var import_ui7 = require("@ttoss/ui");
|
|
401
400
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
402
401
|
var checkDefaultValue = ({
|
|
403
402
|
options,
|
|
@@ -450,15 +449,17 @@ var FormFieldSelect = ({
|
|
|
450
449
|
sx,
|
|
451
450
|
defaultValue: checkedDefaultValue,
|
|
452
451
|
render: ({
|
|
453
|
-
field
|
|
452
|
+
field,
|
|
453
|
+
fieldState
|
|
454
454
|
}) => {
|
|
455
|
-
return /* @__PURE__ */(0, import_jsx_runtime8.jsx)(
|
|
455
|
+
return /* @__PURE__ */(0, import_jsx_runtime8.jsx)(import_ui7.Select, {
|
|
456
456
|
...selectProps,
|
|
457
457
|
...field,
|
|
458
458
|
...{
|
|
459
459
|
...selectProps,
|
|
460
460
|
defaultValue: void 0
|
|
461
461
|
},
|
|
462
|
+
"aria-invalid": fieldState.error ? "true" : void 0,
|
|
462
463
|
children: options.map(option => {
|
|
463
464
|
return /* @__PURE__ */(0, import_jsx_runtime8.jsx)("option", {
|
|
464
465
|
value: option.value,
|
|
@@ -471,7 +472,7 @@ var FormFieldSelect = ({
|
|
|
471
472
|
};
|
|
472
473
|
|
|
473
474
|
// src/FormFieldTextarea.tsx
|
|
474
|
-
var
|
|
475
|
+
var import_ui8 = require("@ttoss/ui");
|
|
475
476
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
476
477
|
var FormFieldTextarea = ({
|
|
477
478
|
label,
|
|
@@ -488,7 +489,7 @@ var FormFieldTextarea = ({
|
|
|
488
489
|
render: ({
|
|
489
490
|
field
|
|
490
491
|
}) => {
|
|
491
|
-
return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(
|
|
492
|
+
return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(import_ui8.Textarea, {
|
|
492
493
|
...field,
|
|
493
494
|
...textareaProps
|
|
494
495
|
});
|
|
@@ -498,7 +499,7 @@ var FormFieldTextarea = ({
|
|
|
498
499
|
|
|
499
500
|
// src/FormGroup.tsx
|
|
500
501
|
var React3 = __toESM(require("react"));
|
|
501
|
-
var
|
|
502
|
+
var import_ui9 = require("@ttoss/ui");
|
|
502
503
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
503
504
|
var FormGroupLevelsManagerContext = React3.createContext({
|
|
504
505
|
levelsLength: 1,
|
|
@@ -558,7 +559,7 @@ var FormGroupWrapper = ({
|
|
|
558
559
|
gap: "md",
|
|
559
560
|
width: "100%"
|
|
560
561
|
};
|
|
561
|
-
return /* @__PURE__ */(0, import_jsx_runtime10.jsxs)(
|
|
562
|
+
return /* @__PURE__ */(0, import_jsx_runtime10.jsxs)(import_ui9.Box, {
|
|
562
563
|
"aria-level": level,
|
|
563
564
|
...boxProps,
|
|
564
565
|
sx: {
|
|
@@ -566,18 +567,18 @@ var FormGroupWrapper = ({
|
|
|
566
567
|
marginBottom: "lg",
|
|
567
568
|
...boxProps.sx
|
|
568
569
|
},
|
|
569
|
-
children: [title && /* @__PURE__ */(0, import_jsx_runtime10.jsx)(
|
|
570
|
+
children: [title && /* @__PURE__ */(0, import_jsx_runtime10.jsx)(import_ui9.Box, {
|
|
570
571
|
sx: {
|
|
571
572
|
marginBottom: "md"
|
|
572
573
|
},
|
|
573
|
-
children: /* @__PURE__ */(0, import_jsx_runtime10.jsx)(
|
|
574
|
+
children: /* @__PURE__ */(0, import_jsx_runtime10.jsx)(import_ui9.Text, {
|
|
574
575
|
sx: {
|
|
575
576
|
fontSize: "2xl",
|
|
576
577
|
fontWeight: "bold"
|
|
577
578
|
},
|
|
578
579
|
children: title
|
|
579
580
|
})
|
|
580
|
-
}), /* @__PURE__ */(0, import_jsx_runtime10.jsx)(
|
|
581
|
+
}), /* @__PURE__ */(0, import_jsx_runtime10.jsx)(import_ui9.Flex, {
|
|
581
582
|
sx: childrenContainerSx,
|
|
582
583
|
children
|
|
583
584
|
})]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/forms",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.8",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": ">=16.8.0",
|
|
30
|
-
"@ttoss/react-i18n": "^1.23.
|
|
31
|
-
"@ttoss/ui": "^2.0.
|
|
30
|
+
"@ttoss/react-i18n": "^1.23.5",
|
|
31
|
+
"@ttoss/ui": "^2.0.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/jest": "^29.5.2",
|
|
35
|
-
"@types/react": "^18.2.
|
|
35
|
+
"@types/react": "^18.2.12",
|
|
36
36
|
"jest": "^29.5.0",
|
|
37
37
|
"react": "^18.2.0",
|
|
38
38
|
"react-error-boundary": "^4.0.9",
|
|
39
39
|
"react-hook-form": "^7.44.3",
|
|
40
|
-
"theme-ui": "^0.
|
|
41
|
-
"tsup": "^
|
|
40
|
+
"theme-ui": "^0.16.0",
|
|
41
|
+
"tsup": "^7.0.0",
|
|
42
42
|
"yup": "^1.2.0",
|
|
43
|
-
"@ttoss/config": "^1.30.
|
|
44
|
-
"@ttoss/i18n-cli": "^0.6.
|
|
45
|
-
"@ttoss/react-i18n": "^1.23.
|
|
46
|
-
"@ttoss/test-utils": "^1.23.
|
|
47
|
-
"@ttoss/ui": "^2.0.
|
|
43
|
+
"@ttoss/config": "^1.30.4",
|
|
44
|
+
"@ttoss/i18n-cli": "^0.6.3",
|
|
45
|
+
"@ttoss/react-i18n": "^1.23.5",
|
|
46
|
+
"@ttoss/test-utils": "^1.23.5",
|
|
47
|
+
"@ttoss/ui": "^2.0.2"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public",
|
package/src/FormFieldInput.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldPath, FieldPathValue, FieldValues } from 'react-hook-form';
|
|
2
2
|
import { FormField, type FormFieldProps } from './FormField';
|
|
3
|
-
import { Input, type InputProps } from '@ttoss/ui';
|
|
3
|
+
import { Input, type InputProps } from '@ttoss/ui/src';
|
|
4
4
|
|
|
5
5
|
export type FormFieldInputProps<TName> = {
|
|
6
6
|
label?: string;
|
|
@@ -33,12 +33,7 @@ export const FormFieldInput = <
|
|
|
33
33
|
const hasError = !!formState.errors[name]?.message;
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<Input
|
|
37
|
-
{...inputProps}
|
|
38
|
-
{...field}
|
|
39
|
-
aria-invalid={hasError.valueOf()}
|
|
40
|
-
trailingIcon={hasError ? 'warning-alt' : undefined}
|
|
41
|
-
/>
|
|
36
|
+
<Input {...inputProps} {...field} aria-invalid={hasError.valueOf()} />
|
|
42
37
|
);
|
|
43
38
|
}}
|
|
44
39
|
/>
|
package/src/FormFieldSelect.tsx
CHANGED
|
@@ -89,12 +89,13 @@ export const FormFieldSelect = <
|
|
|
89
89
|
onTooltipClick={selectProps.onTooltipClick}
|
|
90
90
|
sx={sx}
|
|
91
91
|
defaultValue={checkedDefaultValue}
|
|
92
|
-
render={({ field }) => {
|
|
92
|
+
render={({ field, fieldState }) => {
|
|
93
93
|
return (
|
|
94
94
|
<Select
|
|
95
95
|
{...selectProps}
|
|
96
96
|
{...field}
|
|
97
97
|
{...{ ...selectProps, defaultValue: undefined }}
|
|
98
|
+
aria-invalid={fieldState.error ? 'true' : undefined}
|
|
98
99
|
>
|
|
99
100
|
{options.map((option: FormRadioOption) => {
|
|
100
101
|
return (
|