seam-react 0.12.3 → 0.12.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/README.md +2 -1
- package/dist/FormComponent.d.ts +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/valibot.cjs +2 -0
- package/dist/valibot.cjs.map +1 -0
- package/dist/valibot.d.ts +13 -0
- package/dist/valibot.js +19 -0
- package/dist/valibot.js.map +1 -0
- package/package.json +14 -2
package/dist/valibot.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("valibot");function a(e){if(e===null||typeof e!="object")throw new TypeError("valibotResolver expects a Valibot schema.");return async n=>{const o=await i.safeParseAsync(e,n);if(o.success)return{};const t={};for(const r of o.issues){const s=i.getDotPath(r)??"_form";t[s]===void 0&&(t[s]=r.message)}return t}}exports.valibotResolver=a;
|
|
2
|
+
//# sourceMappingURL=valibot.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valibot.cjs","sources":["../src/valibot.ts"],"sourcesContent":["import { getDotPath, safeParseAsync } from \"valibot\";\nimport type { GenericSchema, GenericSchemaAsync, InferInput } from \"valibot\";\nimport type { FormErrors } from \"./FormComponent\";\n\nexport type ValibotSchema = GenericSchema | GenericSchemaAsync;\n\ntype FormErrorsFor<TSchema extends ValibotSchema> =\n InferInput<TSchema> extends Record<string, unknown>\n ? FormErrors<InferInput<TSchema>>\n : FormErrors;\n\nexport type ValibotValidate<TSchema extends ValibotSchema> = (\n values: InferInput<TSchema>,\n) => Promise<FormErrorsFor<TSchema>>;\n\n/**\n * Adapts a Valibot schema to the existing Form.Root validate contract.\n *\n * The resolver validates only. It does not apply schema transformations to the\n * visible form values or the values passed to onSubmit.\n */\nexport function valibotResolver<const TSchema extends ValibotSchema>(\n schema: TSchema,\n): ValibotValidate<TSchema> {\n if (schema === null || typeof schema !== \"object\") {\n throw new TypeError(\"valibotResolver expects a Valibot schema.\");\n }\n\n return async (values) => {\n const result = await safeParseAsync(schema, values);\n\n if (result.success) return {};\n\n const errors: Record<string, string> = {};\n for (const issue of result.issues) {\n const path = getDotPath(issue) ?? \"_form\";\n if (errors[path] === undefined) {\n errors[path] = issue.message;\n }\n }\n\n return errors as FormErrorsFor<TSchema>;\n };\n}\n"],"names":["valibotResolver","schema","values","result","safeParseAsync","errors","issue","path","getDotPath"],"mappings":"2GAqBO,SAASA,EACdC,EAC0B,CAC1B,GAAIA,IAAW,MAAQ,OAAOA,GAAW,SACvC,MAAM,IAAI,UAAU,2CAA2C,EAGjE,MAAO,OAAOC,GAAW,CACvB,MAAMC,EAAS,MAAMC,iBAAeH,EAAQC,CAAM,EAElD,GAAIC,EAAO,QAAS,MAAO,CAAA,EAE3B,MAAME,EAAiC,CAAA,EACvC,UAAWC,KAASH,EAAO,OAAQ,CACjC,MAAMI,EAAOC,EAAAA,WAAWF,CAAK,GAAK,QAC9BD,EAAOE,CAAI,IAAM,SACnBF,EAAOE,CAAI,EAAID,EAAM,QAEzB,CAEA,OAAOD,CACT,CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GenericSchema, GenericSchemaAsync, InferInput } from "valibot";
|
|
2
|
+
import type { FormErrors } from "./FormComponent";
|
|
3
|
+
export type ValibotSchema = GenericSchema | GenericSchemaAsync;
|
|
4
|
+
type FormErrorsFor<TSchema extends ValibotSchema> = InferInput<TSchema> extends Record<string, unknown> ? FormErrors<InferInput<TSchema>> : FormErrors;
|
|
5
|
+
export type ValibotValidate<TSchema extends ValibotSchema> = (values: InferInput<TSchema>) => Promise<FormErrorsFor<TSchema>>;
|
|
6
|
+
/**
|
|
7
|
+
* Adapts a Valibot schema to the existing Form.Root validate contract.
|
|
8
|
+
*
|
|
9
|
+
* The resolver validates only. It does not apply schema transformations to the
|
|
10
|
+
* visible form values or the values passed to onSubmit.
|
|
11
|
+
*/
|
|
12
|
+
export declare function valibotResolver<const TSchema extends ValibotSchema>(schema: TSchema): ValibotValidate<TSchema>;
|
|
13
|
+
export {};
|
package/dist/valibot.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { safeParseAsync as i, getDotPath as a } from "valibot";
|
|
2
|
+
function f(e) {
|
|
3
|
+
if (e === null || typeof e != "object")
|
|
4
|
+
throw new TypeError("valibotResolver expects a Valibot schema.");
|
|
5
|
+
return async (n) => {
|
|
6
|
+
const t = await i(e, n);
|
|
7
|
+
if (t.success) return {};
|
|
8
|
+
const o = {};
|
|
9
|
+
for (const r of t.issues) {
|
|
10
|
+
const s = a(r) ?? "_form";
|
|
11
|
+
o[s] === void 0 && (o[s] = r.message);
|
|
12
|
+
}
|
|
13
|
+
return o;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
f as valibotResolver
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=valibot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valibot.js","sources":["../src/valibot.ts"],"sourcesContent":["import { getDotPath, safeParseAsync } from \"valibot\";\nimport type { GenericSchema, GenericSchemaAsync, InferInput } from \"valibot\";\nimport type { FormErrors } from \"./FormComponent\";\n\nexport type ValibotSchema = GenericSchema | GenericSchemaAsync;\n\ntype FormErrorsFor<TSchema extends ValibotSchema> =\n InferInput<TSchema> extends Record<string, unknown>\n ? FormErrors<InferInput<TSchema>>\n : FormErrors;\n\nexport type ValibotValidate<TSchema extends ValibotSchema> = (\n values: InferInput<TSchema>,\n) => Promise<FormErrorsFor<TSchema>>;\n\n/**\n * Adapts a Valibot schema to the existing Form.Root validate contract.\n *\n * The resolver validates only. It does not apply schema transformations to the\n * visible form values or the values passed to onSubmit.\n */\nexport function valibotResolver<const TSchema extends ValibotSchema>(\n schema: TSchema,\n): ValibotValidate<TSchema> {\n if (schema === null || typeof schema !== \"object\") {\n throw new TypeError(\"valibotResolver expects a Valibot schema.\");\n }\n\n return async (values) => {\n const result = await safeParseAsync(schema, values);\n\n if (result.success) return {};\n\n const errors: Record<string, string> = {};\n for (const issue of result.issues) {\n const path = getDotPath(issue) ?? \"_form\";\n if (errors[path] === undefined) {\n errors[path] = issue.message;\n }\n }\n\n return errors as FormErrorsFor<TSchema>;\n };\n}\n"],"names":["valibotResolver","schema","values","result","safeParseAsync","errors","issue","path","getDotPath"],"mappings":";AAqBO,SAASA,EACdC,GAC0B;AAC1B,MAAIA,MAAW,QAAQ,OAAOA,KAAW;AACvC,UAAM,IAAI,UAAU,2CAA2C;AAGjE,SAAO,OAAOC,MAAW;AACvB,UAAMC,IAAS,MAAMC,EAAeH,GAAQC,CAAM;AAElD,QAAIC,EAAO,QAAS,QAAO,CAAA;AAE3B,UAAME,IAAiC,CAAA;AACvC,eAAWC,KAASH,EAAO,QAAQ;AACjC,YAAMI,IAAOC,EAAWF,CAAK,KAAK;AAClC,MAAID,EAAOE,CAAI,MAAM,WACnBF,EAAOE,CAAI,IAAID,EAAM;AAAA,IAEzB;AAEA,WAAOD;AAAA,EACT;AACF;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seam-react",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "基于 seam-hooks 与 Motion 的 Fluid React 组件库",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component-library",
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
"import": "./dist/index.js",
|
|
43
43
|
"require": "./dist/index.cjs"
|
|
44
44
|
},
|
|
45
|
+
"./valibot": {
|
|
46
|
+
"types": "./dist/valibot.d.ts",
|
|
47
|
+
"import": "./dist/valibot.js",
|
|
48
|
+
"require": "./dist/valibot.cjs"
|
|
49
|
+
},
|
|
45
50
|
"./styles": {
|
|
46
51
|
"types": "./dist/SeamStyles.d.ts",
|
|
47
52
|
"import": "./dist/styles.js",
|
|
@@ -64,12 +69,19 @@
|
|
|
64
69
|
"react": "^19.0.0",
|
|
65
70
|
"react-dom": "^19.0.0",
|
|
66
71
|
"typescript": "^7.0.2",
|
|
72
|
+
"valibot": "^1.5.0",
|
|
67
73
|
"vite": "^7.0.0",
|
|
68
74
|
"vitest": "^2.1.4"
|
|
69
75
|
},
|
|
70
76
|
"peerDependencies": {
|
|
71
77
|
"react": ">=18.2",
|
|
72
|
-
"react-dom": ">=18.2"
|
|
78
|
+
"react-dom": ">=18.2",
|
|
79
|
+
"valibot": "^1.5.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"valibot": {
|
|
83
|
+
"optional": true
|
|
84
|
+
}
|
|
73
85
|
},
|
|
74
86
|
"engines": {
|
|
75
87
|
"node": ">=18"
|