formspec 0.1.0-alpha.7 → 0.1.0-alpha.9

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 CHANGED
@@ -42,7 +42,7 @@ const ContactForm = formspec(
42
42
  field.text("email", { label: "Email", required: true }),
43
43
  field.enum("subject", ["General", "Support", "Sales"], { label: "Subject" }),
44
44
  field.text("message", { label: "Message", required: true }),
45
- field.boolean("subscribe", { label: "Subscribe to newsletter" }),
45
+ field.boolean("subscribe", { label: "Subscribe to newsletter" })
46
46
  );
47
47
 
48
48
  // Infer TypeScript type from the form
@@ -58,27 +58,21 @@ const { jsonSchema, uiSchema } = buildFormSchemas(ContactForm);
58
58
  ### Field Types
59
59
 
60
60
  ```typescript
61
- field.text("name", { label: "Name", required: true })
62
- field.number("age", { label: "Age", min: 0, max: 120 })
63
- field.boolean("active", { label: "Active" })
64
- field.enum("status", ["draft", "published"], { label: "Status" })
65
- field.dynamicEnum("country", "fetch_countries", { label: "Country" })
66
- field.array("tags", field.text("tag"))
67
- field.object("address", field.text("street"), field.text("city"))
61
+ field.text("name", { label: "Name", required: true });
62
+ field.number("age", { label: "Age", min: 0, max: 120 });
63
+ field.boolean("active", { label: "Active" });
64
+ field.enum("status", ["draft", "published"], { label: "Status" });
65
+ field.dynamicEnum("country", "fetch_countries", { label: "Country" });
66
+ field.array("tags", field.text("tag"));
67
+ field.object("address", field.text("street"), field.text("city"));
68
68
  ```
69
69
 
70
70
  ### Grouping
71
71
 
72
72
  ```typescript
73
73
  const Form = formspec(
74
- group("Personal Info",
75
- field.text("firstName"),
76
- field.text("lastName"),
77
- ),
78
- group("Contact",
79
- field.text("email"),
80
- field.text("phone"),
81
- ),
74
+ group("Personal Info", field.text("firstName"), field.text("lastName")),
75
+ group("Contact", field.text("email"), field.text("phone"))
82
76
  );
83
77
  ```
84
78
 
