Commit b9d3d60e0f8fe1166a0addcc8295365cbe65a7bf

Authored by Lan
Committed by GitHub
1 parent dc09de1e

perf: Add the style injection of the top row to the form. (#102)

Co-authored-by: NorthLan <lan6995@gmail.com>
src/components/Form/src/BasicForm.vue
1 1 <template>
2 2 <Form v-bind="{ ...$attrs, ...$props }" ref="formElRef" :model="formModel">
3   - <Row :class="getProps.compact ? 'compact-form-row' : ''">
  3 + <Row :class="getProps.compact ? 'compact-form-row' : ''" :style="getRowWrapStyleRef">
4 4 <slot name="formHeader" />
5 5 <template v-for="schema in getSchema" :key="schema.field">
6 6 <FormItem
... ... @@ -71,6 +71,11 @@
71 71 const schemaRef = ref<Nullable<FormSchema[]>>(null);
72 72 const formElRef = ref<Nullable<FormActionType>>(null);
73 73  
  74 + const getRowWrapStyleRef = computed((): any => {
  75 + const { baseRowStyle } = unref(getProps);
  76 + return baseRowStyle || {};
  77 + });
  78 +
74 79 const getMergePropsRef = computed(
75 80 (): FormProps => {
76 81 return deepMerge(cloneDeep(props), unref(propsRef));
... ... @@ -207,6 +212,7 @@
207 212 getActionPropsRef,
208 213 defaultValueRef,
209 214 advanceState,
  215 + getRowWrapStyleRef,
210 216 getProps,
211 217 formElRef,
212 218 getSchema,
... ...
src/components/Form/src/props.ts
... ... @@ -28,6 +28,9 @@ export const basicProps = {
28 28 type: Object as PropType<any>,
29 29 default: null,
30 30 },
  31 + baseRowStyle: {
  32 + type: Object as PropType<any>,
  33 + },
31 34 baseColProps: {
32 35 type: Object as PropType<any>,
33 36 },
... ...
src/components/Form/src/types/form.ts
... ... @@ -53,6 +53,9 @@ export interface FormProps {
53 53 // Col configuration for the entire form
54 54 wrapperCol?: Partial<ColEx>;
55 55  
  56 + // General row style
  57 + baseRowStyle?: object;
  58 +
56 59 // General col configuration
57 60 baseColProps?: Partial<ColEx>;
58 61  
... ...