| 53 | * @public |
| 54 | */ |
| 55 | export const defaultConfig = ( |
| 56 | options: DefaultConfigOptions = {} |
| 57 | ): FormKitOptions => { |
| 58 | decodeErrors() |
| 59 | const { |
| 60 | rules = {}, |
| 61 | locales = {}, |
| 62 | inputs = {}, |
| 63 | messages = {}, |
| 64 | locale = undefined, |
| 65 | theme = undefined, |
| 66 | iconLoaderUrl = undefined, |
| 67 | iconLoader = undefined, |
| 68 | icons = {}, |
| 69 | ...nodeOptions |
| 70 | } = options |
| 71 | /** |
| 72 | * The default configuration includes the validation plugin, |
| 73 | * with all core-available validation rules. |
| 74 | */ |
| 75 | const validation = createValidationPlugin({ |
| 76 | ...defaultRules, |
| 77 | ...(rules || {}), |
| 78 | }) |
| 79 | |
| 80 | /** |
| 81 | * Includes the i18n plugin with only the english language |
| 82 | * messages. |
| 83 | */ |
| 84 | const i18n = createI18nPlugin( |
| 85 | extend({ en, ...(locales || {}) }, messages) as FormKitLocaleRegistry |
| 86 | ) |
| 87 | |
| 88 | /** |
| 89 | * Create the library of inputs that are generally available. This default |
| 90 | * config imports all "native" inputs by default, but |
| 91 | */ |
| 92 | const library = createLibraryPlugin(defaultInputs, inputs) |
| 93 | |
| 94 | /** |
| 95 | * Create the theme plugin for the user provided theme |
| 96 | */ |
| 97 | const themePlugin = createThemePlugin(theme, icons, iconLoaderUrl, iconLoader) |
| 98 | |
| 99 | return extend( |
| 100 | { |
| 101 | plugins: [library, themePlugin, bindings, i18n, validation], |
| 102 | ...(!locale ? {} : { config: { locale } }), |
| 103 | }, |
| 104 | nodeOptions || {}, |
| 105 | true |
| 106 | ) as FormKitOptions |
| 107 | } |