@formspec/core 0.1.0-alpha.4 → 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
@@ -77,34 +77,34 @@ function processForm(form: FormSpec<readonly FormElement[]>) {
77
77
 
78
78
  ### Field Types
79
79
 
80
- | Type | Description |
81
- |------|-------------|
82
- | `TextField` | Text input field |
83
- | `NumberField` | Numeric input field |
84
- | `BooleanField` | Boolean/checkbox field |
85
- | `StaticEnumField` | Dropdown with static options |
86
- | `DynamicEnumField` | Dropdown with dynamic options from resolver |
87
- | `DynamicSchemaField` | Field with dynamic schema from resolver |
88
- | `ArrayField` | Array of nested elements |
89
- | `ObjectField` | Nested object with child fields |
90
- | `AnyField` | Union of all field types |
80
+ | Type | Description |
81
+ | -------------------- | ------------------------------------------- |
82
+ | `TextField` | Text input field |
83
+ | `NumberField` | Numeric input field |
84
+ | `BooleanField` | Boolean/checkbox field |
85
+ | `StaticEnumField` | Dropdown with static options |
86
+ | `DynamicEnumField` | Dropdown with dynamic options from resolver |
87
+ | `DynamicSchemaField` | Field with dynamic schema from resolver |
88
+ | `ArrayField` | Array of nested elements |
89
+ | `ObjectField` | Nested object with child fields |
90
+ | `AnyField` | Union of all field types |
91
91
 
92
92
  ### Structural Types
93
93
 
94
- | Type | Description |
95
- |------|-------------|
96
- | `Group` | Groups related fields with a label |
97
- | `Conditional` | Shows fields based on predicate |
94
+ | Type | Description |
95
+ | ------------- | ------------------------------------------- |
96
+ | `Group` | Groups related fields with a label |
97
+ | `Conditional` | Shows fields based on predicate |
98
98
  | `FormElement` | Union of `AnyField`, `Group`, `Conditional` |
99
- | `FormSpec<E>` | Complete form specification |
99
+ | `FormSpec<E>` | Complete form specification |
100
100
 
101
101
  ### State Types
102
102
 
103
- | Type | Description |
104
- |------|-------------|
105
- | `Validity` | `"valid"`, `"invalid"`, `"unknown"` |
106
- | `FieldState<T>` | Runtime state of a single field |
107
- | `FormState<S>` | Runtime state of entire form |
103
+ | Type | Description |
104
+ | --------------- | ----------------------------------- |
105
+ | `Validity` | `"valid"`, `"invalid"`, `"unknown"` |
106
+ | `FieldState<T>` | Runtime state of a single field |
107
+ | `FormState<S>` | Runtime state of entire form |
108
108
 
109
109
  ## License
110
110
 
package/dist/core.d.ts CHANGED
@@ -77,6 +77,27 @@ export declare interface Conditional<FieldName extends string, Value, Elements e
77
77
  readonly elements: Elements;
78
78
  }
79
79
 
80
+ /**
81
+ * Constraint decorator names that are valid as TSDoc tags, mapped to
82
+ * their expected value type for parsing.
83
+ *
84
+ * Both `@formspec/build` (schema generation) and `@formspec/eslint-plugin`
85
+ * (lint-time validation) import this to determine which JSDoc tags to
86
+ * recognize and how to parse their values.
87
+ */
88
+ export declare const CONSTRAINT_TAG_DEFINITIONS: {
89
+ readonly Minimum: "number";
90
+ readonly Maximum: "number";
91
+ readonly ExclusiveMinimum: "number";
92
+ readonly ExclusiveMaximum: "number";
93
+ readonly MinLength: "number";
94
+ readonly MaxLength: "number";
95
+ readonly Pattern: "string";
96
+ };
97
+
98
+ /** Type of a constraint tag name. */
99
+ export declare type ConstraintTagName = keyof typeof CONSTRAINT_TAG_DEFINITIONS;
100
+
80
101
  /**
81
102
  * Creates initial field state with default values.
82
103
  *
@@ -253,6 +274,12 @@ export declare interface FormSpec<Elements extends readonly FormElement[]> {
253
274
  readonly elements: Elements;
254
275
  }
255
276
 
277
+ /** Names of all built-in FormSpec decorators. */
278
+ export declare const FORMSPEC_DECORATOR_NAMES: readonly ["Field", "Group", "ShowWhen", "EnumOptions", "Minimum", "Maximum", "ExclusiveMinimum", "ExclusiveMaximum", "MinLength", "MaxLength", "Pattern"];
279
+
280
+ /** Type of a FormSpec decorator name. */
281
+ export declare type FormSpecDecoratorName = (typeof FORMSPEC_DECORATOR_NAMES)[number];
282
+
256
283
  /**
257
284
  * Represents the runtime state of an entire form.
258
285
  *
package/dist/index.d.ts CHANGED
@@ -8,6 +8,6 @@
8
8
  *
9
9
  * @packageDocumentation
10
10
  */
