Skip to content

Commit

Permalink
perf: Add the style injection of the top row to the form. (#102)
Browse files Browse the repository at this point in the history
Co-authored-by: NorthLan <lan6995@gmail.com>
  • Loading branch information
noahlann and NorthLan committed Nov 25, 2020
1 parent dc09de1 commit b9d3d60
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/Form/src/BasicForm.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<Form v-bind="{ ...$attrs, ...$props }" ref="formElRef" :model="formModel">
<Row :class="getProps.compact ? 'compact-form-row' : ''">
<Row :class="getProps.compact ? 'compact-form-row' : ''" :style="getRowWrapStyleRef">
<slot name="formHeader" />
<template v-for="schema in getSchema" :key="schema.field">
<FormItem
Expand Down Expand Up @@ -71,6 +71,11 @@
const schemaRef = ref<Nullable<FormSchema[]>>(null);
const formElRef = ref<Nullable<FormActionType>>(null);
const getRowWrapStyleRef = computed((): any => {
const { baseRowStyle } = unref(getProps);
return baseRowStyle || {};
});
const getMergePropsRef = computed(
(): FormProps => {
return deepMerge(cloneDeep(props), unref(propsRef));
Expand Down Expand Up @@ -207,6 +212,7 @@
getActionPropsRef,
defaultValueRef,
advanceState,
getRowWrapStyleRef,
getProps,
formElRef,
getSchema,
Expand Down
3 changes: 3 additions & 0 deletions src/components/Form/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const basicProps = {
type: Object as PropType<any>,
default: null,
},
baseRowStyle: {
type: Object as PropType<any>,
},
baseColProps: {
type: Object as PropType<any>,
},
Expand Down
3 changes: 3 additions & 0 deletions src/components/Form/src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export interface FormProps {
// Col configuration for the entire form
wrapperCol?: Partial<ColEx>;

// General row style
baseRowStyle?: object;

// General col configuration
baseColProps?: Partial<ColEx>;

Expand Down

0 comments on commit b9d3d60

Please sign in to comment.