@nanoporetech-digital/components-vue 1.13.11 → 1.13.15
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/CHANGELOG.md +16 -0
- package/package.json +8 -9
- package/dist/demo/main.js +0 -6
- package/dist/demo/main.js.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/nano-vue.js +0 -38
- package/dist/nano-vue.js.map +0 -1
- package/dist/proxies.js +0 -531
- package/dist/proxies.js.map +0 -1
- package/dist/types/demo/main.d.ts +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/nano-vue.d.ts +0 -2
- package/dist/types/proxies.d.ts +0 -1807
- package/dist/types/vue-component-lib/utils.d.ts +0 -20
- package/dist/vetur/attributes.json +0 -1965
- package/dist/vetur/tags.json +0 -547
- package/dist/vue-component-lib/utils.js +0 -166
- package/dist/vue-component-lib/utils.js.map +0 -1
- package/dist/web-types.json +0 -13
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { defineComponent, getCurrentInstance, h, inject, ref } from 'vue';
|
|
2
|
-
const UPDATE_VALUE_EVENT = 'update:modelValue';
|
|
3
|
-
const MODEL_VALUE = 'modelValue';
|
|
4
|
-
const ROUTER_LINK_VALUE = 'routerLink';
|
|
5
|
-
const NAV_MANAGER = 'navManager';
|
|
6
|
-
const ROUTER_PROP_PREFIX = 'router';
|
|
7
|
-
/**
|
|
8
|
-
* Starting in Vue 3.1.0, all properties are
|
|
9
|
-
* added as keys to the props object, even if
|
|
10
|
-
* they are not being used. In order to correctly
|
|
11
|
-
* account for both value props and v-model props,
|
|
12
|
-
* we need to check if the key exists for Vue <3.1.0
|
|
13
|
-
* and then check if it is not undefined for Vue >= 3.1.0.
|
|
14
|
-
* See https://github.com/vuejs/vue-next/issues/3889
|
|
15
|
-
*/
|
|
16
|
-
const EMPTY_PROP = Symbol();
|
|
17
|
-
const DEFAULT_EMPTY_PROP = { default: EMPTY_PROP };
|
|
18
|
-
const getComponentClasses = (classes) => {
|
|
19
|
-
return classes?.split(' ') || [];
|
|
20
|
-
};
|
|
21
|
-
const getElementClasses = (ref, componentClasses, defaultClasses = []) => {
|
|
22
|
-
return [...Array.from(ref.value?.classList || []), ...defaultClasses]
|
|
23
|
-
.filter((c, i, self) => !componentClasses.has(c) && self.indexOf(c) === i);
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Create a callback to define a Vue component wrapper around a Web Component.
|
|
27
|
-
*
|
|
28
|
-
* @prop name - The component tag name (i.e. `ion-button`)
|
|
29
|
-
* @prop componentProps - An array of properties on the
|
|
30
|
-
* component. These usually match up with the @Prop definitions
|
|
31
|
-
* in each component's TSX file.
|
|
32
|
-
* @prop customElement - An option custom element instance to pass
|
|
33
|
-
* to customElements.define. Only set if `includeImportCustomElements: true` in your config.
|
|
34
|
-
* @prop modelProp - The prop that v-model binds to (i.e. value)
|
|
35
|
-
* @prop modelUpdateEvent - The event that is fired from your Web Component when the value changes (i.e. ionChange)
|
|
36
|
-
* @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
|
|
37
|
-
* correctly updated when a user's event callback fires.
|
|
38
|
-
*/
|
|
39
|
-
export const defineContainer = (name, customElement, componentProps = [], modelProp, modelUpdateEvent, externalModelUpdateEvent) => {
|
|
40
|
-
/**
|
|
41
|
-
* Create a Vue component wrapper around a Web Component.
|
|
42
|
-
* Note: The `props` here are not all properties on a component.
|
|
43
|
-
* They refer to whatever properties are set on an instance of a component.
|
|
44
|
-
*/
|
|
45
|
-
if (customElement !== undefined &&
|
|
46
|
-
typeof customElements !== 'undefined' &&
|
|
47
|
-
!customElements.get(name)) {
|
|
48
|
-
customElements.define(name, customElement);
|
|
49
|
-
}
|
|
50
|
-
const Container = defineComponent((props, { attrs, slots, emit }) => {
|
|
51
|
-
let modelPropValue = props[modelProp];
|
|
52
|
-
const containerRef = ref();
|
|
53
|
-
const classes = new Set(getComponentClasses(attrs.class));
|
|
54
|
-
const onVnodeBeforeMount = (vnode) => {
|
|
55
|
-
// Add a listener to tell Vue to update the v-model
|
|
56
|
-
if (vnode.el) {
|
|
57
|
-
const eventsNames = Array.isArray(modelUpdateEvent) ? modelUpdateEvent : [modelUpdateEvent];
|
|
58
|
-
eventsNames.forEach((eventName) => {
|
|
59
|
-
vnode.el.addEventListener(eventName.toLowerCase(), (e) => {
|
|
60
|
-
modelPropValue = e?.target[modelProp];
|
|
61
|
-
emit(UPDATE_VALUE_EVENT, modelPropValue);
|
|
62
|
-
/**
|
|
63
|
-
* We need to emit the change event here
|
|
64
|
-
* rather than on the web component to ensure
|
|
65
|
-
* that any v-model bindings have been updated.
|
|
66
|
-
* Otherwise, the developer will listen on the
|
|
67
|
-
* native web component, but the v-model will
|
|
68
|
-
* not have been updated yet.
|
|
69
|
-
*/
|
|
70
|
-
if (externalModelUpdateEvent) {
|
|
71
|
-
emit(externalModelUpdateEvent, e);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const currentInstance = getCurrentInstance();
|
|
78
|
-
const hasRouter = currentInstance?.appContext?.provides[NAV_MANAGER];
|
|
79
|
-
const navManager = hasRouter ? inject(NAV_MANAGER) : undefined;
|
|
80
|
-
const handleRouterLink = (ev) => {
|
|
81
|
-
const { routerLink } = props;
|
|
82
|
-
if (routerLink === EMPTY_PROP)
|
|
83
|
-
return;
|
|
84
|
-
if (navManager !== undefined) {
|
|
85
|
-
let navigationPayload = { event: ev };
|
|
86
|
-
for (const key in props) {
|
|
87
|
-
const value = props[key];
|
|
88
|
-
if (props.hasOwnProperty(key) && key.startsWith(ROUTER_PROP_PREFIX) && value !== EMPTY_PROP) {
|
|
89
|
-
navigationPayload[key] = value;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
navManager.navigate(navigationPayload);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
console.warn('Tried to navigate, but no router was found. Make sure you have mounted Vue Router.');
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
return () => {
|
|
99
|
-
modelPropValue = props[modelProp];
|
|
100
|
-
getComponentClasses(attrs.class).forEach(value => {
|
|
101
|
-
classes.add(value);
|
|
102
|
-
});
|
|
103
|
-
const oldClick = props.onClick;
|
|
104
|
-
const handleClick = (ev) => {
|
|
105
|
-
if (oldClick !== undefined) {
|
|
106
|
-
oldClick(ev);
|
|
107
|
-
}
|
|
108
|
-
if (!ev.defaultPrevented) {
|
|
109
|
-
handleRouterLink(ev);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
let propsToAdd = {
|
|
113
|
-
ref: containerRef,
|
|
114
|
-
class: getElementClasses(containerRef, classes),
|
|
115
|
-
onClick: handleClick,
|
|
116
|
-
onVnodeBeforeMount: (modelUpdateEvent) ? onVnodeBeforeMount : undefined
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* We can use Object.entries here
|
|
120
|
-
* to avoid the hasOwnProperty check,
|
|
121
|
-
* but that would require 2 iterations
|
|
122
|
-
* where as this only requires 1.
|
|
123
|
-
*/
|
|
124
|
-
for (const key in props) {
|
|
125
|
-
const value = props[key];
|
|
126
|
-
if (props.hasOwnProperty(key) && value !== EMPTY_PROP) {
|
|
127
|
-
propsToAdd[key] = value;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (modelProp) {
|
|
131
|
-
/**
|
|
132
|
-
* If form value property was set using v-model
|
|
133
|
-
* then we should use that value.
|
|
134
|
-
* Otherwise, check to see if form value property
|
|
135
|
-
* was set as a static value (i.e. no v-model).
|
|
136
|
-
*/
|
|
137
|
-
if (props[MODEL_VALUE] !== EMPTY_PROP) {
|
|
138
|
-
propsToAdd = {
|
|
139
|
-
...propsToAdd,
|
|
140
|
-
[modelProp]: props[MODEL_VALUE]
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
else if (modelPropValue !== EMPTY_PROP) {
|
|
144
|
-
propsToAdd = {
|
|
145
|
-
...propsToAdd,
|
|
146
|
-
[modelProp]: modelPropValue
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return h(name, propsToAdd, slots.default && slots.default());
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
Container.displayName = name;
|
|
154
|
-
Container.props = {
|
|
155
|
-
[ROUTER_LINK_VALUE]: DEFAULT_EMPTY_PROP
|
|
156
|
-
};
|
|
157
|
-
componentProps.forEach(componentProp => {
|
|
158
|
-
Container.props[componentProp] = DEFAULT_EMPTY_PROP;
|
|
159
|
-
});
|
|
160
|
-
if (modelProp) {
|
|
161
|
-
Container.props[MODEL_VALUE] = DEFAULT_EMPTY_PROP;
|
|
162
|
-
Container.emits = [UPDATE_VALUE_EVENT, externalModelUpdateEvent];
|
|
163
|
-
}
|
|
164
|
-
return Container;
|
|
165
|
-
};
|
|
166
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/vue-component-lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,eAAe,EAAE,kBAAkB,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAO,MAAM,KAAK,CAAC;AAMtF,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAC/C,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAEpC;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC;AAC5B,MAAM,kBAAkB,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAMnD,MAAM,mBAAmB,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC/C,OAAQ,OAAkB,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAA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F;YAED,IAAI,SAAS,EAAE;gBACb;;;;;mBAKG;gBACH,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,UAAU,EAAE;oBACrC,UAAU,GAAG;wBACX,GAAG,UAAU;wBACb,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;qBAChC,CAAA;iBACF;qBAAM,IAAI,cAAc,KAAK,UAAU,EAAE;oBACxC,UAAU,GAAG;wBACX,GAAG,UAAU;wBACb,CAAC,SAAS,CAAC,EAAE,cAAc;qBAC5B,CAAA;iBACF;aACF;YAED,OAAO,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,CAAC,CAAA;IACH,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC;IAE7B,SAAS,CAAC,KAAK,GAAG;QAChB,CAAC,iBAAiB,CAAC,EAAE,kBAAkB;KACxC,CAAC;IAEF,cAAc,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACrC,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,kBAAkB,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,IAAI,SAAS,EAAE;QACb,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,kBAAkB,CAAC;QAClD,SAAS,CAAC,KAAK,GAAG,CAAC,kBAAkB,EAAE,wBAAwB,CAAC,CAAC;KAClE;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
package/dist/web-types.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json.schemastore.org/web-types",
|
|
3
|
-
"framework": "vue",
|
|
4
|
-
"name": "@nanoporetech-digital/components-vue",
|
|
5
|
-
"version": "1.13.11",
|
|
6
|
-
"contributions": {
|
|
7
|
-
"html": {
|
|
8
|
-
"types-syntax": "typescript",
|
|
9
|
-
"description-markup": "markdown",
|
|
10
|
-
"tags": []
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|