@pipelex/mthds-form 0.33.0 → 0.34.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 (34) hide show
  1. package/dist/brand/index.js +2 -2
  2. package/dist/{chunk-UKTYADY3.js → chunk-5RV3ASMO.js} +141 -69
  3. package/dist/chunk-5RV3ASMO.js.map +1 -0
  4. package/dist/{chunk-VH5CDQDR.js → chunk-AURDKAIC.js} +3 -3
  5. package/dist/{chunk-VH5CDQDR.js.map → chunk-AURDKAIC.js.map} +1 -1
  6. package/dist/{chunk-ZX52CQJ4.js → chunk-CFBK7NO7.js} +3 -3
  7. package/dist/{chunk-ZX52CQJ4.js.map → chunk-CFBK7NO7.js.map} +1 -1
  8. package/dist/{chunk-3GO65HWP.js → chunk-PNNWNRPG.js} +11 -7
  9. package/dist/chunk-PNNWNRPG.js.map +1 -0
  10. package/dist/{chunk-XO5OENNF.js → chunk-TF4RTKLH.js} +32 -5
  11. package/dist/chunk-TF4RTKLH.js.map +1 -0
  12. package/dist/{chunk-IBBAJXIO.js → chunk-XIWBKV7T.js} +3 -3
  13. package/dist/{chunk-IBBAJXIO.js.map → chunk-XIWBKV7T.js.map} +1 -1
  14. package/dist/{chunk-4SRSGZWM.js → chunk-XYS5KCXB.js} +158 -31
  15. package/dist/chunk-XYS5KCXB.js.map +1 -0
  16. package/dist/core/gate.js +2 -2
  17. package/dist/core/index.js +4 -4
  18. package/dist/core/readiness.d.ts +34 -1
  19. package/dist/core/readiness.js +1 -1
  20. package/dist/core/seed.js +2 -2
  21. package/dist/core/values.js +2 -2
  22. package/dist/generative/headless/index.d.ts +15 -9
  23. package/dist/generative/headless/index.js +3 -2
  24. package/dist/generative/index.d.ts +27 -4
  25. package/dist/generative/index.js +628 -240
  26. package/dist/generative/index.js.map +1 -1
  27. package/dist/react/index.d.ts +30 -3
  28. package/dist/react/index.js +4 -4
  29. package/dist/styles.css +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunk-3GO65HWP.js.map +0 -1
  32. package/dist/chunk-4SRSGZWM.js.map +0 -1
  33. package/dist/chunk-UKTYADY3.js.map +0 -1
  34. package/dist/chunk-XO5OENNF.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/readiness.ts"],"names":[],"mappings":";;;AA8BA,IAAM,gBAAA,GAAmB,EAAA;AAGlB,SAAS,SAAS,KAAA,EAAyB;AAChD,EAAA,OAAO,UAAA,CAAW,KAAA,EAAO,CAAA,EAAG,MAAS,CAAA;AACvC;AA0BA,SAAS,UAAA,CAAW,KAAA,EAAgB,KAAA,EAAe,IAAA,EAAgD;AACjG,EAAA,IAAI,KAAA,IAAS,MAAM,OAAO,KAAA;AAM1B,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA,CAAM,MAAK,KAAM,EAAA;AAMvD,EAAA,IAAI,OAAO,KAAA,KAAU,UAAA,EAAY,OAAO,KAAA;AACxC,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,IAAA;AAEtC,EAAA,IAAI,KAAA,IAAS,kBAAkB,OAAO,KAAA;AACtC,EAAA,MAAM,OAAA,GAAU,IAAA,oBAAQ,IAAI,GAAA,EAAoB;AAChD,EAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,GAAA,CAAI,KAAK,CAAA;AAClC,EAAA,IAAI,QAAA,KAAa,MAAA,IAAa,QAAA,IAAY,KAAA,EAAO,OAAO,KAAA;AACxD,EAAA,OAAA,CAAQ,GAAA,CAAI,OAAO,KAAK,CAAA;AAExB,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,SAAU,KAAA,CAAM,IAAA,CAAK,CAAC,IAAA,KAAS,UAAA,CAAW,IAAA,EAAM,KAAA,GAAQ,CAAA,EAAG,OAAO,CAAC,CAAA;AAC1F,EAAA,MAAM,GAAA,GAAM,KAAA;AAEZ,EAAA,IAAI,UAAA,CAAW,GAAA,EAAK,KAAK,CAAA,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,CAAC,KAAA,CAAM,QAAA;AAC3C;AAcO,SAAS,sBAAsB,KAAA,EAAyB;AAC7D,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAOO,SAAS,8BAA8B,KAAA,EAA0B;AACtE,EAAA,OAAO,eAAA,CAAgB,KAAK,CAAA,IAAK,mBAAA,CAAoB,KAAK,CAAA;AAC5D;AASO,SAAS,gBAAA,CAAiB,OAAiB,KAAA,EAAyB;AACzE,EAAA,IAAI,CAAC,6BAAA,CAA8B,KAAK,CAAA,EAAG,OAAO,KAAA;AAClD,EAAA,OAAO,mBAAA,CAAoB,KAAK,CAAA,GAAI,CAAC,sBAAsB,KAAK,CAAA,GAAI,CAAC,QAAA,CAAS,KAAK,CAAA;AACrF;AAGO,SAAS,wBAAA,CACd,QACA,MAAA,EACS;AACT,EAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IACZ,CAAC,CAAA,KAAM,mBAAA,CAAoB,CAAC,CAAA,IAAK,sBAAsB,OAAA,CAAQ,MAAA,EAAQ,CAAA,CAAE,IAAI,CAAC;AAAA,GAChF;AACF","file":"chunk-XO5OENNF.js","sourcesContent":["/**\n * Value readiness - the helpers the runner uses to decide whether the Run\n * button may fire and which inputs are still missing.\n */\n\nimport type { ObjectRunField, RunField } from './descriptor';\nimport { hasOwnProp, ownProp } from './own-property';\n\n/**\n * How deep `isFilled` walks a value before it stops looking, and the answer it\n * gives when it does.\n *\n * The walk is over CALLER-SUPPLIED data - a request body on a public run\n * endpoint, or a form's state - so its depth is whatever the caller sent, and\n * the schema is no bound on it: `pruneEmptyOptionals` copies a property the\n * schema does not declare straight through, so a key ajv never walks reaches\n * this function unwalked. Unbounded, a value a few thousand levels deep threw\n * `RangeError` out of the middle of a host's server gate - a gate whose whole\n * contract is that it returns a verdict instead of throwing.\n *\n * **The cap answers `false`, and that direction is the deliberate half.** Past\n * the cap this function cannot tell whether there is anything down there, and\n * the kernel's rule throughout is that an unanswerable absence fails closed.\n * The cost of the other choice is a run the method cannot use, started (and\n * billed) on a payload no schema validated. The cost of this one is nearly\n * nothing: `isFilled` combines branches with `some`, so a refused over-deep\n * branch only loses its own vote - a real value anywhere beside it still reads\n * filled - and no concept structure declares nesting anywhere near this deep,\n * so a value that reaches the cap is not one the method had a slot for.\n */\nconst MAX_FILLED_DEPTH = 64;\n\n/** True when a value is meaningfully filled (not empty / blank / empty container). */\nexport function isFilled(value: unknown): boolean {\n return walkFilled(value, 0, undefined);\n}\n\n/**\n * `isFilled`'s walk, carrying the depth and the objects already judged.\n *\n * `seen` is a cycle guard first - a value that references itself would\n * otherwise recurse to the cap on every branch - and a memo second. Both uses\n * rest on the same fact: an object reached twice within ONE call answered\n * `false` the first time, because a `true` short-circuits every `some` above it\n * and the walk never gets back down here. So the map can only ever hold empty\n * subtrees, which is what makes it safe to keep entries after unwinding -\n * without that, a value shaped like a diamond chain costs exponential time.\n *\n * **It records the DEPTH each object was judged at, and that is not a detail.**\n * A `false` here has two causes - nothing was down there, or the cap stopped\n * the walk - and only the first travels. An object whose children sit one level\n * past the cap answers `false` at depth 63 and is perfectly filled at depth 5;\n * memoizing identity alone then reported a genuinely filled input as missing\n * the moment a shallower path reached the same object second. So a recorded\n * answer is reused only for a revisit at the SAME depth or deeper, where the\n * walk could see no more than the first one did, and a strictly shallower\n * arrival walks again. That keeps the cycle guard exact (depth rises along\n * every path, so a cycle always revisits deeper) and keeps the memo bounded:\n * an object's recorded depth strictly falls each time it is re-walked, over a\n * range the cap fixes, so the diamond stays linear in all but a constant.\n */\nfunction walkFilled(value: unknown, depth: number, seen: Map<object, number> | undefined): boolean {\n if (value == null) return false;\n // Whitespace is not a value. The Run button lit up over a required text input\n // holding three spaces, ajv passed it (a content model carries no\n // `minLength`), and the run reached the runtime with nothing in it. The same\n // test is what makes a blank OPTIONAL input a real absence on the wire rather\n // than a supplied empty string - see `apiInputsFromSchemaData`.\n if (typeof value === 'string') return value.trim() !== '';\n // No concept in the taxonomy holds a function, so one here arrived by a route\n // that is already wrong - most plausibly an inherited `Object.prototype`\n // member read off a plain object by a colliding input name. `ownProp` closes\n // that route at every lookup; this branch is the backstop for the ones that\n // arrive by another.\n if (typeof value === 'function') return false;\n if (typeof value !== 'object') return true;\n\n if (depth >= MAX_FILLED_DEPTH) return false;\n const visited = seen ?? new Map<object, number>();\n const judgedAt = visited.get(value);\n if (judgedAt !== undefined && judgedAt <= depth) return false;\n visited.set(value, depth);\n\n if (Array.isArray(value)) return value.some((item) => walkFilled(item, depth + 1, visited));\n const obj = value as Record<string, unknown>;\n // A file value is { url } - filled when the url is set.\n if (hasOwnProp(obj, 'url')) return walkFilled(obj.url, depth + 1, visited);\n return Object.values(obj).some((child) => walkFilled(child, depth + 1, visited));\n}\n\n/**\n * True when a slot holds something AND every required field inside it has a\n * value.\n *\n * The two halves are both load-bearing, and the first one is the one that is\n * easy to leave out. A structure is satisfied only if there is something in it:\n * a struct whose concept declares no required child used to be *vacuously*\n * satisfied by an absent value - every child passed the `!f.required` test, so\n * `every` returned true over a value that was not there. Readiness reported\n * nothing missing and the Run button lit up, while the value bridge omitted the\n * untouched structure and the gate then rejected the run on the combined\n * schema's `required` list, naming an input the form had just declared ready.\n *\n * `isFilled` is the SAME predicate `toRjsf` uses to decide whether a structure\n * collapses to an absence (`values.ts`), which is what makes the two halves\n * agree by construction rather than by parallel edits: readiness calls an input\n * present exactly when the bridge keeps it. Absence is what a singular slot\n * expresses, so a required one has to be touched - the button stays dark until\n * the user puts a value somewhere inside, and then the whole shell travels,\n * empty children and all, so a required child left blank still fails loudly.\n *\n * Its own recursion follows the DESCRIPTOR, not the value, so it needs no depth\n * cap of its own: a `RunField` tree only exists because `buildRunFields`\n * finished walking a contract's schema, which bounds it. `isFilled` is where\n * the caller's data is walked, and where the cap lives.\n */\nexport function fieldFilled(field: RunField, value: unknown): boolean {\n if (field.kind === 'object') {\n if (!isFilled(value)) return false;\n const obj = (value ?? {}) as Record<string, unknown>;\n // A required child must be filled. An OPTIONAL child the value holds\n // something in owes its own concept the same - the rule a touched optional\n // input follows at the top level (`computeReadiness`) and a started list\n // row follows below, applied at every depth. Asking required children\n // alone let a half-filled optional structure INSIDE a structure through:\n // `{bank: {holder: 'x', iban: ''}}` satisfied ajv (a present empty string\n // is present, a content model carries no `minLength`) and readiness never\n // looked below `bank`, so the button stayed live and the run went out with\n // a required child blank. An optional child that holds nothing is absent,\n // and absence blocks nothing - which is what closing it writes.\n return field.fields.every((f) => {\n const child = ownProp(obj, f.name);\n return f.required ? fieldFilled(f, child) : !isFilled(child) || fieldFilled(f, child);\n });\n }\n if (field.kind === 'list') {\n // Too many items is not filled, and this is asked of EVERY list, not only\n // one carrying a lower bound. `ListField` will not add past the bound, so\n // it answers the list that arrived from somewhere else - a restored draft,\n // a host seeding values, a bespoke surface calling these predicates over\n // data it did not render. Asking it only inside the `itemCount` branch\n // meant a model stating `maxItems` alone published its ceiling on the\n // descriptor and enforced it nowhere: the button stayed live on a list ajv\n // was about to refuse. Naming it in `missing` is a small stretch of that\n // word, and the alternative is the disagreement.\n if (\n field.maxItemCount !== undefined &&\n Array.isArray(value) &&\n value.length > field.maxItemCount\n )\n return false;\n // A list the method gave a count to (`Concept[N]`) is satisfied only by that\n // many items, each of them filled. Answering it by `isFilled` alone - \"is\n // there anything in the array?\" - left the button live on a `[3]` slot\n // holding two, and the gate then refused it on the very count the method\n // declared. `itemCount` comes off the same `minItems` ajv reads, so the two\n // halves phrase one rule.\n if (field.itemCount !== undefined) {\n if (!Array.isArray(value) || value.length < field.itemCount) return false;\n return value.every((item) => fieldFilled(field.item, item));\n }\n // A VARIABLE list never gates on being empty (see `mustBeFilled`) - a plural\n // slot's empty form IS the empty list. But a row the user STARTED owes its\n // concept every field the concept declares, which is the same rule a touched\n // optional input follows one level up, and `isFilled` alone does not say it:\n // a row holding `{name: 'x', other: ''}` reads filled by `some`, satisfies\n // ajv's `required` (a present empty string is present), and went out as an\n // item the runtime cannot use. An untouched row stays an absence and still\n // blocks nothing.\n if (Array.isArray(value))\n return (\n value.every((item) => !isFilled(item) || fieldFilled(field.item, item)) && isFilled(value)\n );\n }\n return isFilled(value);\n}\n\nexport interface Readiness {\n total: number;\n ready: number;\n missing: string[];\n}\n\n/**\n * True when the user must put a value in this field before the run can start.\n *\n * Distinct from `required`, which also drives layout (a required field always\n * shows; an optional one may collapse). A **variable-plural** field stays\n * required - it is a first-class input and keeps its place in the form - but it\n * never gates: a plural slot is never \"absent\" in MTHDS, its empty form IS the\n * empty list, and no method can declare \"at least one item\". A **fixed-count**\n * list (`[N]`) is the exception the wire now states, and it gates like any other\n * slot - there the method HAS ruled the empty form out.\n *\n * **For a field this package built, the answer comes from `inputMustBeFilled`**\n * (`contracts.ts`) - the SAME predicate the method viewer's Run button, its ajv\n * `required` list and its missing-inputs toast all read. `buildRunFields`\n * stamps it onto `gating`. This used to be re-derived here as\n * `required && kind !== 'list'`: the same rule expressed against the MAPPED\n * field instead of the contract, and the two could disagree - `kind` is `'list'`\n * for a `conceptRef` ending in `[]` OR an array schema, while the contract's\n * plural test is the array schema alone, so a plural input carrying a non-array\n * schema gated on one surface and not the other.\n *\n * The shape heuristic survives only as the fallback for a **hand-authored**\n * `RunField` - story fixtures and unit tests, which have no contract to consult\n * and therefore nothing to disagree with. Every field a host renders comes from\n * `buildRunFields` and carries `gating`, so a host is on the contract's answer\n * alone. (The fallback cannot see a fixed count either - one more thing only the\n * contract knows.)\n */\nexport function mustBeFilled(field: RunField): boolean {\n return field.gating ?? (field.required && field.kind !== 'list');\n}\n\n/**\n * How many top-level inputs stand between the current values and a run.\n *\n * Two kinds count, and the second is easy to miss. An input the method DEMANDS\n * counts always (`mustBeFilled`). An input the method left optional counts once\n * the user has put something in it - because a structure that has been touched\n * owes its concept every field the concept declares, and the gate enforces\n * exactly that. Left out, an optional struct opened and half-filled was ignored\n * here and refused there: the button stayed live and the run came back rejected\n * on a required child, which is the same disagreement the demanded case had.\n *\n * So an optional input moves INTO the denominator the moment it is touched, and\n * out of `missing` as soon as it is complete: 3 of 3 while it is untouched, 3\n * of 4 once it is started, 4 of 4 once it is done. `total` answers \"how many\n * things stand between me and Run\", which is the number a host is displaying.\n */\nexport function computeReadiness(fields: RunField[], values: Record<string, unknown>): Readiness {\n const gating = fields.filter((f) => mustBeFilled(f) || isFilled(ownProp(values, f.name)));\n const missing = gating\n .filter((f) => !fieldFilled(f, ownProp(values, f.name)))\n .map((f) => f.title ?? f.name);\n return { total: gating.length, ready: gating.length - missing.length, missing };\n}\n\n/**\n * Whether a person should see this field as optional: not required AND carrying no authored\n * default. The standard marks a defaulted field `required: false` (it can never be missing), but it\n * is always filled, so presenting it as optional — the badge, the fold behind the optional toggle —\n * misreads it: a choice defaulted to one of its options is still a choice the user must see.\n * Presentation only; what gates a run is `mustBeFilled`.\n */\nexport function shownAsOptional(field: RunField): boolean {\n return !field.required && field.defaultValue === undefined;\n}\n\n/**\n * Whether a field is an optional structure: an OPTIONAL structured concept, at\n * any depth - a structure inside a structure, or an optional structured input\n * at the top level.\n *\n * Its value is either absent (closed) or an object (open), and closing it is\n * the one way a person says \"none of this\" once the structure's children carry\n * defaults - a half-filled optional structure otherwise reads as a choice\n * nobody made. It folds behind its container's \"+ N optional\" disclosure while\n * closed, and that disclosure opens and closes it\n * (`openOptionalStructures`, `closeOptionalStructures`).\n *\n * An item of a list is never one: a row is in the array because the person\n * added it.\n */\nexport function isOptionalStructure(field: RunField): field is ObjectRunField {\n return field.kind === 'object' && !field.required;\n}\n\n/**\n * Whether an optional structure reads open for this value: a plain object,\n * even `{}`. `undefined` and `null` read closed.\n *\n * Derived from the value, never held beside it, so a host that seeds the value\n * (`seedObjectValue`) has opened the structure, and one that clears it has\n * closed it. Open is presentation; what the run makes of the value is\n * `isFilled`'s answer as everywhere else - an open structure holding nothing\n * at all is still absent on the wire, exactly as an opened optional section\n * left blank always was, while one holding anything owes its concept every\n * required child (`fieldFilled`).\n */\nexport function optionalStructureOpen(value: unknown): boolean {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Whether a field takes part in its container's \"+ N optional\" disclosure:\n * shown as optional (`shownAsOptional`), or an optional structure\n * (`isOptionalStructure`) whatever its defaults.\n */\nexport function foldsBehindOptionalDisclosure(field: RunField): boolean {\n return shownAsOptional(field) || isOptionalStructure(field);\n}\n\n/**\n * Whether a field is folded behind the disclosure right now, for this value:\n * it takes part in the disclosure and is empty - for an optional structure,\n * closed (`optionalStructureOpen`); for any other field, not `isFilled`. The\n * disclosure's count, \"+ N optional\", is the number of fields this answers\n * `true` for while it is collapsed.\n */\nexport function isFoldedOptional(field: RunField, value: unknown): boolean {\n if (!foldsBehindOptionalDisclosure(field)) return false;\n return isOptionalStructure(field) ? !optionalStructureOpen(value) : !isFilled(value);\n}\n\n/** Whether any optional structure among `fields` is open in `values`. */\nexport function anyOptionalStructureOpen(\n fields: readonly RunField[],\n values: Record<string, unknown> | undefined,\n): boolean {\n return fields.some(\n (f) => isOptionalStructure(f) && optionalStructureOpen(ownProp(values, f.name)),\n );\n}\n"]}