feat: 更新 formkit 配置,移除不必要的插件和组件,优化代码结构
This commit is contained in:
@ -1,26 +1,23 @@
|
||||
import { form } from '@/__fk-inputs__/inputs/form';
|
||||
import { PInputPassword } from '@/__fk-inputs__/inputs/p-input-password';
|
||||
import { PInputText } from '@/__fk-inputs__/inputs/p-input-text';
|
||||
import { PSelect } from '@/__fk-inputs__/inputs/p-select';
|
||||
import { createAutoAnimatePlugin, createAutoHeightTextareaPlugin } from '@formkit/addons';
|
||||
import { autoAnimatePlugin } from '@formkit/auto-animate/vue';
|
||||
import type { FormKitOptions, FormKitPlugin } from '@formkit/core';
|
||||
import { register as decodeErrors } from '@formkit/dev';
|
||||
import { createI18nPlugin, zh } from '@formkit/i18n';
|
||||
import { createLibraryPlugin, group, list, submit, text } from '@formkit/inputs';
|
||||
import { createLibraryPlugin, group, list, submit } from '@formkit/inputs';
|
||||
import * as defaultRules from '@formkit/rules';
|
||||
import { createValidationPlugin } from '@formkit/validation';
|
||||
import { /* defaultConfig, */ bindings, plugin /* defaultConfig */ } from '@formkit/vue';
|
||||
import type { App } from 'vue';
|
||||
import { addAsteriskPlugin } from './formkit.config.plugin.addAsteriskPlugin';
|
||||
import { debugPlugin } from './formkit.config.plugin.debug';
|
||||
import { PSelect } from '@/__fk-inputs__/inputs/p-select';
|
||||
import { createProPlugin, dropdown } from '@formkit/pro';
|
||||
import { rootClasses } from './formkit.config.theme';
|
||||
|
||||
const plugins: FormKitPlugin[] = [
|
||||
// createLibraryPlugin(fkLibrary),
|
||||
createLibraryPlugin({
|
||||
text,
|
||||
submit,
|
||||
list,
|
||||
group,
|
||||
@ -62,20 +59,11 @@ const plugins: FormKitPlugin[] = [
|
||||
),
|
||||
];
|
||||
|
||||
if (import.meta.env.VITE_FORMKIT_PRO_KEY)
|
||||
plugins.unshift(createProPlugin(import.meta.env.VITE_FORMKIT_PRO_KEY, { dropdown }));
|
||||
|
||||
if (import.meta.env.VITE_DEBUG_FORMKIT === 'true') plugins.push(debugPlugin);
|
||||
|
||||
const config: FormKitOptions = {
|
||||
plugins,
|
||||
config: {
|
||||
// rootClasses: false,
|
||||
rootClasses,
|
||||
// rootClasses: (sectionName: string, node: FormKitNode) => {
|
||||
// console.debug(`sectionName :>> `, sectionName);
|
||||
// }
|
||||
},
|
||||
config: {},
|
||||
};
|
||||
|
||||
export function setupFormKit(app: App) {
|
||||
|
@ -97,13 +97,6 @@ const promiseOptions = new Promise<typeof K_OPTIONS>(resolve => {
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
/>
|
||||
<FormKit
|
||||
type="dropdown"
|
||||
name="dropdown"
|
||||
label="选择框"
|
||||
validation="required"
|
||||
:options="() => { return K_OPTIONS }"
|
||||
/>
|
||||
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<FormKit
|
||||
@ -124,7 +117,7 @@ const promiseOptions = new Promise<typeof K_OPTIONS>(resolve => {
|
||||
name="group"
|
||||
>
|
||||
<FormKit
|
||||
type="text"
|
||||
:type="text"
|
||||
name="text-in-group-1"
|
||||
>
|
||||
</FormKit>
|
||||
@ -135,7 +128,7 @@ const promiseOptions = new Promise<typeof K_OPTIONS>(resolve => {
|
||||
name="group"
|
||||
>
|
||||
<FormKit
|
||||
type="text"
|
||||
:type="text"
|
||||
name="text-in-group-2"
|
||||
>
|
||||
</FormKit>
|
||||
|
Reference in New Issue
Block a user