@live-change/vue3-components 0.8.112 → 0.8.114
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/index.js +1 -1
- package/logic/dependencyInjection.js +13 -1
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export { createReactiveObject }
|
|
|
20
20
|
|
|
21
21
|
export { analytics, useAnalytics, installRouterAnalytics, synchronized, synchronizedList } from "./logic"
|
|
22
22
|
|
|
23
|
-
export { injectComponent, provideComponent } from "./logic/dependencyInjection.js"
|
|
23
|
+
export { injectComponent, provideComponent, InjectComponent } from "./logic/dependencyInjection.js"
|
|
24
24
|
|
|
25
25
|
export {
|
|
26
26
|
useLocale, Locale
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { provide, inject } from 'vue'
|
|
1
|
+
import { provide, inject, h } from 'vue'
|
|
2
2
|
|
|
3
3
|
export function provideComponent(description, component) {
|
|
4
4
|
if(!description) throw new Error("provideComponent: description is required")
|
|
@@ -44,4 +44,16 @@ export function injectComponent(request, defaultComponent, factory) {
|
|
|
44
44
|
if(isValid && filter(component)) return component.component
|
|
45
45
|
}
|
|
46
46
|
return factory ? defaultComponent() : defaultComponent
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// functional component that injects a component based on the request
|
|
50
|
+
export function InjectComponent({ request, defaultComponent, factory, props }, { slots, emit, attrs }) {
|
|
51
|
+
const component = injectComponent(request, defaultComponent, factory)
|
|
52
|
+
const allProps = { ...props }
|
|
53
|
+
if(component?.emits) {
|
|
54
|
+
for(let event of component.emits) {
|
|
55
|
+
allProps['on'+event[0].toUpperCase()+event.slice(1)] = (...args) => emit(event, ...args)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return component ? h(component, allProps, slots) : slots.fallback()
|
|
47
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/vue3-components",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.114",
|
|
4
4
|
"description": "Live Change Framework - vue components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/live-change/live-change-stack",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/vue3-ssr": "^0.8.
|
|
24
|
+
"@live-change/vue3-ssr": "^0.8.114",
|
|
25
25
|
"debug": "^4.3.4",
|
|
26
26
|
"mitt": "3.0.1",
|
|
27
27
|
"vue": "^3.4.29"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "1a5a437aae382d766c2806a11f805370ee8cc40a"
|
|
30
30
|
}
|