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

Function createClasses

packages/core/src/classes.ts:23–43  ·  view source on GitHub ↗
(
  propertyKey: string,
  node: FormKitNode,
  sectionClassList?: FormKitClasses | string | Record<string, boolean>
)

Source from the content-addressed store, hash-verified

21 * @public
22 */
23export function createClasses(
24 propertyKey: string,
25 node: FormKitNode,
26 sectionClassList?: FormKitClasses | string | Record<string, boolean>
27): Record<string, boolean> {
28 if (!sectionClassList) return {}
29 if (typeof sectionClassList === 'string') {
30 const classKeys = sectionClassList.split(' ')
31 return classKeys.reduce(
32 (obj, key) => Object.assign(obj, { [key]: true }),
33 {}
34 )
35 } else if (typeof sectionClassList === 'function') {
36 return createClasses(
37 propertyKey,
38 node,
39 sectionClassList(node, propertyKey)
40 )
41 }
42 return sectionClassList
43}
44
45/**
46 * Combines multiple class lists into a single list.

Callers 2

getFunction · 0.90
getFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected