@ttoss/forms 0.17.9 → 0.17.11

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
  });
@@ -255,6 +257,9 @@ var FormFieldRadio = ({
255
257
  ...sx
256
258
  },
257
259
  children: [label && /* @__PURE__ */jsx7(Label3, {
260
+ sx: {
261
+ marginBottom: "md"
262
+ },
258
263
  children: label
259
264
  }), /* @__PURE__ */jsx7(Box2, {
260
265
  children: options.map(option => {
@@ -282,7 +287,11 @@ var FormFieldRadio = ({
282
287
  // src/FormFieldSelect.tsx
283
288
  import { Select } from "@ttoss/ui";
284
289
  import { jsx as jsx8 } from "react/jsx-runtime";
285
- var checkDefaultValue = (options, defaultValue, placeholder) => {
290
+ var checkDefaultValue = ({
291
+ options,
292
+ defaultValue,
293
+ placeholder
294
+ }) => {
286
295
  if (defaultValue) {
287
296
  return defaultValue;
288
297
  }
@@ -315,7 +324,11 @@ var FormFieldSelect = ({
315
324
  defaultValue,
316
325
  placeholder
317
326
  } = selectProps;
318
- const checkedDefaultValue = checkDefaultValue(options, defaultValue, placeholder);
327
+ const checkedDefaultValue = checkDefaultValue({
328
+ options,
329
+ defaultValue,
330
+ placeholder
331
+ });
319
332
  return /* @__PURE__ */jsx8(FormField, {
320
333
  name,
321
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
  });
@@ -307,6 +309,9 @@ var FormFieldRadio = ({
307
309
  ...sx
308
310
  },
309
311
  children: [label && /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_ui7.Label, {
312
+ sx: {
313
+ marginBottom: "md"
314
+ },
310
315
  children: label
311
316
  }), /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_ui7.Box, {
312
317
  children: options.map(option => {
@@ -334,7 +339,11 @@ var FormFieldRadio = ({
334
339
  // src/FormFieldSelect.tsx
335
340
  var import_ui8 = require("@ttoss/ui");
336
341
  var import_jsx_runtime8 = require("react/jsx-runtime");
337
- var checkDefaultValue = (options, defaultValue, placeholder) => {
342
+ var checkDefaultValue = ({
343
+ options,
344
+ defaultValue,
345
+ placeholder
346
+ }) => {
338
347
  if (defaultValue) {
339
348
  return defaultValue;
340
349
  }
@@ -367,7 +376,11 @@ var FormFieldSelect = ({
367
376
  defaultValue,
368
377
  placeholder
369
378
  } = selectProps;
370
- const checkedDefaultValue = checkDefaultValue(options, defaultValue, placeholder);
379
+ const checkedDefaultValue = checkDefaultValue({
380
+ options,
381
+ defaultValue,
382
+ placeholder
383
+ });
371
384
  return /* @__PURE__ */(0, import_jsx_runtime8.jsx)(FormField, {
372
385
  name,
373
386
  label,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/forms",
3
- "version": "0.17.9",
3
+ "version": "0.17.11",
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.8"
25
+ "@ttoss/ui": "^1.36.10"
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.8"
38
+ "@ttoss/ui": "^1.36.10"
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
  />
@@ -27,9 +27,9 @@ export const FormFieldRadio = <TFieldValues extends FieldValues = FieldValues>({
27
27
 
28
28
  return (
29
29
  <Flex sx={{ flexDirection: 'column', width: '100%', ...sx }}>
30
- {label && <Label>{label}</Label>}
30
+ {label && <Label sx={{ marginBottom: 'md' }}>{label}</Label>}
31
31
  <Box>
32
- {options.map((option) => {
32
+ {options.map((option: FormRadioOption) => {
33
33
  const id = `form-field-radio-${name}-${option.value}`;
34
34
 
35
35
  return (
@@ -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}