@formspec/core 0.1.0-alpha.10 → 0.1.0-alpha.11

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.cjs ADDED
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ CONSTRAINT_TAG_DEFINITIONS: () => CONSTRAINT_TAG_DEFINITIONS,
24
+ FORMSPEC_DECORATOR_NAMES: () => FORMSPEC_DECORATOR_NAMES,
25
+ createInitialFieldState: () => createInitialFieldState
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/types/field-state.ts
30
+ function createInitialFieldState(value) {
31
+ return {
32
+ value,
33
+ dirty: false,
34
+ touched: false,
35
+ validity: "unknown",
36
+ errors: []
37
+ };
38
+ }
39
+
40
+ // src/types/decorators.ts
41
+ var FORMSPEC_DECORATOR_NAMES = [
42
+ "Field",
43
+ "Group",
44
+ "ShowWhen",
45
+ "EnumOptions",
46
+ "Minimum",
47
+ "Maximum",
48
+ "ExclusiveMinimum",
49
+ "ExclusiveMaximum",
50
+ "MinLength",
51
+ "MaxLength",
52
+ "Pattern"
53
+ ];
54
+ var CONSTRAINT_TAG_DEFINITIONS = {
55
+ Minimum: "number",
56
+ Maximum: "number",
57
+ ExclusiveMinimum: "number",
58
+ ExclusiveMaximum: "number",
59
+ MinLength: "number",
60
+ MaxLength: "number",
61
+ Pattern: "string",
62
+ EnumOptions: "json"
63
+ };
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ CONSTRAINT_TAG_DEFINITIONS,
67
+ FORMSPEC_DECORATOR_NAMES,
68
+ createInitialFieldState
69
+ });
70
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/types/field-state.ts","../src/types/decorators.ts"],"sourcesContent":["/**\n * `@formspec/core` - Core type definitions for FormSpec\n *\n * This package provides the foundational types used throughout the FormSpec ecosystem:\n * - Form element types (fields, groups, conditionals)\n * - Field and form state types\n * - Data source registry for dynamic enums\n *\n * @packageDocumentation\n */\n\n// Re-export all types\nexport type {\n // Validity\n Validity,\n\n // Field state\n FieldState,\n\n // Form state\n FormState,\n\n // Data sources\n DataSourceRegistry,\n DataSourceOption,\n FetchOptionsResponse,\n DataSourceValueType,\n\n // Elements\n TextField,\n NumberField,\n BooleanField,\n EnumOption,\n EnumOptionValue,\n StaticEnumField,\n DynamicEnumField,\n DynamicSchemaField,\n ArrayField,\n ObjectField,\n AnyField,\n Group,\n Conditional,\n FormElement,\n FormSpec,\n\n // Predicates\n EqualsPredicate,\n Predicate,\n\n // Decorators\n FormSpecDecoratorName,\n ConstraintTagName,\n} from \"./types/index.js\";\n\n// Re-export functions\nexport {\n createInitialFieldState,\n FORMSPEC_DECORATOR_NAMES,\n CONSTRAINT_TAG_DEFINITIONS,\n} from \"./types/index.js\";\n","import type { Validity } from \"./validity.js\";\n\n/**\n * Represents the runtime state of a single form field.\n *\n * @typeParam T - The value type of the field\n */\nexport interface FieldState<T> {\n /** Current value of the field */\n readonly value: T;\n\n /** Whether the field has been modified by the user */\n readonly dirty: boolean;\n\n /** Whether the field has been focused and blurred */\n readonly touched: boolean;\n\n /** Current validity state */\n readonly validity: Validity;\n\n /** Validation error messages, if any */\n readonly errors: readonly string[];\n}\n\n/**\n * Creates initial field state with default values.\n *\n * @typeParam T - The value type of the field\n * @param value - The initial value for the field\n * @returns Initial field state\n */\nexport function createInitialFieldState<T>(value: T): FieldState<T> {\n return {\n value,\n dirty: false,\n touched: false,\n validity: \"unknown\",\n errors: [],\n };\n}\n","/**\n * Canonical set of FormSpec decorator names.\n *\n * This is the single source of truth for which decorators FormSpec recognizes.\n * Both `@formspec/eslint-plugin` and `@formspec/build` import from here.\n */\n\n/** Names of all built-in FormSpec decorators. */\nexport const FORMSPEC_DECORATOR_NAMES = [\n \"Field\",\n \"Group\",\n \"ShowWhen\",\n \"EnumOptions\",\n \"Minimum\",\n \"Maximum\",\n \"ExclusiveMinimum\",\n \"ExclusiveMaximum\",\n \"MinLength\",\n \"MaxLength\",\n \"Pattern\",\n] as const;\n\n/** Type of a FormSpec decorator name. */\nexport type FormSpecDecoratorName = (typeof FORMSPEC_DECORATOR_NAMES)[number];\n\n/**\n * Constraint decorator names that are valid as TSDoc tags, mapped to\n * their expected value type for parsing.\n *\n * Both `@formspec/build` (schema generation) and `@formspec/eslint-plugin`\n * (lint-time validation) import this to determine which JSDoc tags to\n * recognize and how to parse their values.\n */\nexport const CONSTRAINT_TAG_DEFINITIONS = {\n Minimum: \"number\",\n Maximum: \"number\",\n ExclusiveMinimum: \"number\",\n ExclusiveMaximum: \"number\",\n MinLength: \"number\",\n MaxLength: \"number\",\n Pattern: \"string\",\n EnumOptions: \"json\",\n} as const;\n\n/** Type of a constraint tag name. */\nexport type ConstraintTagName = keyof typeof CONSTRAINT_TAG_DEFINITIONS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC+BO,SAAS,wBAA2B,OAAyB;AAClE,SAAO;AAAA,IACL;AAAA,IACA,OAAO;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ,CAAC;AAAA,EACX;AACF;;;AC/BO,IAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAaO,IAAM,6BAA6B;AAAA,EACxC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,SAAS;AAAA,EACT,aAAa;AACf;","names":[]}
package/dist/index.js CHANGED
@@ -1,13 +1,41 @@
1
- /**
2
- * `@formspec/core` - Core type definitions for FormSpec
3
- *
4
- * This package provides the foundational types used throughout the FormSpec ecosystem:
5
- * - Form element types (fields, groups, conditionals)
6
- * - Field and form state types
7
- * - Data source registry for dynamic enums
8
- *
9
- * @packageDocumentation
10
- */
11
- // Re-export functions
12
- export { createInitialFieldState, FORMSPEC_DECORATOR_NAMES, CONSTRAINT_TAG_DEFINITIONS, } from "./types/index.js";
1
+ // src/types/field-state.ts
2
+ function createInitialFieldState(value) {
3
+ return {
4
+ value,
5
+ dirty: false,
6
+ touched: false,
7
+ validity: "unknown",
8
+ errors: []
9
+ };
10
+ }
11
+
12
+ // src/types/decorators.ts
13
+ var FORMSPEC_DECORATOR_NAMES = [
14
+ "Field",
15
+ "Group",
16
+ "ShowWhen",
17
+ "EnumOptions",
18
+ "Minimum",
19
+ "Maximum",
20
+ "ExclusiveMinimum",
21
+ "ExclusiveMaximum",
22
+ "MinLength",
23
+ "MaxLength",
24
+ "Pattern"
25
+ ];
26
+ var CONSTRAINT_TAG_DEFINITIONS = {
27
+ Minimum: "number",
28
+ Maximum: "number",
29
+ ExclusiveMinimum: "number",
30
+ ExclusiveMaximum: "number",
31
+ MinLength: "number",
32
+ MaxLength: "number",
33
+ Pattern: "string",
34
+ EnumOptions: "json"
35
+ };
36
+ export {
37
+ CONSTRAINT_TAG_DEFINITIONS,
38
+ FORMSPEC_DECORATOR_NAMES,
39
+ createInitialFieldState
40
+ };
13
41
  //# 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;AA6CH,sBAAsB;AACtB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"sources":["../src/types/field-state.ts","../src/types/decorators.ts"],"sourcesContent":["import type { Validity } from \"./validity.js\";\n\n/**\n * Represents the runtime state of a single form field.\n *\n * @typeParam T - The value type of the field\n */\nexport interface FieldState<T> {\n /** Current value of the field */\n readonly value: T;\n\n /** Whether the field has been modified by the user */\n readonly dirty: boolean;\n\n /** Whether the field has been focused and blurred */\n readonly touched: boolean;\n\n /** Current validity state */\n readonly validity: Validity;\n\n /** Validation error messages, if any */\n readonly errors: readonly string[];\n}\n\n/**\n * Creates initial field state with default values.\n *\n * @typeParam T - The value type of the field\n * @param value - The initial value for the field\n * @returns Initial field state\n */\nexport function createInitialFieldState<T>(value: T): FieldState<T> {\n return {\n value,\n dirty: false,\n touched: false,\n validity: \"unknown\",\n errors: [],\n };\n}\n","/**\n * Canonical set of FormSpec decorator names.\n *\n * This is the single source of truth for which decorators FormSpec recognizes.\n * Both `@formspec/eslint-plugin` and `@formspec/build` import from here.\n */\n\n/** Names of all built-in FormSpec decorators. */\nexport const FORMSPEC_DECORATOR_NAMES = [\n \"Field\",\n \"Group\",\n \"ShowWhen\",\n \"EnumOptions\",\n \"Minimum\",\n \"Maximum\",\n \"ExclusiveMinimum\",\n \"ExclusiveMaximum\",\n \"MinLength\",\n \"MaxLength\",\n \"Pattern\",\n] as const;\n\n/** Type of a FormSpec decorator name. */\nexport type FormSpecDecoratorName = (typeof FORMSPEC_DECORATOR_NAMES)[number];\n\n/**\n * Constraint decorator names that are valid as TSDoc tags, mapped to\n * their expected value type for parsing.\n *\n * Both `@formspec/build` (schema generation) and `@formspec/eslint-plugin`\n * (lint-time validation) import this to determine which JSDoc tags to\n * recognize and how to parse their values.\n */\nexport const CONSTRAINT_TAG_DEFINITIONS = {\n Minimum: \"number\",\n Maximum: \"number\",\n ExclusiveMinimum: \"number\",\n ExclusiveMaximum: \"number\",\n MinLength: \"number\",\n MaxLength: \"number\",\n Pattern: \"string\",\n EnumOptions: \"json\",\n} as const;\n\n/** Type of a constraint tag name. */\nexport type ConstraintTagName = keyof typeof CONSTRAINT_TAG_DEFINITIONS;\n"],"mappings":";AA+BO,SAAS,wBAA2B,OAAyB;AAClE,SAAO;AAAA,IACL;AAAA,IACA,OAAO;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ,CAAC;AAAA,EACX;AACF;;;AC/BO,IAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAaO,IAAM,6BAA6B;AAAA,EACxC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,SAAS;AAAA,EACT,aAAa;AACf;","names":[]}
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@formspec/core",
3
- "version": "0.1.0-alpha.10",
3
+ "version": "0.1.0-alpha.11",
4
4
  "description": "Core utilities for formspec",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
