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

Function createInitialProps

packages/vue/src/composables/useInput.ts:198–224  ·  view source on GitHub ↗

* Creates the node's initial props from the context, props, and definition * @returns

()

Source from the content-addressed store, hash-verified

196 * @returns
197 */
198 function createInitialProps(): Record<string, any> {
199 const initialProps: Record<string, any> = {
200 ...nodeProps(props),
201 ...listeners,
202 type: props.type ?? 'text',
203 __root: __root.value,
204 __slots: context.slots,
205 }
206 const attrs = except(nodeProps(context.attrs), pseudoProps)
207 if (!attrs.key) attrs.key = token()
208 initialProps.attrs = attrs
209 const propValues = only(nodeProps(context.attrs), pseudoProps)
210 for (const propName in propValues) {
211 if (boolProps.includes(propName) && propValues[propName] === '') {
212 propValues[propName] = true
213 }
214 initialProps[camel(propName)] = propValues[propName]
215 }
216 const classesProps = { props: {} }
217 classesToNodeProps(classesProps as FormKitNode, props)
218 Object.assign(initialProps, classesProps.props)
219 if (typeof initialProps.type !== 'string') {
220 initialProps.definition = initialProps.type
221 delete initialProps.type
222 }
223 return initialProps
224 }
225
226 /**
227 * Create the FormKitNode.

Callers 1

useInputFunction · 0.85

Calls 6

nodePropsFunction · 0.90
exceptFunction · 0.90
tokenFunction · 0.90
onlyFunction · 0.90
camelFunction · 0.90
classesToNodePropsFunction · 0.70

Tested by

no test coverage detected