@ttoss/forms 0.17.10 → 0.17.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -94,6 +94,7 @@ var FormField = ({
94
94
  sx: {
95
95
  flexDirection: "column",
96
96
  width: "100%",
97
+ gap: "md",
97
98
  ...sx
98
99
  },
99
100
  children: [memoizedRender, /* @__PURE__ */jsx3(ErrorMessage, {
@@ -186,7 +187,8 @@ var FormFieldInput = ({
186
187
  return /* @__PURE__ */jsx5(Input, {
187
188
  ...inputProps,
188
189
  ...field,
189
- "aria-invalid": hasError.valueOf()
190
+ "aria-invalid": hasError.valueOf(),
191
+ trailingIcon: hasError ? "warning-alt" : void 0
190
192
  });
191
193
  }
192
194
  });
@@ -285,7 +287,11 @@ var FormFieldRadio = ({
285
287
  // src/FormFieldSelect.tsx
286
288
  import { Select } from "@ttoss/ui";
287
289
  import { jsx as jsx8 } from "react/jsx-runtime";
288
- var checkDefaultValue = (options, defaultValue, placeholder) => {
290
+ var checkDefaultValue = ({
291
+ options,
292
+ defaultValue,
293
+ placeholder
294
+ }) => {
289
295
  if (defaultValue) {
290
296
  return defaultValue;
291
297
  }
@@ -318,7 +324,11 @@ var FormFieldSelect = ({
318
324
  defaultValue,
319
325
  placeholder
320
326
  } = selectProps;
321
- const checkedDefaultValue = checkDefaultValue(options, defaultValue, placeholder);
327
+ const checkedDefaultValue = checkDefaultValue({
328
+ options,
329
+ defaultValue,
330
+ placeholder
331
+ });
322
332
  return /* @__PURE__ */jsx8(FormField, {
323
333
  name,
324
334
  label,
package/dist/index.js CHANGED
@@ -146,6 +146,7 @@ var FormField = ({
146
146
  sx: {
147
147
  flexDirection: "column",
148
148
  width: "100%",
149
+ gap: "md",
149
150
  ...sx
150
151
  },
151
152
  children: [memoizedRender, /* @__PURE__ */(0, import_jsx_runtime3.jsx)(ErrorMessage, {
@@ -238,7 +239,8 @@ var FormFieldInput = ({
238
239
  return /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui5.Input, {
239
240
  ...inputProps,
240
241
  ...field,
241
- "aria-invalid": hasError.valueOf()
242
+ "aria-invalid": hasError.valueOf(),
243
+ trailingIcon: hasError ? "warning-alt" : void 0
242
244
  });
243
245
  }
244
246
  });
@@ -337,7 +339,11 @@ var FormFieldRadio = ({
337
339
  // src/FormFieldSelect.tsx
338
340
  var import_ui8 = require("@ttoss/ui");
339
341
  var import_jsx_runtime8 = require("react/jsx-runtime");
340
- var checkDefaultValue = (options, defaultValue, placeholder) => {
342
+ var checkDefaultValue = ({
343
+ options,
344
+ defaultValue,
345
+ placeholder
346
+ }) => {
341
347
  if (defaultValue) {
342
348
  return defaultValue;
343
349
  }
@@ -370,7 +376,11 @@ var FormFieldSelect = ({
370
376
  defaultValue,
371
377
  placeholder
372
378
  } = selectProps;
373
- const checkedDefaultValue = checkDefaultValue(options, defaultValue, placeholder);
379
+ const checkedDefaultValue = checkDefaultValue({
380
+ options,
381
+ defaultValue,
382
+ placeholder
383
+ });
374
384
  return /* @__PURE__ */(0, import_jsx_runtime8.jsx)(FormField, {
375
385
  name,
376
386
  label,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/forms",
3
- "version": "0.17.10",
3
+ "version": "0.17.12",
4
4
  "license": "UNLICENSED",
5
5
  "author": "ttoss",
6
6
  "contributors": [
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": ">=16.8.0",
25
- "@ttoss/ui": "^1.36.9"
25
+ "@ttoss/ui": "^1.36.11"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/jest": "^29.5.1",
@@ -35,7 +35,7 @@
35
35
  "yup": "^1.1.1",
36
36
  "@ttoss/config": "^1.30.0",
37
37
  "@ttoss/test-utils": "^1.23.1",
38
- "@ttoss/ui": "^1.36.9"
38
+ "@ttoss/ui": "^1.36.11"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
package/src/FormField.tsx CHANGED
@@ -78,7 +78,7 @@ export const FormField = <
78
78
  ]);
79
79
 
80
80
  return (
81
- <Flex sx={{ flexDirection: 'column', width: '100%', ...sx }}>
81
+ <Flex sx={{ flexDirection: 'column', width: '100%', gap: 'md', ...sx }}>
82
82
  {memoizedRender}
83
83
  <ErrorMessage name={name} />
84
84
  </Flex>
@@ -33,7 +33,12 @@ export const FormFieldInput = <
33
33
  const hasError = !!formState.errors[name]?.message;
34
34
 
35
35
  return (
36
- <Input {...inputProps} {...field} aria-invalid={hasError.valueOf()} />
36
+ <Input
37
+ {...inputProps}
38
+ {...field}
39
+ aria-invalid={hasError.valueOf()}
40
+ trailingIcon={hasError ? 'warning-alt' : undefined}
41
+ />
37
42
  );
38
43
  }}
39
44
  />
@@ -14,11 +14,15 @@ type SelectSwitchProps =
14
14
  const checkDefaultValue = <
15
15
  TFieldValues extends FieldValues = FieldValues,
16
16
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
17
- >(
18
- options: Array<FormRadioOption>,
19
- defaultValue?: FieldPathValue<TFieldValues, TName>,
20
- placeholder?: string
21
- ): FieldPathValue<TFieldValues, TName> => {
17
+ >({
18
+ options,
19
+ defaultValue,
20
+ placeholder,
21
+ }: {
22
+ options: Array<FormRadioOption>;
23
+ defaultValue?: FieldPathValue<TFieldValues, TName>;
24
+ placeholder?: string;
25
+ }): FieldPathValue<TFieldValues, TName> => {
22
26
  if (defaultValue) {
23
27
  return defaultValue;
24
28
  }
@@ -70,11 +74,11 @@ export const FormFieldSelect = <
70
74
  }: FormFieldSelectProps<TFieldValues, TName>) => {
71
75
  const { defaultValue, placeholder } = selectProps;
72
76
 
73
- const checkedDefaultValue = checkDefaultValue<TFieldValues, TName>(
77
+ const checkedDefaultValue = checkDefaultValue<TFieldValues, TName>({
74
78
  options,
75
79
  defaultValue,
76
- placeholder
77
- );
80
+ placeholder,
81
+ });
78
82
 
79
83
  return (
80
84
  <FormField
@@ -92,7 +96,7 @@ export const FormFieldSelect = <
92
96
  {...field}
93
97
  {...{ ...selectProps, defaultValue: undefined }}
94
98
  >
95
- {options.map((option) => {
99
+ {options.map((option: FormRadioOption) => {
96
100
  return (
97
101
  <option key={option.label} value={option.value}>
98
102
  {option.label}