11
- export type { Validity, FieldState, FormState, DataSourceRegistry, DataSourceOption, FetchOptionsResponse, DataSourceValueType, TextField, NumberField, BooleanField, EnumOption, EnumOptionValue, StaticEnumField, DynamicEnumField, DynamicSchemaField, ArrayField, ObjectField, AnyField, Group, Conditional, FormElement, FormSpec, EqualsPredicate, Predicate, } from "./types/index.js";
12
- export { createInitialFieldState } from "./types/index.js";
11
+ export type { Validity, FieldState, FormState, DataSourceRegistry, DataSourceOption, FetchOptionsResponse, DataSourceValueType, TextField, NumberField, BooleanField, EnumOption, EnumOptionValue, StaticEnumField, DynamicEnumField, DynamicSchemaField, ArrayField, ObjectField, AnyField, Group, Conditional, FormElement, FormSpec, EqualsPredicate, Predicate, FormSpecDecoratorName, ConstraintTagName, } from "./types/index.js";
12
+ export { createInitialFieldState, FORMSPEC_DECORATOR_NAMES, CONSTRAINT_TAG_DEFINITIONS, } from "./types/index.js";
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,YAAY,EAEV,QAAQ,EAGR,UAAU,EAGV,SAAS,EAGT,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EAGnB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,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,kBAAkB,CAAC;AAG1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,YAAY,EAEV,QAAQ,EAGR,UAAU,EAGV,SAAS,EAGT,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EAGnB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,EAGR,eAAe,EACf,SAAS,EAGT,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -9,5 +9,5 @@
9
9
  * @packageDocumentation
10
10
  */
11
11
  // Re-export functions
