( _options: FormKitOptions | ((...args: any[]) => FormKitOptions) )
| 43 | * Create a React plugin instance (no global registration required). |
| 44 | */ |
| 45 | export 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. |
no test coverage detected