Skip to content

Commit bfae962

Browse files
authored
perf: display border status color when the form is verified incorrectly (vbenjs#4407)
* perf: display border status color when the form is verified incorrectly * chore: adjust the document preview file order
1 parent 02c4014 commit bfae962

File tree

9 files changed

+30
-3
lines changed

9 files changed

+30
-3
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ node_modules
33
.gitignore
44
*.md
55
dist
6+
.turbo
7+
dist.zip

.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@
212212
"*.env": "$(capture).env.*",
213213
"README.md": "README*,CHANGELOG*,LICENSE,CNAME",
214214
"package.json": "pnpm-lock.yaml,pnpm-workspace.yaml,.gitattributes,.gitignore,.gitpod.yml,.npmrc,.browserslistrc,.node-version,.git*,.tazerc.json",
215-
"Dockerfile": "Dockerfile,.docker*,docker-entrypoint.sh,build-local-docker*,nginx.conf",
216215
"eslint.config.mjs": ".eslintignore,.prettierignore,.stylelintignore,.commitlintrc.*,.prettierrc.*,stylelint.config.*,.lintstagedrc.mjs,cspell.json",
217216
"tailwind.config.mjs": "postcss.*"
218217
},

docs/.vitepress/config/plugins/demo-preview.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ export const demoPreviewPlugin = (md: MarkdownRenderer) => {
8383
if (!state.tokens[index]) {
8484
return '';
8585
}
86-
86+
const firstString = 'index.vue';
87+
childFiles = childFiles.sort((a, b) => {
88+
if (a === firstString) return -1;
89+
if (b === firstString) return 1;
90+
return a.localeCompare(b, 'en', { sensitivity: 'base' });
91+
});
8792
state.tokens[index].content =
8893
`<DemoPreview files="${encodeURIComponent(JSON.stringify(childFiles))}" ><${ComponentName}/>
8994
`;

docs/src/guide/introduction/thin.md

+9
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,12 @@ pnpm install
6565
}
6666
}
6767
```
68+
69+
## 其他
70+
71+
如果你想更进一步精简,你可以删除参考一下文件或者文件夹的作用,判断自己是否需要,不需要删除即可:
72+
73+
- `.changeset` 文件夹用于管理版本变更
74+
- `.github` 文件夹用于存放 GitHub 的配置文件
75+
- `.vscode` 文件夹用于存放 VSCode 的配置文件,如果你使用其他编辑器,可以删除
76+
- `./scripts/deploy` 文件夹用于存放部署脚本,如果你不需要docker部署,可以删除

packages/@core/ui-kit/form-ui/src/form-render/form-field.vue

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { cn, isFunction, isObject, isString } from '@vben-core/shared/utils';
1717
1818
import { toTypedSchema } from '@vee-validate/zod';
19-
import { useFormValues } from 'vee-validate';
19+
import { useFieldError, useFormValues } from 'vee-validate';
2020
2121
import { injectRenderFormProps, useFormContext } from './context';
2222
import useDependencies from './dependencies';
@@ -43,8 +43,11 @@ const {
4343
const { componentBindEventMap, componentMap, isVertical } = useFormContext();
4444
const formRenderProps = injectRenderFormProps();
4545
const values = useFormValues();
46+
const errors = useFieldError(fieldName);
4647
const formApi = formRenderProps.form;
4748
49+
const isInValid = computed(() => errors.value?.length > 0);
50+
4851
const fieldComponent = computed(() => {
4952
const finalComponent = isString(component)
5053
? componentMap.value[component]
@@ -217,6 +220,7 @@ function createComponentProps(slotProps: Record<string, any>) {
217220
<FormItem
218221
v-show="isShow"
219222
:class="{
223+
'form-valid-error': isInValid,
220224
'flex-col': isVertical,
221225
'flex-row items-center': !isVertical,
222226
}"
@@ -248,10 +252,14 @@ function createComponentProps(slotProps: Record<string, any>) {
248252
...slotProps,
249253
...createComponentProps(slotProps),
250254
disabled: shouldDisabled,
255+
isInValid,
251256
}"
252257
>
253258
<component
254259
:is="fieldComponent"
260+
:class="{
261+
'border-destructive focus:border-destructive': isInValid,
262+
}"
255263
v-bind="createComponentProps(slotProps)"
256264
:disabled="shouldDisabled"
257265
>

packages/styles/src/antd/index.css

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
.ant-notification-notice {
1212
@apply dark:border-border/60 dark:border;
1313
}
14+
15+
.ant-app .form-valid-error .ant-select-selector {
16+
border-color: hsl(var(--destructive));
17+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)