@pipelex/mthds-form 0.12.1 → 0.14.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.
Files changed (40) hide show
  1. package/README.md +20 -0
  2. package/dist/{chunk-IUWLOSAM.js → chunk-2EGRONBV.js} +3 -3
  3. package/dist/{chunk-IUWLOSAM.js.map → chunk-2EGRONBV.js.map} +1 -1
  4. package/dist/{chunk-2D4NEFUH.js → chunk-7JRT6ZII.js} +1729 -177
  5. package/dist/chunk-7JRT6ZII.js.map +1 -0
  6. package/dist/{chunk-7KQXGG6J.js → chunk-ICUEHNEH.js} +19 -6
  7. package/dist/chunk-ICUEHNEH.js.map +1 -0
  8. package/dist/{chunk-DARLDVJM.js → chunk-JIGRWJTV.js} +2 -2
  9. package/dist/chunk-JIGRWJTV.js.map +1 -0
  10. package/dist/chunk-VH5CDQDR.js +41 -0
  11. package/dist/chunk-VH5CDQDR.js.map +1 -0
  12. package/dist/{chunk-4KGQ65TQ.js → chunk-VT5E5W4E.js} +4 -3
  13. package/dist/chunk-VT5E5W4E.js.map +1 -0
  14. package/dist/{chunk-PM55AHRO.js → chunk-XO5OENNF.js} +28 -4
  15. package/dist/chunk-XO5OENNF.js.map +1 -0
  16. package/dist/core/gate.js +2 -2
  17. package/dist/core/index.d.ts +2 -1
  18. package/dist/core/index.js +6 -5
  19. package/dist/core/output-form.d.ts +5 -4
  20. package/dist/core/output-form.js +1 -1
  21. package/dist/core/readiness.d.ts +55 -2
  22. package/dist/core/readiness.js +1 -1
  23. package/dist/core/save-plan.d.ts +31 -1
  24. package/dist/core/save-plan.js +1 -1
  25. package/dist/core/seed.d.ts +56 -0
  26. package/dist/core/seed.js +5 -0
  27. package/dist/core/seed.js.map +1 -0
  28. package/dist/core/values.js +2 -2
  29. package/dist/generative/index.d.ts +2 -11
  30. package/dist/generative/index.js +11 -17
  31. package/dist/generative/index.js.map +1 -1
  32. package/dist/react/index.d.ts +739 -185
  33. package/dist/react/index.js +9 -3
  34. package/dist/styles.css +1 -1
  35. package/package.json +3 -1
  36. package/dist/chunk-2D4NEFUH.js.map +0 -1
  37. package/dist/chunk-4KGQ65TQ.js.map +0 -1
  38. package/dist/chunk-7KQXGG6J.js.map +0 -1
  39. package/dist/chunk-DARLDVJM.js.map +0 -1
  40. package/dist/chunk-PM55AHRO.js.map +0 -1