@@ -87,10 +81,11 @@ const Form = formspec(
87
81
  ```typescript
88
82
  const Form = formspec(
89
83
  field.enum("type", ["personal", "business"]),
90
- when(is("type", "business"),
84
+ when(
85
+ is("type", "business"),
91
86
  field.text("companyName", { label: "Company Name" }),
92
- field.text("taxId", { label: "Tax ID" }),
93
- ),
87
+ field.text("taxId", { label: "Tax ID" })
88
+ )
94
89
  );
95
90
  ```
96
91
 
@@ -111,9 +106,7 @@ const handleSubmit = (data: FormData) => {
111
106
  ```typescript
112
107
  import { defineResolvers } from "formspec";
113
108
 
114
- const Form = formspec(
115
- field.dynamicEnum("country", "fetch_countries", { label: "Country" }),
116
- );
109
+ const Form = formspec(field.dynamicEnum("country", "fetch_countries", { label: "Country" }));
117
110
 
118
111
  const resolvers = defineResolvers(Form, {
119
112
  fetch_countries: async () => ({
@@ -143,21 +136,21 @@ writeSchemas(ContactForm, {
143
136
 
144
137
  This umbrella package re-exports from several focused packages:
145
138
 
146
- | Package | Description |
147
- |---------|-------------|
148
- | `@formspec/core` | Core type definitions |
149
- | `@formspec/dsl` | DSL functions (`formspec`, `field`, `group`, `when`, `is`) |
150
- | `@formspec/build` | Schema generators (`buildFormSchemas`, `writeSchemas`) |
151
- | `@formspec/runtime` | Runtime helpers (`defineResolvers`) |
139
+ | Package | Description |
140
+ | ------------------- | ---------------------------------------------------------- |
141
+ | `@formspec/core` | Core type definitions |
142
+ | `@formspec/dsl` | DSL functions (`formspec`, `field`, `group`, `when`, `is`) |
143
+ | `@formspec/build` | Schema generators (`buildFormSchemas`, `writeSchemas`) |
144
+ | `@formspec/runtime` | Runtime helpers (`defineResolvers`) |
152
145
 
153
146
  You can import from the umbrella package for convenience, or from individual packages for smaller bundle sizes.
154
147
 
155
148
  ## Related Packages
156
149
 
157
- | Package | Description |
158
- |---------|-------------|
159
- | `@formspec/decorators` | Decorator-based API for class definitions |
160
- | `@formspec/cli` | CLI tool for static analysis of decorated classes |
150
+ | Package | Description |
151
+ | ---------------------- | ------------------------------------------------- |
152
+ | `@formspec/decorators` | Decorator-based API for class definitions |
153
+ | `@formspec/cli` | CLI tool for static analysis of decorated classes |
161
154
 
162
155
  ## License
163
156
 
package/dist/index.d.ts CHANGED
@@ -53,11 +53,11 @@
53
53
  */
54
54
  export type { Validity, FieldState, FormState, DataSourceRegistry, DataSourceOption, FetchOptionsResponse, DataSourceValueType, TextField, NumberField, BooleanField, StaticEnumField, DynamicEnumField, DynamicSchemaField, ArrayField, ObjectField, AnyField, Group, Conditional, FormElement, FormSpec, EqualsPredicate, Predicate, } from "@formspec/core";
55
55
  export { createInitialFieldState } from "@formspec/core";
56
- export { field, group, when, is, formspec, formspecWithValidation, validateForm, logValidationIssues } from "@formspec/dsl";
56
+ export { field, group, when, is, formspec, formspecWithValidation, validateForm, logValidationIssues, } from "@formspec/dsl";
57
57
  export type { EnumOption, EnumOptionValue } from "@formspec/dsl";
58
58
  export type { InferFieldValue, ExtractFields, ExtractFieldsFromArray, BuildSchema, InferSchema, InferFormSchema, FormSpecOptions, ValidationSeverity, ValidationIssue, ValidationResult, } from "@formspec/dsl";
59
59
  export { generateJsonSchema, generateUiSchema, buildFormSchemas, writeSchemas, } from "@formspec/build";
60
60
  export type { JSONSchema7, JSONSchemaType, UISchema, UISchemaElement, UISchemaElementType, ControlElement, VerticalLayout, HorizontalLayout, GroupLayout, Rule, RuleEffect, SchemaBasedCondition, BuildResult, WriteSchemasOptions, WriteSchemasResult, } from "@formspec/build";
61
61
  export { defineResolvers } from "@formspec/runtime";
62
- export type { Resolver, ResolverMap, ResolverRegistry, } from "@formspec/runtime";
62
+ export type { Resolver, ResolverMap, ResolverRegistry } from "@formspec/runtime";
63
63
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAMH,YAAY,EAEV,QAAQ,EAGR,UAAU,EAGV,SAAS,EAGT,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB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EAGR,UAAU,EAGV,SAAS,EAGT,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EAGnB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,EAGR,eAAe,EACf,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAMzD,OAAO,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,EAAE,EACF,QAAQ,EACR,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEjE,YAAY,EAEV,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,eAAe,EAEf,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAMvB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,WAAW,EACX,cAAc,EACd,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,IAAI,EACJ,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -55,7 +55,7 @@ export { createInitialFieldState } from "@formspec/core";
55
55
  // =============================================================================
56
56
  // DSL functions
57
57
  // =============================================================================
58
- export { field, group, when, is, formspec, formspecWithValidation, validateForm, logValidationIssues } from "@formspec/dsl";
58
+ export { field, group, when, is, formspec, formspecWithValidation, validateForm, logValidationIssues, } from "@formspec/dsl";
59
59
  // =============================================================================
60
60
  // Build tools
61
61
  // =============================================================================
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AA0CH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,sBAAsB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAoB5H,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAoBzB,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AA0CH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF,OAAO,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,EAAE,EACF,QAAQ,EACR,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAoBvB,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAoBzB,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formspec",
3
- "version": "0.1.0-alpha.7",
3
+ "version": "0.1.0-alpha.9",
4
4
  "description": "Type-safe form specifications that compile to JSON Schema and JSON Forms UI Schema",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,10 +16,10 @@
16
16
  "README.md"
17
17
  ],
18
18
  "dependencies": {
19
- "@formspec/core": "0.1.0-alpha.4",
20
- "@formspec/dsl": "0.1.0-alpha.6",
21
- "@formspec/build": "0.1.0-alpha.7",
22
- "@formspec/runtime": "0.1.0-alpha.4"
19
+ "@formspec/core": "0.1.0-alpha.9",
20
+ "@formspec/dsl": "0.1.0-alpha.9",
21
+ "@formspec/build": "0.1.0-alpha.9",
22
+ "@formspec/runtime": "0.1.0-alpha.9"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"