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