formspec 0.0.0 → 0.1.0-alpha.2
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/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -7
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormSpec - Type-safe form specifications
|
|
3
|
+
*
|
|
4
|
+
* This package re-exports everything from the FormSpec library for convenience.
|
|
5
|
+
* You can import everything you need from a single package:
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {
|
|
10
|
+
* // DSL functions
|
|
11
|
+
* formspec, field, group, when, is,
|
|
12
|
+
* // Type inference
|
|
13
|
+
* type InferSchema,
|
|
14
|
+
* // Schema generation
|
|
15
|
+
* buildFormSchemas,
|
|
16
|
+
* // Resolvers
|
|
17
|
+
* defineResolvers,
|
|
18
|
+
* // Core types
|
|
19
|
+
* type FormSpec, type FormElement,
|
|
20
|
+
* } from "formspec";
|
|
21
|
+
*
|
|
22
|
+
* // Define a form
|
|
23
|
+
* const InvoiceForm = formspec(
|
|
24
|
+
* group("Customer",
|
|
25
|
+
* field.text("name", { label: "Name", required: true }),
|
|
26
|
+
* field.dynamicEnum("country", "fetch_countries", { label: "Country" }),
|
|
27
|
+
* ),
|
|
28
|
+
* group("Details",
|
|
29
|
+
* field.number("amount", { label: "Amount", min: 0 }),
|
|
30
|
+
* field.enum("status", ["draft", "sent", "paid"]),
|
|
31
|
+
* when(is("status", "draft"),
|
|
32
|
+
* field.text("notes", { label: "Internal Notes" }),
|
|
33
|
+
* ),
|
|
34
|
+
* ),
|
|
35
|
+
* );
|
|
36
|
+
*
|
|
37
|
+
* // Infer the schema type
|
|
38
|
+
* type Schema = InferSchema<typeof InvoiceForm.elements>;
|
|
39
|
+
*
|
|
40
|
+
* // Generate JSON Schema and UI Schema
|
|
41
|
+
* const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);
|
|
42
|
+
*
|
|
43
|
+
* // Define resolvers for dynamic data
|
|
44
|
+
* const resolvers = defineResolvers(InvoiceForm, {
|
|
45
|
+
* fetch_countries: async () => ({
|
|
46
|
+
* options: [{ value: "us", label: "United States" }],
|
|
47
|
+
* validity: "valid",
|
|
48
|
+
* }),
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @packageDocumentation
|
|
53
|
+
*/
|
|
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
|
+
export { createInitialFieldState } from "@formspec/core";
|
|
56
|
+
export { field, group, when, is, formspec, formspecWithValidation, validateForm, logValidationIssues } from "@formspec/dsl";
|
|
57
|
+
export type { InferFieldValue, ExtractFields, ExtractFieldsFromArray, BuildSchema, InferSchema, InferFormSchema, FormSpecOptions, ValidationSeverity, ValidationIssue, ValidationResult, } from "@formspec/dsl";
|
|
58
|
+
export { generateJsonSchema, generateUiSchema, buildFormSchemas, writeSchemas, } from "@formspec/build";
|
|
59
|
+
export type { JSONSchema7, JSONSchemaType, UISchema, UISchemaElement, UISchemaElementType, ControlElement, VerticalLayout, HorizontalLayout, GroupLayout, Rule, RuleEffect, SchemaBasedCondition, BuildResult, WriteSchemasOptions, WriteSchemasResult, } from "@formspec/build";
|
|
60
|
+
export { defineResolvers } from "@formspec/runtime";
|
|
61
|
+
export type { Resolver, ResolverMap, ResolverRegistry, } from "@formspec/runtime";
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/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,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormSpec - Type-safe form specifications
|
|
3
|
+
*
|
|
4
|
+
* This package re-exports everything from the FormSpec library for convenience.
|
|
5
|
+
* You can import everything you need from a single package:
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {
|
|
10
|
+
* // DSL functions
|
|
11
|
+
* formspec, field, group, when, is,
|
|
12
|
+
* // Type inference
|
|
13
|
+
* type InferSchema,
|
|
14
|
+
* // Schema generation
|
|
15
|
+
* buildFormSchemas,
|
|
16
|
+
* // Resolvers
|
|
17
|
+
* defineResolvers,
|
|
18
|
+
* // Core types
|
|
19
|
+
* type FormSpec, type FormElement,
|
|
20
|
+
* } from "formspec";
|
|
21
|
+
*
|
|
22
|
+
* // Define a form
|
|
23
|
+
* const InvoiceForm = formspec(
|
|
24
|
+
* group("Customer",
|
|
25
|
+
* field.text("name", { label: "Name", required: true }),
|
|
26
|
+
* field.dynamicEnum("country", "fetch_countries", { label: "Country" }),
|
|
27
|
+
* ),
|
|
28
|
+
* group("Details",
|
|
29
|
+
* field.number("amount", { label: "Amount", min: 0 }),
|
|
30
|
+
* field.enum("status", ["draft", "sent", "paid"]),
|
|
31
|
+
* when(is("status", "draft"),
|
|
32
|
+
* field.text("notes", { label: "Internal Notes" }),
|
|
33
|
+
* ),
|
|
34
|
+
* ),
|
|
35
|
+
* );
|
|
36
|
+
*
|
|
37
|
+
* // Infer the schema type
|
|
38
|
+
* type Schema = InferSchema<typeof InvoiceForm.elements>;
|
|
39
|
+
*
|
|
40
|
+
* // Generate JSON Schema and UI Schema
|
|
41
|
+
* const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);
|
|
42
|
+
*
|
|
43
|
+
* // Define resolvers for dynamic data
|
|
44
|
+
* const resolvers = defineResolvers(InvoiceForm, {
|
|
45
|
+
* fetch_countries: async () => ({
|
|
46
|
+
* options: [{ value: "us", label: "United States" }],
|
|
47
|
+
* validity: "valid",
|
|
48
|
+
* }),
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @packageDocumentation
|
|
53
|
+
*/
|
|
54
|
+
export { createInitialFieldState } from "@formspec/core";
|
|
55
|
+
// =============================================================================
|
|
56
|
+
// DSL functions
|
|
57
|
+
// =============================================================================
|
|
58
|
+
export { field, group, when, is, formspec, formspecWithValidation, validateForm, logValidationIssues } from "@formspec/dsl";
|
|
59
|
+
// =============================================================================
|
|
60
|
+
// Build tools
|
|
61
|
+
// =============================================================================
|
|
62
|
+
export { generateJsonSchema, generateUiSchema, buildFormSchemas, writeSchemas, } from "@formspec/build";
|
|
63
|
+
// =============================================================================
|
|
64
|
+
// Runtime helpers
|
|
65
|
+
// =============================================================================
|
|
66
|
+
export { defineResolvers } from "@formspec/runtime";
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;AAiB5H,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,11 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formspec",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
|
+
"description": "Type-safe form specifications that compile to JSON Schema and JSON Forms UI Schema",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/formspec.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/formspec.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@formspec/core": "0.1.0-alpha.2",
|
|
19
|
+
"@formspec/build": "0.1.0-alpha.2",
|
|
20
|
+
"@formspec/dsl": "0.1.0-alpha.2",
|
|
21
|
+
"@formspec/runtime": "0.1.0-alpha.2"
|
|
7
22
|
},
|
|
8
|
-
"
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"form",
|
|
28
|
+
"forms",
|
|
29
|
+
"json-schema",
|
|
30
|
+
"json-forms",
|
|
31
|
+
"type-safe",
|
|
32
|
+
"typescript"
|
|
33
|
+
],
|
|
9
34
|
"license": "UNLICENSED",
|
|
10
|
-
"
|
|
11
|
-
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"clean": "rm -rf dist temp",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"api-extractor": "api-extractor run",
|
|
40
|
+
"api-extractor:local": "api-extractor run --local",
|
|
41
|
+
"api-documenter": "api-documenter markdown -i temp -o docs"
|
|
42
|
+
}
|
|
43
|
+
}
|