@@ -0,0 +1,56 @@
1
+ import { RunField, ObjectRunField } from './descriptor.js';
2
+ import './contracts.js';
3
+ import 'mthds/protocol';
4
+ import './file-formats.js';
5
+
6
+ /**
7
+ * Seeding a form from the method's authored defaults.
8
+ *
9
+ * Pure module: no React, no DOM - a server building a payload and a control
10
+ * opening an optional structure read the same answer from here.
11
+ */
12
+
13
+ /**
14
+ * The `/inputs` seed: the authored defaults, and nothing else.
15
+ *
16
+ * A defaulted field carries `defaultValue` (never the `null` a schema
17
+ * projection attaches to an optional field); a structure's defaults sit inside
18
+ * it. What is NOT seeded is an empty string or a zero for an unfilled field -
19
+ * the kernel's readiness treats an absent value as absent, and a seeded
20
+ * placeholder would count as filled.
21
+ *
22
+ * **An optional structure is not descended into.** Its presence is a choice the
23
+ * person makes with the "+ N optional" disclosure it folds behind (see
24
+ * `isOptionalStructure`), so a seed that put its children's defaults inside it would make that choice
25
+ * for them: the structure would arrive open and be sent, merely because its
26
+ * concept declares defaults. It is seeded only when the structure itself
27
+ * carries an authored default; otherwise it stays absent, and turning it on
28
+ * seeds it then, through `seedObjectValue`. A host that wants it open from the
29
+ * start puts `seedObjectValue(field)` at its path.
30
+ */
31
+ declare function seedInputs(fields: readonly RunField[]): Record<string, unknown>;
32
+ /**
33
+ * The value a structured field holds the moment it is opened: the
34
+ * structure's own authored default when it carries an object one, otherwise
35
+ * an object seeded from its children's defaults by `seedInputs` - which is `{}`
36
+ * when none of them declares one. Always a plain object, so the disclosure that
37
+ * reads the value back (`optionalStructureOpen`) reads open.
38
+ *
39
+ * Optional structures beneath it stay absent, by `seedInputs`' own rule: each
40
+ * opens with its own container's disclosure.
41
+ */
42
+ declare function seedObjectValue(field: ObjectRunField): Record<string, unknown>;
43
+ /**
44
+ * What expanding a "+ N optional" disclosure writes: `values` with every
45
+ * CLOSED optional structure among `fields` opened to `seedObjectValue(field)`.
46
+ * Open ones and every other field are kept as they are. Returns a new object.
47
+ */
48
+ declare function openOptionalStructures(fields: readonly RunField[], values: Record<string, unknown> | undefined): Record<string, unknown>;
49
+ /**
50
+ * What collapsing a "+ N optional" disclosure writes: `values` with every
51
+ * optional structure among `fields` closed to `undefined`, so each leaves the
52
+ * payload. Every other field is kept as it is. Returns a new object.
53
+ */
54
+ declare function closeOptionalStructures(fields: readonly RunField[], values: Record<string, unknown> | undefined): Record<string, unknown>;
55
+
56
+ export { closeOptionalStructures, openOptionalStructures, seedInputs, seedObjectValue };
@@ -0,0 +1,5 @@
1
+ export { closeOptionalStructures, openOptionalStructures, seedInputs, seedObjectValue } from '../chunk-VH5CDQDR.js';
2
+ import '../chunk-XO5OENNF.js';
3
+ import '../chunk-V3OV2XQT.js';
4
+ //# sourceMappingURL=seed.js.map
5
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"seed.js"}
@@ -1,8 +1,8 @@
1
- export { apiInputsFromRunValues, fieldsForContract, inputDataFromWorkingMemory, outputsFromPipeOutput, rjsfDataFromRunValues, runValuesFromStore, setValueAtPath, storeInputDataFromRunValues } from '../chunk-4KGQ65TQ.js';
1
+ export { apiInputsFromRunValues, fieldsForContract, inputDataFromWorkingMemory, outputsFromPipeOutput, rjsfDataFromRunValues, runValuesFromStore, setValueAtPath, storeInputDataFromRunValues } from '../chunk-VT5E5W4E.js';
2
2
  import '../chunk-ZB4RYUKV.js';
3
3
  import '../chunk-XCO6GTEC.js';
4
4
  import '../chunk-GCXV76WU.js';
5
- import '../chunk-PM55AHRO.js';
5
+ import '../chunk-XO5OENNF.js';
6
6
  import '../chunk-GKV77RAS.js';
7
7
  import '../chunk-OD3VYXUY.js';
8
8
  import '../chunk-WYH56SOZ.js';
@@ -8,6 +8,7 @@ import * as _json_render_react from '@json-render/react';
8
8
  import { Components, Renderer } from '@json-render/react';
9
9
  import * as zod_v4_core from 'zod/v4/core';
10
10
  import { F as FieldEnv } from '../field-renderer-C5Onx6qB.js';
11
+ export { seedInputs } from '../core/seed.js';
11
12
  import '../core/contracts.js';
12
13
  import 'mthds/protocol';
13
14
  import '../core/file-formats.js';
