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

Function createLibraryPlugin

packages/inputs/src/plugin.ts:13–36  ·  view source on GitHub ↗
(
  ...libraries: FormKitLibrary[]
)

Source from the content-addressed store, hash-verified

11 * @public
12 */
13export function createLibraryPlugin(
14 ...libraries: FormKitLibrary[]
15): FormKitPlugin {
16 /**
17 * Merge all provided library items.
18 */
19 const library = libraries.reduce(
20 (merged, lib) => extend(merged, lib) as FormKitLibrary,
21 {} as FormKitLibrary
22 )
23 /* eslint-disable-next-line @typescript-eslint/no-empty-function */
24 const plugin = () => {}
25 /**
26 * Enables the hook that exposes all library inputs.
27 * @param node - The primary plugin
28 */
29 plugin.library = function (node: FormKitNode) {
30 const type = camel(node.props.type)
31 if (has(library, type)) {
32 node.define(library[type])
33 }
34 }
35 return plugin
36}

Callers 3

defaultConfigFunction · 0.90
defaultConfigFunction · 0.90
features.spec.tsFile · 0.85

Calls 3

extendFunction · 0.90
camelFunction · 0.90
hasFunction · 0.90

Tested by

no test coverage detected