@ttoss/forms 0.9.0 → 0.10.0

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
@@ -3,6 +3,11 @@
3
3
  // tsup.inject.js
4
4
  import * as React from "react";
5
5
 
6
+ // src/index.ts
7
+ import { yupResolver } from "@hookform/resolvers/yup";
8
+ export * from "react-hook-form";
9
+ import * as yup from "yup";
10
+
6
11
  // src/Form.tsx
7
12
  import { Box } from "@ttoss/ui";
8
13
  import { FormProvider } from "react-hook-form";
@@ -56,7 +61,8 @@ import { useController } from "react-hook-form";
56
61
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
57
62
  var FormFieldCheckbox = ({
58
63
  label,
59
- name
64
+ name,
65
+ disabled
60
66
  }) => {
61
67
  const {
62
68
  field: { onChange, onBlur, value, ref }
@@ -73,11 +79,13 @@ var FormFieldCheckbox = ({
73
79
  /* @__PURE__ */ jsx3(Checkbox, {
74
80
  id,
75
81
  ref,
82
+ disabled,
76
83
  checked: value,
77
84
  onChange,
78
85
  onBlur
79
86
  }),
80
87
  label && /* @__PURE__ */ jsx3(Label, {
88
+ "aria-disabled": disabled,
81
89
  htmlFor: id,
82
90
  children: label
83
91
  })
@@ -96,7 +104,9 @@ import { useController as useController2 } from "react-hook-form";
96
104
  import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
97
105
  var FormFieldInput = ({
98
106
  label,
99
- name
107
+ name,
108
+ disabled,
109
+ placeholder
100
110
  }) => {
101
111
  const {
102
112
  field: { onChange, onBlur, value, ref }
@@ -108,6 +118,7 @@ var FormFieldInput = ({
108
118
  return /* @__PURE__ */ jsxs2(Box3, {
109
119
  children: [
110
120
  label && /* @__PURE__ */ jsx4(Label2, {
121
+ "aria-disabled": disabled,
111
122
  htmlFor: id,
112
123
  children: label
113
124
  }),
@@ -117,6 +128,8 @@ var FormFieldInput = ({
117
128
  onBlur,
118
129
  value,
119
130
  name,
131
+ disabled,
132
+ placeholder,
120
133
  id
121
134
  }),
122
135
  /* @__PURE__ */ jsx4(ErrorMessage, {
@@ -226,14 +239,13 @@ FormField.Input = FormFieldInput;
226
239
  FormField.Radio = FormFieldRadio;
227
240
  FormField.Select = FormFieldSelect;
228
241
  FormField.Checkbox = FormFieldCheckbox;
229
-
230
- // src/index.ts
231
- import { yupResolver } from "@hookform/resolvers/yup";
232
- export * from "react-hook-form";
233
- import * as yup from "yup";
234
242
  export {
235
243
  Form,
236
244
  FormField,
245
+ FormFieldCheckbox,
246
+ FormFieldInput,
247
+ FormFieldRadio,
248
+ FormFieldSelect,
237
249
  yup,
238
250
  yupResolver
239
251
  };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
+ export { yupResolver } from '@hookform/resolvers/yup';
1
2
  import * as react_hook_form from 'react-hook-form';
2
- import { FieldValues } from 'react-hook-form';
3
+ import { FieldValues, Path } from 'react-hook-form';
3
4
  export * from 'react-hook-form';
4
- import * as React from 'react';
5
- import { BoxProps } from '@ttoss/ui';
6
- export { yupResolver } from '@hookform/resolvers/yup';
7
5
  import * as yup from 'yup';
8
6
  export { yup };
7
+ import * as React from 'react';
8
+ import { BoxProps, SelectProps } from '@ttoss/ui';
9
9
 
10
10
  declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children, onSubmit, sx, ...formMethods }: {
11
11
  children?: React.ReactNode;
@@ -15,17 +15,24 @@ declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children,
15
15
  children: React.ReactNode | React.ReactNode[];
16
16
  } & react_hook_form.UseFormReturn<TFieldValues, any>) => JSX.Element;
17
17
 
18
+ /**
19
+ * DEPRECATED: Use `FormFieldInput` instead.
20
+ */
18
21
  declare const FormField: {
19
22
  (): null;
20
- Input: <TFieldValues extends react_hook_form.FieldValues = react_hook_form.FieldValues>({ label, name, }: {
23
+ Input: <TFieldValues extends react_hook_form.FieldValues = react_hook_form.FieldValues>({ label, name, disabled, placeholder, }: {
21
24
  label?: string | undefined;
22
25
  name: react_hook_form.Path<TFieldValues>;
26
+ disabled?: boolean | undefined;
27
+ placeholder?: string | undefined;
23
28
  }) => JSX.Element;
24
29
  Radio: <TFieldValues_1 extends react_hook_form.FieldValues = react_hook_form.FieldValues>({ label, name, options, }: {
25
30
  label?: string | undefined;
26
31
  name: react_hook_form.Path<TFieldValues_1>;
27
32
  options: {
28
- value: string | number;
33
+ value: string | number; /**
34
+ * DEPRECATED: Use `FormFieldInput` instead.
35
+ */
29
36
  label: string;
30
37
  }[];
31
38
  }) => JSX.Element;
@@ -38,10 +45,45 @@ declare const FormField: {
38
45
  }[];
39
46
  arrow?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
40
47
  }) => JSX.Element;
41
- Checkbox: <TFieldValues_3 extends react_hook_form.FieldValues = react_hook_form.FieldValues>({ label, name, }: {
48
+ Checkbox: <TFieldValues_3 extends react_hook_form.FieldValues = react_hook_form.FieldValues>({ label, name, disabled, }: {
42
49
  label?: string | undefined;
43
50
  name: react_hook_form.Path<TFieldValues_3>;
51
+ disabled?: boolean | undefined;
44
52
  }) => JSX.Element;
45
53
  };
46
54
 
47
- export { Form, FormField };
55
+ declare const FormFieldCheckbox: <TFieldValues extends FieldValues = FieldValues>({ label, name, disabled, }: {
56
+ label?: string | undefined;
57
+ name: Path<TFieldValues>;
58
+ disabled?: boolean | undefined;
59
+ }) => JSX.Element;
60
+
61
+ declare const FormFieldInput: <TFieldValues extends FieldValues = FieldValues>({ label, name, disabled, placeholder, }: {
62
+ label?: string | undefined;
63
+ name: Path<TFieldValues>;
64
+ disabled?: boolean | undefined;
65
+ placeholder?: string | undefined;
66
+ }) => JSX.Element;
67
+
68
+ declare type FormRadioOption$1 = {
69
+ value: string | number;
70
+ label: string;
71
+ };
72
+ declare const FormFieldRadio: <TFieldValues extends FieldValues = FieldValues>({ label, name, options, }: {
73
+ label?: string | undefined;
74
+ name: Path<TFieldValues>;
75
+ options: FormRadioOption$1[];
76
+ }) => JSX.Element;
77
+
78
+ declare type FormRadioOption = {
79
+ value: string | number;
80
+ label: string;
81
+ };
82
+ declare const FormFieldSelect: <TFieldValues extends FieldValues = FieldValues>({ label, name, options, arrow, }: {
83
+ label?: string | undefined;
84
+ name: Path<TFieldValues>;
85
+ options: FormRadioOption[];
86
+ arrow?: SelectProps['arrow'];
87
+ }) => JSX.Element;
88
+
89
+ export { Form, FormField, FormFieldCheckbox, FormFieldInput, FormFieldRadio, FormFieldSelect };
package/dist/index.js CHANGED
@@ -30,6 +30,10 @@ var src_exports = {};
30
30
  __export(src_exports, {
31
31
  Form: () => Form,
32
32
  FormField: () => FormField,
33
+ FormFieldCheckbox: () => FormFieldCheckbox,
34
+ FormFieldInput: () => FormFieldInput,
35
+ FormFieldRadio: () => FormFieldRadio,
36
+ FormFieldSelect: () => FormFieldSelect,
33
37
  yup: () => yup,
34
38
  yupResolver: () => import_yup.yupResolver
35
39
  });
@@ -38,6 +42,11 @@ module.exports = __toCommonJS(src_exports);
38
42
  // tsup.inject.js
39
43
  var React = __toESM(require("react"));
40
44
 
45
+ // src/index.ts
46
+ var import_yup = require("@hookform/resolvers/yup");
47
+ __reExport(src_exports, require("react-hook-form"), module.exports);
48
+ var yup = __toESM(require("yup"));
49
+
41
50
  // src/Form.tsx
42
51
  var import_ui = require("@ttoss/ui");
43
52
  var import_react_hook_form = require("react-hook-form");
@@ -91,7 +100,8 @@ var import_react_hook_form3 = require("react-hook-form");
91
100
  var import_jsx_runtime3 = require("react/jsx-runtime");
92
101
  var FormFieldCheckbox = ({
93
102
  label,
94
- name
103
+ name,
104
+ disabled
95
105
  }) => {
96
106
  const {
97
107
  field: { onChange, onBlur, value, ref }
@@ -108,11 +118,13 @@ var FormFieldCheckbox = ({
108
118
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Checkbox, {
109
119
  id,
110
120
  ref,
121
+ disabled,
111
122
  checked: value,
112
123
  onChange,
113
124
  onBlur
114
125
  }),
115
126
  label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Label, {
127
+ "aria-disabled": disabled,
116
128
  htmlFor: id,
117
129
  children: label
118
130
  })
@@ -131,7 +143,9 @@ var import_react_hook_form4 = require("react-hook-form");
131
143
  var import_jsx_runtime4 = require("react/jsx-runtime");
132
144
  var FormFieldInput = ({
133
145
  label,
134
- name
146
+ name,
147
+ disabled,
148
+ placeholder
135
149
  }) => {
136
150
  const {
137
151
  field: { onChange, onBlur, value, ref }
@@ -143,6 +157,7 @@ var FormFieldInput = ({
143
157
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_ui4.Box, {
144
158
  children: [
145
159
  label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ui4.Label, {
160
+ "aria-disabled": disabled,
146
161
  htmlFor: id,
147
162
  children: label
148
163
  }),
@@ -152,6 +167,8 @@ var FormFieldInput = ({
152
167
  onBlur,
153
168
  value,
154
169
  name,
170
+ disabled,
171
+ placeholder,
155
172
  id
156
173
  }),
157
174
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorMessage, {
@@ -261,15 +278,14 @@ FormField.Input = FormFieldInput;
261
278
  FormField.Radio = FormFieldRadio;
262
279
  FormField.Select = FormFieldSelect;
263
280
  FormField.Checkbox = FormFieldCheckbox;
264
-
265
- // src/index.ts
266
- var import_yup = require("@hookform/resolvers/yup");
267
- __reExport(src_exports, require("react-hook-form"), module.exports);
268
- var yup = __toESM(require("yup"));
269
281
  // Annotate the CommonJS export names for ESM import in node:
270
282
  0 && (module.exports = {
271
283
  Form,
272
284
  FormField,
285
+ FormFieldCheckbox,
286
+ FormFieldInput,
287
+ FormFieldRadio,
288
+ FormFieldSelect,
273
289
  yup,
274
290
  yupResolver
275
291
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/forms",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "license": "UNLICENSED",
5
5
  "author": "ttoss",
6
6
  "contributors": [
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "7283c8bffc1b432659339927173eee2ad19b622d"
43
+ "gitHead": "ec2101df23a183e667988b3ca78e3248de7c809b"
44
44
  }
package/src/FormField.tsx CHANGED
@@ -3,6 +3,9 @@ import { FormFieldInput } from './FormFieldInput';
3
3
  import { FormFieldRadio } from './FormFieldRadio';
4
4
  import { FormFieldSelect } from './FormFieldSelect';
5
5
 
6
+ /**
7
+ * DEPRECATED: Use `FormFieldInput` instead.
8
+ */
6
9
  const FormField = () => {
7
10
  // to be implemented
8
11
  return null;
@@ -11,7 +14,6 @@ const FormField = () => {
11
14
  FormField.Input = FormFieldInput;
12
15
  FormField.Radio = FormFieldRadio;
13
16
  FormField.Select = FormFieldSelect;
14
-
15
17
  FormField.Checkbox = FormFieldCheckbox;
16
18
 
17
19
  export { FormField };
@@ -7,9 +7,11 @@ export const FormFieldCheckbox = <
7
7
  >({
8
8
  label,
9
9
  name,
10
+ disabled,
10
11
  }: {
11
12
  label?: string;
12
13
  name: Path<TFieldValues>;
14
+ disabled?: boolean;
13
15
  }) => {
14
16
  const {
15
17
  field: { onChange, onBlur, value, ref },
@@ -26,11 +28,16 @@ export const FormFieldCheckbox = <
26
28
  <Checkbox
27
29
  id={id}
28
30
  ref={ref}
31
+ disabled={disabled}
29
32
  checked={value}
30
33
  onChange={onChange}
31
34
  onBlur={onBlur}
32
35
  />
33
- {label && <Label htmlFor={id}>{label}</Label>}
36
+ {label && (
37
+ <Label aria-disabled={disabled} htmlFor={id}>
38
+ {label}
39
+ </Label>
40
+ )}
34
41
  </Flex>
35
42
  <ErrorMessage name={name} />
36
43
  </Box>
@@ -5,9 +5,13 @@ import { FieldValues, Path, useController } from 'react-hook-form';
5
5
  export const FormFieldInput = <TFieldValues extends FieldValues = FieldValues>({
6
6
  label,
7
7
  name,
8
+ disabled,
9
+ placeholder,
8
10
  }: {
9
11
  label?: string;
10
12
  name: Path<TFieldValues>;
13
+ disabled?: boolean;
14
+ placeholder?: string;
11
15
  }) => {
12
16
  const {
13
17
  field: { onChange, onBlur, value, ref },
@@ -20,13 +24,19 @@ export const FormFieldInput = <TFieldValues extends FieldValues = FieldValues>({
20
24
 
21
25
  return (
22
26
  <Box>
23
- {label && <Label htmlFor={id}>{label}</Label>}
27
+ {label && (
28
+ <Label aria-disabled={disabled} htmlFor={id}>
29
+ {label}
30
+ </Label>
31
+ )}
24
32
  <Input
25
33
  ref={ref}
26
34
  onChange={onChange}
27
35
  onBlur={onBlur}
28
36
  value={value}
29
37
  name={name}
38
+ disabled={disabled}
39
+ placeholder={placeholder}
30
40
  id={id}
31
41
  />
32
42
  <ErrorMessage name={name} />
package/src/index.ts CHANGED
@@ -1,5 +1,10 @@
1
- export { Form } from './Form';
2
- export { FormField } from './FormField';
3
1
  export { yupResolver } from '@hookform/resolvers/yup';
4
2
  export * from 'react-hook-form';
5
3
  export * as yup from 'yup';
4
+
5
+ export { Form } from './Form';
6
+ export { FormField } from './FormField';
7
+ export { FormFieldCheckbox } from './FormFieldCheckbox';
8
+ export { FormFieldInput } from './FormFieldInput';
9
+ export { FormFieldRadio } from './FormFieldRadio';
10
+ export { FormFieldSelect } from './FormFieldSelect';