12
- export { createInitialFieldState } from "./types/index.js";
12
+ export { createInitialFieldState, FORMSPEC_DECORATOR_NAMES, CONSTRAINT_TAG_DEFINITIONS, } from "./types/index.js";
13
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAyCH,sBAAsB;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA6CH,sBAAsB;AACtB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"data-source.d.ts","sourceRoot":"","sources":["../../src/types/data-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,kBAAkB;CAElC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,oDAAoD;IACpD,QAAQ,CAAC,KAAK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jD,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IAEnD,iDAAiD;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,CAAC,MAAM,SAAS,MAAM,IAAI,MAAM,SAAS,MAAM,kBAAkB,GAC5F,kBAAkB,CAAC,MAAM,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,EAAE,CAAA;CAAE,GACjD,EAAE,GACF,MAAM,GACR,MAAM,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Canonical set of FormSpec decorator names.
3
+ *
4
+ * This is the single source of truth for which decorators FormSpec recognizes.
5
+ * Both `@formspec/eslint-plugin` and `@formspec/build` import from here.
6
+ */
7
+ /** Names of all built-in FormSpec decorators. */
8
+ export declare const FORMSPEC_DECORATOR_NAMES: readonly ["Field", "Group", "ShowWhen", "EnumOptions", "Minimum", "Maximum", "ExclusiveMinimum", "ExclusiveMaximum", "MinLength", "MaxLength", "Pattern"];
9
+ /** Type of a FormSpec decorator name. */
10
+ export type FormSpecDecoratorName = (typeof FORMSPEC_DECORATOR_NAMES)[number];
11
+ /**
12
+ * Constraint decorator names that are valid as TSDoc tags, mapped to
13
+ * their expected value type for parsing.
14
+ *
15
+ * Both `@formspec/build` (schema generation) and `@formspec/eslint-plugin`
16
+ * (lint-time validation) import this to determine which JSDoc tags to
17
+ * recognize and how to parse their values.
18
+ */
19
+ export declare const CONSTRAINT_TAG_DEFINITIONS: {
20
+ readonly Minimum: "number";
21
+ readonly Maximum: "number";
22
+ readonly ExclusiveMinimum: "number";
23
+ readonly ExclusiveMaximum: "number";
24
+ readonly MinLength: "number";
25
+ readonly MaxLength: "number";
26
+ readonly Pattern: "string";
27
+ };
28
+ /** Type of a constraint tag name. */
29
+ export type ConstraintTagName = keyof typeof CONSTRAINT_TAG_DEFINITIONS;
30
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/types/decorators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iDAAiD;AACjD,eAAO,MAAM,wBAAwB,2JAY3B,CAAC;AAEX,yCAAyC;AACzC,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;CAQ7B,CAAC;AAEX,qCAAqC;AACrC,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,0BAA0B,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Canonical set of FormSpec decorator names.
3
+ *
4
+ * This is the single source of truth for which decorators FormSpec recognizes.
5
+ * Both `@formspec/eslint-plugin` and `@formspec/build` import from here.
6
+ */
7
+ /** Names of all built-in FormSpec decorators. */
8
+ export const FORMSPEC_DECORATOR_NAMES = [
9
+ "Field",
10
+ "Group",
11
+ "ShowWhen",
12
+ "EnumOptions",
13
+ "Minimum",
14
+ "Maximum",
15
+ "ExclusiveMinimum",
16
+ "ExclusiveMaximum",
17
+ "MinLength",
18
+ "MaxLength",
19
+ "Pattern",
20
+ ];
21
+ /**
22
+ * Constraint decorator names that are valid as TSDoc tags, mapped to
23
+ * their expected value type for parsing.
24
+ *
25
+ * Both `@formspec/build` (schema generation) and `@formspec/eslint-plugin`
26
+ * (lint-time validation) import this to determine which JSDoc tags to
27
+ * recognize and how to parse their values.
28
+ */
29
+ export const CONSTRAINT_TAG_DEFINITIONS = {
30
+ Minimum: "number",
31
+ Maximum: "number",
32
+ ExclusiveMinimum: "number",
33
+ ExclusiveMaximum: "number",
34
+ MinLength: "number",
35
+ MaxLength: "number",
36
+ Pattern: "string",
37
+ };
38
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/types/decorators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iDAAiD;AACjD,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,OAAO;IACP,OAAO;IACP,UAAU;IACV,aAAa;IACb,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,kBAAkB;IAClB,WAAW;IACX,WAAW;IACX,SAAS;CACD,CAAC;AAKX;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,QAAQ;IACjB,gBAAgB,EAAE,QAAQ;IAC1B,gBAAgB,EAAE,QAAQ;IAC1B,SAAS,EAAE,QAAQ;IACnB,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,QAAQ;CACT,CAAC"}
@@ -5,4 +5,6 @@ export type { FormState } from "./form-state.js";
5
5
  export type { DataSourceRegistry, DataSourceOption, FetchOptionsResponse, DataSourceValueType, } from "./data-source.js";
6
6
  export type { TextField, NumberField, BooleanField, EnumOption, EnumOptionValue, StaticEnumField, DynamicEnumField, DynamicSchemaField, ArrayField, ObjectField, AnyField, Group, Conditional, FormElement, FormSpec, } from "./elements.js";
7
7
  export type { EqualsPredicate, Predicate } from "./predicate.js";
8
+ export { FORMSPEC_DECORATOR_NAMES, CONSTRAINT_TAG_DEFINITIONS } from "./decorators.js";
9
+ export type { FormSpecDecoratorName, ConstraintTagName } from "./decorators.js";
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,GACT,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,GACT,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AACvF,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  // Re-export all types from the types directory
2
2
  export { createInitialFieldState } from "./field-state.js";
3
+ export { FORMSPEC_DECORATOR_NAMES, CONSTRAINT_TAG_DEFINITIONS } from "./decorators.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAK/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAK/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AA+B3D,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formspec/core",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.9",
4
4
  "description": "Core utilities for formspec",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",