@atscript/ui 0.1.134 → 0.1.136
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 +44 -5
- package/dist/index.mjs +44 -5
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -362,11 +362,7 @@ function createFormDef(type, opts) {
|
|
|
362
362
|
if (isChildOfStructured(path, structuredPrefixes)) continue;
|
|
363
363
|
const originalProp = resolveOriginalProp(objectType, path) ?? prop;
|
|
364
364
|
const kind = originalProp.type.kind;
|
|
365
|
-
if (kind === "object")
|
|
366
|
-
const hasLabel = getFieldMeta(originalProp, META_LABEL) !== void 0;
|
|
367
|
-
const hasComponent = getFieldMeta(originalProp, UI_FORM_COMPONENT) !== void 0;
|
|
368
|
-
if (!hasLabel && !hasComponent) continue;
|
|
369
|
-
}
|
|
365
|
+
if (kind === "object" && !isStructuredObject(originalProp)) continue;
|
|
370
366
|
if (kind === "array") {
|
|
371
367
|
if (originalProp.type.of.type.kind === "array" && !getFieldMeta(originalProp, "ui.form.component")) continue;
|
|
372
368
|
}
|
|
@@ -508,6 +504,49 @@ function createFieldDef(path, prop) {
|
|
|
508
504
|
phantom: kind === "" && dt === "phantom"
|
|
509
505
|
};
|
|
510
506
|
}
|
|
507
|
+
/** Non-`ui.form.*` keys that still address the object itself. */
|
|
508
|
+
const OBJECT_IDENTITY_KEYS = new Set([
|
|
509
|
+
META_LABEL,
|
|
510
|
+
META_DESCRIPTION,
|
|
511
|
+
UI_TYPE
|
|
512
|
+
]);
|
|
513
|
+
const UI_FORM_NS = "ui.form.";
|
|
514
|
+
/** `ui.form.*` keys that place a field rather than give it an identity. */
|
|
515
|
+
const UI_FORM_PLACEMENT_NS = "ui.form.grid.";
|
|
516
|
+
/**
|
|
517
|
+
* Whether an object prop renders as a field of its own rather than being
|
|
518
|
+
* flattened into its parent.
|
|
519
|
+
*
|
|
520
|
+
* Any `@ui.form.*` annotation (plus `@meta.label` / `@meta.description` /
|
|
521
|
+
* `@ui.type`) means the author addressed the object itself, so it needs a
|
|
522
|
+
* field to carry that instruction to a renderer — a collapsible section, or
|
|
523
|
+
* whatever `@ui.form.component` / `@ui.form.type` names. An object with none
|
|
524
|
+
* of them is a pure namespace: it is dropped and its children render inline
|
|
525
|
+
* in the parent grid, which keeps DB-flattened structs (`addr.street` stored
|
|
526
|
+
* as `addr__street`) from growing chrome nobody asked for. `@db.*`,
|
|
527
|
+
* `@expect.*` and the rest of `@meta.*` stay out for exactly that reason —
|
|
528
|
+
* they are what such a struct carries.
|
|
529
|
+
*
|
|
530
|
+
* Placement keys (`@ui.form.order`, `@ui.form.grid.*`) are excluded: they
|
|
531
|
+
* position a field among its siblings, and a namespace has no position of its
|
|
532
|
+
* own — its children carry their own.
|
|
533
|
+
*
|
|
534
|
+
* A prefix rule rather than a list because the list was wrong the moment it
|
|
535
|
+
* was written. Matching on `@meta.label` and `@ui.form.component` alone left
|
|
536
|
+
* every other key to be read off a prop that never became a field: a
|
|
537
|
+
* `@meta.description` went missing, a `@ui.form.type` component silently
|
|
538
|
+
* never mounted, `@ui.form.pushDown` never pushed down, and — the one that
|
|
539
|
+
* mattered — `@ui.form.hidden` on a struct left every child on screen.
|
|
540
|
+
*/
|
|
541
|
+
function isStructuredObject(prop) {
|
|
542
|
+
for (const key of prop.metadata.keys()) {
|
|
543
|
+
if (OBJECT_IDENTITY_KEYS.has(key)) return true;
|
|
544
|
+
if (!key.startsWith(UI_FORM_NS)) continue;
|
|
545
|
+
if (key === "ui.form.order" || key.startsWith(UI_FORM_PLACEMENT_NS)) continue;
|
|
546
|
+
return true;
|
|
547
|
+
}
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
511
550
|
/** Resolves the original annotated type from the type hierarchy by path. */
|
|
512
551
|
function resolveOriginalProp(type, path) {
|
|
513
552
|
const parts = path.split(".");
|
package/dist/index.mjs
CHANGED
|
@@ -361,11 +361,7 @@ function createFormDef(type, opts) {
|
|
|
361
361
|
if (isChildOfStructured(path, structuredPrefixes)) continue;
|
|
362
362
|
const originalProp = resolveOriginalProp(objectType, path) ?? prop;
|
|
363
363
|
const kind = originalProp.type.kind;
|
|
364
|
-
if (kind === "object")
|
|
365
|
-
const hasLabel = getFieldMeta(originalProp, META_LABEL) !== void 0;
|
|
366
|
-
const hasComponent = getFieldMeta(originalProp, UI_FORM_COMPONENT) !== void 0;
|
|
367
|
-
if (!hasLabel && !hasComponent) continue;
|
|
368
|
-
}
|
|
364
|
+
if (kind === "object" && !isStructuredObject(originalProp)) continue;
|
|
369
365
|
if (kind === "array") {
|
|
370
366
|
if (originalProp.type.of.type.kind === "array" && !getFieldMeta(originalProp, "ui.form.component")) continue;
|
|
371
367
|
}
|
|
@@ -507,6 +503,49 @@ function createFieldDef(path, prop) {
|
|
|
507
503
|
phantom: kind === "" && dt === "phantom"
|
|
508
504
|
};
|
|
509
505
|
}
|
|
506
|
+
/** Non-`ui.form.*` keys that still address the object itself. */
|
|
507
|
+
const OBJECT_IDENTITY_KEYS = new Set([
|
|
508
|
+
META_LABEL,
|
|
509
|
+
META_DESCRIPTION,
|
|
510
|
+
UI_TYPE
|
|
511
|
+
]);
|
|
512
|
+
const UI_FORM_NS = "ui.form.";
|
|
513
|
+
/** `ui.form.*` keys that place a field rather than give it an identity. */
|
|
514
|
+
const UI_FORM_PLACEMENT_NS = "ui.form.grid.";
|
|
515
|
+
/**
|
|
516
|
+
* Whether an object prop renders as a field of its own rather than being
|
|
517
|
+
* flattened into its parent.
|
|
518
|
+
*
|
|
519
|
+
* Any `@ui.form.*` annotation (plus `@meta.label` / `@meta.description` /
|
|
520
|
+
* `@ui.type`) means the author addressed the object itself, so it needs a
|
|
521
|
+
* field to carry that instruction to a renderer — a collapsible section, or
|
|
522
|
+
* whatever `@ui.form.component` / `@ui.form.type` names. An object with none
|
|
523
|
+
* of them is a pure namespace: it is dropped and its children render inline
|
|
524
|
+
* in the parent grid, which keeps DB-flattened structs (`addr.street` stored
|
|
525
|
+
* as `addr__street`) from growing chrome nobody asked for. `@db.*`,
|
|
526
|
+
* `@expect.*` and the rest of `@meta.*` stay out for exactly that reason —
|
|
527
|
+
* they are what such a struct carries.
|
|
528
|
+
*
|
|
529
|
+
* Placement keys (`@ui.form.order`, `@ui.form.grid.*`) are excluded: they
|
|
530
|
+
* position a field among its siblings, and a namespace has no position of its
|
|
531
|
+
* own — its children carry their own.
|
|
532
|
+
*
|
|
533
|
+
* A prefix rule rather than a list because the list was wrong the moment it
|
|
534
|
+
* was written. Matching on `@meta.label` and `@ui.form.component` alone left
|
|
535
|
+
* every other key to be read off a prop that never became a field: a
|
|
536
|
+
* `@meta.description` went missing, a `@ui.form.type` component silently
|
|
537
|
+
* never mounted, `@ui.form.pushDown` never pushed down, and — the one that
|
|
538
|
+
* mattered — `@ui.form.hidden` on a struct left every child on screen.
|
|
539
|
+
*/
|
|
540
|
+
function isStructuredObject(prop) {
|
|
541
|
+
for (const key of prop.metadata.keys()) {
|
|
542
|
+
if (OBJECT_IDENTITY_KEYS.has(key)) return true;
|
|
543
|
+
if (!key.startsWith(UI_FORM_NS)) continue;
|
|
544
|
+
if (key === "ui.form.order" || key.startsWith(UI_FORM_PLACEMENT_NS)) continue;
|
|
545
|
+
return true;
|
|
546
|
+
}
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
510
549
|
/** Resolves the original annotated type from the type hierarchy by path. */
|
|
511
550
|
function resolveOriginalProp(type, path) {
|
|
512
551
|
const parts = path.split(".");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.136",
|
|
4
4
|
"description": "Framework-agnostic runtime for form and table definitions from atscript annotated types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@atscript/db-client": "^0.1.
|
|
50
|
+
"@atscript/db-client": "^0.1.130"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@atscript/core": "^0.1.93",
|
|
54
|
-
"@atscript/db": "^0.1.
|
|
54
|
+
"@atscript/db": "^0.1.130",
|
|
55
55
|
"@atscript/typescript": "^0.1.93",
|
|
56
56
|
"unplugin-atscript": "^0.1.93",
|
|
57
57
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14"
|