Skip to content

Commit ebe5149

Browse files
committed
feat(conclude): add option options.mergeObjectCustomizer
1 parent 7b23d9f commit ebe5149

File tree

15 files changed

+2724
-2241
lines changed

15 files changed

+2724
-2241
lines changed

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,7 @@ npm i vue-global-config
156156
}
157157
</script>
158158
<script type="module">
159-
import {
160-
conclude,
161-
getLocalListeners,
162-
listenGlobalHooks,
163-
resolveConfig,
164-
} from 'vue-global-config'
159+
import { conclude, getLocalListeners, listenGlobalHooks, resolveConfig } from 'vue-global-config'
165160
</script>
166161
```
167162

@@ -170,8 +165,7 @@ npm i vue-global-config
170165
```html
171166
<script src="https://cdn.jsdelivr.net/npm/vue-global-config@0.6"></script>
172167
<script>
173-
const { conclude, getLocalListeners, listenGlobalHooks, resolveConfig } =
174-
VueGlobalConfig
168+
const { conclude, getLocalListeners, listenGlobalHooks, resolveConfig } = VueGlobalConfig
175169
</script>
176170
```
177171

@@ -264,10 +258,11 @@ The role of `conclude` is to help you figure out the final configuration.
264258
* @param {boolean} [options.defaultIsDynamic = false] - Dynamic generation of default values
265259
* @param {boolean} [options.required = false] - Requirement checking
266260
* @param {(prop: any) => boolean} [options.validator] - Custom validator
267-
* @param {string} [options.camelizeObjectKeys = false] - whether to camelize object keys
261+
* @param {string} [options.camelizeObjectKeys = false] - Whether to camelize object keys
268262
* @param {false|string} [options.mergeObject = 'deep'] - The way to merge objects
263+
* @param {(objValue: any, srcValue: any, key: string, object: Record<string, any>, source: Record<string, any>, stack: object) => any} [options.mergeObjectCustomizer] - To produce the merged values of the destination and source properties. Returning undefined to maintain the default behavior
269264
* @param {boolean} [options.mergeObjectApplyOnlyToDefault = false] - `mergeObject` only works on `default`
270-
* @param {false|((accumulator, currentValue, index?, array?) => )} [options.mergeFunction = false] - The way to fuse functions
265+
* @param {false|((accumulator, currentValue, currentIndex?, array?) => )} [options.mergeFunction = false] - The way to merge functions
271266
* @param {boolean} [options.mergeFunctionApplyOnlyToDefault = true] - `mergeFunction` only works on `default`
272267
* @returns {any} Final prop
273268
*/
@@ -295,6 +290,10 @@ Same as [Vue's prop validation](https://vuejs.org/guide/components/props.html#pr
295290
- `'shallow'`: Shallow merge, where the object key of a high weight prop overwrites the key of the same name of a low weight prop, without nested objects
296291
- `false`: No merging, direct overwriting, objects of high weight prop will directly overwrite objects of low weight prop, consistent with the behavior of value types
297292

293+
#### config.mergeObjectCustomizer
294+
295+
The `customizer` argument of [mergeWith](https://lodash.com/docs#mergeWith) (`mergeObject: 'deep'`) or [assignInWith](https://lodash.com/docs#assignInWith) (`mergeObject: 'shallow'`) for customizing assigned values.
296+
298297
#### config.mergeObjectApplyOnlyToDefault
299298

300299
Off by default, only valid when mergeObject is on.
@@ -342,9 +341,9 @@ conclude([
342341
default: () => {
343342
console.log('I am default option')
344343
},
345-
mergeFunction: (accumulator, item) => (...args) => {
344+
mergeFunction: (accumulator, currentValue) => (...args) => {
346345
accumulator(...args)
347-
item?.(...args)
346+
currentValue?.(...args)
348347
},
349348
mergeFunctionApplyOnlyToDefault: false,
350349
})()

commitlint.config.ts renamed to commitlint.config.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Default Config See https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional
2-
import { rules } from '@commitlint/config-conventional'
2+
import config from '@commitlint/config-conventional'
3+
4+
const { rules } = config
35

46
// See https://github.com/vuejs/core/blob/main/scripts/verifyCommit.js
57
rules['type-enum'][2].push('wip', 'types', 'release', 'workflow', 'dx')
6-
rules['header-max-length'][2] = 200
8+
rules['header-max-length'][2] = 300
79
rules['subject-case'][0] = 0
810

911
export default {

demo/vue2.6/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import Vue from 'vue'
21
import VueCompositionAPI from '@vue/composition-api'
3-
import 'element-ui/lib/theme-chalk/index.css'
42
import ElementUI from 'element-ui'
53
import { FaFormDialog, FaImage, FaImageUpload, FaPopButton, FaPopSwitch, FaSelect } from 'faim'
4+
import Vue from 'vue'
65
import App from './App.vue'
76
import YourComponent from './YourComponent.vue'
7+
import 'element-ui/lib/theme-chalk/index.css'
88

99
Vue.use(VueCompositionAPI)
1010
Vue.use(ElementUI)
1111
Vue.use(FaFormDialog, {
1212
// 全局配置
13+
width: `${window.outerWidth / 2}px`,
1314
})
1415
Vue.use(FaImage, {
1516
// 全局配置

demo/vue2.7/YourComponent/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Plugin, install } from 'vue-demi'
1+
import type { install, Plugin } from 'vue-demi'
22
import { resolveConfig } from '../../../src'
33
import Component from './Component.vue'
44

@@ -37,5 +37,5 @@ ComponentWithInstall.install = (app: any, options = {}) => {
3737
app.component(ComponentWithInstall.name, ComponentWithInstall)
3838
}
3939

40-
export { globalProps, globalAttrs, globalListeners, globalHooks, globalSlots }
40+
export { globalAttrs, globalHooks, globalListeners, globalProps, globalSlots }
4141
export default ComponentWithInstall

demo/vue2.7/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import Vue from 'vue'
2-
import 'element-ui/lib/theme-chalk/index.css'
31
import ElementUI from 'element-ui'
42
import { FaFormDialog, FaImage, FaImageUpload, FaPopButton, FaPopSwitch, FaSelect } from 'faim'
3+
import Vue from 'vue'
54
import App from './App.vue'
65
import YourComponent from './YourComponent'
6+
import 'element-ui/lib/theme-chalk/index.css'
77

88
Vue.use(ElementUI)
99
Vue.use(FaFormDialog, {
1010
// 全局配置
11+
width: `${window.outerWidth / 2}px`,
1112
})
1213
Vue.use(FaImage, {
1314
// 全局配置

demo/vue3/YourComponent/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Plugin, install } from 'vue-demi'
1+
import type { install, Plugin } from 'vue-demi'
22
import { resolveConfig } from '../../../src'
33
import Component from './Component.vue'
44

@@ -37,5 +37,5 @@ ComponentWithInstall.install = (app: any, options = {}) => {
3737
app.component(ComponentWithInstall.name, ComponentWithInstall)
3838
}
3939

40-
export { globalProps, globalAttrs, globalListeners, globalHooks, globalSlots }
40+
export { globalAttrs, globalHooks, globalListeners, globalProps, globalSlots }
4141
export default ComponentWithInstall

demo/vue3/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { createApp, h } from 'vue'
2-
import 'element-plus/dist/index.css'
3-
import ElementPlus from 'element-plus'
41
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
2+
import ElementPlus from 'element-plus'
53
import { FaFormDialog, FaImage, FaImageUpload, FaPopButton, FaPopSwitch, FaSelect } from 'faim'
4+
import { createApp } from 'vue'
65
import App from './App.vue'
76
import YourComponent from './YourComponent'
7+
import 'element-plus/dist/index.css'
88

99
const app = createApp(App)
1010
.use(ElementPlus)
1111
.use(FaFormDialog, {
1212
// 全局配置
13+
width: `${window.outerWidth / 2}px`,
1314
})
1415
.use(FaImage, {
1516
// 全局配置
File renamed without changes.

package.json

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
"scripts": {
4242
"dev": "esno ./scripts/dev.mts",
4343
"doc": "vitepress dev --open /README",
44-
"test-unit": "vitest run",
44+
"test": "vitest run",
45+
"test:watch": "vitest",
46+
"test:coverage": "vitest run --coverage",
47+
"test:ui": "vitest --ui",
4548
"build": "vite build",
4649
"serve": "vite preview",
4750
"release": "esno ./scripts/release.mts",
@@ -64,46 +67,44 @@
6467
}
6568
},
6669
"dependencies": {
67-
"vue-demi": "^0.14.7"
70+
"vue-demi": "^0.14.10"
6871
},
6972
"devDependencies": {
70-
"@antfu/eslint-config": "^2.15.0",
71-
"@commitlint/cli": "^19.3.0",
72-
"@commitlint/config-conventional": "^19.2.2",
73-
"@element-plus/icons-vue": "^2.3.1",
73+
"@antfu/eslint-config": "^3.5.0",
74+
"@commitlint/cli": "^19.4.1",
75+
"@commitlint/config-conventional": "^19.4.1",
76+
"@element-plus/icons-vue": "latest",
7477
"@types/lodash-es": "^4.17.12",
75-
"@types/node": "^20.12.7",
76-
"@vitejs/plugin-vue": "^5.0.4",
77-
"@vue/compiler-sfc": "^3.4.25",
78-
"@vue/test-utils": "^2.4.5",
79-
"case-police": "^0.6.1",
78+
"@types/node": "^22.5.4",
79+
"@vitejs/plugin-vue": "latest",
80+
"@vue/compiler-sfc": "latest",
81+
"@vue/test-utils": "latest",
82+
"case-police": "^0.7.0",
8083
"change-case": "^5.4.4",
8184
"cross-spawn": "^7.0.3",
8285
"del": "^7.1.0",
83-
"element-plus": "^2.7.1",
84-
"eslint": "npm:eslint-ts-patch@8.57.0-0",
85-
"eslint-plugin-format": "^0.1.1",
86-
"eslint-ts-patch": "8.57.0-0",
86+
"element-plus": "latest",
87+
"eslint-plugin-format": "^0.1.2",
8788
"esno": "^4.7.0",
88-
"faim": "^0.8.1",
89+
"faim": "^0.9.5",
8990
"kolorist": "^1.8.0",
90-
"lint-staged": "^15.2.2",
91+
"lint-staged": "^15.2.10",
9192
"lodash-es": "^4.17.21",
92-
"magicast": "^0.3.4",
93+
"magicast": "^0.3.5",
9394
"only-allow": "^1.2.1",
9495
"open": "^10.1.0",
9596
"prompts": "^2.4.2",
9697
"rollup-plugin-visualizer": "^5.12.0",
97-
"semver": "^7.6.0",
98+
"semver": "^7.6.3",
9899
"simple-git-hooks": "^2.11.1",
99-
"typescript": "^5.4.5",
100-
"unplugin-auto-import": "^0.17.5",
101-
"unplugin-vue-components": "^0.26.0",
102-
"vite": "^5.2.10",
103-
"vite-plugin-dts": "^3.9.0",
104-
"vitepress": "^1.1.3",
105-
"vitest": "^1.5.2",
106-
"vue": "^3.4.25",
100+
"typescript": "^5.6.2",
101+
"unplugin-auto-import": "^0.18.2",
102+
"unplugin-vue-components": "^0.27.4",
103+
"vite": "^5.4.3",
104+
"vite-plugin-dts": "^4.2.1",
105+
"vitepress": "^1.3.4",
106+
"vitest": "^2.0.5",
107+
"vue": "latest",
107108
"vue-global-config": "workspace:*"
108109
},
109110
"simple-git-hooks": {

0 commit comments

Comments
 (0)