7
8
  "types": "./dist/core.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
11
  "types": "./dist/core.d.ts",
11
- "import": "./dist/index.js"
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
12
14
  }
13
15
  },
14
16
  "files": [
@@ -21,7 +23,7 @@
21
23
  "keywords": [],
22
24
  "license": "UNLICENSED",
23
25
  "scripts": {
24
- "build": "tsc && api-extractor run --local",
26
+ "build": "tsup && tsc --emitDeclarationOnly && api-extractor run --local",
25
27
  "clean": "rm -rf dist temp",
26
28
  "typecheck": "tsc --noEmit",
27
29
  "api-extractor": "api-extractor run",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data-source.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-source.js","sourceRoot":"","sources":["../../src/types/data-source.ts"],"names":[],"mappings":""}
@@ -1,39 +0,0 @@
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
- EnumOptions: "json",
38
- };
39
- //# sourceMappingURL=decorators.js.map
@@ -1 +0,0 @@
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;IACjB,WAAW,EAAE,MAAM;CACX,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Form element type definitions.
3
- *
4
- * These types define the structure of form specifications.
5
- * The structure IS the definition - nesting implies layout and conditional logic.
6
- */
7
- export {};
8
- //# sourceMappingURL=elements.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/types/elements.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Creates initial field state with default values.
3
- *
4
- * @typeParam T - The value type of the field
5
- * @param value - The initial value for the field
6
- * @returns Initial field state
7
- */
8
- export function createInitialFieldState(value) {
9
- return {
10
- value,
11
- dirty: false,
12
- touched: false,
13
- validity: "unknown",
14
- errors: [],
15
- };
16
- }
17
- //# sourceMappingURL=field-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field-state.js","sourceRoot":"","sources":["../../src/types/field-state.ts"],"names":[],"mappings":"AAwBA;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAI,KAAQ;IACjD,OAAO;QACL,KAAK;QACL,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,SAAS;QACnB,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=form-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-state.js","sourceRoot":"","sources":["../../src/types/form-state.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- // Re-export all types from the types directory
2
- export { createInitialFieldState } from "./field-state.js";
3
- export { FORMSPEC_DECORATOR_NAMES, CONSTRAINT_TAG_DEFINITIONS } from "./decorators.js";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Predicate types for conditional logic.
3
- *
4
- * Predicates are used with `when()` to define conditions in a readable way.
5
- */
6
- export {};
7
- //# sourceMappingURL=predicate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../src/types/predicate.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=validity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validity.js","sourceRoot":"","sources":["../../src/types/validity.ts"],"names":[],"mappings":""}