Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Dec 1, 2024
2 parents 2586b08 + 12f216c commit fe9beed
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/@core/base/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@
"dayjs": "catalog:",
"defu": "catalog:",
"lodash.clonedeep": "catalog:",
"lodash.set": "catalog:",
"nprogress": "catalog:",
"tailwind-merge": "catalog:",
"theme-colors": "catalog:"
},
"devDependencies": {
"@types/lodash.clonedeep": "catalog:",
"@types/lodash.set": "catalog:",
"@types/nprogress": "catalog:"
}
}
1 change: 1 addition & 0 deletions packages/@core/base/shared/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from './update-css-variables';
export * from './util';
export * from './window';
export { default as cloneDeep } from 'lodash.clonedeep';
export { default as set } from 'lodash.set';
6 changes: 3 additions & 3 deletions packages/@core/ui-kit/form-ui/src/use-form-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { FormActions, VbenFormProps } from './types';
import { computed, type ComputedRef, unref, useSlots } from 'vue';

import { createContext } from '@vben-core/shadcn-ui';
import { isString } from '@vben-core/shared/utils';
import { isString, set } from '@vben-core/shared/utils';

import { useForm } from 'vee-validate';
import { object, type ZodRawShape } from 'zod';
Expand Down Expand Up @@ -41,9 +41,9 @@ export function useFormInitial(
const zodObject: ZodRawShape = {};
(unref(props).schema || []).forEach((item) => {
if (Reflect.has(item, 'defaultValue')) {
initialValues[item.fieldName] = item.defaultValue;
set(initialValues, item.fieldName, item.defaultValue);
} else if (item.rules && !isString(item.rules)) {
zodObject[item.fieldName] = item.rules;
set(zodObject, item.fieldName, item.defaultValue);
}
});

Expand Down
6 changes: 6 additions & 0 deletions playground/src/views/examples/form/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ const [CustomLayoutForm] = useVbenForm({
formItemClass: 'col-start-1',
label: '字符串',
},
{
component: 'Input',
defaultValue: 'field4.path',
fieldName: 'field4.path',
label: 'field4.path',
},
],
// 一共三列
wrapperClass: 'grid-cols-3',
Expand Down
24 changes: 24 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ catalog:
'@types/jsonwebtoken': ^9.0.7
'@types/lodash.clonedeep': ^4.5.9
'@types/node': ^22.10.1
'@types/lodash.set': ^4.3.9
'@types/nprogress': ^0.2.3
'@types/postcss-import': ^14.0.3
'@types/qrcode': ^1.5.5
Expand Down Expand Up @@ -113,6 +114,7 @@ catalog:
lint-staged: ^15.2.10
lodash.clonedeep: ^4.5.0
lucide-vue-next: ^0.462.0
lodash.set: ^4.3.2
medium-zoom: ^1.1.0
naive-ui: ^2.40.2
nitropack: ^2.10.4
Expand Down

0 comments on commit fe9beed

Please sign in to comment.