@ttoss/forms 0.5.2 → 0.5.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/forms",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "license": "UNLICENSED",
5
5
  "author": "ttoss",
6
6
  "contributors": [
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@hookform/resolvers": "^2.9.8",
30
- "@ttoss/config": "^1.18.1",
31
- "@ttoss/test-utils": "^1.16.8",
32
- "@ttoss/ui": "^1.20.2",
30
+ "@ttoss/config": "^1.18.3",
31
+ "@ttoss/test-utils": "^1.16.10",
32
+ "@ttoss/ui": "^1.20.4",
33
33
  "@types/jest": "^29.0.3",
34
34
  "jest": "^29.0.3",
35
35
  "react": "^18.2.0",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "0759c1ec512f6cb0a613c209beba1fcf6af7e232"
45
+ "gitHead": "b9f9de9b8389be76965f125b593166f10c2171e6"
46
46
  }
package/dist/esm/index.js DELETED
@@ -1,93 +0,0 @@
1
- // tsup.inject.js
2
- import * as React from "react";
3
-
4
- // src/Form.tsx
5
- import { Box } from "@ttoss/ui";
6
- import { FormProvider } from "react-hook-form";
7
- import { jsx } from "react/jsx-runtime";
8
- var Form = ({
9
- children,
10
- onSubmit,
11
- sx,
12
- ...formMethods
13
- }) => {
14
- return /* @__PURE__ */ jsx(FormProvider, {
15
- ...formMethods,
16
- children: /* @__PURE__ */ jsx(Box, {
17
- as: "form",
18
- variant: "forms.form",
19
- onSubmit: formMethods.handleSubmit((data) => onSubmit(data)),
20
- sx,
21
- children
22
- })
23
- });
24
- };
25
-
26
- // src/FormFieldInput.tsx
27
- import { Box as Box2, Input, Label } from "@ttoss/ui";
28
-
29
- // src/ErrorMessage.tsx
30
- import { useFormContext } from "react-hook-form";
31
- import { ErrorMessage as HookFormErrorMessage } from "@hookform/error-message";
32
- import { Text } from "@ttoss/ui";
33
- import { jsx as jsx2 } from "react/jsx-runtime";
34
- var ErrorMessage = ({
35
- name
36
- }) => {
37
- const {
38
- formState: { errors }
39
- } = useFormContext();
40
- return /* @__PURE__ */ jsx2(HookFormErrorMessage, {
41
- errors,
42
- name,
43
- as: /* @__PURE__ */ jsx2(Text, {
44
- variant: "text.error",
45
- role: "alert"
46
- })
47
- });
48
- };
49
-
50
- // src/FormFieldInput.tsx
51
- import { useController } from "react-hook-form";
52
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
53
- var FormFieldInput = ({
54
- label,
55
- name
56
- }) => {
57
- const {
58
- field: { onChange, onBlur, value, ref }
59
- } = useController({
60
- name,
61
- defaultValue: ""
62
- });
63
- const id = `form-field-input-${name}`;
64
- return /* @__PURE__ */ jsxs(Box2, {
65
- children: [
66
- label && /* @__PURE__ */ jsx3(Label, {
67
- htmlFor: id,
68
- children: label
69
- }),
70
- /* @__PURE__ */ jsx3(Input, {
71
- ref,
72
- onChange,
73
- onBlur,
74
- value,
75
- name,
76
- id
77
- }),
78
- /* @__PURE__ */ jsx3(ErrorMessage, {
79
- name
80
- })
81
- ]
82
- });
83
- };
84
-
85
- // src/FormField.tsx
86
- var FormField = () => {
87
- return null;
88
- };
89
- FormField.Input = FormFieldInput;
90
- export {
91
- Form,
92
- FormField
93
- };
package/dist/index.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import * as react_hook_form from 'react-hook-form';
2
- import { FieldValues } from 'react-hook-form';
3
- import * as React from 'react';
4
- import { BoxProps } from '@ttoss/ui';
5
-
6
- declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children, onSubmit, sx, ...formMethods }: {
7
- children?: React.ReactNode;
8
- onSubmit: (data: TFieldValues) => Promise<void> | void;
9
- sx?: BoxProps['sx'];
10
- } & {
11
- children: React.ReactNode | React.ReactNode[];
12
- } & react_hook_form.UseFormReturn<TFieldValues, any>) => JSX.Element;
13
-
14
- declare const FormField: {
15
- (): null;
16
- Input: <TFieldValues extends react_hook_form.FieldValues = react_hook_form.FieldValues>({ label, name, }: {
17
- label?: string | undefined;
18
- name: react_hook_form.Path<TFieldValues>;
19
- }) => JSX.Element;
20
- };
21
-
22
- export { Form, FormField };
package/dist/index.js DELETED
@@ -1,127 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
-
26
- // src/index.ts
27
- var src_exports = {};
28
- __export(src_exports, {
29
- Form: () => Form,
30
- FormField: () => FormField
31
- });
32
- module.exports = __toCommonJS(src_exports);
33
-
34
- // tsup.inject.js
35
- var React = __toESM(require("react"));
36
-
37
- // src/Form.tsx
38
- var import_ui = require("@ttoss/ui");
39
- var import_react_hook_form = require("react-hook-form");
40
- var import_jsx_runtime = require("react/jsx-runtime");
41
- var Form = ({
42
- children,
43
- onSubmit,
44
- sx,
45
- ...formMethods
46
- }) => {
47
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_hook_form.FormProvider, {
48
- ...formMethods,
49
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Box, {
50
- as: "form",
51
- variant: "forms.form",
52
- onSubmit: formMethods.handleSubmit((data) => onSubmit(data)),
53
- sx,
54
- children
55
- })
56
- });
57
- };
58
-
59
- // src/FormFieldInput.tsx
60
- var import_ui3 = require("@ttoss/ui");
61
-
62
- // src/ErrorMessage.tsx
63
- var import_react_hook_form2 = require("react-hook-form");
64
- var import_error_message = require("@hookform/error-message");
65
- var import_ui2 = require("@ttoss/ui");
66
- var import_jsx_runtime2 = require("react/jsx-runtime");
67
- var ErrorMessage = ({
68
- name
69
- }) => {
70
- const {
71
- formState: { errors }
72
- } = (0, import_react_hook_form2.useFormContext)();
73
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_error_message.ErrorMessage, {
74
- errors,
75
- name,
76
- as: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Text, {
77
- variant: "text.error",
78
- role: "alert"
79
- })
80
- });
81
- };
82
-
83
- // src/FormFieldInput.tsx
84
- var import_react_hook_form3 = require("react-hook-form");
85
- var import_jsx_runtime3 = require("react/jsx-runtime");
86
- var FormFieldInput = ({
87
- label,
88
- name
89
- }) => {
90
- const {
91
- field: { onChange, onBlur, value, ref }
92
- } = (0, import_react_hook_form3.useController)({
93
- name,
94
- defaultValue: ""
95
- });
96
- const id = `form-field-input-${name}`;
97
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.Box, {
98
- children: [
99
- label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Label, {
100
- htmlFor: id,
101
- children: label
102
- }),
103
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Input, {
104
- ref,
105
- onChange,
106
- onBlur,
107
- value,
108
- name,
109
- id
110
- }),
111
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorMessage, {
112
- name
113
- })
114
- ]
115
- });
116
- };
117
-
118
- // src/FormField.tsx
119
- var FormField = () => {
120
- return null;
121
- };
122
- FormField.Input = FormFieldInput;
123
- // Annotate the CommonJS export names for ESM import in node:
124
- 0 && (module.exports = {
125
- Form,
126
- FormField
127
- });