@tmagic/form 1.2.0-beta.8 → 1.2.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tmagic-form.mjs +15 -2
- package/dist/tmagic-form.mjs.map +1 -1
- package/dist/tmagic-form.umd.js +15 -2
- package/dist/tmagic-form.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/Form.vue +9 -1
- package/src/containers/Container.vue +7 -4
- package/src/utils/form.ts +4 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.0-beta.
|
|
2
|
+
"version": "1.2.0-beta.9",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@element-plus/icons-vue": "^2.0.9",
|
|
38
|
-
"@tmagic/design": "1.2.0-beta.
|
|
39
|
-
"@tmagic/utils": "1.2.0-beta.
|
|
38
|
+
"@tmagic/design": "1.2.0-beta.9",
|
|
39
|
+
"@tmagic/utils": "1.2.0-beta.9",
|
|
40
40
|
"lodash-es": "^4.17.21",
|
|
41
41
|
"sortablejs": "^1.14.0",
|
|
42
42
|
"vue": "^3.2.37"
|
package/src/Form.vue
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</template>
|
|
26
26
|
|
|
27
27
|
<script setup lang="ts">
|
|
28
|
-
import { provide, reactive, ref, toRaw, watch } from 'vue';
|
|
28
|
+
import { provide, reactive, ref, toRaw, watch, watchEffect } from 'vue';
|
|
29
29
|
import cloneDeep from 'lodash-es/cloneDeep';
|
|
30
30
|
import isEqual from 'lodash-es/isEqual';
|
|
31
31
|
|
|
@@ -96,6 +96,14 @@ const formState: FormState = reactive<FormState>({
|
|
|
96
96
|
},
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
watchEffect(() => {
|
|
100
|
+
formState.initValues = props.initValues;
|
|
101
|
+
formState.config = props.config;
|
|
102
|
+
formState.keyProp = props.keyProp;
|
|
103
|
+
formState.popperClass = props.popperClass;
|
|
104
|
+
formState.parentValues = props.parentValues;
|
|
105
|
+
});
|
|
106
|
+
|
|
99
107
|
provide('mForm', formState);
|
|
100
108
|
|
|
101
109
|
watch(
|
|
@@ -97,7 +97,9 @@
|
|
|
97
97
|
</template>
|
|
98
98
|
|
|
99
99
|
<div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
|
|
100
|
-
<TMagicButton text @click="expandHandler">{{
|
|
100
|
+
<TMagicButton type="primary" size="small" text @click="expandHandler">{{
|
|
101
|
+
expand ? '收起配置' : '展开更多配置'
|
|
102
|
+
}}</TMagicButton>
|
|
101
103
|
</div>
|
|
102
104
|
</div>
|
|
103
105
|
</template>
|
|
@@ -177,11 +179,12 @@ const type = computed((): string => {
|
|
|
177
179
|
});
|
|
178
180
|
|
|
179
181
|
const display = computed((): boolean => {
|
|
180
|
-
|
|
182
|
+
const value = displayFunction(mForm, props.config.display, props);
|
|
183
|
+
|
|
184
|
+
if (value === 'expand') {
|
|
181
185
|
return expand.value;
|
|
182
186
|
}
|
|
183
|
-
|
|
184
|
-
return displayFunction(mForm, props.config.display, props);
|
|
187
|
+
return value;
|
|
185
188
|
});
|
|
186
189
|
|
|
187
190
|
const itemLabelWidth = computed(() => props.config.labelWidth || props.labelWidth);
|
package/src/utils/form.ts
CHANGED
|
@@ -197,6 +197,10 @@ export const filterFunction = (mForm: FormState | undefined, config: any, props:
|
|
|
197
197
|
};
|
|
198
198
|
|
|
199
199
|
export const display = function (mForm: FormState | undefined, config: any, props: any) {
|
|
200
|
+
if (config === 'expand') {
|
|
201
|
+
return config;
|
|
202
|
+
}
|
|
203
|
+
|
|
200
204
|
if (typeof config === 'function') {
|
|
201
205
|
return filterFunction(mForm, config, props);
|
|
202
206
|
}
|