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

Function extendable

packages/inputs/src/createSection.ts:97–127  ·  view source on GitHub ↗
(extensions: FormKitSectionsSchema)

Source from the content-addressed store, hash-verified

95 >
96 ) => {
97 const extendable = (extensions: FormKitSectionsSchema) => {
98 const node = !el || typeof el === 'string' ? { $el: el } : el()
99 if (isDOM(node) || isComponent(node)) {
100 if (!node.meta) {
101 node.meta = { section }
102 } else {
103 node.meta.section = section
104 }
105 if (children.length && !node.children) {
106 node.children = [
107 ...children.map((child) =>
108 typeof child === 'function' ? child(extensions) : child
109 ),
110 ]
111 }
112 if (isDOM(node)) {
113 node.attrs = {
114 class: `$classes.${section}`,
115 ...(node.attrs || {}),
116 }
117 }
118 }
119 return {
120 if: `$slots.${section}`,
121 then: `$slots.${section}`,
122 else:
123 section in extensions
124 ? extendSchema(node, extensions[section])
125 : node,
126 }
127 }
128 extendable._s = section
129 return fragment ? createRoot(extendable) : extendable
130 }

Callers

nothing calls this directly

Calls 3

isDOMFunction · 0.90
isComponentFunction · 0.90
extendSchemaFunction · 0.85

Tested by

no test coverage detected