@streamline-pulse/formkrafter-core 0.33.0 → 0.36.0
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/ai/brick-catalog.d.ts +39 -0
- package/dist/ai/from-strict-spec.d.ts +9 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +165 -1
- package/dist/index.js.map +7 -5
- package/dist/utils/brick-spec.d.ts +18 -0
- package/dist/utils/lint-spec.d.ts +1 -1
- package/package.json +3 -2
- package/schema/form-spec.schema.json +30 -0
- package/schema/form-spec.strict.schema.json +2040 -0
|
@@ -5,6 +5,23 @@ import type { Rule } from "../rules/rule.js";
|
|
|
5
5
|
import type { BrickType } from "./brick-type.js";
|
|
6
6
|
import type { BrickBaseConfigs } from "./common-brick-props.js";
|
|
7
7
|
import type { BrickStyles } from "../utils/brick-styles.js";
|
|
8
|
+
/** One column of a row: `auto`, `min-content`, `max-content`, `2fr`, `12rem`, `30%`, or `minmax(a, b)` of those. */
|
|
9
|
+
export type RowTrack = string;
|
|
10
|
+
/** Where a brick sits in its row: `columns` and `labels` on a row, `span` on one of its children. */
|
|
11
|
+
export interface BrickLayout {
|
|
12
|
+
/**
|
|
13
|
+
* On a row: the number of equal columns, so a lone field keeps its share instead of the whole width;
|
|
14
|
+
* or one track size per column, e.g. `["auto", "1fr", "2fr"]`, so a checkbox column takes only its content.
|
|
15
|
+
*/
|
|
16
|
+
columns?: number | RowTrack[];
|
|
17
|
+
/** On a child of a row: how many of the row's columns it takes (1 by default). */
|
|
18
|
+
span?: number;
|
|
19
|
+
/**
|
|
20
|
+
* On a row: `"hidden"` hides its fields' labels from view and keeps them as accessible names,
|
|
21
|
+
* so a row of a table is one line high. A checkbox keeps its label beside the box.
|
|
22
|
+
*/
|
|
23
|
+
labels?: "visible" | "hidden";
|
|
24
|
+
}
|
|
8
25
|
export interface BrickSpec {
|
|
9
26
|
type: BrickType;
|
|
10
27
|
dataType?: JSONSchemaType;
|
|
@@ -20,6 +37,7 @@ export interface BrickSpec {
|
|
|
20
37
|
configsForm?: BrickSpec;
|
|
21
38
|
configs?: BrickBaseConfigs & Record<string, unknown>;
|
|
22
39
|
styles?: BrickStyles<string>;
|
|
40
|
+
layout?: BrickLayout;
|
|
23
41
|
children?: BrickSpec[];
|
|
24
42
|
}
|
|
25
43
|
export declare function iterateBricks(spec?: BrickSpec, path?: string): Generator<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BrickSpec } from "./brick-spec.js";
|
|
2
|
-
export type SpecIssueCode = "validations-without-data-type" | "input-without-key" | "duplicate-key" | "collection-without-children";
|
|
2
|
+
export type SpecIssueCode = "validations-without-data-type" | "input-without-key" | "duplicate-key" | "collection-without-children" | "content-in-row";
|
|
3
3
|
export interface SpecIssue {
|
|
4
4
|
code: SpecIssueCode;
|
|
5
5
|
path: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamline-pulse/formkrafter-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Framework-agnostic core for FormKrafter: form specs, RFC 6902 ops with undo/redo, Ajv validation, sandboxed rules engine and injectable services",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"types": "./dist/index.d.ts",
|
|
42
42
|
"import": "./dist/index.js"
|
|
43
43
|
},
|
|
44
|
-
"./schema/form-spec.schema.json": "./schema/form-spec.schema.json"
|
|
44
|
+
"./schema/form-spec.schema.json": "./schema/form-spec.schema.json",
|
|
45
|
+
"./schema/form-spec.strict.schema.json": "./schema/form-spec.strict.schema.json"
|
|
45
46
|
},
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"access": "public"
|
|
@@ -68,6 +68,30 @@
|
|
|
68
68
|
"description": "Style tokens applied to the brick, as CSS-like key/value pairs.",
|
|
69
69
|
"additionalProperties": true
|
|
70
70
|
},
|
|
71
|
+
"layout": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"description": "Placement in a row: \"columns\" and \"labels\" on the row itself, \"span\" on one of its children (how many columns it takes). A row still stacks on narrow screens.",
|
|
74
|
+
"properties": {
|
|
75
|
+
"columns": {
|
|
76
|
+
"description": "A number of equal columns (a lone field keeps its share), or one track size per column, e.g. [\"auto\", \"1fr\", \"2fr\"], so a checkbox column takes only its content.",
|
|
77
|
+
"anyOf": [
|
|
78
|
+
{ "type": "integer", "minimum": 1, "maximum": 12 },
|
|
79
|
+
{
|
|
80
|
+
"type": "array",
|
|
81
|
+
"minItems": 1,
|
|
82
|
+
"maxItems": 12,
|
|
83
|
+
"items": { "$ref": "#/$defs/rowTrack" }
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"span": { "type": "integer", "minimum": 1, "maximum": 12 },
|
|
88
|
+
"labels": {
|
|
89
|
+
"enum": ["visible", "hidden"],
|
|
90
|
+
"description": "\"hidden\" hides the labels of the row's fields from view and keeps them as accessible names, so a row of a table is one line high. A checkbox keeps its label beside the box."
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"additionalProperties": false
|
|
94
|
+
},
|
|
71
95
|
"children": {
|
|
72
96
|
"type": "array",
|
|
73
97
|
"items": { "$ref": "#/$defs/brick" },
|
|
@@ -77,6 +101,12 @@
|
|
|
77
101
|
"additionalProperties": false
|
|
78
102
|
},
|
|
79
103
|
|
|
104
|
+
"rowTrack": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"description": "One column of a row: auto, min-content, max-content, 0, a length in fr, px, rem, em, ch or %, or minmax(a, b) of those.",
|
|
107
|
+
"pattern": "^((auto|min-content|max-content|0|[0-9]+(\\.[0-9]+)?(fr|px|rem|em|ch|%))|minmax\\( *(auto|min-content|max-content|0|[0-9]+(\\.[0-9]+)?(fr|px|rem|em|ch|%)) *, *(auto|min-content|max-content|0|[0-9]+(\\.[0-9]+)?(fr|px|rem|em|ch|%)) *\\))$"
|
|
108
|
+
},
|
|
109
|
+
|
|
80
110
|
"brickType": {
|
|
81
111
|
"enum": ["panel", "input", "collection", "output", "action"]
|
|
82
112
|
},
|