* Creates the node's initial props from the context, props, and definition * @returns
()
| 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. |