Skip to content

Commit 10cdc08

Browse files
committed
fix(lib): 添加严格模式配置,更精准计算anyOf 默认值
re #152
1 parent 9dcb7b1 commit 10cdc08

File tree

41 files changed

+25812
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+25812
-28
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Created by Liu.Jun on 2021/2/1 10:00 下午.
3+
*/
4+
5+
import NaiveUI from 'naive-ui';
6+
7+
export default {
8+
install(app) {
9+
app.use(NaiveUI);
10+
}
11+
};

packages/demo/demo-v3/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@lljj/vue3-form-element": "1.11.0",
1515
"ajv-i18n": "^3.5.0",
1616
"ant-design-vue": "^2.0.1",
17+
"naive-ui": "^2.25.2",
1718
"demo-common": "1.2.0",
1819
"vue": "^3.0.0",
1920
"vuedraggable": "2.23.2"

packages/demo/demo-v3/src/pages/index/views/Demo/index.vue

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,30 @@ const VueAntForm = defineAsyncComponent(async () => {
252252
};
253253
});
254254
255+
const VueNaiveForm = defineAsyncComponent(async () => {
256+
// eslint-disable-next-line no-unused-vars
257+
const [naive, antForm] = await Promise.all([
258+
import('demo-common/components/Naive/index.js'),
259+
import('@lljj/vue3-form-naive/src/index')
260+
]);
261+
262+
return {
263+
name: 'naiveFormWrap',
264+
setup(props, { attrs, slots }) {
265+
// hack 动态install antDv,因为我不知其它地方如何获取 vue app
266+
if (!installedAntdv) {
267+
const instance = getCurrentInstance();
268+
instance.appContext.app.use(naive.default);
269+
installedAntdv = true;
270+
}
271+
272+
return () => h(antForm.default, {
273+
...attrs
274+
}, slots);
275+
}
276+
};
277+
});
278+
255279
const typeItems = Object.keys(schemaTypes);
256280
257281
export default {
@@ -260,6 +284,7 @@ export default {
260284
CodeEditor,
261285
VueElementForm,
262286
VueAntForm,
287+
VueNaiveForm,
263288
EditorHeader
264289
},
265290
data() {
@@ -273,6 +298,9 @@ export default {
273298
}, {
274299
name: 'antdv',
275300
component: 'VueAntForm'
301+
}, {
302+
name: 'Naive',
303+
component: 'VueNaiveForm'
276304
}],
277305
customFormats: {
278306
price(value) {
@@ -286,7 +314,7 @@ export default {
286314
return this.$route.query.type;
287315
},
288316
isUseLabelWidth() {
289-
return this.curVueForm === 'VueElementForm';
317+
return this.curVueForm !== 'VueAntForm';
290318
},
291319
trueFormProps() {
292320
if (!this.formProps) return {};

packages/lib/utils/vue3Utils.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Created by Liu.Jun on 2020/4/25 14:45.
33
*/
44

5-
import { resolveComponent as _resolveComponent } from 'vue';
5+
import { defineComponent, h, resolveComponent as _resolveComponent } from 'vue';
66

77
export {
88
nodePath2ClassName, isRootNodePath, computedCurPath, getPathVal, path2prop
@@ -34,3 +34,26 @@ export function resolveComponent(component) {
3434

3535
return component;
3636
}
37+
38+
// 转换antdv、naive等非moduleValue的v-model组件
39+
export const modelValueComponent = (component, {
40+
model = 'value'
41+
} = {}) => defineComponent({
42+
inheritAttrs: false,
43+
setup(props, { attrs, slots }) {
44+
return () => {
45+
const {
46+
modelValue: value,
47+
'onUpdate:modelValue': onUpdateValue,
48+
...otherAttrs
49+
} = attrs;
50+
51+
// eg: 'a-input'
52+
return h(resolveComponent(component), {
53+
[model]: value,
54+
[`onUpdate:${model}`]: onUpdateValue,
55+
...otherAttrs
56+
}, slots);
57+
};
58+
}
59+
});

packages/lib/vue3/vue3-form-ant/src/config/utils.js

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,9 @@
33
*/
44

55
import { defineComponent, h } from 'vue';
6-
import { resolveComponent } from '@lljj/vjsf-utils/vue3Utils';
6+
import { resolveComponent, modelValueComponent } from '@lljj/vjsf-utils/vue3Utils';
77

8-
// 转换antdv 非moduleValue的v-model组件
9-
export const modelValueComponent = (component, {
10-
model = 'value'
11-
} = {}) => defineComponent({
12-
inheritAttrs: false,
13-
setup(props, { attrs, slots }) {
14-
return () => {
15-
const {
16-
modelValue: value,
17-
'onUpdate:modelValue': onUpdateValue,
18-
...otherAttrs
19-
} = attrs;
20-
21-
// eg: 'a-input'
22-
return h(resolveComponent(component), {
23-
[model]: value,
24-
[`onUpdate:${model}`]: onUpdateValue,
25-
...otherAttrs
26-
}, slots);
27-
};
28-
}
29-
});
30-
31-
// 转换antdv 时间日期选择,moment format时间戳number类型报错兼容
32-
export const numberTimeComponent = component => defineComponent({
8+
const numberTimeComponent = component => defineComponent({
339
inheritAttrs: false,
3410
setup(props, { attrs, slots }) {
3511

@@ -61,3 +37,10 @@ export const numberTimeComponent = component => defineComponent({
6137
};
6238
}
6339
});
40+
41+
export {
42+
// 转换antdv 非moduleValue的v-model组件
43+
modelValueComponent,
44+
45+
numberTimeComponent
46+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**/node_modules/*
2+
/**/dist/*
3+
/**/*.css
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/

0 commit comments

Comments
 (0)