( ...libraries: FormKitLibrary[] )
| 11 | * @public |
| 12 | */ |
| 13 | export 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 | } |
no test coverage detected