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

Function createPlugin

packages/react/src/plugin.ts:45–73  ·  view source on GitHub ↗
(
  _options: FormKitOptions | ((...args: any[]) => FormKitOptions)
)

Source from the content-addressed store, hash-verified

43 * Create a React plugin instance (no global registration required).
44 */
45export function createPlugin(
46 _options: FormKitOptions | ((...args: any[]) => FormKitOptions)
47): FormKitReactPlugin {
48 const options: FormKitOptions = Object.assign(
49 {
50 alias: 'FormKit',
51 schemaAlias: 'FormKitSchema',
52 },
53 typeof _options === 'function' ? _options() : _options
54 )
55
56 const rootConfig = createConfig(options.config || {})
57 options.config = { rootConfig }
58
59 return {
60 get: getNode,
61 setLocale: (locale: string) => {
62 if (options.config?.rootConfig) {
63 options.config.rootConfig.locale = locale
64 }
65 },
66 clearErrors,
67 setErrors,
68 submit: submitForm,
69 reset,
70 options,
71 rootConfig,
72 }
73}
74
75/**
76 * Alias used by consumers who expect a `plugin` export.

Callers 1

ssr.spec.tsFile · 0.90

Calls 1

createConfigFunction · 0.90

Tested by

no test coverage detected