@@ -2023,16 +2024,6 @@ declare function absoluteHatchPath(spec: Spec, key: string, path: string, parent
2023
2024
  * the model and the escape hatch read the same tree.
2024
2025
  */
2025
2026
  declare function payloadToState(field: RunField, payload: unknown): unknown;
2026
- /**
2027
- * The `/inputs` seed: the authored defaults, and nothing else.
2028
- *
2029
- * A defaulted field carries `defaultValue` (never the `null` a schema
2030
- * projection attaches to an optional field); a structure's defaults sit inside
2031
- * it. What is NOT seeded is an empty string or a zero for an unfilled field -
2032
- * the kernel's readiness treats an absent value as absent, and a seeded
2033
- * placeholder would count as filled.
2034
- */
2035
- declare function seedInputs(fields: readonly RunField[]): Record<string, unknown>;
2036
2027
 
2037
2028
  /**
2038
2029
  * A spec with its provenance - the shape every fixture takes, whoever produced
@@ -2103,4 +2094,4 @@ declare function fixtureLabel(fixture: Pick<SpecFixture, 'producer' | 'model' |
2103
2094
  /** The fixture a story asks for, or a loud failure: a story must never render a page it did not name. */
2104
2095
  declare function findFixture(fixtures: readonly SpecFixture[], pipeRef: string, id: string): SpecFixture;
2105
2096
 
2106
- export { type BrandManifest, BrandProvider, type BriefSubject, COMPONENT_NAMES, COMPONENT_RENDERINGS, CUSTOM_COMPONENTS, type ComponentRendering, type CriticLoop, DESIGNER_BRIEF_CONCEPT, DESIGNER_CATALOG_CONCEPT, DescriptorProvider, type DescriptorScope, type DesignerAction, type DesignerBrief, type DesignerCatalog, type DesignerComponent, type DesignerPathEntry, GenerativePage, type GenerativePageProps, type GenerativeSpec, ICON_NAMES, INPUTS_ROOT, type LayoutDescriptor, METRIC_FORMATS, PICKED_SHADCN, PRODUCT_COMPONENTS, PROMPT_HASH, type PageRegistry, type Producer, type ProductComponentName, RESULT_ROOT, type ResultSlot, ResultSlotProvider, type SpecFixture, type SpecProblem, type SpecVerdict, type ValidationCatalog, absoluteHatchPath, brandManifestSchema, catalog, designerCatalog, fieldAtSegments, findFixture, fixtureId, fixtureLabel, formatProblems, generativeRegistry, generativeRenderers, inputBrief, inputFieldAtPath, isDelegatedInput, isDelegatedResult, joinPath, jsonlLines, layoutFits, layoutProblems, pathFromDomId, payloadToState, repeatBasePathOf, resultBrief, resultFieldAtPath, seedInputs, segmentsUnder, specFromJsonl, specToJsonl, useBrand, useDescriptorScope, useResultSlot, useStoreSnapshot, validateAgainstCatalog };
2097
+ export { type BrandManifest, BrandProvider, type BriefSubject, COMPONENT_NAMES, COMPONENT_RENDERINGS, CUSTOM_COMPONENTS, type ComponentRendering, type CriticLoop, DESIGNER_BRIEF_CONCEPT, DESIGNER_CATALOG_CONCEPT, DescriptorProvider, type DescriptorScope, type DesignerAction, type DesignerBrief, type DesignerCatalog, type DesignerComponent, type DesignerPathEntry, GenerativePage, type GenerativePageProps, type GenerativeSpec, ICON_NAMES, INPUTS_ROOT, type LayoutDescriptor, METRIC_FORMATS, PICKED_SHADCN, PRODUCT_COMPONENTS, PROMPT_HASH, type PageRegistry, type Producer, type ProductComponentName, RESULT_ROOT, type ResultSlot, ResultSlotProvider, type SpecFixture, type SpecProblem, type SpecVerdict, type ValidationCatalog, absoluteHatchPath, brandManifestSchema, catalog, designerCatalog, fieldAtSegments, findFixture, fixtureId, fixtureLabel, formatProblems, generativeRegistry, generativeRenderers, inputBrief, inputFieldAtPath, isDelegatedInput, isDelegatedResult, joinPath, jsonlLines, layoutFits, layoutProblems, pathFromDomId, payloadToState, repeatBasePathOf, resultBrief, resultFieldAtPath, segmentsUnder, specFromJsonl, specToJsonl, useBrand, useDescriptorScope, useResultSlot, useStoreSnapshot, validateAgainstCatalog };
@@ -1,12 +1,18 @@
1
1
  "use client";
2
- import { cn, fieldControlClass, ResultRoot, ResultField, FieldRenderer, ToggleGroup, ToggleGroupItem, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '../chunk-2D4NEFUH.js';
3
- import '../chunk-7KQXGG6J.js';
2
+ import { cn, fieldControlClass, ResultRoot, ResultField, FieldRenderer, ToggleGroup, ToggleGroupItem, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '../chunk-7JRT6ZII.js';
3
+ export { seedInputs } from '../chunk-VH5CDQDR.js';
4
+ import '../chunk-VT5E5W4E.js';
5
+ import '../chunk-ICUEHNEH.js';
4
6
  import '../chunk-RRTI7AIR.js';
5
7
  import { isNativeValueNode, readDateContent, formatDateContent, isNativeHtmlNode, isNativeDateNode, isNativeCompositeNode } from '../chunk-CM4KVG53.js';
8
+ import '../chunk-ZB4RYUKV.js';
6
9
  import '../chunk-FABY3DEY.js';
7
10
  import '../chunk-XCO6GTEC.js';
8
- import '../chunk-PM55AHRO.js';
11
+ import '../chunk-GCXV76WU.js';
12
+ import '../chunk-XO5OENNF.js';
9
13
  import '../chunk-GKV77RAS.js';
14
+ import '../chunk-OD3VYXUY.js';
15
+ import '../chunk-WYH56SOZ.js';
10
16
  import { hasOwnProp } from '../chunk-V3OV2XQT.js';
11
17
  import { defineSchema, defineCatalog, validateSpec, compileSpecStream } from '@json-render/core';
12
18
  import { z } from 'zod';
@@ -903,7 +909,7 @@ function describe(field, path, depth, side, entries, seeded = false) {
903
909
  entries.push(entry);
904
910
  if (entry.delegated) return;
905
911
  if (field.kind === "object") {
906
- const seededBelow = seeded || field.defaultValue !== void 0;
912
+ const seededBelow = seeded || field.defaultValue !== void 0 || side === "input" && !field.required;
907
913
  for (const child of field.fields) {
908
914
  describe(child, joinPath(path, child.name), depth + 1, side, entries, seededBelow);
909
915
  }
@@ -3042,18 +3048,6 @@ function payloadToState(field, payload) {
3042
3048
  return field;
3043
3049
  }
3044
3050
  }
3045
- function seedInputs(fields) {
3046
- const seed = {};
3047
- for (const field of fields) {
3048
- if (field.defaultValue !== void 0) {
3049
- seed[field.name] = field.defaultValue;
3050
- } else if (field.kind === "object") {
3051
- const nested = seedInputs(field.fields);
3052
- if (Object.keys(nested).length > 0) seed[field.name] = nested;
3053
- }
3054
- }
3055
- return seed;
3056
- }
3057
3051
 
3058
3052
  // src/generative/fixture.ts
3059
3053
  function fixtureId(fixture) {
@@ -3090,6 +3084,6 @@ function findFixture(fixtures, pipeRef, id) {
3090
3084
  return found;
3091
3085
  }
3092
3086
 
3093
- export { BrandProvider, COMPONENT_NAMES, COMPONENT_RENDERINGS, CUSTOM_COMPONENTS, DESIGNER_BRIEF_CONCEPT, DESIGNER_CATALOG_CONCEPT, DescriptorProvider, GenerativePage, ICON_NAMES, INPUTS_ROOT, METRIC_FORMATS, PICKED_SHADCN, PRODUCT_COMPONENTS, PROMPT_HASH, RESULT_ROOT, ResultSlotProvider, absoluteHatchPath, brandManifestSchema, catalog, designerCatalog, fieldAtSegments, findFixture, fixtureId, fixtureLabel, formatProblems, generativeRegistry, generativeRenderers, inputBrief, inputFieldAtPath, isDelegatedInput, isDelegatedResult, joinPath, jsonlLines, layoutFits, layoutProblems, pathFromDomId, payloadToState, repeatBasePathOf, resultBrief, resultFieldAtPath, seedInputs, segmentsUnder, specFromJsonl, specToJsonl, useBrand, useDescriptorScope, useResultSlot, useStoreSnapshot, validateAgainstCatalog };
3087
+ export { BrandProvider, COMPONENT_NAMES, COMPONENT_RENDERINGS, CUSTOM_COMPONENTS, DESIGNER_BRIEF_CONCEPT, DESIGNER_CATALOG_CONCEPT, DescriptorProvider, GenerativePage, ICON_NAMES, INPUTS_ROOT, METRIC_FORMATS, PICKED_SHADCN, PRODUCT_COMPONENTS, PROMPT_HASH, RESULT_ROOT, ResultSlotProvider, absoluteHatchPath, brandManifestSchema, catalog, designerCatalog, fieldAtSegments, findFixture, fixtureId, fixtureLabel, formatProblems, generativeRegistry, generativeRenderers, inputBrief, inputFieldAtPath, isDelegatedInput, isDelegatedResult, joinPath, jsonlLines, layoutFits, layoutProblems, pathFromDomId, payloadToState, repeatBasePathOf, resultBrief, resultFieldAtPath, segmentsUnder, specFromJsonl, specToJsonl, useBrand, useDescriptorScope, useResultSlot, useStoreSnapshot, validateAgainstCatalog };
3094
3088
  //# sourceMappingURL=index.js.map
3095
3089
  //# sourceMappingURL=index.js.map