@uniweb/core 0.7.1 → 0.7.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/package.json +2 -2
- package/src/index.js +1 -0
- package/src/schemas.js +37 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"jest": "^29.7.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@uniweb/semantic-parser": "1.1.
|
|
33
|
+
"@uniweb/semantic-parser": "1.1.10",
|
|
34
34
|
"@uniweb/theming": "0.1.3"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
package/src/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { default as ObservableState } from './observable-state.js'
|
|
|
22
22
|
export { default as singularize } from './singularize.js'
|
|
23
23
|
export { substitutePlaceholders } from './substitute-placeholders.js'
|
|
24
24
|
export { evaluate as evaluateWhere, match as matchWhere } from './where.js'
|
|
25
|
+
export { isRichSchema } from './schemas.js'
|
|
25
26
|
export { resolveStyle as resolveRequestStyle, listStyleNames as listRequestStyleNames } from './request-styles/index.js'
|
|
26
27
|
|
|
27
28
|
/**
|
package/src/schemas.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for rich form schemas.
|
|
3
|
+
*
|
|
4
|
+
* Rich schemas live under `data.schemas` in a component's meta.js. They
|
|
5
|
+
* drive two author input paths that both land at `content.data[schema-id]`:
|
|
6
|
+
*
|
|
7
|
+
* 1. Tagged markdown blocks (``` ```yaml:<id> ``` ```)
|
|
8
|
+
* 2. The FormBlock editor widget
|
|
9
|
+
*
|
|
10
|
+
* Detection is shared across the build pipeline (emit path), the runtime
|
|
11
|
+
* (dispatch in applySchemas), and the editor (filter for FormBlock menu)
|
|
12
|
+
* so all three agree on what counts as a rich schema.
|
|
13
|
+
*
|
|
14
|
+
* Conditional field visibility (a rich-schema feature) is an editor-only
|
|
15
|
+
* concern and is not implemented here — the editor owns its own evaluator.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Does a `data.schemas` entry look like a rich form schema?
|
|
20
|
+
*
|
|
21
|
+
* Rich schemas have an ordered `fields` array (composite arrays and
|
|
22
|
+
* nested objects), distinct from simple keyed-object schemas used for
|
|
23
|
+
* tagged blocks. Markers (any of):
|
|
24
|
+
* - `fields` is an array
|
|
25
|
+
* - `isComposite: true`
|
|
26
|
+
* - `childSchema` present
|
|
27
|
+
*
|
|
28
|
+
* @param {*} schema - Schema value to inspect.
|
|
29
|
+
* @returns {boolean}
|
|
30
|
+
*/
|
|
31
|
+
export function isRichSchema(schema) {
|
|
32
|
+
if (!schema || typeof schema !== 'object') return false
|
|
33
|
+
if (Array.isArray(schema.fields)) return true
|
|
34
|
+
if (schema.isComposite === true) return true
|
|
35
|
+
if (schema.childSchema && typeof schema.childSchema === 'object') return true
|
|
36
|
+
return false
|
|
37
|
+
}
|