@tianditu/vue 0.0.0 → 0.0.1
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/README.md +3 -4
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.mjs +185 -2
- package/package.json +6 -4
- package/dist/components.d.ts +0 -9
- package/dist/components.mjs +0 -10
- package/dist/plugin.d.ts +0 -2
- package/dist/plugin.mjs +0 -11
- package/dist/vue-component-lib/utils.d.ts +0 -20
- package/dist/vue-component-lib/utils.mjs +0 -124
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|

|
|
6
|
-
[](https://www.contributor-covenant.org/version/2/1/code_of_conduct/)
|
|
7
6
|
|
|
8
7
|
> Vue components for tianditu, powered by Demo Macro.
|
|
9
8
|
|
|
@@ -11,13 +10,13 @@
|
|
|
11
10
|
|
|
12
11
|
```bash
|
|
13
12
|
# npm
|
|
14
|
-
$ npm install -D @tianditu/
|
|
13
|
+
$ npm install -D @tianditu/wc @tianditu/vue
|
|
15
14
|
|
|
16
15
|
# yarn
|
|
17
|
-
$ yarn add -D @tianditu/
|
|
16
|
+
$ yarn add -D @tianditu/wc @tianditu/vue
|
|
18
17
|
|
|
19
18
|
# pnpm
|
|
20
|
-
$ pnpm add -D @tianditu/
|
|
19
|
+
$ pnpm add -D @tianditu/wc @tianditu/vue
|
|
21
20
|
```
|
|
22
21
|
|
|
23
22
|
## License
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { Plugin } from 'vue';
|
|
3
|
+
import { JSX } from '@tianditu/wc';
|
|
4
|
+
|
|
5
|
+
interface InputProps<T> {
|
|
6
|
+
modelValue?: T;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare const TdtControl: vue.DefineSetupFnComponent<JSX.TdtControl & InputProps<string | number | boolean>, {}, {}, JSX.TdtControl & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
10
|
+
declare const TdtControlCopyright: vue.DefineSetupFnComponent<JSX.TdtControlCopyright & InputProps<string | number | boolean>, {}, {}, JSX.TdtControlCopyright & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
11
|
+
declare const TdtControlOverviewMap: vue.DefineSetupFnComponent<JSX.TdtControlOverviewMap & InputProps<string | number | boolean>, {}, {}, JSX.TdtControlOverviewMap & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
12
|
+
declare const TdtControlScale: vue.DefineSetupFnComponent<JSX.TdtControlScale & InputProps<string | number | boolean>, {}, {}, JSX.TdtControlScale & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
13
|
+
declare const TdtControlZoom: vue.DefineSetupFnComponent<JSX.TdtControlZoom & InputProps<string | number | boolean>, {}, {}, JSX.TdtControlZoom & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
14
|
+
declare const TdtMap: vue.DefineSetupFnComponent<JSX.TdtMap & InputProps<string | number | boolean>, {}, {}, JSX.TdtMap & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
15
|
+
|
|
16
|
+
declare const ComponentLibrary: Plugin;
|
|
17
|
+
|
|
18
|
+
export { ComponentLibrary, TdtControl, TdtControlCopyright, TdtControlOverviewMap, TdtControlScale, TdtControlZoom, TdtMap };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { Plugin } from 'vue';
|
|
3
|
+
import { JSX } from '@tianditu/wc';
|
|
4
|
+
|
|
5
|
+
interface InputProps<T> {
|
|
6
|
+
modelValue?: T;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare const TdtControl: vue.DefineSetupFnComponent<JSX.TdtControl & InputProps<string | number | boolean>, {}, {}, JSX.TdtControl & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
10
|
+
declare const TdtControlCopyright: vue.DefineSetupFnComponent<JSX.TdtControlCopyright & InputProps<string | number | boolean>, {}, {}, JSX.TdtControlCopyright & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
11
|
+
declare const TdtControlOverviewMap: vue.DefineSetupFnComponent<JSX.TdtControlOverviewMap & InputProps<string | number | boolean>, {}, {}, JSX.TdtControlOverviewMap & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
12
|
+
declare const TdtControlScale: vue.DefineSetupFnComponent<JSX.TdtControlScale & InputProps<string | number | boolean>, {}, {}, JSX.TdtControlScale & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
13
|
+
declare const TdtControlZoom: vue.DefineSetupFnComponent<JSX.TdtControlZoom & InputProps<string | number | boolean>, {}, {}, JSX.TdtControlZoom & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
14
|
+
declare const TdtMap: vue.DefineSetupFnComponent<JSX.TdtMap & InputProps<string | number | boolean>, {}, {}, JSX.TdtMap & InputProps<string | number | boolean> & {}, vue.PublicProps>;
|
|
15
|
+
|
|
16
|
+
declare const ComponentLibrary: Plugin;
|
|
17
|
+
|
|
18
|
+
export { ComponentLibrary, TdtControl, TdtControlCopyright, TdtControlOverviewMap, TdtControlScale, TdtControlZoom, TdtMap };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,185 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { defineComponent, ref, getCurrentInstance, inject, h, withDirectives } from 'vue';
|
|
2
|
+
import { applyPolyfills, defineCustomElements } from '@tianditu/wc/dist/loader';
|
|
3
|
+
|
|
4
|
+
const UPDATE_VALUE_EVENT = "update:modelValue";
|
|
5
|
+
const MODEL_VALUE = "modelValue";
|
|
6
|
+
const ROUTER_LINK_VALUE = "routerLink";
|
|
7
|
+
const NAV_MANAGER = "navManager";
|
|
8
|
+
const ROUTER_PROP_PREFIX = "router";
|
|
9
|
+
const ARIA_PROP_PREFIX = "aria";
|
|
10
|
+
const EMPTY_PROP = Symbol();
|
|
11
|
+
const DEFAULT_EMPTY_PROP = { default: EMPTY_PROP };
|
|
12
|
+
const getComponentClasses = (classes) => {
|
|
13
|
+
return classes?.split(" ") || [];
|
|
14
|
+
};
|
|
15
|
+
const getElementClasses = (ref2, componentClasses, defaultClasses = []) => {
|
|
16
|
+
return [...Array.from(ref2.value?.classList || []), ...defaultClasses].filter(
|
|
17
|
+
(c, i, self) => !componentClasses.has(c) && self.indexOf(c) === i
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
const defineContainer = (name, defineCustomElement, componentProps = [], modelProp, modelUpdateEvent) => {
|
|
21
|
+
if (defineCustomElement !== void 0) {
|
|
22
|
+
defineCustomElement();
|
|
23
|
+
}
|
|
24
|
+
const Container = defineComponent(
|
|
25
|
+
(props, { attrs, slots, emit }) => {
|
|
26
|
+
let modelPropValue = props[modelProp];
|
|
27
|
+
const containerRef = ref();
|
|
28
|
+
const classes = new Set(getComponentClasses(attrs.class));
|
|
29
|
+
const vModelDirective = {
|
|
30
|
+
created: (el) => {
|
|
31
|
+
const eventsNames = Array.isArray(modelUpdateEvent) ? modelUpdateEvent : [modelUpdateEvent];
|
|
32
|
+
eventsNames.forEach((eventName) => {
|
|
33
|
+
el.addEventListener(eventName.toLowerCase(), (e) => {
|
|
34
|
+
if (e.target.tagName === el.tagName) {
|
|
35
|
+
modelPropValue = (e?.target)[modelProp];
|
|
36
|
+
emit(UPDATE_VALUE_EVENT, modelPropValue);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const currentInstance = getCurrentInstance();
|
|
43
|
+
const hasRouter = currentInstance?.appContext?.provides[NAV_MANAGER];
|
|
44
|
+
const navManager = hasRouter ? inject(NAV_MANAGER) : void 0;
|
|
45
|
+
const handleRouterLink = (ev) => {
|
|
46
|
+
const { routerLink } = props;
|
|
47
|
+
if (routerLink === EMPTY_PROP)
|
|
48
|
+
return;
|
|
49
|
+
if (navManager !== void 0) {
|
|
50
|
+
ev.preventDefault();
|
|
51
|
+
let navigationPayload = { event: ev };
|
|
52
|
+
for (const key in props) {
|
|
53
|
+
const value = props[key];
|
|
54
|
+
if (props.hasOwnProperty(key) && key.startsWith(ROUTER_PROP_PREFIX) && value !== EMPTY_PROP) {
|
|
55
|
+
navigationPayload[key] = value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
navManager.navigate(navigationPayload);
|
|
59
|
+
} else {
|
|
60
|
+
console.warn(
|
|
61
|
+
"Tried to navigate, but no router was found. Make sure you have mounted Vue Router."
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return () => {
|
|
66
|
+
modelPropValue = props[modelProp];
|
|
67
|
+
getComponentClasses(attrs.class).forEach((value) => {
|
|
68
|
+
classes.add(value);
|
|
69
|
+
});
|
|
70
|
+
const oldClick = props.onClick;
|
|
71
|
+
const handleClick = (ev) => {
|
|
72
|
+
if (oldClick !== void 0) {
|
|
73
|
+
oldClick(ev);
|
|
74
|
+
}
|
|
75
|
+
if (!ev.defaultPrevented) {
|
|
76
|
+
handleRouterLink(ev);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
let propsToAdd = {
|
|
80
|
+
ref: containerRef,
|
|
81
|
+
class: getElementClasses(containerRef, classes),
|
|
82
|
+
onClick: handleClick
|
|
83
|
+
};
|
|
84
|
+
for (const key in props) {
|
|
85
|
+
const value = props[key];
|
|
86
|
+
if (props.hasOwnProperty(key) && value !== EMPTY_PROP || key.startsWith(ARIA_PROP_PREFIX)) {
|
|
87
|
+
propsToAdd[key] = value;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (modelProp) {
|
|
91
|
+
if (props[MODEL_VALUE] !== EMPTY_PROP) {
|
|
92
|
+
propsToAdd = {
|
|
93
|
+
...propsToAdd,
|
|
94
|
+
[modelProp]: props[MODEL_VALUE]
|
|
95
|
+
};
|
|
96
|
+
} else if (modelPropValue !== EMPTY_PROP) {
|
|
97
|
+
propsToAdd = {
|
|
98
|
+
...propsToAdd,
|
|
99
|
+
[modelProp]: modelPropValue
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (props[ROUTER_LINK_VALUE] !== EMPTY_PROP) {
|
|
104
|
+
propsToAdd = {
|
|
105
|
+
...propsToAdd,
|
|
106
|
+
href: props[ROUTER_LINK_VALUE]
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const node = h(name, propsToAdd, slots.default && slots.default());
|
|
110
|
+
return modelProp === void 0 ? node : withDirectives(node, [[vModelDirective]]);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
if (typeof Container !== "function") {
|
|
115
|
+
Container.name = name;
|
|
116
|
+
Container.props = {
|
|
117
|
+
[ROUTER_LINK_VALUE]: DEFAULT_EMPTY_PROP
|
|
118
|
+
};
|
|
119
|
+
componentProps.forEach((componentProp) => {
|
|
120
|
+
Container.props[componentProp] = DEFAULT_EMPTY_PROP;
|
|
121
|
+
});
|
|
122
|
+
if (modelProp) {
|
|
123
|
+
Container.props[MODEL_VALUE] = DEFAULT_EMPTY_PROP;
|
|
124
|
+
Container.emits = [UPDATE_VALUE_EVENT];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return Container;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const TdtControl = /* @__PURE__ */ defineContainer(
|
|
131
|
+
"tdt-control",
|
|
132
|
+
void 0,
|
|
133
|
+
["control", "position", "visible", "offset", "options", "uniqueId"]
|
|
134
|
+
);
|
|
135
|
+
const TdtControlCopyright = /* @__PURE__ */ defineContainer(
|
|
136
|
+
"tdt-control-copyright",
|
|
137
|
+
void 0,
|
|
138
|
+
["position", "content", "uniqueId"]
|
|
139
|
+
);
|
|
140
|
+
const TdtControlOverviewMap = /* @__PURE__ */ defineContainer(
|
|
141
|
+
"tdt-control-overview-map",
|
|
142
|
+
void 0,
|
|
143
|
+
["position", "isOpen", "uniqueId"]
|
|
144
|
+
);
|
|
145
|
+
const TdtControlScale = /* @__PURE__ */ defineContainer(
|
|
146
|
+
"tdt-control-scale",
|
|
147
|
+
void 0,
|
|
148
|
+
["position", "color", "uniqueId"]
|
|
149
|
+
);
|
|
150
|
+
const TdtControlZoom = /* @__PURE__ */ defineContainer(
|
|
151
|
+
"tdt-control-zoom",
|
|
152
|
+
void 0,
|
|
153
|
+
[
|
|
154
|
+
"position",
|
|
155
|
+
"zoomInText",
|
|
156
|
+
"zoomInTitle",
|
|
157
|
+
"zoomOutText",
|
|
158
|
+
"zoomOutTitle",
|
|
159
|
+
"uniqueId"
|
|
160
|
+
]
|
|
161
|
+
);
|
|
162
|
+
const TdtMap = /* @__PURE__ */ defineContainer(
|
|
163
|
+
"tdt-map",
|
|
164
|
+
void 0,
|
|
165
|
+
[
|
|
166
|
+
"tk",
|
|
167
|
+
"projection",
|
|
168
|
+
"minZoom",
|
|
169
|
+
"maxZoom",
|
|
170
|
+
"maxBounds",
|
|
171
|
+
"center",
|
|
172
|
+
"zoom",
|
|
173
|
+
"uniqueId"
|
|
174
|
+
]
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const ComponentLibrary = {
|
|
178
|
+
async install() {
|
|
179
|
+
applyPolyfills().then(() => {
|
|
180
|
+
defineCustomElements();
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export { ComponentLibrary, TdtControl, TdtControlCopyright, TdtControlOverviewMap, TdtControlScale, TdtControlZoom, TdtMap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tianditu/vue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "Vue components for tianditu, powered by Demo Macro.",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/DemoMacro/tianditu#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"vue": "3.
|
|
33
|
-
"@tianditu/
|
|
32
|
+
"vue": "3.4.37",
|
|
33
|
+
"@tianditu/wc": "0.0.1"
|
|
34
34
|
},
|
|
35
|
-
"scripts": {
|
|
35
|
+
"scripts": {
|
|
36
|
+
"dev": "unbuild --stub"
|
|
37
|
+
}
|
|
36
38
|
}
|
package/dist/components.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { JSX } from "@tianditu/web-components";
|
|
2
|
-
export declare const TControl: import("vue").DefineComponent<JSX.TControl & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.TControl & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {}>;
|
|
3
|
-
export declare const TMap: import("vue").DefineComponent<JSX.TMap & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.TMap & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {
|
|
4
|
-
projection: any;
|
|
5
|
-
minZoom: any;
|
|
6
|
-
maxZoom: any;
|
|
7
|
-
maxBounds: any;
|
|
8
|
-
zoom: any;
|
|
9
|
-
}>;
|
package/dist/components.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { defineContainer } from "./vue-component-lib/utils.mjs";
|
|
2
|
-
export const TControl = /* @__PURE__ */ defineContainer(
|
|
3
|
-
"t-control",
|
|
4
|
-
void 0
|
|
5
|
-
);
|
|
6
|
-
export const TMap = /* @__PURE__ */ defineContainer(
|
|
7
|
-
"t-map",
|
|
8
|
-
void 0,
|
|
9
|
-
["tk", "projection", "minZoom", "maxZoom", "maxBounds", "center", "zoom"]
|
|
10
|
-
);
|
package/dist/plugin.d.ts
DELETED
package/dist/plugin.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface InputProps<T> {
|
|
2
|
-
modelValue?: T;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Create a callback to define a Vue component wrapper around a Web Component.
|
|
6
|
-
*
|
|
7
|
-
* @prop name - The component tag name (i.e. `ion-button`)
|
|
8
|
-
* @prop componentProps - An array of properties on the
|
|
9
|
-
* component. These usually match up with the @Prop definitions
|
|
10
|
-
* in each component's TSX file.
|
|
11
|
-
* @prop customElement - An option custom element instance to pass
|
|
12
|
-
* to customElements.define. Only set if `includeImportCustomElements: true` in your config.
|
|
13
|
-
* @prop modelProp - The prop that v-model binds to (i.e. value)
|
|
14
|
-
* @prop modelUpdateEvent - The event that is fired from your Web Component when the value changes (i.e. ionChange)
|
|
15
|
-
* @prop externalModelUpdateEvent - The external event to fire from your Vue component when modelUpdateEvent fires. This is used for ensuring that v-model references have been
|
|
16
|
-
* correctly updated when a user's event callback fires.
|
|
17
|
-
*/
|
|
18
|
-
export declare const defineContainer: <Props, VModelType = string | number | boolean>(name: string, defineCustomElement: any, componentProps?: string[], modelProp?: string, modelUpdateEvent?: string, externalModelUpdateEvent?: string) => import("vue").DefineComponent<Props & InputProps<VModelType>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<Props & InputProps<VModelType> extends infer T ? T extends Props & InputProps<VModelType> ? T extends import("vue").ComponentPropsOptions<{
|
|
19
|
-
[x: string]: unknown;
|
|
20
|
-
}> ? import("vue").ExtractPropTypes<T> : T : never : never>, import("vue").ExtractDefaultPropTypes<Props & InputProps<VModelType>>>;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineComponent,
|
|
3
|
-
getCurrentInstance,
|
|
4
|
-
h,
|
|
5
|
-
inject,
|
|
6
|
-
ref
|
|
7
|
-
} from "vue";
|
|
8
|
-
const UPDATE_VALUE_EVENT = "update:modelValue";
|
|
9
|
-
const MODEL_VALUE = "modelValue";
|
|
10
|
-
const ROUTER_LINK_VALUE = "routerLink";
|
|
11
|
-
const NAV_MANAGER = "navManager";
|
|
12
|
-
const ROUTER_PROP_PREFIX = "router";
|
|
13
|
-
const ARIA_PROP_PREFIX = "aria";
|
|
14
|
-
const EMPTY_PROP = Symbol();
|
|
15
|
-
const DEFAULT_EMPTY_PROP = { default: EMPTY_PROP };
|
|
16
|
-
const getComponentClasses = (classes) => {
|
|
17
|
-
return classes?.split(" ") || [];
|
|
18
|
-
};
|
|
19
|
-
const getElementClasses = (ref2, componentClasses, defaultClasses = []) => {
|
|
20
|
-
return [...Array.from(ref2.value?.classList || []), ...defaultClasses].filter(
|
|
21
|
-
(c, i, self) => !componentClasses.has(c) && self.indexOf(c) === i
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
export const defineContainer = (name, defineCustomElement, componentProps = [], modelProp, modelUpdateEvent, externalModelUpdateEvent) => {
|
|
25
|
-
if (defineCustomElement !== void 0) {
|
|
26
|
-
defineCustomElement();
|
|
27
|
-
}
|
|
28
|
-
const Container = defineComponent(
|
|
29
|
-
(props, { attrs, slots, emit }) => {
|
|
30
|
-
let modelPropValue = props[modelProp];
|
|
31
|
-
const containerRef = ref();
|
|
32
|
-
const classes = new Set(getComponentClasses(attrs.class));
|
|
33
|
-
const onVnodeBeforeMount = (vnode) => {
|
|
34
|
-
if (vnode.el) {
|
|
35
|
-
const eventsNames = Array.isArray(modelUpdateEvent) ? modelUpdateEvent : [modelUpdateEvent];
|
|
36
|
-
eventsNames.forEach((eventName) => {
|
|
37
|
-
vnode.el.addEventListener(eventName.toLowerCase(), (e) => {
|
|
38
|
-
modelPropValue = (e?.target)[modelProp];
|
|
39
|
-
emit(UPDATE_VALUE_EVENT, modelPropValue);
|
|
40
|
-
if (externalModelUpdateEvent) {
|
|
41
|
-
emit(externalModelUpdateEvent, e);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const currentInstance = getCurrentInstance();
|
|
48
|
-
const hasRouter = currentInstance?.appContext?.provides[NAV_MANAGER];
|
|
49
|
-
const navManager = hasRouter ? inject(NAV_MANAGER) : void 0;
|
|
50
|
-
const handleRouterLink = (ev) => {
|
|
51
|
-
const { routerLink } = props;
|
|
52
|
-
if (routerLink === EMPTY_PROP)
|
|
53
|
-
return;
|
|
54
|
-
if (navManager !== void 0) {
|
|
55
|
-
let navigationPayload = { event: ev };
|
|
56
|
-
for (const key in props) {
|
|
57
|
-
const value = props[key];
|
|
58
|
-
if (props.hasOwnProperty(key) && key.startsWith(ROUTER_PROP_PREFIX) && value !== EMPTY_PROP) {
|
|
59
|
-
navigationPayload[key] = value;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
navManager.navigate(navigationPayload);
|
|
63
|
-
} else {
|
|
64
|
-
console.warn(
|
|
65
|
-
"Tried to navigate, but no router was found. Make sure you have mounted Vue Router."
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
return () => {
|
|
70
|
-
modelPropValue = props[modelProp];
|
|
71
|
-
getComponentClasses(attrs.class).forEach((value) => {
|
|
72
|
-
classes.add(value);
|
|
73
|
-
});
|
|
74
|
-
const oldClick = props.onClick;
|
|
75
|
-
const handleClick = (ev) => {
|
|
76
|
-
if (oldClick !== void 0) {
|
|
77
|
-
oldClick(ev);
|
|
78
|
-
}
|
|
79
|
-
if (!ev.defaultPrevented) {
|
|
80
|
-
handleRouterLink(ev);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
let propsToAdd = {
|
|
84
|
-
ref: containerRef,
|
|
85
|
-
class: getElementClasses(containerRef, classes),
|
|
86
|
-
onClick: handleClick,
|
|
87
|
-
onVnodeBeforeMount: modelUpdateEvent ? onVnodeBeforeMount : void 0
|
|
88
|
-
};
|
|
89
|
-
for (const key in props) {
|
|
90
|
-
const value = props[key];
|
|
91
|
-
if (props.hasOwnProperty(key) && value !== EMPTY_PROP || key.startsWith(ARIA_PROP_PREFIX)) {
|
|
92
|
-
propsToAdd[key] = value;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (modelProp) {
|
|
96
|
-
if (props[MODEL_VALUE] !== EMPTY_PROP) {
|
|
97
|
-
propsToAdd = {
|
|
98
|
-
...propsToAdd,
|
|
99
|
-
[modelProp]: props[MODEL_VALUE]
|
|
100
|
-
};
|
|
101
|
-
} else if (modelPropValue !== EMPTY_PROP) {
|
|
102
|
-
propsToAdd = {
|
|
103
|
-
...propsToAdd,
|
|
104
|
-
[modelProp]: modelPropValue
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return h(name, propsToAdd, slots.default && slots.default());
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
Container.name = name;
|
|
113
|
-
Container.props = {
|
|
114
|
-
[ROUTER_LINK_VALUE]: DEFAULT_EMPTY_PROP
|
|
115
|
-
};
|
|
116
|
-
componentProps.forEach((componentProp) => {
|
|
117
|
-
Container.props[componentProp] = DEFAULT_EMPTY_PROP;
|
|
118
|
-
});
|
|
119
|
-
if (modelProp) {
|
|
120
|
-
Container.props[MODEL_VALUE] = DEFAULT_EMPTY_PROP;
|
|
121
|
-
Container.emits = [UPDATE_VALUE_EVENT, externalModelUpdateEvent];
|
|
122
|
-
}
|
|
123
|
-
return Container;
|
|
124
|
-
};
|