json-schema-to-blocks 0.5.0 → 0.5.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/esm/rules.js CHANGED
@@ -36,7 +36,10 @@ const inputTypes = {
36
36
  url: 'url',
37
37
  password: 'password',
38
38
  };
39
- /** Long free text is a Textarea; the cutoff is a heuristic, overridable by `x-ui`. */
39
+ /**
40
+ * Long free text is a Textarea; the cutoff is a heuristic, overridable by `x-ui`.
41
+ * A `pattern` marks a single token (a slug, a code), so it stays one line.
42
+ */
40
43
  const TEXTAREA_MIN_LENGTH = 256;
41
44
  export const defaultWidgetRules = [
42
45
  {
@@ -86,7 +89,11 @@ export const defaultWidgetRules = [
86
89
  name: 'string-long',
87
90
  match: (ctx) => {
88
91
  const maxLength = ctx.constraints?.maxLength;
89
- return ctx.dataType === 'string' && (maxLength == null || maxLength >= TEXTAREA_MIN_LENGTH);
92
+ if (ctx.dataType !== 'string')
93
+ return false;
94
+ if (maxLength != null)
95
+ return maxLength >= TEXTAREA_MIN_LENGTH;
96
+ return ctx.constraints?.pattern == null;
90
97
  },
91
98
  node: 'Textarea',
92
99
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-schema-to-blocks",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Lower JSON Schema into blocks-schema UI documents: composable widget rules, constraints, and x-ui overrides",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -38,8 +38,8 @@
38
38
  "renderer"
39
39
  ],
40
40
  "dependencies": {
41
- "blocks-schema": "^0.5.1",
42
- "json-renderer": "^0.4.0"
41
+ "blocks-schema": "^0.5.2",
42
+ "json-renderer": "^0.4.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "makage": "^0.6.0",
@@ -49,5 +49,5 @@
49
49
  "engines": {
50
50
  "node": ">=24.0.0"
51
51
  },
52
- "gitHead": "70333e34de6ec02829cca256e9c6183b35bc12e7"
52
+ "gitHead": "47f7c369334a26bf7b944443892b5083acdffb2b"
53
53
  }
package/rules.js CHANGED
@@ -40,7 +40,10 @@ const inputTypes = {
40
40
  url: 'url',
41
41
  password: 'password',
42
42
  };
43
- /** Long free text is a Textarea; the cutoff is a heuristic, overridable by `x-ui`. */
43
+ /**
44
+ * Long free text is a Textarea; the cutoff is a heuristic, overridable by `x-ui`.
45
+ * A `pattern` marks a single token (a slug, a code), so it stays one line.
46
+ */
44
47
  const TEXTAREA_MIN_LENGTH = 256;
45
48
  exports.defaultWidgetRules = [
46
49
  {
@@ -90,7 +93,11 @@ exports.defaultWidgetRules = [
90
93
  name: 'string-long',
91
94
  match: (ctx) => {
92
95
  const maxLength = ctx.constraints?.maxLength;
93
- return ctx.dataType === 'string' && (maxLength == null || maxLength >= TEXTAREA_MIN_LENGTH);
96
+ if (ctx.dataType !== 'string')
97
+ return false;
98
+ if (maxLength != null)
99
+ return maxLength >= TEXTAREA_MIN_LENGTH;
100
+ return ctx.constraints?.pattern == null;
94
101
  },
95
102
  node: 'Textarea',
96
103
  },