@nomos-ui/form 0.0.2 → 0.0.3
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/components/form-input.d.ts.map +1 -1
- package/dist/components/form-input.js +2 -1
- package/dist/components/form-input.js.map +1 -1
- package/dist/utils/helpers/form.helpers.d.ts +2 -0
- package/dist/utils/helpers/form.helpers.d.ts.map +1 -0
- package/dist/utils/helpers/form.helpers.js +14 -0
- package/dist/utils/helpers/form.helpers.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-input.d.ts","sourceRoot":"","sources":["../../src/components/form-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EACP,WAAW,EACX,IAAI,EACJ,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"form-input.d.ts","sourceRoot":"","sources":["../../src/components/form-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EACP,WAAW,EACX,IAAI,EACJ,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,YAAY,SAAS,WAAW,IAAI;IAC7D,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,gEAAgE;IAChE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACzB,4DAA4D;IAC5D,YAAY,CAAC,EAAE,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;CAC5D,GAAG,IAAI,CACN,KAAK,CAAC,cAAc,CAAC,OAAO,KAAK,CAAC,EAClC,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,YAAY,SAAS,WAAW,EAAE,EAClE,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAe,EACf,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,YAAY,CAAC,2CAmB9B"}
|
|
@@ -7,6 +7,7 @@ exports.default = FormInput;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
const input_1 = __importDefault(require("./input"));
|
|
10
|
+
const form_helpers_1 = require("../utils/helpers/form.helpers");
|
|
10
11
|
/**
|
|
11
12
|
* A form input component that adds type-safe form functionality to the base Input component.
|
|
12
13
|
* Designed to integrate with React Hook Form with full TypeScript support.
|
|
@@ -33,6 +34,6 @@ const input_1 = __importDefault(require("./input"));
|
|
|
33
34
|
* ```
|
|
34
35
|
*/
|
|
35
36
|
function FormInput({ control, name, defaultValue, required = true, ...props }) {
|
|
36
|
-
return ((0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: control, name: name, defaultValue: defaultValue, rules: { required: required ? "Required" : false }, render: ({ field: { onChange, value }, fieldState: { error } }) => ((0, jsx_runtime_1.jsx)(input_1.default, { id: `form-input-${name}`, value: value ?? "", onChange: onChange, required: required, error: error
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: control, name: name, defaultValue: defaultValue, rules: { required: required ? "Required" : false }, render: ({ field: { onChange, value }, fieldState: { error } }) => ((0, jsx_runtime_1.jsx)(input_1.default, { id: `form-input-${name}`, value: value ?? "", onChange: onChange, required: required, error: (0, form_helpers_1.getNestedErrorMessage)(error || {}, name), ...props })) }));
|
|
37
38
|
}
|
|
38
39
|
//# sourceMappingURL=form-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-input.js","sourceRoot":"","sources":["../../src/components/form-input.tsx"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"form-input.js","sourceRoot":"","sources":["../../src/components/form-input.tsx"],"names":[],"mappings":";;;;;AAmDA,4BAyBC;;AA5ED,qDAMyB;AACzB,oDAA4B;AAE5B,gEAAsE;AAiBtE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAwB,SAAS,CAAmC,EAClE,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,GAAG,IAAI,EACf,GAAG,KAAK,EACqB;IAC7B,OAAO,CACL,uBAAC,4BAAU,IACT,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,EAClD,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CACjE,uBAAC,eAAK,IACJ,EAAE,EAAE,cAAc,IAAI,EAAE,EACxB,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,IAAA,oCAAqB,EAAC,KAAK,IAAI,EAAE,EAAE,IAAI,CAAC,KAC3C,KAAK,GACT,CACH,GACD,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers/form.helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,IAAI,EAAE,MAAM,OAWb"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNestedErrorMessage = getNestedErrorMessage;
|
|
4
|
+
function getNestedErrorMessage(errors, path) {
|
|
5
|
+
const parts = path.split(".");
|
|
6
|
+
let current = errors;
|
|
7
|
+
for (const part of parts) {
|
|
8
|
+
if (!current || !current[part])
|
|
9
|
+
return null;
|
|
10
|
+
current = current[part];
|
|
11
|
+
}
|
|
12
|
+
return current.message ? current.message : null;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=form.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers/form.helpers.ts"],"names":[],"mappings":";;AAAA,sDAaC;AAbD,SAAgB,qBAAqB,CACnC,MAA2B,EAC3B,IAAY;IAEZ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE9B,IAAI,OAAO,GAAG,MAAM,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAC5C,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC"}
|