MCPcopy Create free account
hub / github.com/formkit/formkit / calm

Function calm

packages/core/src/node.ts:2196–2217  ·  view source on GitHub ↗

* Calms the given node's disturbed state by one. * * @param node - A FormKitNode | FormKitNode * @param context - A FormKitContext | FormKitContext * @param value - A FormKitChildValue | FormKitChildValue * * @internal

(
  node: FormKitNode,
  context: FormKitContext,
  value?: FormKitChildValue
)

Source from the content-addressed store, hash-verified

2194 * @internal
2195 */
2196function calm(
2197 node: FormKitNode,
2198 context: FormKitContext,
2199 value?: FormKitChildValue
2200) {
2201 if (value !== undefined && node.type !== 'input') {
2202 partial(context, value)
2203 const shouldHydrate = !!(
2204 node.config.mergeStrategy && node.config.mergeStrategy[value.name]
2205 )
2206 // Commit the value up, but do not hydrate back down
2207 return commit(node, context, true, shouldHydrate)
2208 }
2209 if (context._d > 0) context._d--
2210 if (context._d === 0) {
2211 context.isSettled = true
2212 node.emit('settled', true, false)
2213 if (node.parent)
2214 node.parent?.calm({ name: node.name, value: context.value })
2215 if (context._resolve) context._resolve(context.value)
2216 }
2217}
2218
2219/**
2220 * This node is being removed and needs to be cleaned up.

Callers

nothing calls this directly

Calls 2

partialFunction · 0.85
commitFunction · 0.85

Tested by

no test coverage detected