From 8a1398d91db3d6d34a7a00cc5d471269c425b1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Tue, 19 Nov 2024 16:07:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E6=8F=92=E4=BB=B6=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20FormKit=20=E9=85=8D=E7=BD=AE=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=88=97=E8=A1=A8=EF=BC=8C=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=92=8C=E7=BB=84=E4=BB=B6=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- formkit.config.ts | 23 ++++++++++++++++++++++- package.json | 1 + pnpm-lock.yaml | 18 ++++++++++++++++++ src/App.vue | 22 +++++++++++++--------- src/guests.vue | 36 ++++++++++++++++++++---------------- src/main.ts | 8 ++++++-- 6 files changed, 80 insertions(+), 28 deletions(-) diff --git a/formkit.config.ts b/formkit.config.ts index 65640d5..23166d7 100644 --- a/formkit.config.ts +++ b/formkit.config.ts @@ -7,6 +7,7 @@ import { createThemePlugin } from '@formkit/themes' import { createValidationPlugin } from '@formkit/validation' import { /* defaultConfig, */ bindings } from '@formkit/vue' import { rootClasses } from "./formkit.theme" +import { createAutoAnimatePlugin } from '@formkit/addons' const library = createLibraryPlugin({ text, form, submit, group, checkbox, range, list, number }) const validation = createValidationPlugin(defaultRules) @@ -54,7 +55,27 @@ function addAsteriskPlugin(node: FormKitNode) { }) } + export default { - plugins: [library, themePlugin, bindings, i18n, validation, addAsteriskPlugin,], + plugins: [ + library, themePlugin, bindings, i18n, validation, addAsteriskPlugin, + + // https://auto-animate.formkit.com/#usage + // https://github.com/formkit/auto-animate/ + // https://github.com/formkit/formkit/blob/46d64d05c1b37875fc6227853f2bcfa987550c91/packages/addons/src/plugins/autoAnimatePlugin.ts + createAutoAnimatePlugin( + { + duration: 250, + easing: 'ease-in-out', + }, + // { + // /* optional animation targets object */ + // // default: + // global: ['outer', 'inner'], + // form: ['form'], + // repeater: ['items'], + // } + ) + ], config: { rootClasses }, } satisfies FormKitOptions \ No newline at end of file diff --git a/package.json b/package.json index f0c1e03..423315e 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "preview": "vite preview" }, "dependencies": { + "@formkit/addons": "^1.6.9", "@formkit/core": "latest", "@formkit/icons": "latest", "@formkit/themes": "latest", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 79aa5e5..a40bf81 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@formkit/addons': + specifier: ^1.6.9 + version: 1.6.9 '@formkit/core': specifier: latest version: 1.6.9 @@ -207,6 +210,12 @@ packages: cpu: [x64] os: [win32] + '@formkit/addons@1.6.9': + resolution: {integrity: sha512-Qfq789kpQ5EYqFl6QPE32vMCs0qivbvR50NNRwUadC2hgfGcayKe8Gc43G8neW6HHPjmyzkHQHLknLxHrGni3Q==} + + '@formkit/auto-animate@0.8.2': + resolution: {integrity: sha512-SwPWfeRa5veb1hOIBMdzI+73te5puUBHmqqaF1Bu7FjvxlYSz/kJcZKSa9Cg60zL0uRNeJL2SbRxV6Jp6Q1nFQ==} + '@formkit/core@1.6.9': resolution: {integrity: sha512-Zb5OkYKMf7Rp1pd4iUMv0TJQvfgl1PdKtRRQoGiTA0XIFLB/7tcRMr1wc5isA2JS+hllfxMTh3RWF8N+64fTMg==} @@ -1039,6 +1048,15 @@ snapshots: '@esbuild/win32-x64@0.21.5': optional: true + '@formkit/addons@1.6.9': + dependencies: + '@formkit/auto-animate': 0.8.2 + '@formkit/core': 1.6.9 + '@formkit/inputs': 1.6.9 + '@formkit/utils': 1.6.9 + + '@formkit/auto-animate@0.8.2': {} + '@formkit/core@1.6.9': dependencies: '@formkit/utils': 1.6.9 diff --git a/src/App.vue b/src/App.vue index 8a86c64..351f2aa 100644 --- a/src/App.vue +++ b/src/App.vue @@ -51,7 +51,7 @@ const SCHEMA: FormKitSchemaDefinition = [ label: 'JSON Schema’ed Input', name: 'input', validation: 'required', - validationLabel: 'input字段', + validationLabel: 'validationLabel', // validation message 使用顺序:validationLabel > label > name errors: ['显式设置的错误是非阻塞的,这意味着它们不会像验证错误那样阻止表单提交。您可以在表单文档中了解更多有关错误处理的信息。'] } ] @@ -69,6 +69,7 @@ const SCHEMA: FormKitSchemaDefinition = [ submit-label="提交 ✨" >
+
+ + + \ No newline at end of file diff --git a/src/guests.vue b/src/guests.vue index cdf00bd..3600ddc 100644 --- a/src/guests.vue +++ b/src/guests.vue @@ -3,15 +3,18 @@ import { FormKitMessages } from '@formkit/vue'